Created
June 15, 2018 01:40
-
-
Save Alexsandr0x/c900bc171d7155fb783a6d5720c6298c to your computer and use it in GitHub Desktop.
compiladores_pratica_1
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> | |
int main(int argc, char *argv[]){ | |
char *str = argv[1]; | |
FILE *fp; | |
char buff[255]; | |
fp = fopen("casos_teste/i_test", "r"); | |
char c; | |
int cursor = 0; | |
int indice = 0; | |
char state = '0'; // 0 == estado inicial | |
while(1){ | |
c = fgetc((FILE*)fp); | |
cursor++; | |
if (c == EOF) { | |
break; | |
} | |
if(c == '0' || c == '1' || c == '2' ||c == '3' ||c == '4' ||c == '5' ||c == '6' ||c == '7' ||c == '8' || c == '9') { | |
state = 'i'; // i == estado 'inteiro' | |
} else { | |
state = 'f'; // f == estado lixo | |
break; | |
} | |
} | |
printf("\n%c", state); | |
} | |
/* | |
for { | |
switch(c){ | |
case -> state | |
if -> transition | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment