A tree-sitter grammar for TTCN-3 (Testing and Test Control Notation, ETSI ES 201 873-1).
v0.2.1 — parses real-world 3GPP conformance TTCN-3 code at 100% clean
(385/385 files in the NR5GC corpus have 0 errors; 0 ERROR nodes total).
Up from v0.2.0's 99.7% / 2 errors. Parser is generated without warnings;
159/159 corpus tests pass.
The v0.2.1 jump closed the last grammar gap left open by v0.2.0:
- Trailing
ifpresentmatching attribute on template assignment RHS — added an optionalextra_matching_attributesfield to thetemplaterule sotemplate T x := f(args) ifpresent;parses (spec rule 95 ExtraMatchingAttributes). One new conflict declared:[$.any_value]— the existingany_value: $ => seq('?', optional($.length_attribute))rule overlapped with the newlength_attributesuffix on expressions; GLR resolves in favor of theany_valueinterpretation.
159/159 corpus tests pass (158 from v0.2.0 + 1 new V1.17 test for the template RHS ifpresent pattern).
- v0.2.0 — 99.7% clean (384/385, 2 errors). Closed four grammar gaps on
top of v0.1.1:
-> value v_Xredirect insidecheck(receive(...)), array type with explicit size, inlineunion/record/setblocks intype recordbody,complement(...)with multiple args, and formal- parameter default with trailingifpresent. - v0.1.1 — 97.7% clean (376/385, 18 errors). Diagnosed the
ident '<'shift-reduce conflict ontype_instantiation_expressionvs.rel_expression: the staticprec(PREC.primary)on type instantiation was committing the LR(1) table to the generics path on everyref < numpattern. Resolved by dropping the static precedence, switching toprec.dynamic(-1, ...), and declaring the table-level conflicts ([$.reference, $.type_instantiation_expression]and[$.name, $.type_instantiation_expression]) so Tree-sitter's GLR engine forks at runtime. Zero regressions; parser size +270 bytes. - v0.1.0 — 83.6% clean (322/385, 204 errors).
- Module definitions, group definitions
- Function / altstep / testcase / configuration / control
- Behavioral types: component, port, timer, signature, class
- Type system: record / set / union / enumerated / map / array / port / signature
- Declarations: var / const / timer / port / template / modulepar
- Templates: restrictions, modifiers, parameterized, modifies, all matching symbols (
?/*/ifpresent/ range / complement / subset / superset / permutation / decmatch / pattern / length) - Expressions: full precedence chain (or → and → not → rel → shift → bitwise → add → mul → unary → primary)
- Statements: if / for / while / select / alt / interleave / do-while / label / goto / break / continue / return
- Communication: port dot-ops, config ops, component lifetime, activate/default, timer ops
- Test operations: testcase.stop, execute, test-component call
- Editor support: syntax highlighting, scope tracking, code navigation, injections
- Tests for the optional external scanner (not used — grammar is pure
grammar.js)
make # produces libtree-sitter-ttcn3.{a,so} + tree-sitter-ttcn3.pc
make install # installs to /usr/localnpm test # regenerates parser + runs corpus tests
npx tree-sitter test # runs corpus tests only
npx tree-sitter generate # regenerates parser onlynpx tree-sitter parse path/to/file.ttcnSix bindings are shipped in-tree:
| Language | Build |
|---|---|
| Node | npm install |
| Python | pip install . |
| Rust | cargo build |
| Go | go build (after tree-sitter generate) |
| C | make |
| Swift | swift build (after tree-sitter generate) |
.
├── grammar.js # The grammar (hand-written)
├── src/ # Generated artifacts (committed, do not edit)
├── test/corpus/ # TTCN-3 grammar tests (158 tests)
├── queries/ # Editor support (highlights, locals, tags, injections)
├── bindings/ # 6 language bindings
└── docs/ # Development plan, gap analysis
- Development plan — task breakdown, status, effort budget
- Gap analysis — feature inventory vs spec coverage
See CONTRIBUTING.md. The grammar is a single hand-written
grammar.js; parser artifacts (src/parser.c, src/grammar.json,
src/node-types.json) are generated and committed.
Note: This project is in maintenance mode. Change requests are welcome, but active development is not scheduled.