Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include <math.h>
- #include <string.h>
- %}
- INTEGER (0|-?[1-9][0-9]*)
- FLOAT (-?0\.[0-9]*[1-9]|-?[1-9][0-9]*\.[0-9]*[1-9])
- STRING \"[,\(\)%\/:=.\\a-zA-Z0-9]*\"
- IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
- %%
- . {
- if(isLanguageSpecific(yytext)){
- printf("Language specific: %s\n", yytext);
- }
- }
- {INTEGER} {
- printf("An integer: %s\n", yytext);
- }
- {FLOAT} {
- printf("A float: %s\n", yytext);
- }
- {IDENTIFIER} printf("An indentifier: %s\n", yytext);
- {STRING} {
- printf("A string: %s\n", yytext);
- }
- %%
- char codesTable[100][50];
- int codesTableDim = 0;
- int isLanguageSpecific(char* atom){
- int i;
- for(i = 0; i < codesTableDim; i++){
- if(strcmp(codesTable[i], atom) == 0){
- return 1;
- }
- }
- return 0;
- }
- void buildCodesVector(){
- printf("Building...");
- FILE* f = fopen("resources\\codesTable.txt", "r");
- char buffer[50];
- while(fgets(buffer, 50, f)){
- //codesTable[codesTableDim++] = buffer;
- strcpy(codesTable[codesTableDim++], buffer);
- }
- }
- int main(int argc, char **argv){
- ++argv; --argc; // skip over program name
- buildCodesVector();
- if(argc > 0){
- yyin = fopen(argv[0], "r");
- } else {
- yyin = stdin;
- }
- //yylex();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement