Subversion Repositories programming

Rev

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

Rev 244 Rev 258
Line 23... Line 23...
23
%%
23
%%
24
 
24
 
25
program : program line
25
program : program line
26
    | ;
26
    | ;
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 : PUT S TAKE S    { System.out.println ("S -> PUT S TAKE S"); }
32
S : P S T S         { System.out.println ("S -> P S T S"); }
33
    | PUT S         { System.out.println ("S -> PUT S"); r.incVal(); }
33
    | P S           { System.out.println ("S -> P S"); }
34
    |               { System.out.println ("S -> epsilon"); };
34
    |               { System.out.println ("S -> epsilon"); };
35
 
35
 
-
 
36
P : PUT             { System.out.println ("P -> p"); r.incVal(); };
-
 
37
 
-
 
38
T : TAKE            { System.out.println ("T -> t"); r.decVal(); };
-
 
39
 
36
%%
40
%%
37
 
41
 
38
private Yylex lexer;
42
private Yylex lexer;
39
static boolean interactive = false;
43
static boolean interactive = false;
40
static String input_str = "Input: ";
44
static String input_str = "Input: ";