Your abstract statement syntax is actually:
VARIABLE = STRING
and not
VARIABLE = 'STRING'
because the quote delimiters are a lexical detail that we generally want to keep out of the syntax. And so, the token patterns are actually this:
ID [a-zA-Z_][a-zA-Z0-9_]*
STRING '[a-zA-Z_0-9]*'
An ID
is a letter or underscore, followed by any combination (including empty) of letters, digits and underscores.
A STRING
is a single quote, followed by a sequence (possibly empty) letters, digits and underscores, followed by another single quote.
So the ambiguity you are concerned about does not exist. An ID
is not in fact a STRING
, nor vice versa.
Somewhere inside your Bison parser, or possibly in the lexer, you might want to massage the yytext
of a STRING
match to remove the quotes and just retain the text in between them as a string. This could be a Bison rule, possibly similar to:
string : STRING
{
$$ = strip_quotes($1);
}
;