Skip to content

Commit cb6e40e

Browse files
committed
Clean features
1 parent a19722b commit cb6e40e

24 files changed

+104
-137
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ dist
107107
.tern-port
108108
.DS_Store
109109
test-results/
110+
/.claude

feature/async.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Async/await/yield: async function, async arrow, await, yield expressions
2-
import { unary, expr, skip, space, cur, idx, word, operator, compile } from '../parse.js';
3-
import { keyword } from './block.js';
2+
import { unary, expr, skip, space, keyword, cur, idx, word, operator, compile } from '../parse.js';
43

54
const PREFIX = 140, ASSIGN = 20;
65

feature/block.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

feature/class.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Class declarations and expressions
22
// class A extends B { ... }
3-
import { binary, unary, token, expr, space, next, parse, literal, word, operator, compile, skip, cur, idx } from '../parse.js';
4-
import { keyword, block } from './block.js';
3+
import { binary, unary, token, expr, space, next, parse, keyword, literal, word, operator, compile, skip, cur, idx } from '../parse.js';
4+
import { block } from './if.js';
55

66
const TOKEN = 200, PREFIX = 140, COMP = 90;
77
const STATIC = Symbol('static');

feature/collection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
* ['{}', 'a'] → ['{}', 'a'] object shorthand {a}
1313
* ['{}', [':', k, v]] → ['{}', ...] object literal
1414
*/
15-
import { group, binary, operator, compile } from '../parse.js';
15+
import { group, binary, operator, compile, parse, peek } from '../parse.js';
1616
import { ACC } from './accessor.js';
1717

1818
const ASSIGN = 20, TOKEN = 200;
1919

20+
// Allow {keyword: value} - prevent keyword match before colon
21+
parse.prop = pos => peek(pos) !== 58;
22+
2023
// Object inner: null, string, or array starting with : , ... get set
2124
const isObject = a => a == null || typeof a === 'string' || [':', ',', '...', 'get', 'set'].includes(a[0]);
2225

feature/control.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

feature/destruct.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

feature/function.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Function declarations and expressions
2-
import { space, next, parse, parens, expr, operator, compile, cur, idx, skip } from '../parse.js';
3-
import { RETURN } from './control.js';
4-
import { keyword, block } from './block.js';
2+
import { space, next, parse, keyword, parens, expr, operator, compile, cur, idx, skip } from '../parse.js';
3+
import { block } from './if.js';
4+
import { RETURN } from './op/arrow.js';
55

66
const TOKEN = 200;
77

feature/if.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
// If/else statement - else consumed internally
2-
import { space, skip, parens, word, idx, seek, operator, compile } from '../parse.js';
3-
import { body, keyword } from './block.js';
2+
import { space, skip, expr, err, keyword, parens, word, idx, seek, operator, compile } from '../parse.js';
43

54
const STATEMENT = 5, SEMI = 59;
65

6+
// block() - parse required { body }
7+
export const block = () =>
8+
(space() === 123 || err('Expected {'), skip(), expr(STATEMENT - .5, 125) || null);
9+
10+
// body() - parse { body } or single statement
11+
export const body = () =>
12+
space() !== 123 ? expr(STATEMENT + .5) : (skip(), expr(STATEMENT - .5, 125) || null);
13+
714
// Check for `else` after optional semicolon
815
const checkElse = () => {
916
const from = idx;

feature/literal.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
* [, undefined] serializes to [null, null] which would compile to null.
88
* [] serializes to [] and compiles back to undefined.
99
*/
10-
import { literal } from '../parse.js';
11-
import { keyword } from './block.js';
10+
import { literal, keyword } from '../parse.js';
1211

1312
literal('true', true);
1413
literal('false', false);

0 commit comments

Comments
 (0)