This commit is contained in:
24
node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.l
generated
vendored
Normal file
24
node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.l
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
int "-"?([0-9]|[1-9][0-9]+)
|
||||
exp [eE][-+]?[0-9]+
|
||||
frac "."[0-9]+
|
||||
|
||||
%%
|
||||
\s+ /* skip whitespace */
|
||||
|
||||
{int}{frac}?{exp}?\b return 'NUMBER'
|
||||
\"(?:'\\'[\\"bfnrt/]|'\\u'[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*\" yytext = yytext.substr(1,yyleng-2); return 'STRING'
|
||||
|
||||
"{" return '{'
|
||||
"}" return '}'
|
||||
"[" return '['
|
||||
"]" return ']'
|
||||
"," return ','
|
||||
":" return ':'
|
||||
"true" return 'TRUE'
|
||||
"false" return 'FALSE'
|
||||
"null" return 'NULL'
|
||||
<<EOF>> return 'EOF'
|
||||
. return 'INVALID'
|
||||
|
||||
%%
|
||||
|
||||
110
node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.y
generated
vendored
Normal file
110
node_modules/@mapbox/jsonlint-lines-primitives/src/jsonlint.y
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
%start JSONText
|
||||
|
||||
/*
|
||||
ECMA-262 5th Edition, 15.12.1 The JSON Grammar.
|
||||
*/
|
||||
|
||||
|
||||
%%
|
||||
|
||||
JSONString
|
||||
: STRING
|
||||
{ // replace escaped characters with actual character
|
||||
$$ = new String(yytext.replace(/\\(\\|")/g, "$"+"1")
|
||||
.replace(/\\n/g,'\n')
|
||||
.replace(/\\r/g,'\r')
|
||||
.replace(/\\t/g,'\t')
|
||||
.replace(/\\v/g,'\v')
|
||||
.replace(/\\f/g,'\f')
|
||||
.replace(/\\b/g,'\b'));
|
||||
$$.__line__ = @$.first_line;
|
||||
}
|
||||
;
|
||||
|
||||
JSONNumber
|
||||
: NUMBER
|
||||
{
|
||||
$$ = new Number(yytext);
|
||||
$$.__line__ = @$.first_line;
|
||||
}
|
||||
;
|
||||
|
||||
JSONNullLiteral
|
||||
: NULL
|
||||
{
|
||||
$$ = null;
|
||||
}
|
||||
;
|
||||
|
||||
JSONBooleanLiteral
|
||||
: TRUE
|
||||
{
|
||||
$$ = new Boolean(true);
|
||||
$$.__line__ = @$.first_line;
|
||||
}
|
||||
| FALSE
|
||||
{
|
||||
$$ = new Boolean(false);
|
||||
$$.__line__ = @$.first_line;
|
||||
}
|
||||
;
|
||||
|
||||
JSONText
|
||||
: JSONValue EOF
|
||||
{return $$ = $1;}
|
||||
;
|
||||
|
||||
JSONValue
|
||||
: JSONNullLiteral
|
||||
| JSONBooleanLiteral
|
||||
| JSONString
|
||||
| JSONNumber
|
||||
| JSONObject
|
||||
| JSONArray
|
||||
;
|
||||
|
||||
JSONObject
|
||||
: '{' '}'
|
||||
{$$ = {}; Object.defineProperty($$, '__line__', {
|
||||
value: @$.first_line,
|
||||
enumerable: false
|
||||
})}
|
||||
| '{' JSONMemberList '}'
|
||||
{$$ = $2; Object.defineProperty($$, '__line__', {
|
||||
value: @$.first_line,
|
||||
enumerable: false
|
||||
})}
|
||||
;
|
||||
|
||||
JSONMember
|
||||
: JSONString ':' JSONValue
|
||||
{$$ = [$1, $3];}
|
||||
;
|
||||
|
||||
JSONMemberList
|
||||
: JSONMember
|
||||
{{$$ = {}; $$[$1[0]] = $1[1];}}
|
||||
| JSONMemberList ',' JSONMember
|
||||
{$$ = $1; $1[$3[0]] = $3[1];}
|
||||
;
|
||||
|
||||
JSONArray
|
||||
: '[' ']'
|
||||
{$$ = []; Object.defineProperty($$, '__line__', {
|
||||
value: @$.first_line,
|
||||
enumerable: false
|
||||
})}
|
||||
| '[' JSONElementList ']'
|
||||
{$$ = $2; Object.defineProperty($$, '__line__', {
|
||||
value: @$.first_line,
|
||||
enumerable: false
|
||||
})}
|
||||
;
|
||||
|
||||
JSONElementList
|
||||
: JSONValue
|
||||
{$$ = [$1];}
|
||||
| JSONElementList ',' JSONValue
|
||||
{$$ = $1; $1.push($3);}
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user