@@ -89,7 +89,7 @@ function parse(buffer) {
89
89
}
90
90
91
91
function node ( type , start , attrs ) {
92
- const end = tok ? Pos . before ( tok ) : new Pos ( lexer . line , lexer . col , lexer . index )
92
+ const end = tok != null ? Pos . before ( tok ) : new Pos ( lexer . line , lexer . col , lexer . index )
93
93
const region = new Region ( start , end , buffer )
94
94
return new Node ( type , region , attrs )
95
95
}
@@ -101,6 +101,9 @@ function parse(buffer) {
101
101
}
102
102
103
103
function parseValue ( ) {
104
+ if ( tok == null ) {
105
+ expectError ( "value" )
106
+ }
104
107
const start = Pos . before ( tok )
105
108
const name = tok . value
106
109
@@ -125,6 +128,9 @@ function parse(buffer) {
125
128
126
129
function parseKey ( start , key ) {
127
130
expect ( ":" )
131
+ if ( tok == null ) {
132
+ expect ( "value" )
133
+ }
128
134
const atomStart = Pos . before ( tok )
129
135
const value = parseValue ( )
130
136
const match = parseModifier ( value , atomStart )
@@ -144,6 +150,9 @@ function parse(buffer) {
144
150
}
145
151
146
152
function parseAtom ( ) {
153
+ if ( tok == null ) {
154
+ expectError ( "value" )
155
+ }
147
156
const start = Pos . before ( tok )
148
157
switch ( tok . type ) {
149
158
case "string" :
@@ -180,6 +189,9 @@ function parse(buffer) {
180
189
}
181
190
182
191
function parseNodeType ( ) {
192
+ if ( tok == null ) {
193
+ expectError ( "node type" )
194
+ }
183
195
const start = Pos . before ( tok )
184
196
const value = tok . value
185
197
switch ( tok && tok . type ) {
0 commit comments