/* This is a nonsense grammar from a programming contest: the lowercase words are non-terminals, the uppercase characters are the terminals of this language. slurpy -> slimp slump slimp -> A rest_slimp rest_slimp -> H rest_slimp -> B slimp C rest_slimp -> slump C slump -> d_or_e F f_string end d_or_e -> D d_or_e -> E f_string -> F f_string | lambda end -> slump end -> G Some strings in the language: AHDFG, ADFGCDFFFFFG, ABAEFGCCDFEFFFFFFG Some strings NOT in the lanuage: AHDFGA, DFGAH, ABABCC Assumption about input: Input is a file that contains lines of strings. The entire file is either accepted or rejected. */ import java.io.*; %% %class slurp %unicode %line %column %eofval{ return 0; %eofval} %{ /* Self-defined tokens */ static final int A_TOKEN=1; static final int B_TOKEN=2; static final int C_TOKEN=3; static final int D_TOKEN=4; static final int E_TOKEN=5; static final int F_TOKEN=6; static final int G_TOKEN=7; static final int H_TOKEN=8; static final int EOLN=100; %} %type int %% A {return(A_TOKEN);} B {return(B_TOKEN);} C {return(C_TOKEN);} D {return(D_TOKEN);} E {return(E_TOKEN);} F {return(F_TOKEN);} G {return(G_TOKEN);} H {return(H_TOKEN);} [ \t] {;} \r|\n|\r\n {return(EOLN);} . {;}