[antlr-interest] Value types - can't be set to null in C#

Micheal J open.zone at virgin.net
Tue Jan 8 02:47:57 PST 2008


> "Small" bug indeed... The entire problem is based on the 
> fact, that there is only a limited map in CSharp.stg, which 
> includes basically only the inbuilt value types (edited to 
> include DateTime):
> 
> csharpTypeInitMap ::= [
> 	"int":"0",
> 	"uint":"0",
> 	"long":"0",
> 	"ulong":"0",
> 	"float":"0.0",
> 	"double":"0.0",
> 	"bool":"false",
> 	"byte":"0",
> 	"sbyte":"0",
> 	"short":"0",
> 	"ushort":"0",
> 	"char":"char.MinValue",
> 	"DateTime":"DateTime.MinValue",
> 	default:"null" // anything other than an atomic type ]
> 
> The default is, as you see, null. Adding new types to this 
> structure is an open-ended task. So we'd need a new way to 
> tell ANTLR, that there is a special case. Maybe "prog: 
> dt(DateTime.MinValue)=datetime"? Ter?

Can maps be extended using the region syntax/feature?. If yes, end users can
extend the type_init map as required...

> In any case, I'm reluctant to change the official template 
> for this special case. I suggest to rebuild ANTLR yourself 
> with the delivered sources, along with the change in 
> CSharp.stg, until Ter can make a real fix.

I don't disagree but, DateTime is a frequently-used standard type - just
like char or ushort...

Micheal



More information about the antlr-interest mailing list