Skip to content

Gremlator#3382

Open
spmallette wants to merge 2 commits intomasterfrom
gremlator
Open

Gremlator#3382
spmallette wants to merge 2 commits intomasterfrom
gremlator

Conversation

@spmallette
Copy link
Copy Markdown
Contributor

@spmallette spmallette commented Apr 8, 2026

Introducing Gremlator in its javascript only form. This is a port of the prototype application currently running at https://gremlator.com and built by @bechbd

@spmallette spmallette marked this pull request as ready for review April 13, 2026 23:57
Comment thread bin/generate-home.sh Outdated
if [ $? -eq 0 ]; then
rsync -avq docs/site/home target/site --exclude template
rsync -avq docs/gremlint/dist/ target/site/home/gremlint
rsync -avq docs/gremlator/build/ target/site/home/gremlator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
rsync -avq docs/gremlator/build/ target/site/home/gremlator
rsync -avq docs/gremlator/dist/ target/site/home/gremlator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure what happened there. thought i purposely changed that to build after dist didn't work but now i see it doesn't work with build....

Comment thread bin/generate-home.sh Outdated
else
cp -R docs/site/home target/site
cp -R docs/gremlint/dist/. target/site/home/gremlint
cp -R docs/gremlator/build/. target/site/home/gremlator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
cp -R docs/gremlator/build/. target/site/home/gremlator
cp -R docs/gremlator/dist/. target/site/home/gremlator


export default defineConfig({
plugins: [react()],
base: '/gremlator',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
base: '/gremlator',
base: '/gremlator',
esbuild: {
keepNames: true,
},

In local testing, I was noticing that step arguments seemed to just pass straight through without any translation.

image image

My AI overlord of choice had this to say about it, resulting in this fix:

The TranslateVisitor.visit() method dispatches to the correct visitor method (e.g. visitStringLiteral, visitIntegerLiteral) by inspecting tree.constructor.name at runtime — it expects names like StringLiteralContext and strips the Context suffix to find the method.

Vite's production build minifies class names, so StringLiteralContext becomes something like Qh. The className.endsWith('Context') check fails, the dispatch never matches any specific visitor method, and every rule context falls through to the generic visitChildren() path, which just walks down to terminal
tokens and outputs raw text.

That's why step names translate correctly (they're terminal tokens handled by visitTerminal) but all arguments — strings, numbers, booleans, collections — pass through unmodified. The language-specific visitor overrides for those literal types never get called.

The fix is adding esbuild: { keepNames: true } to vite.config.ts so class names survive minification. But the deeper issue is in gremlin-js itself: the visit() dispatch relies on runtime class name reflection, which is inherently fragile under minification. A more robust approach would be to dispatch on
ruleIndex (a stable integer) rather than the class name string.

That is quite an unexpected failure mode in my opinion. It does give me some concerns about the frailty of the JS translators in embedded webapp deployments (which is their intended purpose).

I don't think the translator fragility is of concern for this PR, but it's something to think about going forward.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

New React+TypeScript single-page application under docs/gremlator/ that
translates canonical Gremlin input into 8 target languages (Canonical,
JavaScript, Python, Go, .NET, Java, Groovy, Anonymized) using GremlinTranslator
from gremlin-javascript. Purely browser-based; no backend required.

Also updates bin/generate-home.sh to build and deploy gremlator alongside
gremlint via the existing Apache SVN publish pipeline.
@Cole-Greer
Copy link
Copy Markdown
Contributor

VOTE +1

"eslint-plugin-prettier": "^5.0.0",
"globals": "^15.14.0",
"js-yaml": "^3.14.2",
"jsdoc": "^4.0.5",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: leaked dependency addition?

@xiazcy
Copy link
Copy Markdown
Contributor

xiazcy commented Apr 17, 2026

VOTE +1

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.

3 participants