Root -> Leaf visiting possible?

View: New views
4 Messages — Rating Filter:   Alert me  

Root -> Leaf visiting possible?

by twashing :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi there,

Is there a way to do Root -> Depth parsing? I took a look at the Visitors that are generated by sablecc. The DepthFirstAdapter parses from the leaf to the root of the expression tree. The ReverseDepthFirstAdapter parses expression A) like the order in B). Ideally, I would like the parse order to be something like C). How can I visit the tree starting from the Root and ending with the leaves?

Thanks in advance
Tim


A) /system[ @sys1='value' and @sys2='value' ]/application[ @app1='value' or @app2='value' ][ @app3='value' ]

B)
/
application
[
@app3='value'
]
[
@app1='value'
or
@app2='value'
]
/
system
[
@sys1='value'
and
@sys2='value'
]

C)
/
system
[
@sys1='value'
and
@sys2='value'
]
/
application
[
@app1='value'
or
@app2='value'
]
[
@app3='value'
]





Now with a new friend-happy design! Try the new Yahoo! Canada Messenger
_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

Re: Root -> Leaf visiting possible?

by Etienne M. Gagnon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Tim,

The inXXX() methods and/or the defaultIn() method in DepthFirstAdapter is what you are looking for, I think.

There is one inXXX() method for each alternative of the grammar. By default when not redefined (overridden), it calls defaultIn().

The defaultIn() method is called when entering every alternative node in the AST, unless the inXXX() was overridden by a version that does not call defaultIn().

Merry Xmas!

Etienne

Timothy Washington wrote:
Is there a way to do Root -> Depth parsing? I took a look at the Visitors that are generated by sablecc. The DepthFirstAdapter parses from the leaf to the root of the expression tree. The ReverseDepthFirstAdapter parses expression A) like the order in B). Ideally, I would like the parse order to be something like C). How can I visit the tree starting from the Root and ending with the leaves?
[...]
A) /system[ @sys1='value' and @sys2='value' ]/application[ @app1='value' or @app2='value' ][ @app3='value' ]
[...]
B)
C)
/
system
[
@sys1='value'
and
@sys2='value'
]
/
application
[
@app1='value'
or
@app2='value'
]
[
@app3='value'
]

-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            http://sablecc.org


_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

signature.asc (265 bytes) Download Attachment

Re: Root -> Leaf visiting possible?

by twashing :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Oh ho!! Ok I'll give that a try when I get back. I'm taking a few days for Christmas here in T.O. Thanks Etienne, and Merry Christmas to you too :)

Cheers
Tim



From: Etienne M. Gagnon <egagnon@...>
To: Discussion mailing list for the SableCC project <sablecc-discussion@...>
Sent: Thursday, December 25, 2008 8:56:19 PM
Subject: Re: Root -> Leaf visiting possible?

Hi Tim,

The inXXX() methods and/or the defaultIn() method in DepthFirstAdapter is what you are looking for, I think.

There is one inXXX() method for each alternative of the grammar. By default when not redefined (overridden), it calls defaultIn().

The defaultIn() method is called when entering every alternative node in the AST, unless the inXXX() was overridden by a version that does not call defaultIn().

Merry Xmas!

Etienne

Timothy Washington wrote:
Is there a way to do Root -> Depth parsing? I took a look at the Visitors that are generated by sablecc. The DepthFirstAdapter parses from the leaf to the root of the expression tree. The ReverseDepthFirstAdapter parses expression A) like the order in B). Ideally, I would like the parse order to be something like C). How can I visit the tree starting from the Root and ending with the leaves?
[...]
A) /system[ @sys1='value' and @sys2='value' ]/application[ @app1='value' or @app2='value' ][ @app3='value' ]
[...]
B)
C)
/
system
[
@sys1='value'
and
@sys2='value'
]
/
application
[
@app1='value'
or
@app2='value'
]
[
@app3='value'
]

-- 
Etienne M. Gagnon, Ph.D.
SableCC: http://sablecc.org


Get the name you've always wanted ! @ymail.com or @rocketmail.com.
_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

Re: Root -> Leaf visiting possible?

by twashing :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Yes, ok I think that's it. Thanks very much :) 

Tim



From: Etienne M. Gagnon <egagnon@...>
To: Discussion mailing list for the SableCC project <sablecc-discussion@...>
Sent: Thursday, December 25, 2008 8:56:19 PM
Subject: Re: Root -> Leaf visiting possible?

Hi Tim,

The inXXX() methods and/or the defaultIn() method in DepthFirstAdapter is what you are looking for, I think.

There is one inXXX() method for each alternative of the grammar. By default when not redefined (overridden), it calls defaultIn().

The defaultIn() method is called when entering every alternative node in the AST, unless the inXXX() was overridden by a version that does not call defaultIn().

Merry Xmas!

Etienne

Timothy Washington wrote:
Is there a way to do Root -> Depth parsing? I took a look at the Visitors that are generated by sablecc. The DepthFirstAdapter parses from the leaf to the root of the expression tree. The ReverseDepthFirstAdapter parses expression A) like the order in B). Ideally, I would like the parse order to be something like C). How can I visit the tree starting from the Root and ending with the leaves?
[...]
A) /system[ @sys1='value' and @sys2='value' ]/application[ @app1='value' or @app2='value' ][ @app3='value' ]
[...]
B)
C)
/
system
[
@sys1='value'
and
@sys2='value'
]
/
application
[
@app1='value'
or
@app2='value'
]
[
@app3='value'
]

-- 
Etienne M. Gagnon, Ph.D.
SableCC:                                            http://sablecc.org


Yahoo! Canada Toolbar : Search from anywhere on the web and bookmark your favourite sites. Download it now!


_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion