Example #1
0
def _comment():
   print "Creating comments DFA..."

   # As defined in the Ada83 LRM section 2.8 and partly in section 2.2 
   notLineEnd = kleene(reduce(alt, map(symbol, graphic_chars | horiz_tab)))
   commentsDFA = (string("--") & notLineEnd & _lineEnd()).toDFA()
   return ((commentsDFA, tokens.Comment),)
Example #2
0
def _identifier():
   print "Creating identifier DFA..."

   # XXX TEST untested.
   ident = _letter() & \
           kleene((symbol("_") | epsilon()) & \
                  (_letter() | _digit()))
   return ((ident.toDFA(), tokens.Identifier),)
Example #3
0
def _stringLiteral():
   print "Creating string literal DFA..."

   # XXX TEST untested.
   # XXX TODO support escaping of the " character.
   strLit = symbol('"') &\
            kleene(reduce(alt, map(symbol, graphic_chars - set(['"'])))) &\
            symbol('"')

   return ((strLit.toDFA(), tokens.StringLit),)