34 "BEGIN",
"END",
"BEG_G",
"END_G",
"N",
"E",
"EOF",
"ERROR",
43 while ((c = getc(
str)) !=
'\n') {
62 switch (c = getc(
str)) {
78 switch (c = getc(
str)) {
85 switch (cc = getc(
str)) {
140static void parseID(FILE *
str,
int c,
char *buf,
size_t bsize) {
142 char *eptr = buf + (bsize - 1);
175 error(
ERROR_ERROR,
"expected keyword BEGIN/END/N/E...; found '%c', line %d",
182 if (strcmp(buf,
"BEGIN") == 0) {
184 }
else if (strcmp(buf,
"BEG_G") == 0) {
186 }
else if (strcmp(buf,
"E") == 0) {
188 }
else if (strcmp(buf,
"END") == 0) {
190 }
else if (strcmp(buf,
"END_G") == 0) {
192 }
else if (strcmp(buf,
"N") == 0) {
208 while ((c = getc(
ins)) != ec) {
236 if (c < 0 || c == ec)
245 }
else if (c ==
'\'' || c ==
'"') {
338static void addBlock(parse_blocks_t *list,
char *stmt,
int line,
339 case_infos_t nodelist, case_infos_t
edgelist) {
342 item.l_beging = line;
343 item.begg_stmt = stmt;
344 item.node_stmts = nodelist;
347 parse_blocks_append(list,
item);
351static void addCase(case_infos_t *list,
char *
guard,
int gline,
char *action,
353 if (!
guard && !action) {
355 "Case with neither guard nor action, line %d - ignored",
kwLine);
365 case_infos_append(list,
item);
386 parse_blocks_t blocklist = {0};
388 case_infos_t nodelist = {0};
389 int line = 0, gline = 0;
401 str = fopen(input,
"r");
430 if (action && (begg_stmt || !case_infos_is_empty(&nodelist) ||
436 nodelist = (case_infos_t){0};
464 if (begg_stmt || !case_infos_is_empty(&nodelist) ||
482 for (
size_t i = 0; i < parse_blocks_size(ip); ++i) {
488 parse_blocks_free(ip);
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbputc(agxbuf *xb, char c)
add character to buffer
static char * agxbdisown(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void ins(Dict_t *d, Dtlink_t **set, Agedge_t *e)
replacements for ctype.h functions
static bool gv_isalpha(int c)
static bool gv_isspace(int c)
textitem scanner parser str
static char * parseGuard(FILE *str, agxbuf *buf)
void freeParseProg(parse_prog *prog)
static char * parseBracket(FILE *str, agxbuf *buf, int bc, int ec)
static void addBlock(parse_blocks_t *list, char *stmt, int line, case_infos_t nodelist, case_infos_t edgelist)
create new block and append to list; return new item as tail
static void unreadc(FILE *str, int c)
push character back onto stream; if newline, reduce lineno
static case_t parseKind(FILE *str)
static int readc(FILE *str, agxbuf *ostr)
static void parseID(FILE *str, int c, char *buf, size_t bsize)
Put initial alpha in buffer; add additional alphas, up to buffer size.
static int endString(FILE *ins, agxbuf *outs, char ec)
static char * parseAction(FILE *str, agxbuf *buf)
static case_t parseCase(FILE *str, char **guard, int *gline, char **action, int *aline)
static int eol(FILE *str)
eat characters until eol
static void addCase(case_infos_t *list, char *guard, int gline, char *action, int line)
create new case_info and append to list
static void freeBlocks(parse_blocks_t *ip)
static char * caseStr(case_t cs)
convert case_t to string
static int endBracket(FILE *ins, agxbuf *outs, char bc, char ec)
parse_prog * parseProg(char *input, int isFile)
parses input into gpr sections
static void bindAction(case_t cs, char *action, int aline, char **ap, int *lp)
static int skipWS(FILE *str)