diff options
author | Brad King <brad.king@kitware.com> | 2013-10-14 19:24:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-17 13:06:59 (GMT) |
commit | 56457837e28de29d4f94b0cc9c47ef314d8f05e1 (patch) | |
tree | 89c9eb6855fab9b6b6169b8086c523a731367f38 | |
parent | 8f2b0c330706fe479fb0804b3526bf28503cd52a (diff) | |
download | CMake-56457837e28de29d4f94b0cc9c47ef314d8f05e1.zip CMake-56457837e28de29d4f94b0cc9c47ef314d8f05e1.tar.gz CMake-56457837e28de29d4f94b0cc9c47ef314d8f05e1.tar.bz2 |
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.
-rw-r--r-- | Source/cmListFileLexer.c | 2 | ||||
-rw-r--r-- | Source/cmListFileLexer.in.l | 2 | ||||
-rw-r--r-- | Tests/RunCMake/Syntax/OneLetter-stderr.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Syntax/OneLetter.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/Syntax/RunCMakeTest.cmake | 1 |
5 files changed, 11 insertions, 2 deletions
diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index f127add..ad5a83d 100644 --- a/Source/cmListFileLexer.c +++ b/Source/cmListFileLexer.c @@ -381,7 +381,7 @@ struct yy_trans_info static yyconst flex_int16_t yy_accept[45] = { 0, 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, 10, 0, 7, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 0 diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l index bd3c1eb..89f2917 100644 --- a/Source/cmListFileLexer.in.l +++ b/Source/cmListFileLexer.in.l @@ -107,7 +107,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\" return 1; } -[A-Za-z_][A-Za-z0-9_]+ { +[A-Za-z_][A-Za-z0-9_]* { lexer->token.type = cmListFileLexer_Token_Identifier; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; diff --git a/Tests/RunCMake/Syntax/OneLetter-stderr.txt b/Tests/RunCMake/Syntax/OneLetter-stderr.txt new file mode 100644 index 0000000..87c01c7 --- /dev/null +++ b/Tests/RunCMake/Syntax/OneLetter-stderr.txt @@ -0,0 +1 @@ +message diff --git a/Tests/RunCMake/Syntax/OneLetter.cmake b/Tests/RunCMake/Syntax/OneLetter.cmake new file mode 100644 index 0000000..3c341fa --- /dev/null +++ b/Tests/RunCMake/Syntax/OneLetter.cmake @@ -0,0 +1,7 @@ +function(f) + g(${ARGN}) +endfunction() +macro(g) + message(${ARGN}) +endmacro() +f(message) diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index 94963f3..2d87328 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -9,6 +9,7 @@ run_cmake(CommandError1) run_cmake(String0) run_cmake(String1) run_cmake(StringNoSpace) +run_cmake(OneLetter) run_cmake(Unquoted0) run_cmake(Unquoted1) run_cmake(ParenNoSpace) |