compiler in applications

View: New views
3 Messages — Rating Filter:   Alert me  

compiler in applications

by Philipp Cimiano-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear javacc community,

  I am a newby to javacc and have started to use javacc to create some
simple grammars. I would like to use javacc for a larger project, but need
to know how to use the created compiler in an own java application. So far,
all examples I have seen describe how to start the generated compiler as a
main() method, reading input from System.in. However, I would like to use
the generated compiler from my own program by passing a String object. Is
there any documentation how to do this or is it so trivial that I should
have figured out myself how to do it? ;-)

Thanks and best regards for your help and time,

 Philipp.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Parent Message unknown Re: compiler in applications

by Artur Rataj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.

Just instantiate the parser object, and then call the production that represents
the stream you parse, like:

parser = new JavaParser(fileName);
Unit unit = parser.CompilationUnit();

The productions are just methods in the generated file.

Best regards,
Artur


 I am a newby to javacc and have started to use javacc to create some
simple grammars. I would like to use javacc for a larger project, but need
to know how to use the created compiler in an own java application. So far,
all examples I have seen describe how to start the generated compiler as a
main() method, reading input from System.in. However, I would like to use
the generated compiler from my own program by passing a String object. Is
there any documentation how to do this or is it so trivial that I should
have figured out myself how to do it? ;-)

Thanks and best regards for your help and time,

 Philipp.



Re: compiler in applications

by Artur Rataj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you want to parse a string:

parser = new JavaParser(new StringReader(string));