require 'cal'

class MyParser < Parser
  TOKEN_STACK = [Token::NUMBER, 100, ?+, Token::NUMBER, 200]

  def initialize
    super
#    @yydebug = true
  end

  def yylex()
    t = TOKEN_STACK.shift || 0
    case t
    when Token::NUMBER
      @yylval = TOKEN_STACK.shift
    when Token::SYMBOL
      @yylval = TOKEN_STACK.shift
    end
    t
  end
end

my = MyParser.new

while( MyParser::TOKEN_STACK.size > 0 && my.yyparse == 0 )
  printf("result = #{$result}\n")
end
