[antlr-interest] Re: parsing problem
lgcraymer
lgc at mail1.jpl.nasa.gov
Tue Dec 23 11:39:12 PST 2003
Thomas--
While you could count dots in the parser, it's probably easier to
have a
DOTS : ('.')+ ;
rule in the lexer and use semantic predicates:
a
:
d:DOTS
( { #d.getText().length() == 2 }? foo
| bar
)
;
for example. Or you could have a
dots
returns [ int count ]
:
d:DOTS { count = #d.getText().length(); }
;
and use the return value for a case statement in an action.
--Loring
--- In antlr-interest at yahoogroups.com, "thomaskrebs"
<Thomas_Krebs at g...> wrote:
> Hi,
>
> I have a problem parsing the following syntax:
> The format is a kind of serialized objects which are dumped like
this:
> Each object name is prefixed with one or more dots where the
number of
> dots describe the context in which the object is used. E.g.:
>
> .PAD "103th thermal"
> ..4_WEB_ROUND_THERMAL_45
> ...DIAMETER 103
> ...TIE_LEG_WIDTH 12
> ...THERMAL_CLEARANCE 12
> ..TIMESTAMP "1998/07/10 at 20:03:20"
> ..PAD_OPTIONS USER_GENERATED_NAME
> ..OFFSET (0, 0)
>
> That means I have an object "PAD" (of name "103th thermal") with
> members 4_WEB_ROUND_THERMAL_45, TIMESTAMP, PAD_OPTIONS and OFFSET.
> 4_WEB_ROUND_THERMAL_45 itself is an object with the members
DIAMETER,
> TIE_LEG_WIDTH and THERMAL_CLEARANCE.
> My problem now is that identical members can appear in objects and
> their members. So I have to take into account the 'context' where
they
> appear. That means that I have to evaluate the (number of) dots to
> be able to decide if an entry is a member of the current object or
> a member of the super object.
> Can somebody give me a hint how to do that?
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