4 ms·
I also wrote a language in which keywords are not reserved, called Leazy, during high school ( https://github.com/jochenleidner/leazy https://github.com/jochenl
by jll29 1y ago
I also wrote a language in which keywords are not reserved,
called Leazy, during high school ( https://github.com/jochenleidner/leazy https://github.com/jochenleidner/leazy ), but just for fun.
It`s arguably a good idea to treat keywords as reserved, in order to avoid confusion and to write faster compilers.
No-one should (be able to) write confusing code like:
if if = then then then = else else else = end end if
It's good to have a PL/1 compiler available to those that hwve legacy needs and that want to learn about the language, but it has been said it was overly complex (what I read about it sound like it was "the C++ of its time"). Since then, many language designers, at least the good ones (e.g. Wirth, Gosling), have recognized that less is more.
- trealira 1y agoThanks 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.