Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <collezione_film><film></film></collezione_film>
- %%
- %byaccj
- %{
- private Parser yyparser;
- public Yylex(java.io.Reader r, Parser yyparser) {
- this(r);
- this.yyparser = yyparser;
- }
- %}
- %x IN_GROUP IN_PROPERTY
- %state COLLEZIONE_FILM
- TAG_COLLEZIONE_FILM_START = <collezione_film>
- TAG_FILM_OPEN_START = <film+[ t]
- %%
- <YYINITIAL> {
- {TAG_COLLEZIONE_FILM_START} {
- yyparser.yylval = new ParserVal("collezione_film");
- yybegin(COLLEZIONE_FILM);
- return Parser.TAG_START;
- }
- [^] { /* Non fare nulla */ }
- }
- <COLLEZIONE_FILM> {
- {TAG_FILM_OPEN_START} {
- yyparser.yylval = new ParserVal("film");
- return Parser.TAG_START;
- }
- [^] { /* Non fare nulla */ }
- }
- %token<sval> TAG_START
- %type<sval> tags
- %%
- config : tags { System.out.print($1); }
- tags : TAG_START tags {
- $$ = $1 + " " + $2;
- }
- | TAG_START { $$ = $1; }
- ;
- %%
- private Yylex lexer;
- private int yylex () {
- int yyl_return = -1;
- try {
- yylval = new ParserVal(0);
- yyl_return = lexer.yylex();
- }
- catch (java.io.IOException e) {
- System.err.println("IO error :"+e);
- }
- return yyl_return;
- }
- public void yyerror (String error) {
- System.err.println ("Error: " + error);
- }
- public Parser(java.io.Reader r) {
- lexer = new Yylex(r, this);
- }
- public static void main(String args[]) throws java.io.IOException {
- Parser yyparser;
- if ( args.length > 0 ) {
- yyparser = new Parser(new java.io.FileReader(args[0]));
- yyparser.yyparse();
- }
- else {
- System.out.println("Nessun file specificato.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement