@@ -20,7 +20,9 @@ public static AbstractSyntaxTree[] Parse(string expression)
2020 }
2121 catch ( ParsingException e )
2222#if DEBUG
23+ #pragma warning disable CS7095 // Filter expression is a constant
2324 when ( false )
25+ #pragma warning restore CS7095 // Filter expression is a constant
2426#endif
2527
2628 {
@@ -237,6 +239,7 @@ private AbstractSyntaxTree Multiplicative(AbstractSyntaxTree e)
237239 return e ;
238240 }
239241 }
242+
240243 private AbstractSyntaxTree Exponent ( )
241244 {
242245 return Exponent ( Primary ( ) ) ;
@@ -299,9 +302,9 @@ private AbstractSyntaxTree Primary()
299302 case "null" :
300303 return new NullNode ( ) ;
301304 case "true" :
302- return new BooleanNode ( true ) ;
305+ return new ValueNode ( true ) ;
303306 case "false" :
304- return new BooleanNode ( false ) ;
307+ return new ValueNode ( false ) ;
305308 case "NOW" :
306309 case "Now" :
307310 case "now" :
@@ -533,7 +536,7 @@ private AbstractSyntaxTree Primary()
533536
534537 if ( formula0 != null )
535538 {
536- var ex = lex + " is a formula that takes zero arguments. You must call it like this: \" " + lex + " ()\" ";
539+ var ex = $ " { lex } is a formula that takes zero arguments. You must call it like this: \" { lex } ()\" ";
537540
538541 if ( scanner . GetToken ( ) . TokenType != TokenType . LParen )
539542 throw new ParsingException ( scanner . Position , ex ) ;
@@ -545,7 +548,7 @@ private AbstractSyntaxTree Primary()
545548 else if ( formula1 != null )
546549 {
547550 // Create a formula1.
548- var ex = lex + " is a formula that takes one argument. You must specify the arguments like this: \" " + lex + " (3)\" ";
551+ var ex = $ " { lex } is a formula that takes one argument. You must specify the arguments like this: \" { lex } (3)\" ";
549552
550553 if ( scanner . GetToken ( ) . TokenType != TokenType . LParen )
551554 throw new ParsingException ( scanner . Position , ex ) ;
@@ -569,8 +572,8 @@ private AbstractSyntaxTree Primary()
569572 else if ( formula2 != null )
570573 {
571574 // Create a formula2.
572- var ex = lex + " is a formula that takes two arguments . You must specify the arguments like this: \" " + lex + " (3;2)\" ";
573- if ( lex == "round" )
575+ var ex = $ " { lex } is a formula that takes two argument . You must specify the arguments like this: \" { lex } (3;2)\" ";
576+ if ( lex . ToLower ( ) == "round" )
574577 ex = "round is a formula that takes one or two argments. You must specify the argument(s) like this: round(4.693) or round(4.693;2)" ;
575578
576579 if ( scanner . GetToken ( ) . TokenType != TokenType . LParen )
@@ -618,13 +621,13 @@ private AbstractSyntaxTree Primary()
618621 {
619622 // Create a formulaN.
620623 if ( scanner . GetToken ( ) . TokenType != TokenType . LParen )
621- throw new ParsingException ( scanner . Position , "You must specify arguments for " + lex + " . Those arguments must be enclosed in parentheses.") ;
624+ throw new ParsingException ( scanner . Position , $ "You must specify arguments for { lex } . Those arguments must be enclosed in parentheses.") ;
622625
623626 var trees = new List < AbstractSyntaxTree > ( ) ;
624627
625628 if ( scanner . GetToken ( ) . TokenType == TokenType . RParen )
626629 {
627- throw new ParsingException ( scanner . Position , "You must specify at least one argument for " + lex + " .") ;
630+ throw new ParsingException ( scanner . Position , $ "You must specify at least one argument for { lex } .") ;
628631 }
629632 else
630633 {
@@ -639,7 +642,7 @@ private AbstractSyntaxTree Primary()
639642 }
640643 catch ( Exception e )
641644 {
642- throw new ParsingException ( scanner . Position , "Error parsing arguments for " + lex + " .", e ) ;
645+ throw new ParsingException ( scanner . Position , $ "Error parsing arguments for { lex } .", e ) ;
643646 }
644647
645648 var type = scanner . GetToken ( ) . TokenType ;
@@ -650,7 +653,7 @@ private AbstractSyntaxTree Primary()
650653 case TokenType . Semicolon :
651654 break ;
652655 default :
653- throw new ParsingException ( scanner . Position , "Error parsing arguments for " + lex + " . Invalid character: " + type + " . Expected either a comma, semicolon, or right parenthesis.") ;
656+ throw new ParsingException ( scanner . Position , $ "Error parsing arguments for { lex } . Invalid character: { type } . Expected either a comma, semicolon, or right parenthesis.") ;
654657 }
655658 }
656659 }
0 commit comments