Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: RIL on August 23, 2013, 08:07:10 am
-
I'm trying to pick up COMMENT as a node in the AST tree, but it seems like it doesn't even try as long as <COMMENT> is defined as a token (in the beginning of the nBNF file).
I noticed that the Simple Example started with the following declaration for tokens, and, it seems to me, thus suppressing node generation from any of those tokens:
<TOKENS> ::= <WHITESPACE> |
<COMMENT> | <--- Huh?
token(<NUMBER>) |
token(<QUOTE>) token(<STRING_BODY>) token(<QUOTE>) |
token( keywords() ) |
token(<IDENTIFIER>);
What I'm at is that since EA recognizes the term COMMENT as a distinct model element, then why is a comment considered being only a "token" (and thus can't be picked up and stored in the model)?
I might be entirely off track here though. Am I missing the meaning of token vsv terms/named nodes? Something else? Or all of it? :)
I couldn't find a clear description in the help about how EA parser treats tokens compared to named nodes.
// Rolf
-
So make it a token?
<TOKENS> ::= <WHITESPACE> |
token(<COMMENT>) |
token(<NUMBER>) |
token(<QUOTE>) token(<STRING_BODY>) token(<QUOTE>) |
token( keywords() ) |
token(<IDENTIFIER>);
In your parse statement you then specify that as a language escape.
parse(<translationUnit>, <languageEscape>);
<languageEscape> ::= attribute("COMMENT", <COMMENT>);
-
Ok, thank you Simon, this really clears up my fog.
I was entirely off track, simply had a "missing link" leading me astray, but now things are getting interesting. :)
// Rolf