Skip to content

feat: godot, webassembly, mongodb, powershell, vim, cobol, ruby, php, c++ and c# - #86

Open
lvolland wants to merge 11 commits into
speed-highlight:mainfrom
lvolland:feat/new-languages
Open

feat: godot, webassembly, mongodb, powershell, vim, cobol, ruby, php, c++ and c##86
lvolland wants to merge 11 commits into
speed-highlight:mainfrom
lvolland:feat/new-languages

Conversation

@lvolland

@lvolland lvolland commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

the ten boxes on #17: godot, webassembly, mongodb, powershell, vim, cobol, ruby, php, c++, c#.

one commit per language, each touching only its own files plus the three shared lines, so you
can drop any of them without unpicking the rest.

the ten new languages rendered with the github-dark theme

class detection
cobol shj-lang-cobol
c++ shj-lang-cpp
c# shj-lang-cs
gdscript shj-lang-gd
mongodb shj-lang-mongodb
php shj-lang-php
powershell shj-lang-ps1
ruby shj-lang-rb
vimscript shj-lang-vim
webassembly shj-lang-wat

verified

10/10   new languages: rules well formed, every match carries /g, tokenize
        reconstructs the source exactly, under budget, coverage 59-83 %
33/34   existing languages unchanged (plain colours nothing by design)
37/37   existing fixtures detect exactly as they did before

that last line is the one that mattered. a detection regex is the only way a new language can
break an existing one, so every entry was tested against the whole fixture set, and four
languages ship with no detection at all
because the candidate regex had real false positives:

  • wat\b(local|global)\.(get|set|tee)\b also matches ordinary java, js and python
  • gd@export-style prefixes collide with jsdoc tags and python decorators
  • mongodb — matches pymongo
  • ps1Verb-Noun is also how title case works in prose

cpp is registered at weight 500 rather than 100: std::cout cannot occur in valid c, and at
100 the six #include lines in the fixture made c win on volume.

what the review pass caught

each grammar was written, then attacked by a second pass whose job was to break it. eight of the
ten came back with real defects, fixed before this branch existed. the ones worth naming:

  • cobol\b[\w-]+[ \t]+(DIVISION|SECTION)\b was quadratic
  • php#[Attribute] was swallowed whole by the # comment branch, and a ?> inside a //
    comment never handed control back to html
  • ruby — the heredoc rule accepted any \w+ after <<, so a << b opened a string
  • gdscript — a multi-line """ string leaked, and 7%2 was read as a %variable
  • vimscript — vim does not escape backslashes in single quotes, and the @" register opened a
    string that ate the rest of the line

known limits, stated rather than hidden

  • nested (; … ;) in wat stops at the first ;) — the same compromise c.js already makes for /* */
  • a lone apostrophe outside a literal in cobol opens a string to end of line
  • c# raw strings (""") have no rule yet
  • the func rule idiom (/[a-z_]\w*(?=\s*\()/) is quadratic on a very long identifier with no
    paren — measured at 480-500 ms on 20 000 chars. that is not new: c, py, rs and java all
    score within 40 ms of each other on the same input, so i kept the shared idiom rather than make
    these ten diverge. flagging it because it is the repo's slowest path, not because of this pr

notes

  • names follow the existing convention — file extension for the class (rb, cpp, cs, ps1,
    gd, wat), full name in the readme table. mongodb and cobol have no natural short form,
    so they are spelled out. all of that is yours to overrule
  • the last commit only widens the readme table's name column by one character, because
    webassembly is 11 wide and the column was 10. it is whitespace only and safe to drop
  • dist/ untouched

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.

1 participant