Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full support for reserved type #676

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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