A. Venkateswaran
2004-06-20 14:47:39 UTC
Hi,
What if I have invalid characters interspersed with what looks like an
identifier? For example:
bo$b
Which is the correct output?
a) Invalid character at line 1
b) <ID bo>
Invalid character at line 1
As I have it now, since the lexer chooses the regular expression which
matches the longest string, the regexp matching "bo" would be selected
producing an <ID bob> token, then input would begin again starting with "$",
which would match nothing, throwing the error message. So if output (a)
from above is correct, does this mean we need to explicitly check for the
following pattern: <letter><any number of valid identifier characters><one or more invalid identifier characters><any number of valid
identifier characters> ? so that we can catch this error?
Along the same lines, here's another:
bo!b
Which is correct?
a) <ID bo><NOT><ID b>
b) <ID bo>
Invalid character at line 1
c) Invalid character at line 1
Thank in advance,
Anandh
What if I have invalid characters interspersed with what looks like an
identifier? For example:
bo$b
Which is the correct output?
a) Invalid character at line 1
b) <ID bo>
Invalid character at line 1
As I have it now, since the lexer chooses the regular expression which
matches the longest string, the regexp matching "bo" would be selected
producing an <ID bob> token, then input would begin again starting with "$",
which would match nothing, throwing the error message. So if output (a)
from above is correct, does this mean we need to explicitly check for the
following pattern: <letter><any number of valid identifier characters><one or more invalid identifier characters><any number of valid
identifier characters> ? so that we can catch this error?
Along the same lines, here's another:
bo!b
Which is correct?
a) <ID bo><NOT><ID b>
b) <ID bo>
Invalid character at line 1
c) Invalid character at line 1
Thank in advance,
Anandh