質問

I am looking to create a JavaScript parser for an existing language, that currently has clumsy "hand-made" C# and Java parsers. I want to use Jison, and have been trying to learn the basics of Bison as well.

A question I'm not sure how to answer is what exactly is the output of Bison/Jison? Do I get anything automatically (such as an AST)? Or is everything done using rule actions by the person writing the bison file. So for example, if I have a rule specifying a new variable assignment that fits the rule:

VariableStatement : VAR VariableDeclarationList ';'

Do I have to specify an action such as { var var1 = {name: $1, value: $2 } (well, wouldn't work with this specific rule but assume $2 is some terminal token) to be run in the javascript file generated by Jison to actually create the new variable? Or am I getting it wrong.

Thanks!

役に立ちましたか?

解決

The only thing you get automatically are syntax errors. In other words, if you don't provide actions, the bison-generated code will verify that the input corresponds to the grammar, and nothing else.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top