My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#%semantic token '*' '='
%right '='
%left '-' '+'
%left '*' '/'
%left NEG

%lexer {
m{\G[ \t]*}gc;
m{\G(\n)+}gc and $self->tokenline($1 =~ tr/\n//);
m{\G([0-9]+(?:\.[0-9]+)?)}gc and return ('NUM', $1);
m{\Gprint}gc and return ('PRINT', 'PRINT');
m{\G([A-Za-z_][A-Za-z0-9_]*)}gc and return ('VAR', $1);
m{\G(.)}gc and return ($1, $1);
}

#%tree
%tree bypass

%%
line:
sts <%name EXPS + ';'>
;

sts:
%name PRINT
PRINT leftvalue
| exp
;

exp:
%name NUM
NUM
| %name VAR
VAR
| %name ASSIGN
leftvalue '=' exp
| %name PLUS
exp '+' exp
| %name MINUS
exp '-' exp
| %name TIMES
exp '*' exp
| %name DIV
exp '/' exp
| %no bypass NEG
#| %name NEG
'-' exp %prec NEG
| '(' exp ')'
;

leftvalue : %name VAR VAR
;
%%

Change log

r852 by casiano.rodriguez.leon on Jan 19, 2011   Diff
merged trunk with PPCR branch (and with
the one with auxiliar syntactic variables)
Go to: 
Project members, sign in to write a code review

Older revisions

r715 by casiano.rodriguez.leon on Dec 2, 2010   Diff
PPCR branch has been synchronized with
the trunk
r509 by casiano.rodriguez.leon on Jan 31, 2010   Diff
new Infix.eyp with %token ID=/regexp/
directives
r379 by casiano.rodriguez.leon on Dec 26, 2009   Diff
updating parrot example
All revisions of this file

File info

Size: 976 bytes, 53 lines

File properties

svn:mergeinfo
/branches/PPCR/examples/ParsingString...yp:2-508
Powered by Google Project Hosting