YACDB
Yet Another C(rappy) Database
parser.h
Go to the documentation of this file.
1
7#ifndef PARSER_H
8#define PARSER_H
9
10#include <stdio.h>
11#include <string.h>
12#include <stdlib.h>
13#include <unistd.h>
15#include "instruction.h"
16
20typedef enum keyword
21{
31 with
37{
38 int corresponding_enum;
39 int size;
40 char *inString;
41};
42
46void remove_spaces(char **data);
47
54int parse_comma(char **data);
61int parse_equalsign(char **data);
68char *parse_ident(char **data);
75char *parse_value(char **data);
82instrType parse_instrtype(char **data);
90int parse_expected_keyword(char **data, keyword expected);
91//
100int count_comma_list(char *data);
108int parse_comma_list(char **data, charray *res);
115struct condition *parse_condition(char **data);
116//
123instr *parse_instr(char *data);
130instr *parse_selinstr(char **data);
137instr *parse_crtinstr(char **data);
144instr *parse_addinstr(char **data);
153InstrArray *parse_user_input(char *data);
154
155#endif
Structures for instruction management.
instrType
The different instruction types, such as select or add.
Definition: instruction.h:25
instr * parse_crtinstr(char **data)
Parse a CrtInstr.
Definition: parser.c:393
instr * parse_instr(char *data)
Parse an instruction.
Definition: parser.c:423
keyword
The different keyword in the yacdb language, used for parsing.
Definition: parser.h:21
@ set
Not implemented yet.
Definition: parser.h:29
@ where
where (in SelInstr)
Definition: parser.h:23
@ with
with (in CrtInstr)
Definition: parser.h:31
@ in
in (in AddInstr)
Definition: parser.h:27
@ from
from (in SelInstr)
Definition: parser.h:25
char * parse_value(char **data)
Parse a value, either an int or a "string", increase data pointer on success.
Definition: parser.c:194
int parse_comma(char **data)
Increase data pointer past a comma.
Definition: parser.c:247
instr * parse_addinstr(char **data)
Parse a AddInstr.
Definition: parser.c:408
InstrArray * parse_user_input(char *data)
Parse the user input.
Definition: parser.c:452
int parse_comma_list(char **data, charray *res)
Parse a comma separated list, increase data pointer on success.
Definition: parser.c:293
int count_comma_list(char *data)
Counts the size of the comma s and return an array of instruct to be executed eparated list at the st...
Definition: parser.c:25
int parse_expected_keyword(char **data, keyword expected)
Parse the expected keyword, increase data pointer on success.
Definition: parser.c:141
void remove_spaces(char **data)
Increase data pointer past leading spaces.
Definition: parser.c:239
int parse_equalsign(char **data)
Increase data pointer past an equalsign.
Definition: parser.c:262
struct condition * parse_condition(char **data)
Parse a single condition (COL = VALUE), increase data pointer on success.
Definition: parser.c:278
instr * parse_selinstr(char **data)
Parse a SelInstr.
Definition: parser.c:365
char * parse_ident(char **data)
Parse the identifier at the start of the data, increase data pointer on success.
Definition: parser.c:167
instrType parse_instrtype(char **data)
Parse the instrType at the start of the data, increase data pointer on success.
Definition: parser.c:113
Frees and mallocs helper for the structures in instruction.h.
An array of instruction.
Definition: instruction.h:128
An array of char* (string)
Definition: instruction.h:48
An equality condition.
Definition: instruction.h:59
One yacDB instruction, this type is meant to be casted into other instr type.
Definition: instruction.h:69
Internal struct used when parsing.
Definition: parser.h:37