@@ -353,6 +353,7 @@ <h1><a href="https://github.com/dy/subscript" class="logo-link" target="_blank"
353353 'function' : 'feature/function.js' ,
354354 'throw' : 'feature/try.js' , // throw is part of try.js
355355 'try' : 'feature/try.js' ,
356+ control : 'feature/control.js' , // BREAK, CONTINUE, RETURN symbols
356357 accessor : 'feature/accessor.js' ,
357358 async : 'feature/async.js' ,
358359 'class' : 'feature/class.js' ,
@@ -366,15 +367,17 @@ <h1><a href="https://github.com/dy/subscript" class="logo-link" target="_blank"
366367 'number' , 'string' ,
367368 // Operators - order matters for token chain
368369 'assign' , 'logical' , 'bit' , 'cmp' , 'equality' , 'arithmetic' , 'increment' ,
370+ // Control flow foundations (needed by group via loop)
371+ 'control' , 'block' , 'destruct' , 'loop' ,
369372 // Expression features
370373 'group' , 'access' ,
371374 // Justin additions
372375 'comment' , 'identity' , 'nullish' , 'pow' , 'unary' ,
373376 'literal' , 'ternary' , 'arrow' , 'spread' , 'optional' ,
374- 'collection' , 'template' , 'regex' , 'unit' ,
375- // Jessie additions (block before control flow)
376- 'block' , ' var', 'function' , 'async' , 'class' , 'destruct ',
377- 'if' , 'loop' , ' try', 'switch' , 'module' , 'accessor ', 'asi'
377+ 'accessor' , ' collection', 'template' , 'regex' , 'unit' ,
378+ // Jessie additions
379+ 'var' , 'function' , 'async' , 'class' ,
380+ 'if' , 'try' , 'switch' , 'module' , 'asi'
378381]
379382
380383// UI feature groups (maps to internal IDs)
@@ -708,11 +711,14 @@ <h1><a href="https://github.com/dy/subscript" class="logo-link" target="_blank"
708711
709712// Strip imports from source, replacing sibling imports with _ object references
710713const stripImports = code => {
711- // First, handle sibling imports: import { X, Y } from './file.js' → const { X, Y } = _
712- code = code . replace ( / ^ i m p o r t \s + \{ ( [ ^ } ] + ) \} \s + f r o m \s + [ ' " ] \. \/ .+ ?[ ' " ] ; ? \s * $ / gm, ( match , names ) => {
714+ // Handle feature-to-feature imports: import { X, Y } from './file.js' or '../file.js' → const { X, Y } = _
715+ // But skip imports from parse.js (those are already global in bundled context)
716+ code = code . replace ( / ^ i m p o r t \s + \{ ( [ ^ } ] + ) \} \s + f r o m \s + [ ' " ] ( \. \. ? \/ [ ^ ' " ] + ?) [ ' " ] ; ? \s * $ / gm, ( match , names , path ) => {
717+ // Skip parse.js imports - these are global
718+ if ( path . endsWith ( 'parse.js' ) ) return ''
713719 return `const { ${ names } } = _;`
714720 } )
715- // Remove remaining imports (from '../parse.js' etc) - these are global in bundled context
721+ // Remove any remaining imports
716722 return code . replace ( / ^ i m p o r t \s + .* $ / gm, '' )
717723}
718724
@@ -739,8 +745,8 @@ <h1><a href="https://github.com/dy/subscript" class="logo-link" target="_blank"
739745
740746 // Features that export things used by other features
741747 const exports = {
748+ control : [ 'BREAK' , 'CONTINUE' , 'RETURN' ] ,
742749 block : [ 'keyword' , 'infix' , 'block' , 'body' ] ,
743- loop : [ 'BREAK' , 'CONTINUE' , 'RETURN' , 'loop' ] ,
744750 access : [ 'unsafe' , 'isLval' , 'prop' ] ,
745751 destruct : [ 'destructure' ] ,
746752 accessor : [ 'ACC' ] ,
@@ -750,10 +756,12 @@ <h1><a href="https://github.com/dy/subscript" class="logo-link" target="_blank"
750756 // Feature dependencies - these features import from other features
751757 // Includes transitive dependencies (e.g., group→loop→block means group needs block)
752758 const dependencies = {
759+ // control exports BREAK, CONTINUE, RETURN - used by loop, function, try, switch, group
760+ control : [ 'loop' , 'function' , 'try' , 'switch' , 'group' ] ,
753761 // block exports keyword, infix, block, body - used by control flow features
754762 // Also needed transitively by: group (via loop)
755763 block : [ 'if' , 'loop' , 'switch' , 'function' , 'try' , 'var' , 'async' , 'class' , 'module' , 'group' ] ,
756- // loop exports BREAK, CONTINUE, RETURN, loop - used by features that handle control flow
764+ // loop exports loop - used by features that handle control flow
757765 loop : [ 'group' , 'function' , 'try' , 'switch' ] ,
758766 // destruct exports destructure - used by var and loop
759767 destruct : [ 'var' , 'loop' , 'group' ] , // group needs loop which needs destruct
@@ -1221,11 +1229,12 @@ <h1><a href="https://github.com/dy/subscript" class="logo-link" target="_blank"
12211229// Feature dependencies - these features import from other features
12221230// Includes transitive dependencies (e.g., group→loop→block means group needs block)
12231231const DEPENDENCIES = {
1232+ // control exports BREAK, CONTINUE, RETURN - used by loop, function, try, switch, group
1233+ control : [ 'loop' , 'function' , 'try' , 'switch' , 'group' ] ,
12241234 // block exports keyword, infix, block, body - used by control flow features
12251235 // Also needed transitively by: group (via loop)
12261236 block : [ 'if' , 'loop' , 'switch' , 'function' , 'try' , 'var' , 'async' , 'class' , 'module' , 'group' ] ,
1227- // loop exports BREAK, CONTINUE, RETURN, loop - used by features that handle control flow
1228- loop : [ 'group' , 'function' , 'try' , 'switch' ] ,
1237+ // loop - no longer exports anything needed by other features
12291238 // destruct exports destructure - used by var and loop
12301239 destruct : [ 'var' , 'loop' , 'group' ] , // group needs loop which needs destruct
12311240 // access exports prop, unsafe, isLval - used by group
0 commit comments