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

Fix references when rules are unused, and fix missing cloneExpr #83

Merged
merged 5 commits into from
May 20, 2019

Conversation

mna
Copy link
Owner

@mna mna commented May 16, 2019

This fixes #70 and an additional issue with optimization where a clone was missing, resulting in build errors on otherwise valid grammars.

This includes the changes in #71 .

@mna mna requested a review from breml May 16, 2019 14:48
ast/ast.go Outdated
@@ -166,7 +166,7 @@ func (a *ActionExpr) Pos() Pos { return a.p }

// String returns the textual representation of a node.
func (a *ActionExpr) String() string {
return fmt.Sprintf("%s: %T{Expr: %v, Code: %v}", a.p, a, a.Expr, a.Code)
return fmt.Sprintf("%s: %T{Expr: %v, Code: %v, FuncIx: %d, ID: %p}", a.p, a, a.Expr, a.Code, a.FuncIx, a)
Copy link
Owner Author

Choose a reason for hiding this comment

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

I had added this for easier debugging (and noticing the missing clone), let me know if you'd rather have it removed (this could be considered a breaking change, but I think that's a stretch :) )

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove it.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@breml breml left a comment

Choose a reason for hiding this comment

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

@mna Thanks for the updated PR.

I checked my local branches and found a commit, where I started to work on the bigger problem, that I mentioned in #70. I updated the issue #70. Would you like to look into this as well?

Makefile Outdated
@@ -154,6 +154,12 @@ $(TEST_DIR)/issue_65/optimized/issue_65.go: $(TEST_DIR)/issue_65/issue_65.peg $(
$(TEST_DIR)/issue_65/optimized-grammar/issue_65.go: $(TEST_DIR)/issue_65/issue_65.peg $(BINDIR)/pigeon
$(BINDIR)/pigeon -nolint -optimize-grammar $< > $@

$(TEST_DIR)/issue_70/issue_70.go: $(TEST_DIR)/issue_70/issue_70.peg $(BINDIR)/pigeon
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have you removed the additional lines for the optimized parsers? (see here)?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Probably a mistake when fixing the makefile conflict. Added them back.

ast/ast.go Outdated
@@ -166,7 +166,7 @@ func (a *ActionExpr) Pos() Pos { return a.p }

// String returns the textual representation of a node.
func (a *ActionExpr) String() string {
return fmt.Sprintf("%s: %T{Expr: %v, Code: %v}", a.p, a, a.Expr, a.Code)
return fmt.Sprintf("%s: %T{Expr: %v, Code: %v, FuncIx: %d, ID: %p}", a.p, a, a.Expr, a.Code, a.FuncIx, a)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove it.

Copy link
Owner Author

@mna mna left a comment

Choose a reason for hiding this comment

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

I checked my local branches and found a commit, where I started to work on the bigger problem, that I mentioned in #70. I updated the issue #70. Would you like to look into this as well?

I noticed that cycle too, as mentioned in https://github.com/mna/pigeon/pull/83/files#diff-e9f48c3beb9b8048f6d2247c99564198R47 . I don't have the bandwidth to look into this, but with the clone fix, this shouldn't cause any build issues, it is just additional code minification optimization that could be improved.

Makefile Outdated
@@ -154,6 +154,12 @@ $(TEST_DIR)/issue_65/optimized/issue_65.go: $(TEST_DIR)/issue_65/issue_65.peg $(
$(TEST_DIR)/issue_65/optimized-grammar/issue_65.go: $(TEST_DIR)/issue_65/issue_65.peg $(BINDIR)/pigeon
$(BINDIR)/pigeon -nolint -optimize-grammar $< > $@

$(TEST_DIR)/issue_70/issue_70.go: $(TEST_DIR)/issue_70/issue_70.peg $(BINDIR)/pigeon
Copy link
Owner Author

Choose a reason for hiding this comment

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

Probably a mistake when fixing the makefile conflict. Added them back.

ast/ast.go Outdated
@@ -166,7 +166,7 @@ func (a *ActionExpr) Pos() Pos { return a.p }

// String returns the textual representation of a node.
func (a *ActionExpr) String() string {
return fmt.Sprintf("%s: %T{Expr: %v, Code: %v}", a.p, a, a.Expr, a.Code)
return fmt.Sprintf("%s: %T{Expr: %v, Code: %v, FuncIx: %d, ID: %p}", a.p, a, a.Expr, a.Code, a.FuncIx, a)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

@breml breml merged commit 9fec389 into master May 20, 2019
@breml
Copy link
Collaborator

breml commented May 20, 2019

@mna Thank Martin, LGTM.

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.

Build failure only when --optimize-grammar is set; grammar with not referenced rule
2 participants