Token at least one time

59 views Asked by At

I need to use javaCC to identify the correct syntax from the errors.

< #horario : "<"<hora>":"<minuto>"-"<hora>":"<minuto>">"<retorno> >
< #horarioError : "<" ("()"|"(" (~["<", ">"])+")")? ">"<retorno> >

The first one is the correct syntax and the second one identify tge errors.

An error definition can contain the correct syntax but at least one time the error.

This is what I thought, but it classifies the correct ones as an error:

< error : (<diaSemana>(<horarioError>|<horario>)<retorno>)+<delimitador> >

How can I make to appear at least one time horarioError in any line?

Thanks.

1

There are 1 answers

0
Theodore Norvell On

First off I think you are trying to do way too much at the lexical level. I suggest using parsing (BNF) rules for all but the lowest level tokenizing.

To answer the question, you can do the following:

< error : ( <diaSemana> 
            <horario><retorno>
          )*
          ( <diaSemana> 
            <horarioError><retorno>
          )
          ( <diaSemana> 
            (<horarioError>|<horario>)<retorno>
          )*
          <delimitador>
>