|grammar for bytecodes ? firstname.lastname@example.org (1997-06-30)|
|From:||email@example.com (Alan Reider)|
|Date:||30 Jun 1997 22:49:16 -0400|
|Organization:||Spacelab.net Internet Access|
|Keywords:||code, parse, question|
I'm wondering if its possible to come up with a grammar for a stack
based VM instruction stream such as Smalltalk which would enable
top-down (recursive descent) parsing.
As an example, consider the following grammar loosely based on
UnaryExpression := primary [unarySelector]* "0 or more"
KeywordExpression := unaryExpression [keyword unaryExpression]+
"1 or more"
Primary := varName
| '(' MessageExpression ')'
aView addView: (aTopPane addSubPane: (aButton text: 'ok'
might be compiled to:
The question is, is there a grammar that can represent this bytecode
'language'? For example:
UnaryExpression := push primary [send selector]*
unaryExpression [unaryExpression*] send selector
doesnt work because it would only recognize the byteCodes
to (aButton text: 'ok' asUppercase) instead of the outermost
I suspect there is no grammar but i'm not up enough on compiler theory
to explain why (something about tail recursion or LL something or
I know that bytecodes can be parsed (decompiled) by 'executing' them
using a stack (eg pushing message nodes instead of evaluating message
sends). At the end the stack contains the parse tree.
But I'm curious if it can be done with recursive descent.
Return to the
Search the comp.compilers archives again.