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

"Type is not declared" on %define api.value.type #6

Open
madopew opened this issue Nov 3, 2020 · 5 comments · May be fixed by #8
Open

"Type is not declared" on %define api.value.type #6

madopew opened this issue Nov 3, 2020 · 5 comments · May be fixed by #8

Comments

@madopew
Copy link
Contributor

madopew commented Nov 3, 2020

Nonterminals are highlighted as "Semantic value used inside actions but has not declared the type."

type


although all values %defined to be api.value.type {some data type}

define

@madopew
Copy link
Contributor Author

madopew commented Nov 3, 2020

I think it could be fixed by adding '%define' case here:

case '%precedence':
lastNode = { nodeType: NodeType.Precedence, offset: offset, length: -1, end: -1 }
state = ParserState.WaitingPrecedence;
break;
default:
break;

with new ParserState, and a new case here (with additional modifications to TokenType.Word):
case TokenType.Action:
switch (state) {
case ParserState.WaitingUnion: // if we are inside union, extract type information
tokenText = scanner.getTokenText();
parseUnion(tokenText).forEach(t => {

that, probably, should set a default type for all the rules (?)

I know that adding %define makes things more complicated but it would be nice to get rid of that annoying message :)

@babyraging
Copy link
Owner

Hi there, thanks for the issue.

I see, this is a feature that we didn't implement, mainly because we didn't use it :)

Can you provide me a minimal example to reproduce this issue that I can test with?

@madopew
Copy link
Contributor Author

madopew commented Nov 3, 2020

%define directive of Bison is used to set some features. There are many of them but in that case (and it's really the one that I ever used) defines the data type of a stack. (reference %define value)

So the minimal example would be:

%define api.value.type {double}

%token TEST

%%

expr
    : TEST {$$ = $1}

%%

@madopew madopew linked a pull request Nov 4, 2020 that will close this issue
@kawinie
Copy link

kawinie commented May 23, 2021

Is there any process on this?

@Ashitemaru
Copy link

Ashitemaru commented Oct 2, 2021

I may run into a similar problem when using %define api.value.type variant in bison.
Statements like %token<std::string> IDENTIFIER "identifier" are considered as wrong statements while they work properly.

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 a pull request may close this issue.

4 participants