Skip to content

Add ucode language - #8043

Open
janeblower wants to merge 3 commits into
github-linguist:mainfrom
janeblower:add-ucode-language
Open

Add ucode language#8043
janeblower wants to merge 3 commits into
github-linguist:mainfrom
janeblower:add-ucode-language

Conversation

@janeblower

@janeblower janeblower commented Jul 1, 2026

Copy link
Copy Markdown

Description

This adds detection and syntax highlighting for ucode, the JavaScript-like scripting language created for OpenWrt (interpreter by Jo-Philipp Wich). It is widely used across the OpenWrt ecosystem — openwrt/openwrt, openwrt/luci, and a large number of luci-app-* and related package repositories — for rpcd backends, LuCI controllers/dispatchers, and CLI utilities.

ucode's primary extension .uc is already registered to UnrealScript, so this is a shared-extension addition:

  • both languages keep the .uc extension;
  • UnrealScript already ships two .uc samples, and this PR adds three ucode samples;
  • a content heuristic is added to heuristics.yml to disambiguate the two. ucode is matched on markers that never appear in UnrealScript (the #!/usr/bin/ucode shebang, 'use strict', ES import/export, require(/include(, let bindings, printf/sprintf), and UnrealScript on its own markers (class X extends Y, defaultproperties, var(...), #exec, simulated/exec/native function modifiers). let is used rather than const because UnrealScript also has const.
  • a test (test_uc_by_heuristics) asserts both directions classify correctly.

Checklist:

@janeblower
janeblower marked this pull request as ready for review July 1, 2026 04:54
@janeblower
janeblower requested a review from a team as a code owner July 1, 2026 04:54

@lildude lildude left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

samples/ucode/http.uc is too big - of it's suppressed by the diff, it's too big for it needs - please replace it with a smaller sample.

Replace samples/ucode/http.uc with sys.uc from luci-base: same
Apache-2.0 upstream, about a quarter of the size, and it still covers
the import/export, builtin call and template string constructs the
.uc heuristic keys on.
@janeblower
janeblower requested a review from lildude July 21, 2026 06:37
@janeblower

Copy link
Copy Markdown
Author

2026-07-21T08:55:40.0603373Z UnrealScript/MutU2Weapons.uc BAD (ucode)
I see this, I'll fix it.

UnrealScript has owned .uc since long before ucode existed, so anything
without a ucode marker should stay UnrealScript rather than being handed
to the statistical classifier, which has far more ucode samples to lean on.
@janeblower

Copy link
Copy Markdown
Author

@lildude I fixed it. Can you check it?

@janeblower

Copy link
Copy Markdown
Author

@lildude
Is there anything else I need to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants