Next: 7. Grammar for Parsers
Up: Yapps 1.0
Previous: 5. Parser Mechanics
There are three extensions that were considered for Yapps 1, but not implemented until Yapps 2:
- User defined actions inside clauses would allow parsing code to
be mixed in with other code, which processes parts of a clause that
have been parsed so far. For example, ID {{ if ID not in
self.declarations: raise InvalidIdentifier }} ":=" expr would
check, at parse time, whether the identifier has been declared, and
if not, raise an exception. Only if the identifier had been
declared would parsing continue to the “:=” and
expr.
-
Parsing forms X* and X+ would be very
convenient for matching commonly occuring list patterns in
languages.
-
At present, tokens must be strings. It would be convenient to
also allow some standard regular expressions to be imported, most
likely from the tokenize module, which defines regular
expressions for Python strings, identifiers, numbers, and several
other common tokens.
-
It would be nice to somehow automatically deal with
end-of-string tokens. A common error I make is to forget to define
END to be
"\\'"
, and then the resulting parser is unable to
parse text that seems correct.
In addition, the possibility of backtracking and LL(k) parsing
were being investigated, but neither made it into Yapps 2.
Next: 7. Grammar for Parsers
Up: Yapps 1.0
Previous: 5. Parser Mechanics
Amit J Patel, amitp@cs.stanford.edu