[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Grammatica-users] GetParent question
From: |
Luc Morin |
Subject: |
[Grammatica-users] GetParent question |
Date: |
Sat, 13 Dec 2003 13:26:21 -0500 |
Hi,
I'm trying to create an Analyzer for the following simple grammar:
/*-------------------------------------------------------------------*/
%header%
GRAMMARTYPE = "LL"
DESCRIPTION = "A grammar for Eplan 21 Format Strings."
AUTHOR = "Luc Morin"
VERSION = "1.0"
DATE = "9 December 2003"
%tokens%
LEFT_BRACKET = "<"
RIGHT_BRACKET = ">"
SPACE = <<[ ]+>>
NUMBER = <<[0-9]+>>
WHITESPACE = <<[\t\n\r]+>> %error unexpected token%
ALPHA = <<[a-zA-Z]+>> %error
unexpected token%
%productions%
Property = LEFT_BRACKET NUMBER [Index] [IndirectProperty] RIGHT_BRACKET ;
Index = SPACE NUMBER ;
IndirectProperty = Property ;
/*-----------------------------------------------------------------------*/
I'm overriding some of the Exit functions in my own Analyzer, for example
ExitProperty(Production node).
Here's a printout of the parse tree for the input string "<5<10>>"
Property(2001)
LEFT_BRACKET(1001): "<", line: 1, col: 1
NUMBER(1004): "5", line: 1, col: 2
IndirectProperty(2003)
Property(2001)
LEFT_BRACKET(1001): "<", line: 1, col: 3
NUMBER(1004): "10", line: 1, col: 4
RIGHT_BRACKET(1002): ">", line: 1, col: 6
RIGHT_BRACKET(1002): ">", line: 1, col: 7
I need to know if a property(2001) has an IndirectProperty(2003) parent, as the
treatment is different. The problem is that within ExitProperty(), the
Production cannot access its parent node. A call to node.GetParent() always
returns null.
Is this a normal behavior?
How can I access the parent node of a Production ?
Thanks
Luc Morin
Electrical Designer
Wulftec / M.J. Maillis Group
Ph.: (819) 838-4232 ext. 232
Fx.: (819) 838-5539
www.wulftec.com
www.maillis.gr
<< Avis de confidentialité >>
Ce courrier électronique ainsi que tous les documents qui y sont attachés sont
de nature privilégiée et confidentielle et sont destinés à l'utilisation
exclusive du ou des destinataire(s) ci-haut mentionné(s) . Toute autre personne
ayant reçu ce message par erreur est priée de bien vouloir s'abstenir de
divulguer, distribuer ou reproduire ce message et/ou son contenu. Si le
destinataire ne peut être rejoint ou vous est inconnu, nous vous prions
d'informer immédiatement l'expéditeur de ce présent message par retour de
courriel en plus d'effacer ce message et détruire toutes les copies. Merci.
<< Confidentiality Notice >>
This e-mail message and any files transmitted with it are confidential, may be
privileged and are intended for the exclusive use of the addressee(s). Any
other person is strictly prohibited from disclosing, distributing or
reproducing it. If the addressee cannot be reached or is unknown to you, please
inform the sender by return e-mail immediately, delete this e-mail message and
destroy all copies. Thank you.
- [Grammatica-users] GetParent question,
Luc Morin <=