A parser interface and its implementation are generated automatically by m3build by running the command
where MyLang.t is a token specification , MyLangTok.i3 is a token interface , MyLang. y is a parser specification , and MyLangParse .i3 is the generated parser interface.
The set of valid grammar symbols consists of whatever tokens were declared in the token interface , plus whatever reduction method return types are declared as above.
The reduction method names have the form ruleName_returnType ; ext expects the methods to have these names. To avoid Modula-3 name conflicts, parse types should not contain underscores.
and all reduction method return types are declared as subtypes of either StartType or OtherType . Hence all ParseType s of importance (i.e. those appearing as parameters in reduction methods) are either StartType s, OtherType s, or MyLangTok.Token s.
In addition to the reduction methods, the parser type T also generically contains the following:
METHODS setLex(lex: MyLangTok.Lexer): T; parse(exhaustInput: BOOLEAN := TRUE): StartType;A generated parser is initialized as often as necessary by calling its setLex method, with a compatible lexer given as an argument. There is no method named init , to allow customized initialization parameters in extended lexers.
If parse is called with exhaustInput = FALSE , then the parser will continue reading tokens until reading another token would cause a syntax error (this may or may not require peeking ahead one token. If peeking is required and the last token would cause an error, it calls lex.unget() ). It returns the StartType representing everything up to just before the error. This feature is useful for parsing a language block whose end is delimited by some token not meaningful in that language, such as an unmatched '}' .
$Id: kyacc.html,v 1.4 2001/01/08 07:08:02 kp Exp $