feat: major grammar upgrade for SCL spec conformance (Phase 1)
Comprehensive grammar rewrite to conform to SCL specs. Improves parse success rate from 0% to 90% (187 of 208 reference project files). Case-insensitive keywords: - Add ci() helper for case-insensitive token matching - All keywords (TYPE, STRUCT, VAR, IF, etc.) now match any case - All type names (BOOL, Int, Dint, etc.) now match any case New grammar constructs: - RETURN statement - GOTO statement - AUTHOR/FAMILY/NAME block headers - VAR DB_SPECIFIC section - ARRAY[*] (variable-length arrays) - Multidimensional ARRAY[a..b, c..d] - REF_TO <type> - VARIANT type - Anonymous STRUCT...END_STRUCT as a type - Compound assignment operators (+=, -=, *=, /=, &=, |=, ^=) - Chained assignments (lvalue := lvalue := expression) - Bit access (lvalue.%X0) - Method calls (lvalue.field(...)) - Struct/array initializers ((TRUE, FALSE, ...), (name := value)) - END_STRUCT; (semicolon after END_STRUCT in UDTs) - Typed DB associated block name (DATA_BLOCK "Name" : "UDT") - BOM (Byte Order Mark) handling - TITLE as single-token statement (avoids keyword/identifier conflict) New type_builtin aliases: - LWORD, LINT, ULINT, UDINT, DATE, TIME_OF_DAY, DATE_AND_TIME - S5TIME, LTIME, DTL, LTOD, LDT, LTIME_OF_DAY, DATE_AND_LTIME New literal formats: - Binary (2#...), Octal (8#...) - BOOL#TRUE/FALSE - Typed integers (INT#, SINT#, DINT#, etc.) - Date/time literals (DATE#, TOD#, DT#, LTIME#, S5TIME#, DTL#) - WSTRING# and STRING# typed string literals - C# char literal - Time units with case-insensitive matching (T#1S, T#2s) Updated constructs: - CASE labels: comma-separated lists, string labels - Function call parameters: interleaved input (:=) and output (=>) params - FOR loop variable: accepts prefixed_identifier (#tempVar) - Array bounds: accept string/identifier constants (Array[0.."MAX"]) - Author/Family values: accept unquoted text with hyphens/slashes Known remaining issues (21 files, 10%): - Triple-nested parentheses in expressions - Some multi-line function call parameter patterns - END_REGION with trailing region name - Complex chained field access in assignments
This commit is contained in:
+2757
-1168
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user