Loading ...
Sorry, an error occurred while loading the content.

Allowing whitespace in symbols

Expand Messages
  • soraz30
    I have a problem, and I m not even sure I m close to solving it. I have a grammar, that defines two types of symbols, in seperate symbol tables AList BList A
    Message 1 of 1 , Oct 1, 2004
    • 0 Attachment
      I have a problem, and I'm not even sure I'm close to solving it.


      I have a grammar, that defines two types of symbols, in seperate
      symbol tables
      AList
      BList


      A symbol in one of the lists, must be allowed to include spaces in
      their names i.e.

      in the DiagnoseList, I have "Foo Bar" as a valid entry.
      in the InterventionList, I have "Poo Par" as a valid entry.

      In my lexer, I have a rule that basically says (pseudo-code)
      ID : [a-z0-9 ]+
      { if text in AList, _ttype=ASYMBOL;
      if text in BList, _ttype=BSYMBOL;
      }


      The parser then has
      Line:- ASYMBOL BSYMBOL

      On the input "Foo Bar Poo Par", this, ofcourse fails, because the rule
      for ASYMBOL (that is: ID), has globbed the Poo Bar as part of the
      reg-exp for ID.

      Is there any way to achieve this? What I'm looking for, is a way for
      the ID rule to say "Ok: That is enough. I now match an entry from one
      of the lists.".

      I thought about an approach to match it manually against the lists,
      and push the remainder back on the input-stream. Is this a viable
      solution? Is it possible?

      The symbol tables are loaded from an external source at run-time, so I
      cant just insert them as literals (which, by the way, works nicely).

      Thanks in advance
      Asger
    Your message has been successfully submitted and would be delivered to recipients shortly.