This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
GDB/MI Output Syntax ambiguity
- From: Bob Rossi <bob at brasko dot net>
- To: gdb at sources dot redhat dot com
- Date: Mon, 23 Aug 2004 17:03:14 -0400
- Subject: GDB/MI Output Syntax ambiguity
Hi,
I am generating a bottom up parser for 'GDB/MI Output Syntax' using
bison. Unfortunately, I think that I found an ambiguity, which makes it
not easily parsable. Please correct me if I am wrong.
output -> ( out-of-band-record )* [ result-record ] "(gdb)" nl
result-record -> [ token ] "^" result-class ( "," result )* nl
out-of-band-record -> async-record | stream-record
async-record -> exec-async-output | status-async-output | notify-asyn
exec-async-output -> [ token ] "*" async-output
status-async-output -> [ token ] "+" async-output
notify-async-output -> [ token ] "=" async-output
I am assuming that the grammar above for 'output' means that there can
be 0 or more 'out-of-band-record', followed by 0 or 1 'result-record',
followed by '(gdb)' and then a newline.
The problem is, when you are parsing 'output', and you get a 'token' as
the first token from the lexer, you don't know if that is part of the
'out-of-band-record' or if it is part of the 'result-record'. Both of
these rules optionally start with 'token'.Has anyone actually written a
recursive descent parser, or generated a parser from bison for GDB/MI's
output yet, or am I the first?
Help would be greatly appreciated. This is the only shift/reduce
conflict I have in my modified BNF version of the grammar. Other than
this, the grammar looks very well written.
I consider this to be a serious problem so I hope that I am not doing
something incorrectly or am mis-understanding the grammar.
Thanks,
Bob Rossi