Posted 13 years ago by Wesner Moise
Version: 4.0.0233
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Avatar
You should really test out your .NET Addon C# Parser on the SSCLI source code of the .NET base class library.

Your parser has problems with attributes:

1) Attributes can be applied to each parameter in a method.
2) Attributes can be applied via attribute keywords to other parts of a method
[return: attribute]
[assembly: attribute]
etc

Secondly, I need to extend the C# Addon parser to support specifications with special comments starting with //@ or /*@.

For example,

void MyCode(int x, int y)
{
//@ require x + y == 2
}

Is there support for extending the parser (without using the blueprint license)? If not, is there support with the blueprint license.

Comments (6)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Wesner,

1) This appeared to be a bug. It was parsing attributes on the first attribute of a formal parameter list but not on the others. This is fixed for the next maintenance release.

2) This should already be working but maybe the bug in #1 made you think that wasn't supported.

3) To add special comments like that you would have to get the blueprint license and modify the lexer and semantic parser code yourself. If you have specific questions on the blueprint code after getting it you can email them over. But if it's something that will be extremely lengthy for us to work on then we may have to charge an hourly rate for the work. Generally people ask quick questions though, and those are free.


Actipro Software Support

Posted 12 years ago by Wesner Moise
Avatar
I still encounter syntax errors with the return keyword inside attributes. The following snippets of code illustrate the problem.

using System.Runtime.InteropServices;

[ComImport]
[Guid("CB5BDC81-93C1-11cf-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IObjectSafety
{
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int GetInterfaceSafetyOptions(ref Guid riid, [Out] out int pdwSupportedOptions, [Out] out int pdwEnabledOptions);

[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions);
}

[Modified at 08/13/2007 03:25 AM]
Posted 12 years ago by Wesner Moise
Avatar
The return text is probably being seen as a keyword, preventing it from being properly anaylyzed.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks, this is now fixed for the upcoming maintenance release.


Actipro Software Support

Posted 12 years ago by Wesner Moise
Avatar
I need to extend the C# Addon parser to support specifications with special comments starting with //@ or /*@.

For example,

void MyCode( /*nonnull*/ int x, int y)
//@ require x + y == 2
{
}

I have the .NET add-on + source. Is there a recommended approach that I should use to go about adding specifications? I want syntax highlighting inside the special @// comments and I want to be able to parse these comments correctly into an AST even as the comments may span multiple lines.

It seems the existing code base packs these comments in a special field in the AST. I also read that language merging was not yet supported.
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Wesner,

Correct, formal language merging is not supported quite yet with the add-on. While the semantic parsing will transition ok, the problem lies more in the context building code since that doesn't know how to skip over child languages.

This can be tricky, since comments can appear anywhere. What I would suggest is almost doing what we do for documentation comments. I believe those have their own lexical state so you can do syntax highlighting inside of them. As they are found, they are cached up in the RecursiveDescentLexicalParser and the retrieved by another production in the SemanticParser such as a type or member declaration. You would most likely want to do something similar for your child language but you would obviously pull in your special comments at different locations (like before a block or before a parameter declaration).


Actipro Software Support

The latest build of this product (v2018.1 build 0342) was released 12 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.