3 ms·
That definitely looks like normal recursive descent- it has functions `Script`, `Statements`, `Statement`, `FunctionDefinition`, `Expression`, etc.
by Rusky 9y ago
That definitely looks like normal recursive descent- it has functions `Script`, `Statements`, `Statement`, `FunctionDefinition`, `Expression`, etc.
- chubot 9y agoRecursive ascent / bottom-up also has functions that follow the grammar, so that doesn't mean anything. It's a matter of whether the children are resolved before the parents, or the parents are resolved before the children. The pushTarget() calls all over makes it look like bottom-up parsing. That doesn't appear in recursive descent (top down) parsers.
- Rusky 9y ago> It's a matter of whether the children are resolved before the parents, or the parents are resolved before the children. Yep, and Narcissus resolves the parents before the children by virtue of `Script` calling `Statements`, `Statements` calling `Statement`, etc. before ever actually seeing the bodies of their corresponding production rules. A bottom-up parser doesn't work that way at all. Its states aren't determined by what they're about to parse, but by what has already been parsed. The `pushTarget` function in Narcissus is completely unrelated to bottom-up parsing.
- chubot 9y agoYeah I see what you mean. There is some stuff that doesn't look like a recursive descent parser to me, but that's probably because there are some JavaScript idioms and that's not my main language.
- BrendanEich 9y agoThe code you mentioned, pushTarget in particular, is for semantic checking, nothing to do with purely syntactic analysis AKA parsing. In particular, pushTarget is for break to label and continue to label (the "Target" is a labeled statement's exit or continue point).
- chubot 9y agoOK interesting, thanks. Yes that definitely could be part of my confusion -- that the code is doing more than parsing; it's also doing some semantic analysis in the same pass.