[antlr-interest] related question: multiple grammars..

Eitan Suez eitan.suez at gmail.com
Wed Mar 28 19:40:02 PDT 2007


as a followup to my last post..
  the antlr betabook discusses in an early chapter
  the analogy to humans' ability to parse language.

  how when we read, we have one grammar for
  assembling the letters into words and a separate
  grammar for assembling words into phrases.
  basically that there's a hierarchy of languages.

  anyhow, is there a construct that will allow me
  to parse a file at more than one level?

  for example, i'm trying to learn antlr v3 by writing
  a css parser (or i'm trying to write a css parser using
  antlr v3 and i'm an antlr newbie).  css is really
  two languages:  there's the primary language,
  then there's the sublanguage for interpreting
  selectors.

  one can get by ignoring whitespace for the main
  language but not for the selectors.

  so, back to my question:  is there a way to
  say to antlr in one grammar:  when you come
  across a certain kind of block in this stream, use
  subgrammar x to parse that.  some vague
  analog to a sort of "include" statement in the domain of
  parsing.

thanks, eitan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070328/4911b209/attachment.html 


More information about the antlr-interest mailing list