KorMoon
KorMoon

Reputation: 15

How to differentiate "+" and +

I am trying to make a simple lexical analyzer for JISP where the content is:

["+", 1, 2]

Which is basically a simple addition operation. The problem is that the plus sign must be recognized as a valid addition token only if it is surrounded by quotation marks.

Hence "+" is a valid token while + is not a valid token

I tried to recognize this token with simply "+" printf("tADD") in the flex file. However, this expression recognizes both "+" and + as valid addition tokens. How can I accept "+" as a valid token while not recognizing + as a valid token.

Upvotes: 0

Views: 61

Answers (1)

Peter Thoeny
Peter Thoeny

Reputation: 7616

Escape the quotes:

"\"+\""  printf("tADD")

Upvotes: 1

Related Questions