58 while ((c = getc(
str)) !=
'\n') {
78 switch (c = getc(
str)) {
94 switch (c = getc(
str)) {
101 switch (cc = getc(
str)) {
164static void parseID(FILE *
str,
int c,
char *buf,
size_t bsize) {
166 char *eptr = buf + (bsize - 1);
202 "expected keyword BEGIN/END/N/E...; found '%c', line %d", c,
209 if (strcmp(buf,
"BEGIN") == 0) {
211 }
else if (strcmp(buf,
"BEG_G") == 0) {
213 }
else if (strcmp(buf,
"E") == 0) {
215 }
else if (strcmp(buf,
"END") == 0) {
217 }
else if (strcmp(buf,
"END_G") == 0) {
219 }
else if (strcmp(buf,
"N") == 0) {
236 while ((c = getc(
ins)) != ec) {
265 if (c < 0 || c == ec)
274 }
else if (c ==
'\'' || c ==
'"') {
302 "unclosed bracket %c%c expression, start line %d", bc, ec,
383 item->l_beging = line;
384 item->begg_stmt = stmt;
385 item->n_nstmts = n_nstmts;
386 item->n_estmts = n_estmts;
387 item->node_stmts = nodelist;
400 char *action,
int line,
size_t *
cnt) {
401 if (!
guard && !action) {
403 "Case with neither guard nor action, line %d - ignored",
kwLine);
410 item->action = action;
413 item->gstart = gline;
459 int line = 0, gline = 0;
472 str = fopen(input,
"r");
501 if (action && (begg_stmt || nodelist ||
edgelist)) {
502 blockl =
addBlock(blockl, begg_stmt, l_beging,
503 n_nstmts, nodelist, n_estmts,
edgelist);
509 n_nstmts = n_estmts = 0;
525 nodel =
addCase(nodel,
guard, gline, action, line, &n_nstmts);
530 edgel =
addCase(edgel,
guard, gline, action, line, &n_estmts);
542 if (begg_stmt || nodelist ||
edgelist) {
543 blockl =
addBlock(blockl, begg_stmt, l_beging,
544 n_nstmts, nodelist, n_estmts,
edgelist);
static agxbuf last
last message
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 * gv_alloc(size_t size)
static void ins(Dict_t *d, Dtlink_t **set, Agedge_t *e)
void error(int level, const char *s,...)
static int cnt(Dict_t *d, Dtlink_t **set)
replacements for ctype.h functions
static bool gv_isalpha(int c)
static bool gv_isspace(int c)
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 unreadc(FILE *str, int c)
static case_t parseKind(FILE *str)
static int readc(FILE *str, agxbuf *ostr)
static void freeCaseList(case_info *ip)
static void parseID(FILE *str, int c, char *buf, size_t bsize)
static parse_block * addBlock(parse_block *last, char *stmt, int line, size_t n_nstmts, case_info *nodelist, size_t n_estmts, case_info *edgelist)
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)
static void freeBlocks(parse_block *ip)
static char * caseStr(case_t cs)
static case_info * addCase(case_info *last, char *guard, int gline, char *action, int line, size_t *cnt)
static int endBracket(FILE *ins, agxbuf *outs, char bc, char ec)
parse_prog * parseProg(char *input, int isFile)
static void bindAction(case_t cs, char *action, int aline, char **ap, int *lp)
static int skipWS(FILE *str)
struct _parse_block * next