parsing primitive


PASM syntax



define a parsing rule


 = xxx

followed by parsing rules ; parsing rules consist of the PASM syntax shown below


define a parsing predicate


 - <xxx>

followed by parsing rules ; must return ^ok or ^fail


accept a character




lookahead one character




accept a token



Token kind (class) in upper case


accept a token with given string as its text



Token kind in upper case, token text verbatim (case matters) as str


accept any token




lookahead one token




lookahead one token with given string as its text




call a parsing rule




call a parsing predicate




call an external mechanism (function)








exit cycle




return success from a parsing predicate


>> ^ok


return failure from a parsing predicate


>> ^fail


return from a parsing rule (no value)




begin choice



followed by a parsing predicate then parsing rules ; the first choice which returns ^ok is evaluated


choice alternate




end choice




always succeed



usually used as ‘otherwise’ in a choice


call filter



filter operation - call rule <xxx> for every input token, if ‘accepted-token’ and ‘next-token’ are the same as before the filter operation, accept once (thereby advancing the stream), else save the newly accepted token onto a list of new tokens ==> i.e. filter the token stream, using a rule that creates one accepted token at a time, throw away tokens that were not accepted (see example of rmspaces in dsl0.pasm

(which removes ( / filters out) whitespace tokens))


N.B. parser has one character in lookahead position and one in accepted position


N.B. see for an implementation (the name means assembly language for parsing”)






source code