0

I was wondering what's the difference between a Terminal symbol and a Token generated in Lexical Analysis, as well as a Non-terminal and a Lexeme.

Seems to me like they are the same thing, but used interchangeably depending on the context of which you use them in.

gEdringer
  • 16,284
  • 3
  • 14
  • 27
  • 2
    Related: http://stackoverflow.com/questions/14954721/what-is-the-difference-between-token-and-lexeme – BlackBear Jan 03 '16 at 18:49
  • @BlackBear given that thread, when I say: assignment => exp '=' exp ... then exp '=' exp is a lexeme of the token called assignment yes? – gEdringer Jan 03 '16 at 19:54
  • @gEdringer No, in that production `assignment` and `exp` are non-terminals and `=` is a terminal. Given the input `x=42+y`, the lexemes would be "x", "=", "42", "+" and "y" and the tokens would be something like `ID("x")`, `EQ`, `INT(42)`, `PLUS` and `ID("y")`. – sepp2k Jan 05 '16 at 13:38

0 Answers0