Skip to content

phwhite/tree-sitter-ucode

 
 

Repository files navigation

tree-sitter-ucode

CI discord matrix crates npm pypi

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.

Key Differences from JavaScript

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 a this 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* or yield expressions
  • No regex literals: Use match() and replace() functions instead of /pattern/flags
  • No decorators or private fields: No @decorator or #privateField syntax

Supported Features

  • 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 legacy require())
  • Built-in function calls (print, json, jsonstr, etc.)

References

About

ucode grammar for tree-sitter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • UnrealScript 56.4%
  • JavaScript 28.3%
  • C 9.6%
  • Tree-sitter Query 5.7%