lazar
fb55915147
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
2026-07-18 19:19:03 +02:00
lazar
553192e7a1
feat: improve tree-sitter syntax highlighting with named nodes
...
- Add aliases for keywords (VAR_INPUT, BEGIN, IF, etc.) as named nodes
- Add aliases for built-in types (INT, BOOL, STRING, etc.) as type_builtin
- Add aliases for constants (TRUE, FALSE)
- Add aliases for operators (AND, OR, NOT, MOD)
- Add prefix node for # variable prefix highlighting
- Highlight FB instance names in calls
- Highlight FB parameter names as properties
- Update README with detailed syntax highlighting features
- Update .gitignore for *.wasm files
2026-02-20 23:29:26 +01:00
lazar
dfa4ef3381
feat: add builtin types/functions to diagnostics and completions
...
Files Modified/Created:
- src/builtin_instructions.lua - NEW: Contains all TIA Portal built-in types, FBs, and functions
- src/diagnostics.lua - Added missing data types + builtin instruction checking
- src/main.lua - Added completion support for built-in types/F Bs/functions
- src/plc_json.lua - Added .db file parsing + BOM handling fixes
- lua/scl/blink_cmp_source.lua - Extended completion with all built-in types/F Bs/functions
- src/node-types.json - Added node types for parser
- AGENTS.md - Updated documentation
Features Added:
1. Diagnostics - No more false "Unknown data type" warnings for:
- All elementary types (USINT, SINT, UINT, UDINT, LINT, ULINT, TOD, DTL, etc.)
- Timer/counter types (IEC_TON, TOF, TP, CTU, CTD, CTUD)
- TIA Portal built-in FBs and functions
2. Auto-completion - Shows in VAR section after ::
- 28 elementary data types
- 23 built-in function blocks (TON, TOF, TP, CTU, CTD, CTUD, R_TRIG, F_TRIG, etc.)
- 80+ built-in functions (ADD, SUB, MUL, DIV, SIN, COS, SQRT, etc.)
2026-02-20 13:08:28 +01:00