YACDB
Yet Another C(rappy) Database
parser.h File Reference

Main parsing file, transform a user input into instruction from instruction.h. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "parser_mallocs_frees.h"
#include "instruction.h"
Include dependency graph for parser.h:

Go to the source code of this file.

Data Structures

struct  parsingData
 Internal struct used when parsing. More...
 

Typedefs

typedef enum keyword keyword
 The different keyword in the yacdb language, used for parsing.
 

Enumerations

enum  keyword {
  where , from , in , set ,
  with
}
 The different keyword in the yacdb language, used for parsing. More...
 

Functions

void remove_spaces (char **data)
 Increase data pointer past leading spaces.
 
int parse_comma (char **data)
 Increase data pointer past a comma. More...
 
int parse_equalsign (char **data)
 Increase data pointer past an equalsign. More...
 
char * parse_ident (char **data)
 Parse the identifier at the start of the data, increase data pointer on success. More...
 
char * parse_value (char **data)
 Parse a value, either an int or a "string", increase data pointer on success. More...
 
instrType parse_instrtype (char **data)
 Parse the instrType at the start of the data, increase data pointer on success. More...
 
int parse_expected_keyword (char **data, keyword expected)
 Parse the expected keyword, increase data pointer on success. More...
 
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 stat of the string given. More...
 
int parse_comma_list (char **data, charray *res)
 Parse a comma separated list, increase data pointer on success. More...
 
struct conditionparse_condition (char **data)
 Parse a single condition (COL = VALUE), increase data pointer on success. More...
 
instrparse_instr (char *data)
 Parse an instruction. More...
 
instrparse_selinstr (char **data)
 Parse a SelInstr. More...
 
instrparse_crtinstr (char **data)
 Parse a CrtInstr. More...
 
instrparse_addinstr (char **data)
 Parse a AddInstr. More...
 
InstrArrayparse_user_input (char *data)
 Parse the user input. More...
 

Detailed Description

Main parsing file, transform a user input into instruction from instruction.h.

Author
Mateo

Enumeration Type Documentation

◆ keyword

enum keyword

The different keyword in the yacdb language, used for parsing.

Enumerator
where 

where (in SelInstr)

from 

from (in SelInstr)

in 

in (in AddInstr)

set 

Not implemented yet.

with 

with (in CrtInstr)

Function Documentation

◆ count_comma_list()

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 stat of the string given.

Parameters
dataPointer to current position in user input
Returns
int The number of element in the list

◆ parse_addinstr()

instr * parse_addinstr ( char **  data)

Parse a AddInstr.

Parameters
dataPointer to current position in user input
Returns
instr* The instruction parsed (casted in instr*)

◆ parse_comma()

int parse_comma ( char **  data)

Increase data pointer past a comma.

Parameters
dataPointer to current position in user input
Returns
1 on success, 0 on failure

◆ parse_comma_list()

int parse_comma_list ( char **  data,
charray res 
)

Parse a comma separated list, increase data pointer on success.

Parameters
dataPointer to current position in user input
resStores the result of the operation
Returns
1 on success, 0 on failure

◆ parse_condition()

struct condition * parse_condition ( char **  data)

Parse a single condition (COL = VALUE), increase data pointer on success.

Parameters
dataPointer to current position in user input
Returns
struct condition*

◆ parse_crtinstr()

instr * parse_crtinstr ( char **  data)

Parse a CrtInstr.

Parameters
dataPointer to current position in user input
Returns
instr* The instruction parsed (casted in instr*)

◆ parse_equalsign()

int parse_equalsign ( char **  data)

Increase data pointer past an equalsign.

Parameters
dataPointer to current position in user input
Returns
1 on success, 0 on failure

◆ parse_expected_keyword()

int parse_expected_keyword ( char **  data,
keyword  expected 
)

Parse the expected keyword, increase data pointer on success.

Parameters
dataPointer to current position in user input
expectedExpected keyword to be parsed
Returns
1 on success, 0 on failure

◆ parse_ident()

char * parse_ident ( char **  data)

Parse the identifier at the start of the data, increase data pointer on success.

Parameters
dataPointer to current position in user input
Returns
char* A pointer to the identifier parsed

◆ parse_instr()

instr * parse_instr ( char *  data)

Parse an instruction.

Parameters
dataUser input
Returns
instr* The instruction parsed (casted in instr*)

◆ parse_instrtype()

instrType parse_instrtype ( char **  data)

Parse the instrType at the start of the data, increase data pointer on success.

Parameters
dataPointer to current position in user input
Returns
instrType

◆ parse_selinstr()

instr * parse_selinstr ( char **  data)

Parse a SelInstr.

Parameters
dataPointer to current position in user input
Returns
instr* The instruction parsed (casted in instr*)

◆ parse_user_input()

InstrArray * parse_user_input ( char *  data)

Parse the user input.

User input should be a semicolon separated list of instruction

Parameters
dataUser input
Returns
InstrArray* The array of instruction parsed

◆ parse_value()

char * parse_value ( char **  data)

Parse a value, either an int or a "string", increase data pointer on success.

Parameters
dataPointer to current position in user input
Returns
char* A pointer to the value parsed