0

I'm using jflex and i have to recognize characters, which can be:

  • Normal chars, like 'a'
  • Numbers, like '\126'

I've made this regular expression (Integer is a macro already defined):

Character = (\'.\')|(\'\\{Integer}\')

I don't know if it's ok, but my real problem is that i don't know what code i have to put to turn both type of strings into Characters, because this doesn't work:

{Character} { this.yylval = new Character(yytext());
              return Parser.CHARACTER; }

Any idea?

novayhulk14
  • 113
  • 11

1 Answers1

0

You have to write valid Java: the only constructor for Character is Character(char) but you are invoking Character(String).

You need to extract what you want from yytext().

rds
  • 26,253
  • 19
  • 107
  • 134