declare
scanner LambdaScanner from GumpScanner.'class'
   attr LineNumber
   meth init()
      GumpScanner.'class', init()
      LineNumber <- 1
   end
   meth getLineNumber($)
      @LineNumber
   end

   lex digit = <[0-9]> end
   lex letter = <[A-Za-z]> end
   lex id = <{letter}({letter}|{digit})*> end
   lex int = <{digit}+> end

   lex <define>
      GumpScanner.'class', putToken1('define')
   end
   lex <lambda>
      GumpScanner.'class', putToken1('lambda')
   end
   lex <{id}> A in
      GumpScanner.'class', getAtom(?A)
      GumpScanner.'class', putToken('id' A)
   end
   lex <{int}> S in
      GumpScanner.'class', getString(?S)
      GumpScanner.'class', putToken('int' {String.toInt S})
   end
   lex <"."|"("|")"|"="|";"> A in
      GumpScanner.'class', getAtom(?A)
      GumpScanner.'class', putToken1(A)
   end

   lex <[ \t]> skip end
   lex <"%".*> skip end
   lex <\n>
      LineNumber <- @LineNumber + 1
   end
   lex <.>
      {System.showInfo 'line '#@LineNumber#': unrecognized character'}
      GumpScanner.'class', putToken1('error')
   end

   lex <<EOF>>
      GumpScanner.'class', putToken1('EOF')
   end
end
