-
Notifications
You must be signed in to change notification settings - Fork 0
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
Causes an ambigious trigger when a previously declared integer variable gets assigned with a double/float data #6
Comments
Tried this scenario, this no longer triggers the ambiguous flag and instead the variable remains of int /*******************************************************
Code generated by s2sc.js
*******************************************************/
int main ( void ) {
int a = 1000;
a = 22.34;
return 0;
} even if i force it to trigger by adding a = "222" at the end of the code, what it will generate is this /*******************************************************
Code generated by s2sc.js
*******************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef union {
bool *boolValue;
int *intValue;
float *floatValue;
double *doubleValue;
char *charValue;
void *voidValue;
} ambiguous;
int main ( void ) {
ambiguous a;
a.intValue = ( int * ) calloc(1, sizeof( int ) );
(*a.intValue) = 1000;
(*a.intValue) = 22.34;
free(a.intValue);
a.charValue = ( char * ) calloc(2048, sizeof( char ) );
sprintf(a.charValue, "%s", "222");
return 0;
} |
Ok, i'll work on that this week. |
Nice, i think though that the parser.js should follow the BNF format, I noticed that it uses a similar syntax to BNF. Maybe we should add support for BNF or change everything to follow BNF for consistency. |
I'll try to help you with the documentation as well |
What does the gc.h header represent, is it a library? |
Yes! it's a garbage collection library. I have my own compiled copy(from source) both in 64bit and 32bit but i can only send you that on weekends since i'm busy with work. Or you can do yourself a favor and compile (http://www.hboehm.info/) your own. |
I'll also do the transidtion to BNF once i get back home |
Same same... ill probably do the documentation on Monday. |
A python code such as this
will generate this
although the code generated is compilable, a better solution is that instead of triggering the ambigious flag, it just changes data types, since both double and int are compatible
The text was updated successfully, but these errors were encountered: