-
Notifications
You must be signed in to change notification settings - Fork 18
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
List Instantiation #17
Conversation
51ffb3b
to
18607e1
Compare
@@ -65,7 +72,7 @@ Rule ZeroArgumentMethodCall() { | |||
|
|||
Rule FieldAccess() { | |||
return FirstOf( | |||
Sequence("[ ", AdditiveExpression(), "] ", push(nodeFactory.mapAccess(pop(1), pop()))), | |||
Sequence("[ ", Expression(), "] ", push(nodeFactory.mapAccess(pop(1), pop()))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'a bug? Can we hava a simple test for it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, and I add some test
return Sequence( | ||
"[ ", | ||
"] ", | ||
push(nodeFactory.emptyListInstantiation())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to put this push at the beginning of Args() (the same way I did in Declarations()) so you don't need EmptyList()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same way ZeroArgsCall() may be removed (not sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
private final Optional<ArgumentsListExpressionNode> listElements; | ||
|
||
public ListInstantiationExpressionNode(ArgumentsListExpressionNode listElements) { | ||
this.listElements = Optional.of(listElements); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional of list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it
return parsingResult.resultValue.getValue(embeddedEvalContext); | ||
} | ||
|
||
private String additionalErrorMsq(ParsingResult<OpelNode> parsingResult) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this format of error available in parse - eval flow ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when expression has error return parsingResult.resultValue.getValue(embeddedEvalContext) throw npe. This as additional error message of OpelExeption.
boolean hasAdditionalMeg = parsingResult.parseErrors.stream() | ||
.map(ParseError::getErrorMessage) | ||
.anyMatch(it -> it != null); | ||
if (hasAdditionalMeg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all errors have errorMessage but we always have position where parsing error occured. Maybe reporting position is also a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe, this is better then npe from return parsingResult.resultValue.getValue(embeddedEvalContext);
return parsingResult.resultValue.getValue(embeddedEvalContext); | ||
} | ||
|
||
private String additionalErrorMsq(ParsingResult<OpelNode> parsingResult) { | ||
boolean hasAdditionalMeg = parsingResult.parseErrors.stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos, meg & msq -> msg ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
6e9f0d9
to
2b20996
Compare
); | ||
} | ||
|
||
Rule Object() { | ||
return FirstOf(FunctionCall(),StringLiteral(), NamedValue(), ListInstantiation(), Sequence("( ", Expression(), ") ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change here: we can access field on string literal, but this doesn't have to be detected by parsing engine, it can be detected later
this.listElements = listElements; | ||
} | ||
|
||
public ListInstantiationExpressionNode() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be no longer used.
return Sequence(Expression(), | ||
ZeroOrMore(", ", Expression(), push(nodeFactory.argumentsList(pop(), getFunctionArguments())))); | ||
return Sequence( | ||
push(nodeFactory.emptyArgumentsList()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this change :) 👍
|
||
class OpelEngineListIntegrationSpec extends Specification { | ||
@Unroll | ||
def 'should instantiation list in #input'() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should instantiate / should create ?
No description provided.