IdentifierName > Identifier
This commit is contained in:
parent
6bc85de256
commit
26969475f7
|
@ -287,17 +287,18 @@ function peg$parse(input, options) {
|
||||||
expression: expression,
|
expression: expression,
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
var peg$f7 = function(operator, expression) {
|
var peg$f7 = function(name) { return [name, location()]; };
|
||||||
|
var peg$f8 = function(operator, expression) {
|
||||||
return createNode( OPS_TO_PREFIXED_TYPES[operator], {
|
return createNode( OPS_TO_PREFIXED_TYPES[operator], {
|
||||||
expression: expression,
|
expression: expression,
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
var peg$f8 = function(expression, operator) {
|
var peg$f9 = function(expression, operator) {
|
||||||
return createNode( OPS_TO_SUFFIXED_TYPES[operator], {
|
return createNode( OPS_TO_SUFFIXED_TYPES[operator], {
|
||||||
expression: expression,
|
expression: expression,
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
var peg$f9 = function(expression) {
|
var peg$f10 = function(expression) {
|
||||||
// The purpose of the "group" AST node is just to isolate label scope. We
|
// The purpose of the "group" AST node is just to isolate label scope. We
|
||||||
// don't need to put it around nodes that can't contain any labels or
|
// don't need to put it around nodes that can't contain any labels or
|
||||||
// nodes that already isolate label scope themselves. This leaves us with
|
// nodes that already isolate label scope themselves. This leaves us with
|
||||||
|
@ -306,19 +307,18 @@ function peg$parse(input, options) {
|
||||||
? createNode( "group", { expression: expression } )
|
? createNode( "group", { expression: expression } )
|
||||||
: expression;
|
: expression;
|
||||||
};
|
};
|
||||||
var peg$f10 = function(name) {
|
var peg$f11 = function(name) {
|
||||||
return createNode( "rule_ref", { name: name } );
|
return createNode( "rule_ref", { name: name } );
|
||||||
};
|
};
|
||||||
var peg$f11 = function(operator, code) {
|
var peg$f12 = function(operator, code) {
|
||||||
return createNode( OPS_TO_SEMANTIC_PREDICATE_TYPES[operator], { code: code } );
|
return createNode( OPS_TO_SEMANTIC_PREDICATE_TYPES[operator], { code: code } );
|
||||||
};
|
};
|
||||||
var peg$f12 = function(comment) {
|
var peg$f13 = function(comment) {
|
||||||
return addComment(comment, true);
|
return addComment(comment, true);
|
||||||
};
|
};
|
||||||
var peg$f13 = function(comment) {
|
var peg$f14 = function(comment) {
|
||||||
return addComment(comment, false);
|
return addComment(comment, false);
|
||||||
};
|
};
|
||||||
var peg$f14 = function(name) { return [name, location()]; };
|
|
||||||
var peg$f15 = function(head, tail) { return head + tail.join(""); };
|
var peg$f15 = function(head, tail) { return head + tail.join(""); };
|
||||||
var peg$f16 = function(sequence) { return sequence; };
|
var peg$f16 = function(sequence) { return sequence; };
|
||||||
var peg$f17 = function(value, ignoreCase) {
|
var peg$f17 = function(value, ignoreCase) {
|
||||||
|
@ -624,7 +624,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s0 = peg$currPos;
|
s0 = peg$currPos;
|
||||||
s1 = peg$parseIdentifierName();
|
s1 = peg$parseIdentifier();
|
||||||
if (s1 !== peg$FAILED) {
|
if (s1 !== peg$FAILED) {
|
||||||
s2 = peg$parse__();
|
s2 = peg$parse__();
|
||||||
s3 = peg$currPos;
|
s3 = peg$currPos;
|
||||||
|
@ -830,7 +830,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s0 = peg$currPos;
|
s0 = peg$currPos;
|
||||||
s1 = peg$parseIdentifier();
|
s1 = peg$parseIdentifierName();
|
||||||
if (s1 !== peg$FAILED) {
|
if (s1 !== peg$FAILED) {
|
||||||
s2 = peg$parse__();
|
s2 = peg$parse__();
|
||||||
rule$expects(peg$e2);
|
rule$expects(peg$e2);
|
||||||
|
@ -865,6 +865,24 @@ function peg$parse(input, options) {
|
||||||
return s0;
|
return s0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function peg$parseIdentifierName() {
|
||||||
|
var s0, s1;
|
||||||
|
|
||||||
|
var rule$expects = function (expected) {
|
||||||
|
if (peg$silentFails === 0) peg$expect(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
s0 = peg$currPos;
|
||||||
|
s1 = peg$parseIdentifier();
|
||||||
|
if (s1 !== peg$FAILED) {
|
||||||
|
peg$savedPos = s0;
|
||||||
|
s1 = peg$f7(s1);
|
||||||
|
}
|
||||||
|
s0 = s1;
|
||||||
|
|
||||||
|
return s0;
|
||||||
|
}
|
||||||
|
|
||||||
function peg$parsePrefixedExpression() {
|
function peg$parsePrefixedExpression() {
|
||||||
var s0, s1, s2, s3;
|
var s0, s1, s2, s3;
|
||||||
|
|
||||||
|
@ -879,7 +897,7 @@ function peg$parse(input, options) {
|
||||||
s3 = peg$parseSuffixedExpression();
|
s3 = peg$parseSuffixedExpression();
|
||||||
if (s3 !== peg$FAILED) {
|
if (s3 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f7(s1, s3);
|
s0 = peg$f8(s1, s3);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -945,7 +963,7 @@ function peg$parse(input, options) {
|
||||||
s3 = peg$parseSuffixedOperator();
|
s3 = peg$parseSuffixedOperator();
|
||||||
if (s3 !== peg$FAILED) {
|
if (s3 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f8(s1, s3);
|
s0 = peg$f9(s1, s3);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1036,7 +1054,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
if (s5 !== peg$FAILED) {
|
if (s5 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f9(s3);
|
s0 = peg$f10(s3);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1066,7 +1084,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s0 = peg$currPos;
|
s0 = peg$currPos;
|
||||||
s1 = peg$parseIdentifierName();
|
s1 = peg$parseIdentifier();
|
||||||
if (s1 !== peg$FAILED) {
|
if (s1 !== peg$FAILED) {
|
||||||
s2 = peg$currPos;
|
s2 = peg$currPos;
|
||||||
peg$begin();
|
peg$begin();
|
||||||
|
@ -1108,7 +1126,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
if (s2 !== peg$FAILED) {
|
if (s2 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f10(s1);
|
s0 = peg$f11(s1);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1135,7 +1153,7 @@ function peg$parse(input, options) {
|
||||||
s3 = peg$parseCodeBlock();
|
s3 = peg$parseCodeBlock();
|
||||||
if (s3 !== peg$FAILED) {
|
if (s3 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f11(s1, s3);
|
s0 = peg$f12(s1, s3);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1431,7 +1449,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
if (s3 !== peg$FAILED) {
|
if (s3 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f12(s2);
|
s0 = peg$f13(s2);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1541,7 +1559,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
if (s3 !== peg$FAILED) {
|
if (s3 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f12(s2);
|
s0 = peg$f13(s2);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1625,7 +1643,7 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
s2 = input.substring(s2, peg$currPos);
|
s2 = input.substring(s2, peg$currPos);
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s0 = peg$f13(s2);
|
s0 = peg$f14(s2);
|
||||||
} else {
|
} else {
|
||||||
peg$currPos = s0;
|
peg$currPos = s0;
|
||||||
s0 = peg$FAILED;
|
s0 = peg$FAILED;
|
||||||
|
@ -1635,24 +1653,6 @@ function peg$parse(input, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function peg$parseIdentifier() {
|
function peg$parseIdentifier() {
|
||||||
var s0, s1;
|
|
||||||
|
|
||||||
var rule$expects = function (expected) {
|
|
||||||
if (peg$silentFails === 0) peg$expect(expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
s0 = peg$currPos;
|
|
||||||
s1 = peg$parseIdentifierName();
|
|
||||||
if (s1 !== peg$FAILED) {
|
|
||||||
peg$savedPos = s0;
|
|
||||||
s1 = peg$f14(s1);
|
|
||||||
}
|
|
||||||
s0 = s1;
|
|
||||||
|
|
||||||
return s0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function peg$parseIdentifierName() {
|
|
||||||
var s0, s1, s2, s3;
|
var s0, s1, s2, s3;
|
||||||
|
|
||||||
var rule$expects = function (expected) {
|
var rule$expects = function (expected) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ Initializer
|
||||||
}
|
}
|
||||||
|
|
||||||
Rule
|
Rule
|
||||||
= name:IdentifierName __
|
= name:Identifier __
|
||||||
displayName:(StringLiteral __)?
|
displayName:(StringLiteral __)?
|
||||||
"=" __
|
"=" __
|
||||||
expression:Expression EOS
|
expression:Expression EOS
|
||||||
|
@ -141,7 +141,7 @@ SequenceExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
LabeledExpression
|
LabeledExpression
|
||||||
= label:Identifier __ ":" __ expression:PrefixedExpression {
|
= label:IdentifierName __ ":" __ expression:PrefixedExpression {
|
||||||
if (RESERVED_WORDS.indexOf(label[0]) >= 0) {
|
if (RESERVED_WORDS.indexOf(label[0]) >= 0) {
|
||||||
error(`Label can't be a reserved word "${label[0]}".`, label[1]);
|
error(`Label can't be a reserved word "${label[0]}".`, label[1]);
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,9 @@ LabeledExpression
|
||||||
}
|
}
|
||||||
/ PrefixedExpression
|
/ PrefixedExpression
|
||||||
|
|
||||||
|
IdentifierName
|
||||||
|
= name:Identifier { return [name, location()]; }
|
||||||
|
|
||||||
PrefixedExpression
|
PrefixedExpression
|
||||||
= operator:PrefixedOperator __ expression:SuffixedExpression {
|
= operator:PrefixedOperator __ expression:SuffixedExpression {
|
||||||
return createNode( OPS_TO_PREFIXED_TYPES[operator], {
|
return createNode( OPS_TO_PREFIXED_TYPES[operator], {
|
||||||
|
@ -196,7 +199,7 @@ PrimaryExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleReferenceExpression
|
RuleReferenceExpression
|
||||||
= name:IdentifierName !(__ (StringLiteral __)? "=") {
|
= name:Identifier !(__ (StringLiteral __)? "=") {
|
||||||
return createNode( "rule_ref", { name: name } );
|
return createNode( "rule_ref", { name: name } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,10 +255,7 @@ SingleLineComment
|
||||||
return addComment(comment, false);
|
return addComment(comment, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier
|
Identifier "identifier"
|
||||||
= name:IdentifierName { return [name, location()]; }
|
|
||||||
|
|
||||||
IdentifierName "identifier"
|
|
||||||
= head:IdentifierStart tail:IdentifierPart* { return head + tail.join(""); }
|
= head:IdentifierStart tail:IdentifierPart* { return head + tail.join(""); }
|
||||||
|
|
||||||
IdentifierStart
|
IdentifierStart
|
||||||
|
|
Loading…
Reference in a new issue