AstNode underlying field names conflict with C# keywords

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Alexander Pavlyshak
Version: 4.0.0276
Avatar
Hi

When generating the parser from grammar XML, the generator doesn't prefix C# keywords which are used as variables with "@" character. For example, from this definition
<AstNode Name="SomeNode" Description="">
    <AstNodeProperty Name="Operator" PropertyType="Simple" Type="System.String" Description="" />
    <AstNodeProperty Name="Value" PropertyType="Simple" Type="System.String" Description="" />
</AstNode>
we'll get the following code:
private System.String    operator;
private System.String    value;
...

public System.String Operator {
    get {
        return operator;
    }
    set {
        operator = value;
    }
}


public System.String Value {
    get {
        return value;
    }
    set {
        value = value;
    }
}
which obviously won't compile. It should be
private System.String    @operator;
...
public System.String Operator {
    get {
        return @operator;
    }
    set {
        @operator = value;
    }
}
and similar for Value property.

BTW, why do you call the parser semantic parser, not syntax parser?

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks, this is now fixed for the next maintenance release.


Actipro Software Support

The latest build of this product (v23.1.2) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.