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

parse just a context of grammar #31

Closed
wilkerlucio opened this issue Feb 23, 2011 · 1 comment
Closed

parse just a context of grammar #31

wilkerlucio opened this issue Feb 23, 2011 · 1 comment

Comments

@wilkerlucio
Copy link

Hi, Im implementing an CSS parser with Jison, but sometimes I will need to use just a context of grammar, instead it all.

For example, a full parse works ok with this:

body { background: #fff }

but sometimes I just wanna parse the Attributes context, like:

background: #fff

Will be nice to be able to do something like:

attributes = parser.parse("background: #fff", "Attributes")

@zaach
Copy link
Owner

zaach commented Feb 27, 2011

This is a challenge of designing any parser based on context free grammars. How it is solved depends on the methods you prefer. You could use two separate parsers in conjunction and it would look similar to your example. You could also try using flags and start conditions, which Jison supports.

This issue was closed.
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