yash icon indicating copy to clipboard operation
yash copied to clipboard

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

Open madopew opened this issue 5 years ago • 5 comments

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 avatar Nov 03 '20 21:11 madopew

I think it could be fixed by adding '%define' case here: https://github.com/babyraging/yash/blob/021fdbf1a611ac6395fa92bb88f1eb3ef8b3b4f0/src/languages/parser/yaccParser.ts#L221-L226 with new ParserState, and a new case here (with additional modifications to TokenType.Word): https://github.com/babyraging/yash/blob/021fdbf1a611ac6395fa92bb88f1eb3ef8b3b4f0/src/languages/parser/yaccParser.ts#L175-L179 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 :)

madopew avatar Nov 03 '20 21:11 madopew

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?

babyraging avatar Nov 03 '20 22:11 babyraging

%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 avatar Nov 03 '20 23:11 madopew

Is there any process on this?

kawinie avatar May 23 '21 23:05 kawinie

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.

Ashitemaru avatar Oct 02 '21 22:10 Ashitemaru