%% %{public static void main(String [] args) throws java.io.IOException{ EnglishLexer yy= new EnglishLexer(System.in); while(true) yy.yylex(); } %} %class EnglishLexer %type void %eofval{ return; %eofval} NOUN = dog|cat|book|class|course VERB = likes|like|is|am|are|was|were|be|being|been|do|does|did|should|would|can|could|has|had|go ADVERB = very|simply|gently|quietly|calmly|angrily PREPOSITION = to|from|behind|above|below|between|below CONJUNCTIVE = if|then|and|but|or ADJECTIVE = my|your|her|his|its|their PRONOUN = she|he|I|we|you|they %% {VERB} {System.out.println("<" +yytext()+ "> is a verb"); } {NOUN} {System.out.println("<" +yytext()+ "> is a noun"); } [a-zA-Z]+ {System.out.println("<" +yytext()+ "> is not in our dictionary"); } \r|\n {System.out.println("\n");} . {}