[antlr-interest] Filtering ASTs?
Derek
electron_neutrino at yahoo.com
Fri Oct 29 02:13:25 PDT 2004
Hi
I am using the VAMS grammar
(http://www.antlr.org/grammar/1086696923011/vhdlams/vams.g) to parse
VHDL, as it is very similar, and build an AST.
However, in my tree grammar I only want to match parts of that tree,
not starting at the root node. How can I do this? There is a filter
option in the lexer but I want to use the full AST later.
The examples I have seen always have the same top rule in the tree
grammar and the parser grammar.
In vams.g the top rule is "design_file" but I want to only match
entities from the rule "entity_declaration" so that I can extract the
name. So, if in my tree grammar I have:
entity_declaration
: #(ENTITY name:identifier)
{ System.out.println("Got ENTITY named " + name.getText()); }
;
identifier
: BASIC_IDENTIFIER
| EXTENDED_IDENTIFIER
;
ANTLR will give this error message: "<AST>:0:0: expecting ENTITY,
found 'library'" for this test file:
library IEEE;
use IEEE.std_logic_1164.all;
entity test1 is
port
(
a : in std_logic;
b : out std_logic
);
end entity test1;
How can I only match the entities within a VHDL file without having to
have my tree grammar declare all the rules from "design_file" down to
"entity_declaration"?
Thanks in advance,
Derek
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list