Update parser
This commit is contained in:
parent
b0c9ad7994
commit
1988b401a0
2 changed files with 15 additions and 21 deletions
|
@ -440,18 +440,9 @@ class Parser {
|
|||
return null;
|
||||
}
|
||||
|
||||
ValueOrVariableContext parseValueOrVariable() {
|
||||
var value = parseValue();
|
||||
if (value != null)
|
||||
return new ValueOrVariableContext(value, null);
|
||||
else {
|
||||
var variable = parseVariable();
|
||||
if (variable != null)
|
||||
return new ValueOrVariableContext(null, variable);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// Use [parseInputValue] instead.
|
||||
@deprecated
|
||||
InputValueContext parseValueOrVariable() => parseInputValue();
|
||||
|
||||
VariableContext parseVariable() {
|
||||
if (next(TokenType.DOLLAR)) {
|
||||
|
@ -498,14 +489,18 @@ class Parser {
|
|||
return null;
|
||||
}
|
||||
|
||||
ValueContext parseValue() {
|
||||
/// Use [parseInputValue] instead.
|
||||
@deprecated
|
||||
InputValueContext parseValue() => parseInputValue();
|
||||
|
||||
InputValueContext parseInputValue() {
|
||||
return (parseNumberValue() ??
|
||||
parseStringValue() ??
|
||||
parseBooleanValue() ??
|
||||
parseNullValue() ??
|
||||
parseEnumValue() ??
|
||||
parseListValue() ??
|
||||
parseObjectValue()) as ValueContext;
|
||||
parseObjectValue()) as InputValueContext;
|
||||
}
|
||||
|
||||
StringValueContext parseStringValue() => next(TokenType.STRING)
|
||||
|
@ -532,14 +527,14 @@ class Parser {
|
|||
if (next(TokenType.LBRACKET)) {
|
||||
var LBRACKET = current;
|
||||
var lastSpan = LBRACKET.span;
|
||||
List<ValueContext> values = [];
|
||||
ValueContext value = parseValue();
|
||||
List<InputValueContext> values = [];
|
||||
var value = parseInputValue();
|
||||
|
||||
while (value != null) {
|
||||
lastSpan = value.span;
|
||||
values.add(value);
|
||||
eatCommas();
|
||||
value = parseValue();
|
||||
value = parseInputValue();
|
||||
}
|
||||
|
||||
eatCommas();
|
||||
|
|
|
@ -54,10 +54,9 @@ class _IsArgument extends Matcher {
|
|||
if (arg == null) return false;
|
||||
print(arg.span.highlight());
|
||||
return equals(name).matches(arg.name, matchState) &&
|
||||
equals(value).matches(
|
||||
arg.valueOrVariable.value?.value ??
|
||||
arg.valueOrVariable.variable?.name,
|
||||
matchState);
|
||||
((arg is VariableContext &&
|
||||
equals(value).matches(arg.name, matchState)) ||
|
||||
equals(value).matches(arg.value.computeValue({}), matchState));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue