[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Grammatica-users] Simple question
From: |
Luc Morin |
Subject: |
[Grammatica-users] Simple question |
Date: |
Fri, 11 Mar 2005 11:41:47 -0500 |
Hi all,
Is it possible to have certain
tokens to be part of a production, but not to be included in the parse tree
?
For example, I want to create a
parse tree from the following line:
<5 1> = "allo" ?
<6> : <7<8 1>>
Which is a conditional
_expression_. I "need" the < and > tokens to be compatible with some third
party software, but I don't want to clutter the parse tree with
them.
I'd also like to get rid of the
=, ? and : tokens
I find that if I use the
%ignore% directive for those tokens, I get parse errors because of unreckognized
tokens.
Right now the parse tree looks
like this:
File(2001)
_expression_(2002)
Property(2004)
SMALLER_THAN(1005): "<",
line: 1, col: 1
Propnum(2005)
NUMBER(1007): "5",
line: 1, col: 2
Index(2006)
NUMBER(1007): "1",
line: 1, col: 4
GREATER_THAN(1004): ">",
line: 1, col: 5
CondStatement(2003)
EQUAL(1003): "=", line: 1,
col: 7
QUOTED_STRING(1006): ""allo"", line: 1,
col: 9
Q_MARK(1001): "?", line: 1, col:
16
Property(2004)
SMALLER_THAN(1005):
"<", line: 1, col: 18
Propnum(2005)
NUMBER(1007): "6", line: 1, col:
19
GREATER_THAN(1004): ">",
line: 1, col: 20
COLON(1002): ":", line: 1,
col: 22
Property(2004)
SMALLER_THAN(1005):
"<", line: 1, col: 24
Propnum(2005)
NUMBER(1007): "7", line: 1, col:
25
Property(2004)
SMALLER_THAN(1005): "<", line: 1, col:
26
Propnum(2005)
NUMBER(1007): "8", line: 1, col:
27
Index(2006)
NUMBER(1007): "1", line: 1, col:
29
GREATER_THAN(1004):
">", line: 1, col: 30
GREATER_THAN(1004): ">", line: 1, col: 31
I'd like it to look like
this:
File(2001)
_expression_(2002)
Property(2004)
Propnum(2005)
NUMBER(1007): "5",
line: 1, col: 2
Index(2006)
NUMBER(1007): "1",
line: 1, col: 4
CondStatement(2003)
QUOTED_STRING(1006):
""allo"", line: 1, col: 9
Property(2004)
Propnum(2005)
NUMBER(1007): "6", line: 1, col: 19
Property(2004)
Propnum(2005)
NUMBER(1007): "7", line: 1, col:
25
Property(2004)
Propnum(2005)
NUMBER(1007): "8", line: 1, col:
27
Index(2006)
NUMBER(1007): "1", line: 1, col: 29
Here's the
grammar:
------------------------8<----------------------------
%header%
GRAMMARTYPE = "LL"
DESCRIPTION = "A grammar for a new form generator."
AUTHOR = "Luc Morin"
VERSION = "1.0"
DATE = "10 march 2005"
%tokens%
Q_MARK = "?"
COLON = ":"
EQUAL = "="
GREATER_THAN = ">"
SMALLER_THAN = "<"
QUOTED_STRING = <<"[^"]*">>
NUMBER = <<[0-9]+>>
WHITESPACE = <<[ \t\n\r]+>> %ignore%
%productions%
File = _expression_+ ;
_expression_ = Property [CondStatement] ;
CondStatement = EQUAL QUOTED_STRING Q_MARK Property COLON Property ;
Property = SMALLER_THAN Propnum [Index] [Property] GREATER_THAN ;
Propnum = NUMBER ;
Index = NUMBER ;
------------------------8<----------------------------
Is that at all possible ? I
find that it makes "navigating" the tree easier.
Regards,
Luc
Morin
Electrical Designer
Wulftec / M.J. Maillis Group
address@hidden
Ph.: (819) 838-4232 ext. 232
Fx.: (819) 838-5539
<<
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] Simple question,
Luc Morin <=