Skip to content
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

Merged
merged 5 commits into from
Oct 6, 2016
Merged

List Instantiation #17

merged 5 commits into from
Oct 6, 2016

Conversation

tfij
Copy link
Contributor

@tfij tfij commented Oct 5, 2016

No description provided.

@@ -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()))),
Copy link
Contributor

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 ?

Copy link
Contributor Author

@tfij tfij Oct 5, 2016

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()));
Copy link
Contributor

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()

Copy link
Contributor

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)

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional of list?

Copy link
Contributor Author

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) {
Copy link
Contributor

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 ?

Copy link
Contributor Author

@tfij tfij Oct 5, 2016

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) {

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?

Copy link
Contributor Author

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()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typos, meg & msq -> msg ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

);
}

Rule Object() {
return FirstOf(FunctionCall(),StringLiteral(), NamedValue(), ListInstantiation(), Sequence("( ", Expression(), ") "));
Copy link
Contributor

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() {

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()),
Copy link

@pawel-piecyk pawel-piecyk Oct 6, 2016

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'() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should instantiate / should create ?

@rzukow rzukow merged commit 029e977 into master Oct 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants