Show
Ignore:
Timestamp:
08/06/08 02:23:08 (5 months ago)
Author:
Chuck.Esterbrook
Message:

Added support for a Cobra compiler directive to specify the type for number
credit:hopscc
ticket:21

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/CobraParser.cobra

    r1564 r1569  
    522522                                                isGood = false 
    523523                                if not isGood 
    524                                         sugg = Compiler.suggestionFor(tok.text) 
     524                                        sugg = if(tok.text.length, Compiler.suggestionFor(tok.text), nil) 
    525525                                        sugg = if(sugg, ' Try "[sugg]".', '') 
    526526                                        .throwError('Expecting use, assembly, namespace, class, interface or enum, but got [tok].[sugg]') 
     
    543543                                # TODO: throw AssertException(SourceSite sourceSite, object[] expressions, object thiss, object info) 
    544544                                assert false, IdentifierExpr(token, 'throw') 
     545                        on 'number' 
     546                                # number 'decimal' | 'float' | 'float32' | 'float64' 
     547                                typeName = .grab 
     548                                if typeName.text not in ['decimal', 'float', 'float32', 'float64'] 
     549                                        .throwError('Compiler directive "number": unrecognized type "[typeName.text]". Must be one of "decimal", "float", "float32" or "float64".') 
     550                                .expect('EOL') 
     551                                comp = .typeProvider to Compiler? 
     552                                if comp, comp.numberTypeName = typeName.text 
    545553                        else 
    546554                                .throwError('Unknown compiler directive.')