![]() ![]() If your intention is to translate the custom language into equivalent C code, then the translated code would need to be output by the parser, not part of the parser. Semantic actions contribute to the code for the generated parser itself - that is, code used when parsing the language. If that's the case then you've committed a frame error. It occurs to me that perhaps you were not trying to set a semantic value at all, but rather create a parser that generates C code. You need to rethink your approach, paying more careful attention to data types and how to preserve and convey type information. Although that might take care of your compilation errors, it leaves you with a result that you cannot use, because you need to know the original type, and also because converting from a pointer to an int may be inherently lossy. As a wild guess, perhaps you were trying to clean that up by casting one or both to type int, ala $$ = (int) $2. ![]() ![]() With $2 in the first action and $5 in the second action corresponding to tokens of the same type, there is no way that the two actions above are both compatible with the (undeclared) type of your declaration production. Here is the YACC file: %īUT you have a problem with data types. I have to write a parser for a mini language and I have some problems.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |