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

start_production parameter in parser constructor #80

Closed
SupraSummus opened this issue Nov 3, 2018 · 2 comments
Closed

start_production parameter in parser constructor #80

SupraSummus opened this issue Nov 3, 2018 · 2 comments

Comments

@SupraSummus
Copy link
Contributor

For me it is misleading. I think there are two problems with it:

  • it allows just for single production, whereas it should accept a start symbol (which can expand to multiple productions)
  • it is a part of parser constructor, whereas (in formal grammar definition) start symbol/production is a part of grammar specification.

So I propose moving start symbol/production parameter to Grammar constructor and forbidding to specify it in Parser constructor.

There is start_symbol parameter for Grammar constructor, but it seems unused. (I may be unfamiliar with code and missed something.) The only place it is used is around parglare/grammar.py:861 where based on it AUGSYMBOL rule is inserted as a first production. But then parser uses production of index 1 as a default starting production, so it makes no sense to me.

@igordejanovic
Copy link
Owner

Implementation around start_production indeed needs a cleanup. It is a left-over that was not reworked completely. The initial idea for specifying start_production on the parser was to enable user to instantiate a parser for the part of the language, but I haven't had that use-case yet so not sure that we should support it at all. After introduction of table serialization it only complicates matter.

@SupraSummus
Copy link
Contributor Author

If the use case for instantiating parser for part of the language is viable, then it can be satisfied with start_symbol in Grammar constructor. User could take existing grammar and change start_symbol. But it needs to be implemented before ;)

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

2 participants