]>
Piment Noir Git Repositories - TP_AL_C.git/blob - lexer/lexical_analyzer.c
39c82e075169b69eb50ce895bc283227a45f72cc
6 #include "global_vars.h"
7 #include "print_helper.h"
8 #include "lexical_analyzer.h"
12 /* It looks silly to check for each characters but for debugging, it's just the way to go */
13 static bool isAlphaNum() {
14 if (c
== L
'a' || c
== L
'b' || c
== L
'c' || c
== L
'd' || c
== L
'e' || c
== L
'f' || c
== L
'g' || \
15 c
== L
'h' || c
== L
'i' || c
== L
'j' || c
== L
'k' || c
== L
'l' || c
== L
'm' || c
== L
'n' || \
16 c
== L
'o' || c
== L
'p' || c
== L
'q' || c
== L
'r' || c
== L
's' || c
== L
't' || c
== L
'u' || \
17 c
== L
'v' || c
== L
'w' || c
== L
'x' || c
== L
'y' || c
== L
'z' || \
18 c
== L
'A' || c
== L
'B' || c
== L
'C' || c
== L
'D' || c
== L
'E' || c
== L
'F' || c
== L
'G' || \
19 c
== L
'H' || c
== L
'I' || c
== L
'J' || c
== L
'K' || c
== L
'L' || c
== L
'M' || c
== L
'N' || \
20 c
== L
'O' || c
== L
'P' || c
== L
'Q' || c
== L
'R' || c
== L
'S' || c
== L
'T' || c
== L
'U' || \
21 c
== L
'V' || c
== L
'W' || c
== L
'X' || c
== L
'Y' || c
== L
'Z' || \
22 c
== L
'.' || c
== L
'?' || c
== L
'!' || c
== L
',' || c
== L
';' || c
== L
':' || c
== L
'-' || \
23 c
== L
'\''|| c
== L
'#' || \
24 c
== L
'0' || c
== L
'1' || c
== L
'2' || c
== L
'3' || c
== L
'4' || c
== L
'5' || c
== L
'6' || \
25 c
== L
'7' || c
== L
'8' || c
== L
'9' || \
26 //FIXME: Accentued characters (aka multibytes characters) support is still buggy
27 c
== L
'à' || c
== L
'â' || c
== L
'ç' || c
== L
'è' || c
== L
'é' || c
== L
'î' || c
== L
'ô' || \
28 c
== L
'ù' || c
== L
'û' || \
29 c
== L
'À' || c
== L
'Â' || c
== L
'Ç' || c
== L
'È' || c
== L
'É' || c
== L
'Î' || c
== L
'Ô' || \
30 c
== L
'Ù' || c
== L
'Û') {
36 static bool isSeparator() {
37 if (c
== L
'\t' || c
== L
' ' || c
== L
'\n') {
56 if (c
== L
' ' || c
== L
'\t') {
84 if (c
== L
'A' && !wcscmp(fgetws(m
, 6, source
), L
"uteur")) {
85 wcscpy((wchar_t*)tokenValue
, L
">Auteur");
89 if (c
== L
'T' && !wcscmp(fgetws(m
, 5, source
), L
"itre")) {
90 wcscpy((wchar_t*)tokenValue
, L
">Titre");
101 if (isSeparator() || isEOF()) {
107 if (isSeparator() || isEOF()) {
117 tokenType
= SSECTION
;
127 if (isSeparator() || isEOF()) {
133 if (c
== L
' ' || c
== L
'\t') {
188 wcscpy((wchar_t*)token
[tokenFound
].value
, (wchar_t*)tokenValue
);
192 if (isSeparator() || isEOF()) {
199 wcscpy((wchar_t*)token
[tokenFound
].value
, (wchar_t*)tokenValue
);
207 if (tokenType
== MOT
|| tokenType
== MOTCLE
) {
208 fwprintf(stderr
, L
"%s error with token type: %s and value: %ls\n",
210 tokenTypestr
[tokenType
],
213 fwprintf(stderr
, L
"%s error with token type: %s\n",
215 tokenTypestr
[tokenType
]);