Created
May 13, 2018 09:36
-
-
Save Yoxem/132e9b6535043eaaa9c73b7633db5af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
typedef enum { | |
STATE_start, //0 | |
STATE_num1, //1 | |
STATE_num2, //2 | |
STATE_num3, //3 | |
STATE_num4, //4 | |
STATE_id1, //5 | |
STATE_id2, //6 | |
STATE_op, //7 | |
STATE_end //8 | |
} ParserState; | |
struct token_pair{ | |
char *pair[2]; | |
}; | |
char * input = "2+2 = 4"; | |
// input = "2+2*a=4" | |
/* | |
// out_put = {{"NUM","2"},{"OP","+"},{"NUM","2"},{"OP","*"},{"ID","a"},{"OP","="},{"NUM","4"}} | |
struct token_pair[] tokenize(char * input){ | |
} | |
*/ | |
int* int_append(int* array, size_t array_size, int a){ | |
int * ret; | |
ret = malloc((array_size+1)*sizeof(int)); | |
ret=array; | |
ret[array_size] = a; | |
for (int i=0;i<array_size+1;i++) | |
{ | |
printf("%d",ret[i]); | |
} | |
return ret; | |
} | |
int main(void){ | |
int c[] = {1,5,3,4,2,7,8,9}; | |
int_append(c,sizeof(c)/sizeof(int),6); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment