1. Steven! Ragnarök
  2. TopDowner


Steven! Ragnarök  committed 7b37436

Still working on my meta-recognizer.

It will be much {easier,sadder,lamer} to hard code
these in Java. sigh.

  • Participants
  • Parent commits 978b510
  • Branches default

Comments (0)

Files changed (1)

File top_down.rb

View file
 raise ArgumentError.new "too many arguments" if ARGV.length > 1
 raise ArgumentError.new "no argument given" if ARGV.empty?
-# A Token Type Detector
+## A Token Type Detector ##
 def detect(token)
 	TokenTypes.each do |type, matcher|
 		if token =~ matcher
 @enumerator = parsed_tokens.each
 @tree = Hash.new
+## Recognizer ##
 # Returns a symbol describing what is constructed by the token(bitch) 
 # and lookahead. For a token :return and a lookahead :"4", it returns
 # :ReturnStatement. For a token :lparen and a lookahead :ident it would
 	@cache[:"#{bitch},#{lookahead}"] ||=
 		Grammar.each do |key, val|
 		# Let's assume our key is :ReturnStatement and our val is [:return, :int_lit]
-			if bitch == val[0] && lookahead == val[1]
+			if bitch == first(val[0])
 				return key