help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

simple parsing problem


From: anton wilson
Subject: simple parsing problem
Date: Tue, 22 Oct 2002 18:06:18 -0400

The following is a simple test grammer I wrote to recognize token sequences 
composed of an optional INDENT or DEDENT token followed by an ID and then a 
NEWLINE.

When the lexer sends it the token sequence:

ID 
NEWLINE
INDENT 
ID 
NEWLINE
DEDENT 
ID
NEWLINE

there is a syntax error called between the DEDENT and the ID. 
Is there something wrong with my grammer? Thanks.


%token NEWLINE INDENT DEDENT ID


%%

lines:               {printf("lines\n");}
| lines line         {printf("lines\n");}
;
line:  id newline        {printf("line\n");}
| dedent  id newline        {printf("line\n");}
| indent  id newline        {printf("line\n");}
;
newline: NEWLINE {printf("newline token\n");}
;
indent:  INDENT  {printf("indent token\n");}
;
dedent:  DEDENT {printf("dedent token\n");}
;
id: ID {printf("id token\n");}

%%





reply via email to

[Prev in Thread] Current Thread [Next in Thread]