[DGD] Re: Parsing grammar problem

Jason Cone jcone at cs.tamu.edu
Sun May 31 23:16:11 CEST 1998


-----Original Message-----
From: Felix A. Croes <felix at xs1.simplex.nl>
To: dgd at list.imaginary.com <dgd at list.imaginary.com>
Date: Sunday, May 31, 1998 12:38 PM
Subject: [DGD] Re: Parsing grammar problem


>See dgd/doc/parser, near the end, for an example of how to write the
>grammar in a non-ambiguous way.  The same document also describes
>how you can detect ambiguity in a grammar.



Thanks for the feedback.  Using parse_string() is my first attempt at any
kind of lexical grammar composition and ambiguity is one of those things I
didn't know much about. :)  The doc, however, did a good job of explaining
it.  Here is what I'm using now (only the updated portion of the grammar):

  array_value: '({' element_list '})' ? compose_array
  mapping_value: '([' assoc_element_list '])' ? compose_mapping

  list_element:
  list_element: variable_type

  element_list: list_element
  element_list: element_list ',' list_element

  assoc_element:
  assoc_element: variable_type ':' list_element ? compose_association

  assoc_element_list: assoc_element
  assoc_element_list: assoc_element_list ',' assoc_element

There are still a few things that can be improved, such as having a
simple_variable_type rule (int, float, string) that can replace
variable_type as the key of a mapping.  Anyway, we will be re-releasing the
I-3 daemon with the changes/improvements once they have been tested in full.

--
  Jason H. Cone
  Dept. Computer Science
  Texas A&M University
  jcone at cs.tamu.edu

  "Even in the gigantic and the ideal, the dream, which is
   completely spontaneous, takes and keeps the form of our
   mind."
                                             - Victor Hugo






List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list