This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GDB/MI Output Syntax


On Thu, Aug 26, 2004 at 04:44:06PM -0400, Michael Chastain wrote:
> Grammar comments:
> 
> ===
> 
> Can you write the terminal symbols in ALL CAPS;
> that's the usual style for bison grammars.
> 
> I think the terminals are:
> 
>   STRING C_STRING CR LF TOKEN
>   "(gdb)" "^" "*" "+" "=" "," "~" "@" "&"
>   "done" "running" "connected" "error" "exit"
>   "stopped"
> 
> The literal strings are okay as is, but I'd really like
> symbolic terminals capitalized.

Done. 

I would prefer remove all string literals. Or make rules for them.
gdb -> "(gdb)"
done -> "done"

Any thoughts?
> 
> ===
> 
> Hmmm, in my gdb.log, there is a space in "(gdb) ^M", but in
> the gdb.texinfo grammar and the new grammar, there is no space.

My lexer ignores whitespace,
[ \t\v\f]               {}
is this bad?

we could note in the doco that the grammar doesn't care about
whitespace. Or, we could fix GDB in that case?
> ===
> 
> In the result_record rules:
> 
>   result_record -> opt_token "^" result_class
>   result_record -> opt_token "^" result_class "," opt_result_list
> 
> In the second form, if there is a ",", there must be at least
> one result.  So the last symbol should be result_list rather
> than opt_result_list.
> 

Done, and this is great because it remove the dependency of
opt_result_list. It is no longer needed.
> ===
> 
> Same deal with the async_output rule:
> 
>   async_output -> async_class "," opt_result_list
> 
> This should be like result_record.  If opt_result_list is empty
> then there is no "," .  Example:
> 
>   403*stopped^M
>   (gdb) ^M
> 
> In fact async_output doesn't add much value to the grammar.
> How about just:
> 
>   async_record -> opt_token async_record_class async_class
>   async_record -> opt_token async_record_class async_class "," result_list

Very very good. Done.

Personally, this grammar seems much easier for me to understand,
however, I will look at it more to see if it can be reduced or
simplified anymore.

Here is an update that still seems to work with bison. Andrew, do you
like the idea of starting with a grammar like this, and then showing it
in the style that's on the webpage? Or what do you have in mind?

opt_output_list         -> epsilon | output_list
output_list             -> output | output_list output
output                  -> opt_oob_record_list opt_result_record "(gdb)" nl
opt_oob_record_list     -> epsilon | opt_oob_record_list oob_record nl
opt_result_record       -> epsilon | result_record nl
result_record           -> opt_token "^" result_class
result_record           -> opt_token "^" result_class "," result_list
oob_record              -> async_record | stream_record
async_record            -> opt_token async_record_class async_class
async_record            -> opt_token async_record_class async_class "," result_list
async_record_class      -> "*" | "+" | "="
result_class            -> "done" | "running" | "connected" | "error" | "exit"
async_class             -> "stopped"
result_list             -> result | result_list "," result
result                  -> variable "=" value
variable                -> STRING
value_list              -> value | value_list "," value
value                   -> C_STRING | tuple | list
tuple                   -> "{}" | "{" result_list "}"
list                    -> "[]" | "[" value_list "]" | "[" result_list "]"
stream_record           -> stream_record_class C_STRING
stream_record_class     -> "~" | "@" | "&"
nl                      -> CR | LF | CR LF
opt_token               -> epsilon | TOKEN

BTW, I don't have any string literals in my real grammar. I return
tokens from the parser for each of this. So, I have 

"(gdb)" -> GDB
token   -> INTEGER_LITERAL
CR | LF | CR LF -> NEWLINE

is this pertinant?

Thanks,
Bob Rossi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]