error recovery

Jan 14, 2010 at 9:18 PM

How do I activate error recovery? Is there any way I could indicate some syncronization points in the grammar?

 

Coordinator
Jan 14, 2010 at 9:25 PM

assign NonTerminal.ErrorRule property - look at c# grammar as an example

Jan 14, 2010 at 9:43 PM

Excellent ! Now it is working !

Last question I hope

I need to match something like this

{ A, B, C, D, }

I tried with the star rule, however, the delimiter is only used inside. So when I tried to add it at the end, it is not working

MakeStarRule(nt_fields, t_comma, nt_field) + t_comma.

 

Why is this happening?

Thanks again. I really like your work, and you've been very helpful today.

Coordinator
Jan 14, 2010 at 10:23 PM

you'll have to create an extra non-terminal containing the list plus optional comma. I already recognized that this is a common case, so i'm working on adding support for this optional tailing delimiter in list-making methods

Jan 14, 2010 at 11:04 PM

When I try to do that I get the following error:

Shift-reduce conflict. State S20, lookaheads [,]. Selected shift as preferred action.

 

State S20 (Inadequate)
  Shift items:
    Field+ -> Field+ ·, Field 
  Reduce items:
    Fields -> Field+ · [, } )]
  Transitions: ,->S32, 

State S20 (Inadequate)

  Shift items:

    Field+ -> Field+ ·, Field 

  Reduce items:

    Fields -> Field+ · [, } )]

  Transitions: ,->S32, 

----
Contents  (Nullable) 
   Contents -> BodyId , FieldsComma 
   Contents -> FieldsComma 
   Contents -> Value 
BodyId
   BodyId -> Name 
   BodyId -> Number 
FieldsComma  (Nullable) 
   FieldsComma -> Fields 
   FieldsComma -> Fields , 
Fields  (Nullable) 
   Fields -> 
   Fields -> Field+ 
Field+
   Field+ -> Field 
   Field+ -> Field+ , Field 
Field
   Field -> Name = Value 
I have tried a lot of alternatives, but I still don't get it...

 

Coordinator
Jan 14, 2010 at 11:09 PM

please post the source code of grammar constructor, at least a reduced version with all involved terminals and non-terminals