}
bool is_number(char c) {
- return ('0' < c) && (c < '9');
+ return ('0' <= c) && (c <= '9');
}
bool is_alpha(char c) {
- return (c == '_') || (('a' < c) && (c < 'z')) || (('A' < c) && (c < 'Z'));
+ return (c == '_') || (('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z'));
}
bool is_alpha_num(c) {
return is_number(c) || is_alpha(c);
}
-#define PARSE_ERROR(str) ParseError_set_pos_message(error, str, i, c)
+size_t DLList_equation_print(DLList* l, FILE* fp) {
+ size_t cant = 0;
+ Equation* eq;
+ for (eq = DLList_begin(l); DLList_have_more(l); eq = DLList_next(l)) {
+ cant += Equation_print(eq, fp);
+ }
+ return cant;
+}
+
+void DLList_equation_delete(DLList* l) {
+ if (l) {
+ while (!DLList_empty(l)) {
+ Equation_delete((Equation*)DLList_pop(l));
+ }
+ }
+ DLList_delete(l);
+}
+
+#define PARSE_ERROR(str) ParseError_set_pos_message(error, str, i + 1, c)
bool parser_equation(const char* line, size_t len, DLList* equation_list,
ParseError* error) {
char c;
Equation* eq;
for (i = 0; i < len; i++) {
+ c = line[i];
switch (state) {
case SEARCH_VAR: /* Busca el comienzo de una variable. */
if (!is_space(c)) {
} else if (c == '=') {
/* Es igual, empieza la expresión. */
state = EXP;
+ /* Calculo la longitud de la variable. */
+ var_len = i - var_start;
} else { /* es otra cosa */
PARSE_ERROR(
"un espacio, una letra, un número o un igual");