parsing - how to connect ANTLRWorks output to c# project? -
I wrote a grammar in ANTLRWorks 1.5.2. I have also added some functions, when I debug my code for a while, it will show 3 address codes in the output of ANLRWorks. My grammar is like this:
name: letter (letter | digit | '_') *; Number: DIGIT +; // just the integer piece points: '0' .. '9'; Piece Letter: 'A' .. 'Z' | 'One' .. 'z'; Relation: '& lt;' | '& Lt; = '| '==' | '& Gt; = '| '& Gt;' | '! = '; WHITESPACE: ('' '' '\ t' | '\ r' | '' \ n ') + {$ channel = HIDDEN; };
And I generate my grammar and I have that while in Parser.cs and whileLexer.cs in the Output folder. Now I want to add my grammar to a C # project. I want to get input from the user and then show them my grammar product. And I do not know how to add .g file and output class in C # project. I am using Visual Studio 2013 Can anyone help me?
You have Java code in grammar, you need to translate them to the first in C # In, you may have a good chance to switch to ANTLR4 and / or Pars tree approach instead. I should mention a version, mostly for ANTLR4, you need it.
However, just install it and handle it for yourself. It works with both ANTLR 3 and 4.
You have to add an ATLR runtime to your project. For this, you can install or install depending on which version you have chosen to use at the end.
Comments
Post a Comment