diff options
author | Pierre-Marie de Rodat <derodat@adacore.com> | 2015-08-19 17:12:48 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2015-08-20 10:12:24 +0200 |
commit | af39b3270a1385027b2a5d145b9ba7564bd39f7a (patch) | |
tree | d8376e96f1f09543651fe48bb625603aa410fc1d /gdb/ada-lex.l | |
parent | 9215b98bb27c071386a277f5578dbb17569a1471 (diff) | |
download | binutils-gdb-af39b3270a1385027b2a5d145b9ba7564bd39f7a.tar.gz |
[Ada] Fix parsing for expressions with attributes and characters
Before this change, trying to evaluate the following Ada expression
yielded a syntax error, even though it's completely legal:
(gdb) p s'first = 'a'
Error in expression, near `'.
The problem lies in the lexer (gdb/ada-lex.l): at the point we reach "'a'",
we're still in the BEFORE_QUAL_QUOTE start condition (the mechanism to
distinguish character literals from other "tick" usages: qualified
expressions and attributes), so we consider that this quote is actually a
separate "tick".
This changes resets the start condition to INITIAL in the
{TICK}[a-zA-Z][a-zA-Z]+ rule (for attributes): attributes activate this
BEFORE_QUAL_QUOTE condition and in this case the above rule is always
executed rather than the <BEFORE_QUAL_QUOTE>"'" one (in flex, it's
always the longest match that is chosen). We now have instead:
(gdb) p s'first = 'a'
$1 = true
gdb/ChangeLog:
* ada-lex.l: Reset the start condition to INITIAL in the rule
that matches attributes.
gdb/testsuite/ChangeLog:
* gdb.ada/attr_ref_and_charlit.exp: New testcase.
* gdb.ada/attr_ref_and_charlit/foo.adb: New file.
Tested on x86_64-linux, no regression.
Diffstat (limited to 'gdb/ada-lex.l')
-rw-r--r-- | gdb/ada-lex.l | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 7ef6efb0553..1a93a5ce960 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -205,7 +205,7 @@ false { return FALSEKEYWORD; } /* ATTRIBUTES */ -{TICK}[a-zA-Z][a-zA-Z]+ { return processAttribute (yytext+1); } +{TICK}[a-zA-Z][a-zA-Z]+ { BEGIN INITIAL; return processAttribute (yytext+1); } /* PUNCTUATION */ |