Created
August 27, 2012 13:34
-
-
Save thiagojedi/3488444 to your computer and use it in GitHub Desktop.
Analizador Lexico Pascal Compiladores 2012.2
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 <stdlib.h> | |
#include <string.h> | |
char messages[1000] = ""; | |
unsigned int lc = 1; | |
unsigned int ln; | |
void mensagemErro(char *message, unsigned int ln) { | |
char buffer[50]; | |
sprintf(buffer, "Erro na linha %i %s.\n", ln, message); | |
strcat(messages, buffer); | |
} | |
void mostrarMensagens(){ | |
if(strlen(messages) > 0){ | |
printf("\n%s", messages); | |
} | |
printf("%d lines\n", lc); | |
} | |
%} | |
caractere \'.\' | |
flutuante -?[0-9]+\.[0-9]+ | |
inteiro -?[0-9]+ | |
identificador [a-zA-Z][a-zA-Z0-9_]* | |
espaco [ \t]+ | |
erro . | |
%x comentario string | |
%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment