Pegged: Syntax Highlighting

bls bizprac at orange.fr
Sat Mar 17 13:04:23 PDT 2012


On 03/17/2012 01:53 PM, Philippe Sigaud wrote:
> Does anyone have experience with other languages similar to D and that
> offer AST-walking? Doesn't C# have something like this?
> (I'll have a look at Scala macros)
>

Hi Philippe.
Of course the visitor pattern comes in mind.

Eclipse (Java) uses a specialized visitor pattern  called "hierarchical 
visitor pattern" to traverse the AST.

The classic visitor pattern has the following disadvantages :

-- hierarchical navigation -- the traditional Visitor Pattern has no 
concept of depth. As a result, visitor cannot determine if one composite 
is within another composite or beside it.

-- conditional navigation -- the traditional Visitor Pattern does not 
allow branches to be skipped. As a result, visitor cannot stop, filter, 
or optimize traversal based on some condition.

Interesting stuff at :

http://c2.com/cgi/wiki?HierarchicalVisitorPattern
You'll find some implementation details at the bottom of the doc.
hth Bjoern


More information about the Digitalmars-d-announce mailing list