Skip to content

Instantly share code, notes, and snippets.

@markmarch
Created October 19, 2011 22:25
Show Gist options
  • Save markmarch/1299867 to your computer and use it in GitHub Desktop.
Save markmarch/1299867 to your computer and use it in GitHub Desktop.
Syntax directed translation
// Example of computing attributes in Rats!
AssignStmt assignStmt = l : expr COLONEQ r : expr { yyValue = new AssignStmt(l, r) }
// class that represents an assignment statement node.
class AssignStmt extends Stmt {
Expression _lhs, _rhs; // children
public AssignStmt(Expression l, Expression r) {
_lhs = l;
_rhs = l;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment