Case Sensitivity and Non Standard Language Features

Case sensitivity

  • Case sensitivity is controlled by property bool IsLanguageCaseSensitive { get; } in interface UniversalExpressionParser.IExpressionLanguageProvider.

  • If the value of this property IsLanguageCaseSensitive is true, any two expressions are considered different, if the expressions are the same, except for capitalization of some of the text (say “public class Dog” vs “Public ClaSS DOg”). Otherwise, if the value of property IsLanguageCaseSensitive is false, the capitalization of any expression items does not matter (i.e., parsing will succeed regardless of capitalization in expression).

  • For example C# is considered a case sensitive language, and Visual Basic is considered case insensitive.

  • The value of property IsLanguageCaseSensitive in abstract implementation UniversalExpressionParser.ExpressionLanguageProviderBase of UniversalExpressionParser.IExpressionLanguageProvider returns true.

  • The expression below demonstrates parsing the expression by UniversalExpressionParser.IExpressionLanguageProvider with overridden IsLanguageCaseSensitive to return false.

Non standard comment markers

  • The properties string LineCommentMarker { get; }, string MultilineCommentStartMarker { get; }, and string MultilineCommentEndMarker { get; } in interface UniversalExpressionParser.IExpressionLanguageProvider determine the line comment marker as well as code block comment start and end markers.

  • The default implementation UniversalExpressionParser.ExpressionLanguageProviderBase of UniversalExpressionParser.IExpressionLanguageProvider returns “//”, “/”, and “/” for these properties to use C# like comments. However, other values can be used for these properties.

  • The expression below demonstrates parsing the expression by an instance of UniversalExpressionParser.IExpressionLanguageProvider with overridden LineCommentMarker, MultilineCommentStartMarker, and MultilineCommentEndMarker to return “rem”, “rem*”, “*rem”.

Non standard code separator character and code block markers

  • The properties char ExpressionSeparatorCharacter { get; }, string CodeBlockStartMarker { get; }, and string CodeBlockEndMarker { get; } in interface UniversalExpressionParser.IExpressionLanguageProvider determine the code separator character, as well as the code block start and end markers.

  • The default implementation UniversalExpressionParser.ExpressionLanguageProviderBase of UniversalExpressionParser.IExpressionLanguageProvider returns “;”, “{”, and “}” for these properties to use C# like code separator and code block markers. However, other values can be used for these properties.

  • The expression below demonstrates parsing the expression by an instance of UniversalExpressionParser.IExpressionLanguageProvider with overridden ExpressionSeparatorCharacter, CodeBlockStartMarker, and CodeBlockEndMarker to return “;”, “BEGIN”, and “END”.

Example demonstrating case insensitivity and non standard language features

  • The expression below is parsed using the expression language provider UniversalExpressionParser.DemoExpressionLanguageProviders.VerboseCaseInsensitiveExpressionLanguageProvider, which overrides IsLanguageCaseSensitive to return false. As can bee seen in this example, the keywords (e.g., var, public, class, ::pragma, etc), non standard code comment markers (i.e., “rem”, “rem*”, “rem”), code block markers (i.e., **BEGIN*, END) and operators IS NULL, IS NOT NULL can be used with any capitalization, and the expression is still parsed without errors.

 1rem This line commented out code with verbose line comment marker 'rem'
 2rem*this is a demo of verbose code block comment markers*rem
 3
 4rem#No space is required between line comment marker and the comment, if the first
 5rem character is a special character (such as operator, opening, closing round or squer braces, comma etc.)
 6
 7BEGIN
 8    println(x); println(x+y)
 9    rem* this is an example of code block
10    with verbose code block start and end markers 'BEGIN' and 'END'.
11    *rem
12END
13
14Rem Line comment marker can be used with any capitalization
15
16REm* Multi-line comment start/end markers can be used with
17any capitalization *ReM
18
19rem keywords public and class can be used with any capitalization.
20PUBLIC Class DOG
21BEGIN Rem Code block start marker 'BEGIN' can be used with any capitalization
22    PUBLIc static F1(); rem keywords (e.g., 'PUBLIC') can be used with any capitalization
23end
24
25REm keyword 'var' can be used with any capitalization.
26VaR x=::PRagma y;
27
28PRintLN("X IS NOT NULL=" + X Is noT Null && ::pRAGMA y is NULL);
29
30f1(x1, y1)
31BEGin Rem Code block start marker 'BEGIN'can be used with any capitalization.
32   Rem Line comment marker 'rem' can be used with any capitalization
33   rem Line comment marker 'rem' can be used with any capitalization
34
35   REm* Multi line comment start/end markers can be used with
36   any capitalization *rEM
37
38   RETurN X1+Y1; rem unary prefix operator 'return' (and any other) operator  can be used with any capitalization.
39enD rem Code block end marker 'END' can be used  with any capitalization.

Click here to see the visualized instance of UniversalExpressionParser.IParseExpressionResult