3+2*(126+4)=
I am Hamad Fawad
a
A
3.654e5
2/9*1=
2*+3=
pippo
%%
%standalone
%class Calc
nl = \n|\r|\r\n
intNumber = [1-9][0-9]*
scientificNo = [-+]?[0-9]*\..?+([eE])[-+-]?[0-9]+)?
Alphabets = [a-zA-Z]
Words = [a-zA-Z][a-zA-Z0-9]*
%%
{intNumber} {System.out.println("NUMBER: " +yytext());}
{scientificNo} {System.out.println("SNumber: " +yytext());}
{Alphabets} {System.out.println("Alphabets: " +yytext());}
{Words} {System.out.println("Words: " +yytext());}
"+" {System.out.println("PLUS");}
"-" {System.out.println("MINUS");}
"*" {System.out.println("STAR");}
"/" {System.out.println("DIV");}
"(" {System.out.println("OPEN_BRACKET");}
")" {System.out.println("CLOSE_BRACKET");}
"=" {System.out.println("EQUAL\n");}
"p" {System.out.println("Chracter";}
{nl}|" "|\t {;}
. {System.out.println("Error: " + yytext());}
|