Make the lexical analysis on the given module.
54{
55 char message[128];
56 int ch;
57 unsigned int line = 1;
58 unsigned int column = 1;
60
62 if (isblank(ch)) {
64 continue;
65 }
66
67 switch (ch) {
68 case '#':
70 line++;
71 column = 0;
72 continue;
73 case '\n':
74 line++;
75 column = 0;
76 break;
77 case '{':
79 break;
80 case '}':
82 break;
83 case '(':
85 break;
86 case ')':
88 break;
89 case '[':
91 break;
92 case ']':
94 break;
95 case ';':
97 break;
98 case ':':
100 break;
101 case ',':
103 break;
104 case '=':
106 break;
107 case '"':
108 column += _mod_read_string(
module, line, column) - 1;
109 continue;
110 default:
111 if (isdigit(ch)) {
112 column += _mod_read_number(
module, line, column) - 1;
113 continue;
114 }
115
116 if (ispunct(ch)) {
117 column += _mod_read_operator(
module, line, column) - 1;
118 continue;
119 }
120
121 if (isalnum(ch)) {
122 column += _mod_read_identifier(
module, line, column) - 1;
123 continue;
124 }
125
126 sprintf(message, "Character '%c' is unexpected here!\n", ch);
127
129 break;
130 }
131
133 }
134
136
138}
#define MOD_ADD(lexeme, type)
void module_add_error(module_t *module, unsigned int line, unsigned int column, unsigned int length, const char *message)
Add error for the given module.
error_code_t module_lookup(module_t *module, int *chret, unsigned int seek)
Get a character on module's file, without removing it from the queue.
error_code_t module_getc(module_t *module, int *chret)
Get next character on module's file, removing it from the queue.
Struct that represents a Mya module.
unsigned int errors_count
Number of errors on errors list.
struct token token_t
Struct for a Mya token.