[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using sablecc to build a syntaxical analyser



Pascal AUDANT wrote:
Hello to all,
My name is Pascal and I am new here.
I would like to use sablecc to build a syntaxical analyser that will
tell me if a sentence (a set of terminal term) belongs to my grammar or
not.
Ex. :
I have
S -> aSa
S-> b
I wont to know if aabaa  is part of my grammar .
Can sablecc give me that kind of info ?

Yes, it can. You simply need to feed your small grammar specification to SableCC (using the appropriate syntax), and SableCC will automatically generate a parser that will recognize whether any input sentence conforms to this grammar or not.


The SableCC grammar should more or less look like:

Tokens

  a = 'a';
  b = 'b';

Productions
  s = {recursive} a s a |
      {leaf} b;


Etienne



-- Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/