Skip to content

Commit ca9887b

Browse files
add quantifier type
1 parent 667bc2f commit ca9887b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lib/index.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var _ = 0
4040
, DISCARD = _++
4141
, DOWHILELOOP = _++
4242
, PLACEHOLDER = _++
43+
, QUANTIFIER = _++
4344

4445
var DECL_ALLOW_ASSIGN = 0x1
4546
, DECL_ALLOW_COMMA = 0x2
@@ -88,7 +89,8 @@ var stmt_type = _ = [
8889
, 'continue'
8990
, 'discard'
9091
, 'do-while'
91-
, '(placeholder)'
92+
, 'placeholder'
93+
, 'quantifier'
9294
]
9395

9496
function parser() {
@@ -105,6 +107,7 @@ function parser() {
105107
, whilestmt = n(WHILELOOP)
106108
, returnstmt = n(RETURN)
107109
, dowhilestmt = n(DOWHILELOOP)
110+
, quantifier = n(QUANTIFIER)
108111

109112
var parse_struct
110113
, parse_precision
@@ -114,6 +117,7 @@ function parser() {
114117
, parse_function
115118
, parse_function_args
116119
, parse_dowhileloop
120+
, parse_quantifier
117121

118122
setup_stative_parsers()
119123

@@ -191,6 +195,7 @@ function parser() {
191195
case DOWHILELOOP: parse_dowhileloop(); break
192196
case RETURN: parse_return(); break
193197
case IF: parse_if(); break
198+
case QUANTIFIER: parse_quantifier(); break
194199
}
195200
}
196201

@@ -452,6 +457,12 @@ function parser() {
452457
return state.shift()
453458
}
454459

460+
if(token.data === '[') {
461+
// oh lord.
462+
state.unshift(quantifier())
463+
return
464+
}
465+
455466
if(token.data === ')') return state.shift()
456467

457468
if(token.data === ';') {
@@ -514,6 +525,9 @@ function parser() {
514525

515526
state.unshift(expr(',', ';'))
516527
return
528+
} else if(token.data === '[') {
529+
state.unshift(quantifier())
530+
return
517531
}
518532
}
519533
return state.shift()
@@ -778,6 +792,14 @@ function parser() {
778792
, function() { return state.shift() }
779793
)
780794

795+
parse_quantifier =
796+
stative(
797+
advance('[')
798+
, advance_expr(']')
799+
, advance(']')
800+
, function() { return state.shift() }
801+
)
802+
781803
parse_forloop =
782804
stative(
783805
advance('for', 'keyword')

0 commit comments

Comments
 (0)