Previous page Table of Contents Next page
The following methods are useful helpers for parsing. Their names are in the compiler module (except for =).
(x is name) = (y is name)Two names are equal if they must refer to the same definition when used in the same scope. In other words, their spellings are the same and their contexts are eq. If either name is a simple-name, = is the same as eq.
same-spelling?(x is name, y is name)True if the two names' spellings are the same, ignoring alphabetic case. Use this to compare absolute particles.
punctuation?(x is name) punctuation?(x is newline)True if x is punctuation.
match?(x is name, ts is token-stream) is booleanLook at the next token. If this token is a name and matches x using same-spelling?, advance the token-stream past this token and return true, else false. There are analogous methods for keywords and literals that compare with =.
match!(x is name, ts is token-stream) is booleanLook at the next token. If this token is a name and matches x using same-spelling?, advance the token-stream past this token and return true, else call wrong-token-error. There are analogous methods for keywords and literals that compare with =.
match(x, ts is token-stream, error? is boolean) is booleanCall match? or match! depending on error?.
match-bound-particle?(value, ts is token-stream) is boolean)Look at the next token. If this token is a name and has a known definition of value, advance the token-stream past this token and return true, else false. This is how you match an optional bound particle.
match-bound-particle!(name, value, ts is token-stream) is booleanLook at the next token. If this token is a name and has a known definition of value, advance the token-stream past this token and return true, else call wrong-token-error. This is how you match a required bound particle.
match-bound-particle(name, value, ts is token-stream, error? is boolean) is booleanCall match-bound-particle? or match-bound-particle! depending on error?.
wrong-token-error(ts is token-stream, expected is anything)Signal a parsing error. The error message indicates that expected was expected but next(ts) or token-after-newline(ts) was seen. The expected argument can be a string or a collection of names or strings. The ts argument also supplies the source-location.
Previous page Table of Contents Next page