ucode grammar for tree-sitter.
This grammar provides parsing support for ucode, a lightweight scripting language used by OpenWrt with ECMAScript-like syntax. ucode is designed for system scripting, configuration management, and template processing in embedded Linux environments.
It was originally forked from tree-sitter-javascript and then modified to fit the needs of ucode.
This grammar is based on tree-sitter-javascript but removes features not supported in ucode:
- No classes: No ES6 classes, prototypes, or object-oriented programming constructs
- No
this
keyword: Functions don't have athis
context - No
new
operator: Cannot instantiate objects with constructors - No arrow functions: Use
function() {}
syntax only - No async/await: Synchronous execution only
- No generators: No
function*
oryield
expressions - No regex literals: Use
match()
andreplace()
functions instead of/pattern/flags
- No decorators or private fields: No
@decorator
or#privateField
syntax
- Function declarations and expressions
- Variables (
let
,const
,var
) - Control flow (
if
,for
,while
,switch
,try/catch
) - Objects and arrays (with bracket notation for arrays only)
- Template literals with substitution
- Import/export statements (modern
import
and legacyrequire()
) - Built-in function calls (
print
,json
,jsonstr
, etc.)