Nothing Special   »   [go: up one dir, main page]

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

Haskell backend: happy does not accept empty token list, so bnfc should check for it #213

Closed
andreasabel opened this issue Nov 7, 2017 · 3 comments
Assignees
Labels
enhancement Haskell LBNF Concerning the LBNF syntax and its checking parser Issues concerning parser generating
Milestone

Comments

@andreasabel
Copy link
Member

This (evil) grammar fails with a parse error in the Par.y file raised by happy:

A. S := T;
B. T := S;

happy does not like empty %token list.

@bafain
Copy link
Contributor
bafain commented Nov 14, 2018

Although the user guide says that the %token directive is mandatory, happy 1.19.9 does not complain if we omit it.

@andreasabel
Copy link
Member Author
andreasabel commented Feb 7, 2019

In case of no tokens, happy now does not output a %token declaration: f42310d.
Works for Haskell and Java backends now.

C/CPP: bison complains:

bison -t -pIssue213 Issue213.y -o Parser.c
Issue213.y: warning: 3 nonterminals useless in grammar [-Wother]
Issue213.y: warning: 3 rules useless in grammar [-Wother]
Issue213.y:68.8: fatal error: start symbol S does not derive any sentence
 %start S
        ^

I think this issue is not worth pursuing further.

@andreasabel andreasabel added enhancement LBNF Concerning the LBNF syntax and its checking parser Issues concerning parser generating and removed abandoned labels Oct 8, 2020
@andreasabel andreasabel added this to the 2.8.4 milestone Oct 8, 2020
@andreasabel
Copy link
Member Author

It is easy to insert a check whether any terminals appear in the grammar.

@andreasabel andreasabel reopened this Oct 8, 2020
andreasabel added a commit that referenced this issue Oct 8, 2020
The test in 84e19a0 was not correct
since it ignored user-defined token categories in the grammar.
If one of these appears on a rhs, the language may not be empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Haskell LBNF Concerning the LBNF syntax and its checking parser Issues concerning parser generating
Projects
None yet
Development

No branches or pull requests

2 participants