1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * Copyright (C) 2000 Gerwin Klein <lsf@jflex.de> * 3 * All rights reserved. * 4 * * 5 * Thanks to Larry Bell and Bob Jamison for suggestions and comments. * 6 * * 7 * License: BSD * 8 * * 9 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 10 11%% 12 13%byaccj 14 15%{ 16 private Parser yyparser; 17 18 public Yylex(java.io.Reader r, Parser yyparser) { 19 this(r); 20 this.yyparser = yyparser; 21 } 22%} 23 24NUM = [0-9]+ ("." [0-9]+)? 25NL = \n | \r | \r\n 26 27%% 28 29/* operators */ 30"+" | 31"-" | 32"*" | 33"/" | 34"^" | 35"(" | 36")" { return (int) yycharat(0); } 37 38/* newline */ 39{NL} { return Parser.NL; } 40 41/* float */ 42{NUM} { yyparser.yylval = new ParserVal(Double.parseDouble(yytext())); 43 return Parser.NUM; } 44 45/* whitespace */ 46[ \t]+ { } 47 48\b { System.err.println("Sorry, backspace doesn't work"); } 49 50/* error fallback */ 51[^] { System.err.println("Error: unexpected character '"+yytext()+"'"); return -1; } 52