Having trouble again getting a my input properly ingested, and I'm not sure what I'm doing wrong. The full file I'm using to to define my lexers can be seen here. But specifically what I'm running into is that it won't identify an expression within parentheses. My issue is specifically with this Lexer:
Parser fhirPathExpression() {
final _expression = undefined();
final _invocation = undefined();
final _function = undefined();
final _paramList = undefined();
final Parser expressionPart = (_invocation |
(literal & char('.') & _invocation) |
_function |
literal |
string('\$this') |
string('\$index') |
string('\$total') |
externalConstant |
/// ******* line is the issue ***********************
(char('(') & _expression & char(')'))) &
/// ***********************************************
(identifyingOperations |
(operations & _expression) |
(char('.') & _invocation))
.star();
/// | (IDENTIFIER)? '=>' expression #lambdaExpression
/// invocation : // Terms that can be used after the function/member invocation '.'
final Parser invocationPart = ((_function |
identifier |
string('\$this') |
string('\$index') |
string('\$total')) &
(char('.') & _invocation).star());
final Parser functionPart = ((pattern('A-Za-z').plus().flatten().where(
(value) => noArgumentFunctions.keys.contains(value)) &
string('()'))
.map((value) {
return noArgumentFunctions[value[0]]!;
}) |
(pattern('A-Za-z')
.plus()
.flatten()
.where((value) => argumentFunctionNames.contains(value)) &
char('(') &
_paramList.optional() &
char(')')))
.map((value) => value);
final Parser paramListPart = _expression & (char(',') & _expression).star();
_expression.set(expressionPart.end());
_invocation.set(invocationPart);
_function.set(functionPart);
_paramList.set(paramListPart);
return _expression;
}
And I'm trying to parse "(1.2 / 1.8)". When I attempt this, I get this error:
FhirPathInvalidExpressionException (Expression could not be parsed: end of input expected
[
Expression: (1.2 / 1.8)
Offset: 5
Cause: Instance of 'ParserException': end of input expected (at 1:6)
])
The thing that confuses me is if instead I parse "(1.2 / 1.8", and change the offending line to:
(char('(') & _expression)) &
It works fine. Any thoughts on where I'm going wrong?