3 ms·
Thanks for sharing your old compiler and the source code listing for it, though I can't read the documentation in German. Out of curiosity, how did you deal wi
by trealira 1y ago
Thanks for sharing your old compiler and the source code listing for it, though I can't read the documentation in German.
Out of curiosity, how did you deal with the fact that for a top-down parser, 1 token of lookahead isn't enough to know if, say, you're dealing with an if-statement (e.g. "if x > 0 then ...") or an assignment or procedure call using a variable named "if" (e.g. "if = 1", "if(x, y, z)")?
I feel like the best solution would be an LR parser that reduced to an if statement only when seeing "if <expr> then" (and I saw you mentioned LALR and LL parsers somehow in your documentation), but you could also maybe use a backtracking top down parser.
I realize could read the source code listing, but I think it would be easier just to ask, and I might misunderstand it.