3 ms·
> I'm not familiar with "single-pass analysis” Sure, not many programmers are today, sadly. I was referring to syntax analysis, or “parsing.” Some (admittedly,
by Koshkin 5y ago
> I'm not familiar with "single-pass analysis”
Sure, not many programmers are today, sadly. I was referring to syntax analysis, or “parsing.” Some (admittedly, relatively simple) grammars allow syntax analysis to be done in one pass, so that an intermediate representation (e.g. in the form of an AST) becomes unnecessary; the latter is only needed if the grammar is complex and thus requires two or more passes for further analysis and/or machine code generation. Writing an interpreter for a command language is straightforward - exactly because analysis of its syntax can be done in one pass. Pascal is not a command language, but its grammar is (was?) still simple enough for many students of programming having gone through this (still highly recommended) exercise when Pascal was a teaching language.
- zozbot234 5y agoSingle-pass compile was a basic requirement back when your compiler only had access to a 64KB address space for its code and data. But it forces program organization into a clunky bottom-up sequential shape that just doesn't jive with the most basic concerns for larger-scale, professional software development. There's a reason why most of us don't code in FORTH, and why more recently Rust even chose the 'crate' rather than the single program file as its compilation unit.
- Koshkin 5y agoAll is true; note that “compile” is not the same as syntax analysis - because the former implies generation of code whereas the latter does not. (This is why we have two classes of language “translators”, one is compilers and the other, interpreters - although this distinction in modern practice has become somewhat blurry, because an interpreter may generate some sort of byte code which it then immediately executes.)