def next_token
return if @ss.eos?
text = @ss.peek(1)
@lineno += 1 if text == "\n"
token = case @state
when nil
case
when (text = @ss.scan(/\\(\(|\)|:|\*)/))
action { [:CHAR, @ss[1]] }
when (text = @ss.scan(/\:([a-zA-Z_]\w*)/))
action { [:PARAM, @ss[1]] }
when (text = @ss.scan(/\*([a-zA-Z_]\w*)/))
action { [:GLOB, @ss[1]] }
when (text = @ss.scan(/\(/))
action { [:LPAREN, text] }
when (text = @ss.scan(/\)/))
action { [:RPAREN, text] }
when (text = @ss.scan(/./))
action { [:CHAR, text] }
else
text = @ss.string[@ss.pos .. -1]
raise ScanError, "can not match: '" + text + "'"
end
else
raise ScanError, "undefined state: '" + state.to_s + "'"
end
token
end