Posted 18 years ago by John Youren
Version: 4.0.0233
Avatar
I'm just getting into generating a grammer for use with my university project. The problem is that when I generate a parser and import it into my project I get errors.

If I compare the generated code to that of the one in the example project there are differences, e.g.

Mine:
public partial class CompilationUnit : ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.AstNode {

Example:
public class CompilationUnit : AstNode, ICompilationUnit, ISemanticParseData {

I've attached my build output

C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(282,25): error CS0117: 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.CompilationUnit' does not contain a definition for 'SyntaxErrors'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(282,83): error CS0117: 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.CompilationUnit' does not contain a definition for 'SyntaxErrors'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(282,112): error CS0117: 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.CompilationUnit' does not contain a definition for 'SyntaxErrors'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(285,20): error CS0117: 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.CompilationUnit' does not contain a definition for 'SyntaxErrors'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(356,24): error CS0117: 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.FunctionDeclaration' does not contain a definition for 'BlockStartOffset'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(359,24): error CS0117: 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.FunctionDeclaration' does not contain a definition for 'BlockEndOffset'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(375,17): error CS1501: No overload for method 'Identifier' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\Identifier.cs(23,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\Identifier.cs(29,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(432,17): error CS1501: No overload for method 'VariableDeclarationStatement' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\VariableDeclarationStatement.cs(26,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\VariableDeclarationStatement.cs(32,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(445,17): error CS1501: No overload for method 'AssignmentStatement' takes '3' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\AssignmentStatement.cs(31,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\AssignmentStatement.cs(37,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(455,17): error CS1501: No overload for method 'ReturnStatement' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\ReturnStatement.cs(26,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\ReturnStatement.cs(32,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(531,5): error CS0246: The type or namespace name 'OperatorType' could not be found (are you missing a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(531,33): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(536,22): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(543,22): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(550,18): error CS1501: No overload for method 'BinaryExpression' takes '4' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\BinaryExpression.cs(34,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\BinaryExpression.cs(40,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(568,5): error CS0246: The type or namespace name 'OperatorType' could not be found (are you missing a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(568,33): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(573,22): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(580,22): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(587,18): error CS1501: No overload for method 'BinaryExpression' takes '4' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\BinaryExpression.cs(34,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\BinaryExpression.cs(40,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(605,5): error CS0246: The type or namespace name 'OperatorType' could not be found (are you missing a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(605,33): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(610,22): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(617,22): error CS0103: The name 'OperatorType' does not exist in the current context
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(624,18): error CS1501: No overload for method 'BinaryExpression' takes '4' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\BinaryExpression.cs(34,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\BinaryExpression.cs(40,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(643,19): error CS1501: No overload for method 'NumberExpression' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\NumberExpression.cs(23,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\NumberExpression.cs(29,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(652,19): error CS1501: No overload for method 'SimpleName' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\SimpleName.cs(23,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\SimpleName.cs(29,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(656,47): error CS1501: No overload for method 'Identifier' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\Identifier.cs(23,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\Identifier.cs(29,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(656,18): error CS1502: The best overloaded method match for 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.FunctionAccessExpression.FunctionAccessExpression(ActiproSoftware.SyntaxEditor.TextRange)' has some invalid arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(656,47): error CS1503: Argument '1': cannot convert from 'ActiproSoftware.SyntaxEditor.Addons.Simple.Ast.Identifier' to 'ActiproSoftware.SyntaxEditor.TextRange'
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\SimpleSemanticParser.cs(676,18): error CS1501: No overload for method 'ParenthesizedExpression' takes '2' arguments
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\ParenthesizedExpression.cs(26,10): (Related location)
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SyntaxTest\SyntaxTest\Generated\ParenthesizedExpression.cs(32,10): (Related location)
Thanks!

Comments (7)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

When generating ASTs from the semantic grammar definition, the ASTs that are output are
intended to be a starting point only. Although sometimes they may contain everything that
you need for certain AST nodes, sometimes you will want to add other overrides or constructors, etc.
to the AST nodes. Therefore you customize the nodes once they have been initially generated.
Although the Simple language AST nodes that ship in the sample were originally generated from
the grammar, I believe they have been customized a little from what the grammar outputs.
Does that help?


Actipro Software Support

Posted 18 years ago by John Youren
Avatar
Thank you for the reply.

I now know that I wasen't doing anything wrong, but I really wanted to build up my grammar as I went along, so that I can test and document each part. Would you ever be willing to improve the grammar designer so that it generates compilable code? It would be great if when ever there is a SyntaxEditor or grammar update I could just rebuild my grammar and overwrite the old one.

Thanks
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I think it does currently build compilable code however what we probably would
need so that you can always keep it in sync is a way to add custom properties,
methods and constructors to it. Maybe we just need to add a custom code tag
section for each AST tag similar to the Declarations part of the main grammar.
What do you think?


Actipro Software Support

Posted 18 years ago by John Youren
Avatar
Quote:
Maybe we just need to add a custom code tag
section for each AST tag similar to the Declarations part of the main grammar.


Yep, thats fine, also could you double check that it makes compilable code. Having a solid base is something I can extend on, and use to learn.

Thanks for your time!

[Modified at 11/06/2006 12:56 PM]
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

For the next maintenance release we now have implemented the ability to add custom code to the AST node declarations in the grammar. And the Simple example will now show this along with actually running off all the generated AST node classes.


Actipro Software Support

Posted 17 years ago by John Youren
Avatar
The code generation is better, however there is still one problem.

The code uses the enum OperatorType. This is declared in SyntaxEditor.Addons.DotNet.Net20 which I have to reference, but if I add a using statement, then I get ambigous errors.

Once I fully reference OperatorType (include namespace etc) it works.

Thanks
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

OperatorType is an enum defined in the sample project's Languages/SimpleAddon folder. It is not code generated (thus why it is defined in that folder), but it is referenced by some of the generated AST code.

You will never need to reference another add-on for the Simple language sample.


Actipro Software Support

The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.