#include "libxml/parser.h"
#include "libxml/parserInternals.h"
#include "libparser.hh"
#include <cstdarg>
#include <ctype.h>
#include <cassert>
#include <vector>
#include <map>
#include <sstream>
#include "tags.cc"
Compounds | |
struct | compare_str |
Comparator structure for map<char*,char*> of locations mapping id -> name. More... | |
class | ParserState |
We need many additional things to save temporary into the parsing state. More... | |
Defines | |
#define | CHAR xmlChar |
SAX specific type for strings. | |
Typedefs | |
typedef map< char *, char *, compare_str > | locationmap_t |
The map of locations for quick lookup id -> name. | |
Enumerations | |
enum | tag_t { TAG_NTA, TAG_IMPORTS, TAG_DECLARATION, TAG_TEMPLATE, TAG_INSTANTIATION, TAG_SYSTEM, TAG_NAME, TAG_PARAMETER, TAG_LOCATION, TAG_INIT, TAG_TRANSITION, TAG_URGENT, TAG_COMMITTED, TAG_SOURCE, TAG_TARGET, TAG_LABEL, TAG_NAIL } |
Enumeration type for tags. More... | |
enum | state_t { ERR, UNKNOWN, INITIAL, NTA, IMPORTS, DECLARATION, TEMPLATE, INSTANTIATION, SYSTEM, NAME, PARAMETER, LOCATION, INIT, TRANSITION, LABEL, URGENT, COMMITTED, SOURCE, TARGET, NAIL } |
We enumerate all possible states of state machine that listens to SAX. More... | |
enum | labelkind_t { L_NONE, L_INV, L_GUARD, L_SYNC, L_ASSIGN } |
We enumerate all possible label kinds to get rid of strings and save the memory. More... | |
Functions | |
char * | append (char *dest, int32_t &dlen, const CHAR *source, int32_t slen) |
Returns the source appended to dest keeping track of allocated memory. | |
bool | isempty (const char *p) |
returns TRUE if string is NULL, zero length or contains only white spaces otherwise FALSE | |
bool | isAlpha (char c) |
bool | isIdChr (char c) |
char * | symbol (const char *str) |
Extracts the alpha-numerical symbol used for variable/type identifiers. | |
const char * | retrieve (const char **attrs, const char *name) |
Retrieves an attribute value from list of attributes given the name of attribute. | |
char * | mystrdup (const char *str) |
Copies the string into a newly allocated memory area. | |
void | NTA_startDocument (void *user_data) |
SAX calls before reading the document. | |
void | NTA_endDocument (void *user_data) |
Final checks just before parsing quits. | |
void | NTA_characters (void *user_data, const CHAR *ch, int32_t len) |
SAX passes tag content here, the content is broken by inner tags and XML entities. | |
bool | checkSiblings (ParserState *s, bool cond) |
void | NTA_startElement (void *user_data, const CHAR *n, const CHAR **attrs) |
SAX notifies when the tag start is found (e.g. | |
void | NTA_endElement (void *user_data, const CHAR *n) |
SAX notifies when it encounters the end of tag (e.g. | |
xmlEntityPtr | NTA_getEntity (void *user_data, const CHAR *name) |
SAX uses to interpret the XML entities (e.g. | |
void | NTA_warning (void *user_data, const char *msg,...) |
SAX passes its warnings here. | |
void | NTA_error (void *user_data, const char *msg,...) |
SAX passes its errors here. | |
void | NTA_fatalError (void *user_data, const char *msg,...) |
SAX passes its fatal errors here. | |
int32_t | parseXMLBuffer (const char *buffer, ParserBuilder *pb, ErrorHandler *errHandler, bool newxta) |
The actual parsing interface function. | |
int32_t | parseXMLFile (const char *filename, ParserBuilder *pb, ErrorHandler *errHandler, bool newxta) |
The actual parsing interface function. | |
Variables | |
char | errormsg [256] |
xmlSAXHandler | handler |
Function addresses passed to SAX. |
|
SAX specific type for strings. xmlChar is treated as char, as written in documentation. Please review the code when multibyte encodings are introduced! |
|
The map of locations for quick lookup id -> name.
|
|
We enumerate all possible label kinds to get rid of strings and save the memory.
|
|
We enumerate all possible states of state machine that listens to SAX.
|
|
Enumeration type for tags. We use gperf to generate a perfect hash function to map tag strings to one of these tags. |
|
Returns the source appended to dest keeping track of allocated memory. dest - the destination string, a new page will be allocated if NULL dlen - memory of bytes allocated for dest source - the source string, not necessary ended with '' slen - the byte number to be appended from source. returns the dest if there were enough memory, a new allocated string if not enough memory (the old is deleted!) |
|
|
|
|
|
returns TRUE if string is NULL, zero length or contains only white spaces otherwise FALSE
|
|
|
|
Copies the string into a newly allocated memory area. The new string is allocated with new[]. |
|
SAX passes tag content here, the content is broken by inner tags and XML entities.
|
|
Final checks just before parsing quits.
|
|
SAX notifies when it encounters the end of tag (e.g. input: => n="tag") |
|
SAX passes its errors here.
|
|
SAX passes its fatal errors here.
|
|
SAX uses to interpret the XML entities (e.g. input:< => "<") |
|
SAX calls before reading the document. Used to initialize state before actual parse. |
|
SAX notifies when the tag start is found (e.g. input: => n="tag") |
|
SAX passes its warnings here.
|
|
The actual parsing interface function.
|
|
The actual parsing interface function.
|
|
Retrieves an attribute value from list of attributes given the name of attribute. attrs - the list of strings terminated with NULL, even members are attribute names, odd members are attribute values. name - the name of attribute Returns NULL if attribute not found, or the value of the attribute (not a copy of the string!). |
|
Extracts the alpha-numerical symbol used for variable/type identifiers. Identifier starts with alpha and further might contain digits, white spaces are ignored. Throws a TypeException is identifier is invalid or a newly allocated string to be destroyed with delete []. |
|
|
|
Initial value: { NULL, NULL, NULL, NULL, NULL, NTA_getEntity, NULL, NULL, NULL, NULL, NULL, NULL, NTA_startDocument, NTA_endDocument, NTA_startElement, NTA_endElement, NULL, NTA_characters, NULL, NULL, NULL, NTA_warning, NTA_error, NTA_fatalError } SAX validates only the XML welformedness if all members a NULL. (NULL members are ignored). |