Skip to content

Commit

Permalink
use new function readReserved to handle reserved type, since only ran…
Browse files Browse the repository at this point in the history
…ge values (a to b) were being handled
  • Loading branch information
seth.schwiet committed Feb 11, 2017
1 parent 2ddb76b commit abba570
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,39 @@ function parse(source, root, options) {
return [ start, end ];
}

function readReserved(){
var r_list = [];
var val;
var add_range = false;
var i;

while( !skip( ';', true ) ){

skip( ",", true );

if( !skip( 'to', true ) ){

val = readValue();

/* add each val between last and val*/
if( add_range ){
for ( i = r_list[ r_list.length - 1 ] + 1; i < val; i += 1 ){
r_list.push( i );
}
add_range = false;
}

r_list.push( val );
}
else{
/*will need to add each value between last val and next*/
add_range = true;
}
}

return r_list;
}

function parseNumber(token, insideTryCatch) {
var sign = 1;
if (token.charAt(0) === "-") {
Expand Down Expand Up @@ -294,7 +327,7 @@ function parse(source, root, options) {
break;

case "reserved":
(type.reserved || (type.reserved = [])).push(readRange(type, tokenLower));
(type.reserved || (type.reserved = [])).push(readReserved(type, tokenLower));
break;

default:
Expand Down

0 comments on commit abba570

Please sign in to comment.