def step
case
when check( /program\s+/ )
start_group :keyword, scan( /program\s+/ )
start_group :function, scan_until( /(?=[;(\s]|#{EOL})/ )
when check( /subroutine\s+/ )
start_group :keyword, scan( /subroutine\s+/ )
start_group :function, scan_until( /(?=[;(\s]|#{EOL})/ )
when check( /function\s+/ )
start_group :keyword, scan( /function\s+/ )
start_group :function, scan_until( /(?=[;(\s]|#{EOL})/ )
when check( /module\s+/ )
start_group :keyword, scan( /module\s+/ )
start_group :function, scan_until( /(?=[;\s]|#{EOL})/ )
when check( /\.true\.|\.false\.|\.TRUE\.|\.FALSE\./ )
start_group :constant,
scan(/\.true\.|\.false\.|\.TRUE\.|\.FALSE\./)
when scan( /(\d+\.?\d*|\d*\.?\d+)([eEdDqQ][+-]?\d+)?(_\w+)?/ )
start_group :number, matched
when scan( /[bB]\'[01]+\'|[oO]\'[0-7]+\'|[zZ]\'[0-9a-fA-F]+\'/ )
start_group :number, matched
else
case peek(1)
when /[\n\r]/
start_group :normal, scan( /\s+/ )
when /\s/
start_group :normal, scan( /\s+/ )
when "!"
start_group :comment, scan( /![^\n\r]*/ )
when /[A-Za-z]/
word = scan( /\w+/ )
if KEYWORDS.include?(word)
start_group :keyword, word
elsif TYPES.include?(word)
start_group :type, word
elsif INTRINSICS.include?(word)
start_group :function, word
elsif
start_group :ident, word
end
when '"'
start_group :string, scan(/"([^"]*(&[ ]*[\n\r]+)?)*"/)
when "'"
start_group :string, scan(/'([^']*(&[ ]*[\n\r]+)?)*'/)
when /[-!?*\/+=<>()\[\]\{}:;,&|%]/
start_group :punct, scan(/./)
else
append getch
end
end
end