Add unified grammar engine (RVGG, L-systems, ShapeGrammar), robust lexer/parser, SmartEditor and enhanced WebGL renderer - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 973de5928a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const sorted = [...variable_list].sort((a, b) => b.var_name.length - a.var_name.length); | ||
|
|
||
| for (let i = 0; i < sorted.length; i++) { | ||
| const v = sorted[i]; | ||
| const name = v.var_name; | ||
| const re = new RegExp(`\\b${escRe(name)}\\b`, "g"); | ||
| s = s.replace(re, String(v.value)); |
There was a problem hiding this comment.
Preserve scope precedence in variable substitution
replacevars now sorts variable_list by name length before substitution, which loses the stack-like scoping order for duplicate names. When a rule introduces a shadowed variable (via addVariableInstance), the older outer variable is substituted first and the newer in-scope value is never applied, so expressions like repeat counts/transforms can evaluate with stale values in recursive or nested rule execution. This is a regression from the previous reverse traversal that preferred the most recent binding.
Useful? React with 👍 / 👎.
Motivation
Description
RVGG,ProGen3DGrammar,GrammarLibrary,ShapeGrammar,ProGen3DUnifiedGrammar,GrammarAnalyzerandGrammarVisualizerplus helpers to generate, score and export grammar programs.GrammarLexer, math evaluator (Solution/MathS2_js), variable management, grammarGrammar/Rule/Tokenclasses,Context/Scopeexecution model andSmartEditorhighlighting/diagnostics (tooltip, wrapping, scroll sync, NL/spacing checks).WebGLSceneRenderernow has textured Blinn-Phong shaders, correct cube UVs, procedural texture generators (solid/checker/noise), batching for opaque/transparent draws, camera/orbit controls and anexportSTLimplementation.localStorage(and can download JSON), dropdown chooser population, buttons wired to generation/save/export/open actions, and tutorial/demo loading.Testing
Codex Task