Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
parse.c File Reference
#include <ast/ast.h>
#include <ast/error.h>
#include <gvpr/parse.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <util/agxbuf.h>
#include <util/alloc.h>
#include <util/gv_ctype.h>
#include <util/unreachable.h>
Include dependency graph for parse.c:

Go to the source code of this file.

Macros

#define BSIZE   8
 

Functions

static char * caseStr (case_t cs)
 convert case_t to string
 
static int eol (FILE *str)
 eat characters until eol
 
static int readc (FILE *str, agxbuf *ostr)
 
static void unreadc (FILE *str, int c)
 push character back onto stream; if newline, reduce lineno
 
static int skipWS (FILE *str)
 
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 case_t parseKind (FILE *str)
 
static int endString (FILE *ins, agxbuf *outs, char ec)
 
static int endBracket (FILE *ins, agxbuf *outs, char bc, char ec)
 
static char * parseBracket (FILE *str, agxbuf *buf, int bc, int ec)
 
static char * parseAction (FILE *str, agxbuf *buf)
 
static char * parseGuard (FILE *str, agxbuf *buf)
 
static case_t parseCase (FILE *str, char **guard, int *gline, char **action, int *aline)
 
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 addCase (case_infos_t *list, char *guard, int gline, char *action, int line)
 create new case_info and append to list
 
static void bindAction (case_t cs, char *action, int aline, char **ap, int *lp)
 
parse_progparseProg (char *input, int isFile)
 parses input into gpr sections
 
static void freeBlocks (parse_blocks_t *ip)
 
void freeParseProg (parse_prog *prog)
 

Variables

static int lineno = 1
 
static int col0 = 1
 
static int startLine = 1
 
static int kwLine = 1
 
static char * case_str []
 

Macro Definition Documentation

◆ BSIZE

#define BSIZE   8

Definition at line 161 of file parse.c.

Function Documentation

◆ addBlock()

static void addBlock ( parse_blocks_t *  list,
char *  stmt,
int  line,
case_infos_t  nodelist,
case_infos_t  edgelist 
)
static

Definition at line 338 of file parse.c.

Referenced by parseProg().

Here is the caller graph for this function:

◆ addCase()

static void addCase ( case_infos_t *  list,
char *  guard,
int  gline,
char *  action,
int  line 
)
static

Definition at line 351 of file parse.c.

References error, ERROR_WARNING, guard, and kwLine.

Referenced by parseProg().

Here is the caller graph for this function:

◆ bindAction()

static void bindAction ( case_t  cs,
char *  action,
int  aline,
char **  ap,
int *  lp 
)
static

Definition at line 368 of file parse.c.

References caseStr(), error, ERROR_ERROR, ERROR_WARNING, and kwLine.

Referenced by parseProg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ caseStr()

static char * caseStr ( case_t  cs)
static

Definition at line 38 of file parse.c.

References case_str.

Referenced by bindAction().

Here is the caller graph for this function:

◆ endBracket()

static int endBracket ( FILE *  ins,
agxbuf outs,
char  bc,
char  ec 
)
static

Definition at line 231 of file parse.c.

References agxbputc(), endBracket(), endString(), ins(), and readc().

Referenced by endBracket(), and parseBracket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endString()

static int endString ( FILE *  ins,
agxbuf outs,
char  ec 
)
static

Definition at line 204 of file parse.c.

References agxbputc(), error, ERROR_ERROR, ins(), and lineno.

Referenced by endBracket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eol()

static int eol ( FILE *  str)
static

Definition at line 41 of file parse.c.

References col0, lineno, and str.

Referenced by readc().

Here is the caller graph for this function:

◆ freeBlocks()

static void freeBlocks ( parse_blocks_t *  ip)
static

Definition at line 481 of file parse.c.

References parse_block::begg_stmt, parse_block::edge_stmts, free(), and parse_block::node_stmts.

Referenced by freeParseProg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeParseProg()

void freeParseProg ( parse_prog prog)

Definition at line 491 of file parse.c.

References parse_prog::begin_stmt, parse_prog::blocks, parse_prog::end_stmt, parse_prog::endg_stmt, free(), and freeBlocks().

Referenced by gvpr(), and parseProg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseAction()

static char * parseAction ( FILE *  str,
agxbuf buf 
)
static

Definition at line 279 of file parse.c.

References parseBracket(), and str.

Referenced by parseCase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseBracket()

static char * parseBracket ( FILE *  str,
agxbuf buf,
int  bc,
int  ec 
)
static

Definition at line 258 of file parse.c.

References agxbdisown(), endBracket(), error, ERROR_ERROR, getErrorErrors(), lineno, skipWS(), startLine, str, and unreadc().

Referenced by parseAction(), and parseGuard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseCase()

static case_t parseCase ( FILE *  str,
char **  guard,
int *  gline,
char **  action,
int *  aline 
)
static

Definition at line 298 of file parse.c.

References agxbfree(), Begin, BeginG, End, EndG, Eof, Error, getErrorErrors(), guard, parseAction(), parseGuard(), parseKind(), startLine, str, and UNREACHABLE.

Referenced by parseProg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseGuard()

static char * parseGuard ( FILE *  str,
agxbuf buf 
)
static

Definition at line 283 of file parse.c.

References parseBracket(), and str.

Referenced by parseCase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseID()

static void parseID ( FILE *  str,
int  c,
char *  buf,
size_t  bsize 
)
static

Definition at line 140 of file parse.c.

References gv_isalpha(), readc(), str, and unreadc().

Referenced by parseKind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseKind()

static case_t parseKind ( FILE *  str)
static

Definition at line 166 of file parse.c.

References Begin, BeginG, BSIZE, End, EndG, Eof, error, Error, ERROR_ERROR, gv_isalpha(), kwLine, lineno, parseID(), skipWS(), and str.

Referenced by parseCase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseProg()

parse_prog * parseProg ( char *  input,
int  isFile 
)

Definition at line 381 of file parse.c.

References addBlock(), addCase(), Begin, parse_prog::begin_stmt, BeginG, bindAction(), parse_prog::blocks, col0, End, parse_prog::end_stmt, EndG, parse_prog::endg_stmt, Eof, error, Error, ERROR_ERROR, free(), freeParseProg(), getErrorErrors(), guard, kwLine, parse_prog::l_begin, parse_prog::l_end, parse_prog::l_endg, lineno, NULL, parseCase(), parse_prog::source, startLine, str, and UNREACHABLE.

Referenced by gvpr_core().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readc()

static int readc ( FILE *  str,
agxbuf ostr 
)
static

Definition at line 58 of file parse.c.

References agxbputc(), col0, eol(), lineno, and str.

Referenced by endBracket(), parseID(), and skipWS().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipWS()

static int skipWS ( FILE *  str)
static

Definition at line 128 of file parse.c.

References gv_isspace(), readc(), and str.

Referenced by parseBracket(), and parseKind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unreadc()

static void unreadc ( FILE *  str,
int  c 
)
static

Definition at line 122 of file parse.c.

References lineno, and str.

Referenced by parseBracket(), and parseID().

Here is the caller graph for this function:

Variable Documentation

◆ case_str

char* case_str[]
static
Initial value:
= {
"BEGIN", "END", "BEG_G", "END_G", "N", "E", "EOF", "ERROR",
}

Definition at line 33 of file parse.c.

Referenced by caseStr().

◆ col0

int col0 = 1
static

Definition at line 29 of file parse.c.

Referenced by eol(), parseProg(), and readc().

◆ kwLine

int kwLine = 1
static

Definition at line 31 of file parse.c.

Referenced by addCase(), bindAction(), parseKind(), and parseProg().

◆ lineno

int lineno = 1
static

◆ startLine

int startLine = 1
static

Definition at line 30 of file parse.c.

Referenced by parseBracket(), parseCase(), and parseProg().