parsers.h
Go to the documentation of this file.
1 
9 #ifndef _PARSERS_H_
10 #define _PARSERS_H_
11 
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <limits.h>
16 
17 #include "../types/examples.h"
18 #include "../types/model.h"
19 #include "../types/string-type.h"
20 #include "../app/output.h"
21 
23 #define PARSED_EXAMPLE 1
24 
25 #define PARSED_COUNTEREXAMPLE 2
26 
30 struct StringVector {
32  Vector(char*) seen;
33 };
34 
42 char* getIncludeFile(char const* pathname, size_t * pos);
43 
52 Examples* loadExampleFile(char const* pathname, Model* model, size_t startPos);
53 
60 unsigned int getNextExample(FILE* f);
61 
71 int parseExample(FILE* fp, char** error, Example* ex, Model* m);
72 
83 int parseExampleObject(FILE* fp, char** error, Object* o, Model* m, struct StringVector* seenObjects);
84 
92 int getAttributePosition(const char* attr, Model* m);
93 
101 int getRelationPosition(const char* rel, Model* m);
102 
113 void parseAttrValue(FILE* fp, char** error, Model* m, attrType type, Attribute* attr, unsigned int position, struct StringVector* seenObjects);
114 
121 Model* loadConfigFile(char const* pathname);
122 
131 int parseConfigLine(FILE* fp, char** error, Model* out) ;
132 
140 char* parseAttrName(FILE* fp, char** error);
141 
149 ModelType* parseAttrType(FILE* fp, char** error);
150 
158 Interval* parseAttrTypeInterval(FILE* fp, char** error);
159 
167 Enum* parseAttrTypeEnum(FILE* fp, char** error);
168 
178 Tree* parseAttrTypeTree(FILE* fp, char** error, int* index, int indent);
179 
187 int isValidAttrChar(char c, unsigned int first);
188 
194 void readFileSpaces(FILE* fp, char const* set);
195 
201 void readTil(FILE* fp, char const* set);
202 
203 #endif // _PARSERS_H_
Structure that contains the type and the values of the attribute depending on type.
Definition: model-type.h:20
int parseExampleObject(FILE *fp, char **error, Object *o, Model *m, struct StringVector *seenObjects)
Parse an object (only its properties. The name must already be known)
Definition: parsers.c:264
All the objects composing an example (or a counter-example)
Definition: example.h:22
Interval * parseAttrTypeInterval(FILE *fp, char **error)
Tries to parse an interval.
Definition: parsers.c:612
int getRelationPosition(const char *rel, Model *m)
Returns the position at which can be found a relation (by name)
Definition: parsers.c:336
unsigned char attrType
Stores the type of the attribute.
Definition: attribute-types.h:17
unsigned int getNextExample(FILE *f)
Get the type of the next example (example or counter-example). Stop reading at the end of the example...
Definition: parsers.c:133
Enum * parseAttrTypeEnum(FILE *fp, char **error)
Tries to parse an enumeration.
Definition: parsers.c:697
Represents an attribute and the value it holds.
Definition: attribute.h:21
void readFileSpaces(FILE *fp, char const *set)
Reads a file from the current position and reads while characters are in the set. Stops on the last o...
Definition: parsers.c:824
char * getIncludeFile(char const *pathname, size_t *pos)
Get the pathname to the config file included at the begening of an example file.
Definition: parsers.c:10
int isValidAttrChar(char c, unsigned int first)
Check whether the character is allowed in an attribute name or not.
Definition: parsers.c:816
Vector(char *) seen
An array of strings.
int parseExample(FILE *fp, char **error, Example *ex, Model *m)
Parse an example or a counterexample.
Definition: parsers.c:161
Structure that contains the examples and counter-examples of the parsed example file.
Definition: examples.h:20
int parseConfigLine(FILE *fp, char **error, Model *out)
Tries to parse the line as a config file attribute definition. If the line is empty, continues to read until it finds a line.
Definition: parsers.c:449
Structure that defines the enumeration type.
Definition: enum.h:30
int getAttributePosition(const char *attr, Model *m)
Returns the position at which can be found an attribute (by name)
Definition: parsers.c:326
Contains the attributes and relations definitions found in the model file.
Definition: model.h:20
Examples * loadExampleFile(char const *pathname, Model *model, size_t startPos)
Loads the example file given and generate the Example object that represents its content.
Definition: parsers.c:71
Stores an array of C string.
Definition: parsers.h:30
void readTil(FILE *fp, char const *set)
Reads a file from the current position and reads until it finds a character in the set...
Definition: parsers.c:844
Model * loadConfigFile(char const *pathname)
Loads the config file given anf the generate the Model object that represents its content...
Definition: parsers.c:422
Contains all the attributes and relations that compose an Object.
Definition: object.h:18
Defines the n-ary tree.
Definition: tree.h:25
Tree * parseAttrTypeTree(FILE *fp, char **error, int *index, int indent)
Tries to parse a tree.
Definition: parsers.c:737
ModelType * parseAttrType(FILE *fp, char **error)
Tries to parse the attribute&#39;s value definition at the current position in the file (may read more th...
Definition: parsers.c:544
Structure that contains a signed integer interval.
Definition: interval.h:17
char * parseAttrName(FILE *fp, char **error)
Tries to parse the attribute name at the current position in the file (spaces & tabs are ommited) ...
Definition: parsers.c:516
void parseAttrValue(FILE *fp, char **error, Model *m, attrType type, Attribute *attr, unsigned int position, struct StringVector *seenObjects)
Parse the attribute&#39;s value and populate the Attribute object accordingly.
Definition: parsers.c:346