On 01/31/2013 11:30 AM, Vladimir Kazanov wrote:
> Hi, all!
>
> I have been playing with "java.wy" grammar (switched to it by changing
> the autoloads), looking for ways to make variables from the
> initialization expression available in autocompletion. Example:
>
> void main(String args[]) {
> String outer;
> for (String arg: args) {
> ar // I want arg to be available here
> }
> }
>
> So, first thing I did was changing TODOs in the "foreach_statement"
> production into something like the following:
>
> foreach_statement
> : FOR LPAREN type variable_declarator_id
> COLON expression RPAREN statement
> (EXPANDTAG
> (VARIABLE-TAG $4 $3 nil))
>
> Then compile/reload the table/check. Nothing. I don't get it! For some
> reason I only have "outer" variable. But if I add "(message "foreach
> found")" instead of the macros - it shows shows everything correctly. I
> studied semantic-get-local-variables in wisent/java.el. Local scope
> parsing logic seems to be correct, but the wisent parser only goes until
> "for". I have also checked lexer output - everything looks fine.
>
> Same goes to usual "for" loops.
>
> Thus, the questions:
>
> 1) am I missing or misunderstanding something about the parser?
Yes. The value created with you EXPANDTAG call becomes the value of the
foreach_statement where that is used. If you look at its caller:
statement
: statement_without_trailing_substatement
| labeled_statement
| if_then_statement
| if_then_else_statement
| while_statement
| for_statement
| foreach_statement
;
it has no production, so the value of your EXPANDTAG becomes the value
of statement. The caller of that is this:
block_statement
: local_variable_declaration_statement
| statement
() ;; TODO
| class_declaration
| enum_declaration
| interface_declaration
;
and your value goes up through misc things I didn't follow to:
block
: LBRACE block_statements_opt RBRACE
(progn $2)
| LBRACE error
;; On error, skip current block and try to continue.
(SKIP-BLOCK)
;
which captures your value in the progn.
One of the places block is used is:
method_body
: block
| SEMICOLON
()
;
and that is used here:
method_declaration
: method_header method_body
(let ((tag (eval $1)))
;; Don't store the :body attribute in function tag as this
;; information is not (yet) used by Semantic. This will save
;; space in the DB.
;;(semantic-tag-put-attribute tag :body $2)
(EXPANDTAG tag)
)
;
and there it is. $2 (the method_body) is not stored in your tag.
I think you need to uncomment that line.
> 2) can somebody recommend another method of debugging the issue?
I just traced through the file. Unfortunately, the wisent parser
generator didn't get a nice step-through debugger feature as the bovine
one did.
> PS. 3) And why does cedet-devel on sourceforge shows all my emails as
> empty? :)
Cute. Set your email client to send plain text messages. It appears to
dislike your html attachment that is your message body.
Eric
|