0

I started here and here to come up with the following start, but I am getting the error: "Problems calling org.antlr.v4.gui.TestRig.main(args)". If someone could tell me where I am messing up I would appreciate it

Form to parse : dd/mm/yyyy

  • dd must be between 01 and 31
  • mm must be between 01 and 12

    lexer grammar dates;
    
    fragment DIGIT: [0123456789];
    
    DATE : DAY ('/'MONTH+) ('/'YEAR+)
        {System.out.println(getText() + " is a valid Date");};
    
    DAY : TWODIGIT
        {Integer.parseInt(getText()) >= 1 && Integer.parseInt(getText()) <= 31}?;
    MONTH : TWODIGIT
        {Integer.parseInt(getText()) >= 1 && Integer.parseInt(getText()) <= 12}?;
    YEAR : FOURDIGIT
        {Integer.parseInt(getText()) >= 2000 && Integer.parseInt(getText()) <= 2100}?;
    
    TWODIGIT : DIGIT DIGIT;
    FOURDIGIT : DIGIT DIGIT DIGIT DIGIT;
    WS: [\r\n\t]+{skip();};
    

Does the problem have to do with the fact that according to how things are currently, all months are days?

Thanks!

Community
  • 1
  • 1

0 Answers0