Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation needed #7

Open
drekka opened this issue Jun 3, 2011 · 2 comments
Open

Documentation needed #7

drekka opened this issue Jun 3, 2011 · 2 comments

Comments

@drekka
Copy link

drekka commented Jun 3, 2011

The intro documentation is great and got me started. But I need more details. The HeaderDoc links are all dead and from the source code it appears that they would not be much help anyway. What I'm looking for:

  1. Reference for the grammer syntax. Most specifically keywords. Just referring to BNF is not enough because parsekit's syntax appears to be different and doesn't give us the built ins. For example "Word" appears to be a built in keyword.
  2. How does parsekit decide what methods to call on the call back. From the examples it appear they these are dynamically produced, but the doco doesn't tell me how and it appears that parsekit doesn't either. So I'm guessing at what methods I have to include.
@grgcombs
Copy link

grgcombs commented Jun 5, 2011

I think in the readme he refers us to a book on parsers. Evidently, the convention of this framework follows what's set out in the book. My guess is that the concept of parsers are so complex that any included documentation wouldn't really do it much justice.

@profburke
Copy link

@drekka:

The answer to your second question can be found in the PKParserFactory class, in particular, the method named defaultAssemblerSelectorNameForParserName. Each production rule in your grammar (except those which start with a '@') have a matching callback. Given the name someSortOfProduction the callback name is formed by prepending didMatch and making the first letter of the production name upper case. So in the previous example, the callback would be didMatchSomeSortOfProduction.

Actually, looking in PKGrammarParser, it looks like you can override this by providing your own selector. I haven't tried this yet, but if you had a rule in your grammar as follows:

statement (handleStatement:) = doStatement | whileStatement | assignmentStatement ;

Then the callback for matching a statement would be handleStatement:

As for your first question, looks like you can find most of the info in the PKGrammarParser class. It's late, and my eyes are getting blurry, so I might have missed a few but: Number, Word, LowercaseWord, UppercaseWord, QuotedString, Empty, DelimitedString, oh, and '!' will cause a token to be discarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants