I am tasked with a program that is a scanner. My alphabet is as follows:
all english letters (upper and lower), digits,
plus the extra character _ (underscore) & ws. Identifier begins with a letter and can
continue with any number of letters, digits or _ up to 10 significant characters.
I am wanting to make sure my table is correct. For some reason my scanner is not working with the underscore. I can get it work for letters and digits. I am trying to narrow down my problem and wanting to make sure it is not the table.
Here is my table, just a partial part:
// state token ws L D _
{ 0, 0, 0, 1, 11, 21,
{ 1, id_tk, -1, 2, 2, 2,
{ 2, id_tk, -1, 3, 3, 3,
{ 3, id_tk, -1, 4, 4, 4,
{ 4, id_tk, -1, 5, 5, 5,
{ 5, id_tk, -1, 6, 6, 6,
{ 6, id_tk, -1, 7, 7, 7,
{ 7, id_tk, -1, 8, 8, 8,
{ 8, id_tk, -1, 9, 9, 9,
{ 9, id_tk, -1, 10, 10, 10,
{ 10, id_tk, -1, -2, -2, -2,
{ 11, num_tk, -1, -1, 12, -2,
{ 12, num_tk, -1, -1, 13, -2,
{ 13, num_tk, -1, -1, 14, -2,
{ 14, num_tk, -1, -1, 14, -2,
{ 15, num_tk, -1, -1, 15, -2,
{ 16, num_tk, -1, -1, 16, -2,
{ 17, num_tk, -1, -1, 17, -2,
{ 18, num_tk, -1, -1, 18, -2,
{ 19, num_tk, -1, -1, 19, -2,
{ 20, num_tk, -1, -1, 20, -2,
{ 21, undrs_tk, -1, -2, -2, -2,
Legend is as follows:
WS = whitespace
L = letter
D = digit
_ = underscore
-1 = final state
-2 = error state
Is this table correct with the above mentioned alphabet? I really appreciate the help. Thanks