ohboyohboyohboy/antlr3 — Issue #20: Test rig failure
Author: milanmitrovic
Created: 2012-02-06 12:44:01+00:00
State: open

I tried running the examples from the antlr book and used the default test rig (passing the generated files to ruby directly). It worked fine for the simple grammar but is failing now for the tree parser. This is the error message I got:

```
$ ruby Eval.rb
~/.rvm/gems/ruby-1.9.3-p0@cg/gems/antlr3-1.8.12/lib/antlr3/main.rb:549:in `setup': unable to locate the lexer class (RuntimeError)
from ~/.rvm/gems/ruby-1.9.3-p0@cg/gems/antlr3-1.8.12/lib/antlr3/main.rb:137:in `execute'
from ~/.rvm/gems/ruby-1.9.3-p0@cg/gems/antlr3-1.8.12/lib/antlr3/tree.rb:108:in `main'
from Eval.rb:363:in `block in '
```

The file is copied from the antler book and modified to output ruby code:

```ruby
tree grammar Eval;

options {
language = Ruby;
tokenVocab = Expr;
ASTLabelType = CommonTree;
}

@members{
memory = {}
}

prog: stat+ ;

stat
: expr { puts $expr.value }
| ^('=' ID expr) { memory[$ID.text] = $expr.value.to_i }
;

expr returns [value]
: ^('+' a=expr b=expr) {$value = a+b}
| ^('-' a=expr b=expr) {$value = a-b}
| ^('*' a=expr b=expr) {$value = a*b}
| ID
{
v = memory[$ID.text].to_i
if !v.nil? then
$value = v
else
puts "undefined variable " + $ID.text
end
}
| INT { $value = $INT.text.to_i }
;
```

Is this a bug in the code or am I doing something wrong?