[DGD] Help with parse_string() grammar

Petter Nyström md1pette at mdstud.chalmers.se
Mon Apr 10 14:08:01 CEST 2006


On Mon, 10 Apr 2006, Felix A. Croes wrote:

> Your grammar has the rule:
>
>    Output: Output Elem
>
> Changing that to:
>
>    Output: Elem Output
>
> should do the trick.

I actually thought of that one, but the trick doesn't come for me. 
Changing the order of the recursion has no effect at all. I think I'm 
doing things right and updating the grammar right. It's atleast good to 
know that this *should* do it though. I just need to figure out why it 
doesn't... My grammar has become a bit longer now, I'll add it below.

Regards,

Jimorie

The grammar
===========
macro      = /$[a-zA-Z0-9]+/
color      = /&[a-zA-Z0-9]/

string     = /"(\\.|[^"])*"/
object     = /<[^>]+>/
float      = /[-]?[0-9]+\.[0-9]+/
integer    = /[-]?[0-9]+/
nil        = /nil/

plain      = nomatch

Output     : Elem Output
Output     :

Elem       : macro '(' ArrList ')' ? matched_macro
Elem       : color ? matched_color
Elem       : plain
Elem       : string
Elem       : object
Elem       : float
Elem       : integer
Elem       : nil
Elem       : '('
Elem       : ')'
Elem       : '({'
Elem       : '})'
Elem       : '(['
Elem       : '])'
Elem       : ','
Elem       : '|'
Elem       : ':'

Mixed      : Nil
Mixed      : Integer
Mixed      : Float
Mixed      : String
Mixed      : Object
Mixed      : Array
Mixed      : Mapping

Nil        : nil ? matched_nil

Integer    : integer ? matched_integer

Float      : float ? matched_float

String     : string ? matched_string

Object     : object ? matched_object

Array      : '({' ArrList '})' ? matched_array
Array      : '({' ArrList ',' '})' ? matched_comma_array
Array      : '({' integer '|' ArrList '})' ? matched_sized_array
Array      : '({' integer '|' ArrList ',' '})' ? matched_sized_comma_array
ArrList    : ArrList ',' Mixed
ArrList    : Mixed
ArrList    :

Mapping    : '([' MapList '])' ? matched_mapping
Mapping    : '([' MapList ',' '])' ? matched_comma_mapping
Mapping    : '([' integer '|' MapList '])' ? matched_sized_mapping
Mapping    : '([' integer '|' MapList ',' '])' ? matched_sized_comma_mapping
MapList    : MapList ',' MapItem
MapList    : MapItem
MapList    :
MapItem    : Mixed ':' Mixed
===========



More information about the DGD mailing list