Subversion Repositories programming

Rev

Rev 258 | Rev 261 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 258 Rev 259
Line 27... Line 27...
27
 
27
 
28
line: NL            { if (interactive) System.out.print (input_str); r.reset(); }
28
line: NL            { if (interactive) System.out.print (input_str); r.reset(); }
29
    | S NL          { System.out.println ("There are: " + r.getVal() + " apples in the bag!");
29
    | S NL          { System.out.println ("There are: " + r.getVal() + " apples in the bag!");
30
                      if (interactive) System.out.print (input_str); r.reset(); };
30
                      if (interactive) System.out.print (input_str); r.reset(); };
31
 
31
 
32
S : P S T S         { System.out.println ("S -> P S T S"); }
32
S : P S T S         { }
33
    | P S           { System.out.println ("S -> P S"); }
33
    | P S           { }
34
    |               { System.out.println ("S -> epsilon"); };
34
    |               { };
35
 
35
 
36
P : PUT             { System.out.println ("P -> p"); r.incVal(); };
36
P : PUT             { System.out.println ("PUT  an apple in the bag"); r.incVal(); };
37
 
37
 
38
T : TAKE            { System.out.println ("T -> t"); r.decVal(); };
38
T : TAKE            { System.out.println ("TAKE an apple out of the bag"); r.decVal(); };
39
 
39
 
40
%%
40
%%
41
 
41
 
42
private Yylex lexer;
42
private Yylex lexer;
43
static boolean interactive = false;
43
static boolean interactive = false;