35 "BEGIN",
"END",
"BEG_G",
"END_G",
"N",
"E",
"EOF",
"ERROR",
44 while ((c = getc(
str)) !=
'\n') {
63 switch (c = getc(
str)) {
79 switch (c = getc(
str)) {
86 switch (cc = getc(
str)) {
141static void parseID(FILE *
str,
int c,
char *buf,
size_t bsize) {
143 char *eptr = buf + (bsize - 1);
176 error(
ERROR_ERROR,
"expected keyword BEGIN/END/N/E...; found '%c', line %d",
183 if (strcmp(buf,
"BEGIN") == 0) {
185 }
else if (strcmp(buf,
"BEG_G") == 0) {
187 }
else if (strcmp(buf,
"E") == 0) {
189 }
else if (strcmp(buf,
"END") == 0) {
191 }
else if (strcmp(buf,
"END_G") == 0) {
193 }
else if (strcmp(buf,
"N") == 0) {
209 while ((c = getc(
ins)) != ec) {
237 if (c < 0 || c == ec)
246 }
else if (c ==
'\'' || c ==
'"') {
339static void addBlock(parse_blocks_t *list,
char *stmt,
int line,
340 case_infos_t nodelist, case_infos_t
edgelist) {
343 item.l_beging = line;
344 item.begg_stmt = stmt;
345 item.node_stmts = nodelist;
352static void addCase(case_infos_t *list,
char *
guard,
int gline,
char *action,
354 if (!
guard && !action) {
356 "Case with neither guard nor action, line %d - ignored",
kwLine);
392 parse_blocks_t blocklist = {0};
395 int line = 0, gline = 0;
407 str = fopen(input,
"r");
488 for (
size_t i = 0; i <
LIST_SIZE(ip); ++i) {
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
type-generic dynamically expanding list
#define LIST_APPEND(list, item)
#define LIST_IS_EMPTY(list)
#define LIST_GET(list, index)
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 void free_case_info(case_info c)
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)