cmListFileLexer: Allow command names with one letter (#14181)

Teach the lexer to treat a single letter as an identifier instead of an
unquoted argument.  Outside of a command invocation, the parser treats
an identifier as a command name and an unquoted argument as an error.
Inside of a command invocation, the parser treats an identifier as an
unquoted argument.  Therefore this change to the lexer will make what
was previously an error case work with no other behavioral change.
This commit is contained in:
Brad King 2013-10-14 15:24:06 -04:00
parent 8f2b0c3307
commit 56457837e2
5 changed files with 11 additions and 2 deletions

View File

@ -381,7 +381,7 @@ struct yy_trans_info
static yyconst flex_int16_t yy_accept[45] = static yyconst flex_int16_t yy_accept[45] =
{ 0, { 0,
0, 0, 0, 0, 17, 6, 14, 1, 8, 2, 0, 0, 0, 0, 17, 6, 14, 1, 8, 2,
6, 3, 4, 6, 15, 9, 11, 12, 13, 6, 6, 3, 4, 5, 15, 9, 11, 12, 13, 6,
0, 6, 0, 14, 2, 0, 5, 6, 9, 0, 0, 6, 0, 14, 2, 0, 5, 6, 9, 0,
10, 0, 7, 0, 0, 0, 7, 0, 7, 0, 10, 0, 7, 0, 0, 0, 7, 0, 7, 0,
0, 0, 0, 0 0, 0, 0, 0

View File

@ -107,7 +107,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\"
return 1; return 1;
} }
[A-Za-z_][A-Za-z0-9_]+ { [A-Za-z_][A-Za-z0-9_]* {
lexer->token.type = cmListFileLexer_Token_Identifier; lexer->token.type = cmListFileLexer_Token_Identifier;
cmListFileLexerSetToken(lexer, yytext, yyleng); cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng; lexer->column += yyleng;

View File

@ -0,0 +1 @@
message

View File

@ -0,0 +1,7 @@
function(f)
g(${ARGN})
endfunction()
macro(g)
message(${ARGN})
endmacro()
f(message)

View File

@ -9,6 +9,7 @@ run_cmake(CommandError1)
run_cmake(String0) run_cmake(String0)
run_cmake(String1) run_cmake(String1)
run_cmake(StringNoSpace) run_cmake(StringNoSpace)
run_cmake(OneLetter)
run_cmake(Unquoted0) run_cmake(Unquoted0)
run_cmake(Unquoted1) run_cmake(Unquoted1)
run_cmake(ParenNoSpace) run_cmake(ParenNoSpace)