Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
parse.c File Reference
#include <ast/ast.h>
#include <ast/error.h>
#include <cgraph/agxbuf.h>
#include <cgraph/alloc.h>
#include <cgraph/gv_ctype.h>
#include <cgraph/unreachable.h>
#include <gvpr/parse.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.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)
 
static int eol (FILE *str)
 
static int readc (FILE *str, agxbuf *ostr)
 
static void unreadc (FILE *str, int c)
 
static int skipWS (FILE *str)
 
static void parseID (FILE *str, int c, char *buf, size_t bsize)
 
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 parse_blockaddBlock (parse_block *last, char *stmt, int line, size_t n_nstmts, case_info *nodelist, size_t n_estmts, case_info *edgelist)
 
static case_infoaddCase (case_info *last, char *guard, int gline, char *action, int line, size_t *cnt)
 
static void bindAction (case_t cs, char *action, int aline, char **ap, int *lp)
 
parse_progparseProg (char *input, int isFile)
 
static void freeCaseList (case_info *ip)
 
static void freeBlocks (parse_block *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 186 of file parse.c.

Function Documentation

◆ addBlock()

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

Definition at line 378 of file parse.c.

References gv_alloc(), and last.

Referenced by parseProg().

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

◆ addCase()

static case_info * addCase ( case_info last,
char *  guard,
int  gline,
char *  action,
int  line,
size_t *  cnt 
)
static

Definition at line 399 of file parse.c.

References error(), ERROR_WARNING, guard, gv_alloc(), kwLine, last, and NULL.

Referenced by parseProg().

Here is the call graph for this function:
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 427 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 48 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 260 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 232 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 56 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_block ip)
static

Definition at line 577 of file parse.c.

References _parse_block::begg_stmt, _parse_block::edge_stmts, free(), freeCaseList(), _parse_block::next, and _parse_block::node_stmts.

Referenced by freeParseProg().

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

◆ freeCaseList()

static void freeCaseList ( case_info ip)
static

Definition at line 564 of file parse.c.

References _case_info::action, free(), _case_info::guard, and _case_info::next.

Referenced by freeBlocks().

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 590 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 312 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 287 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 334 of file parse.c.

References agxbfree(), Begin, BeginG, End, EndG, Eof, Error, getErrorErrors(), guard, kind, 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 318 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 164 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 192 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 444 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, parse_prog::n_blocks, 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 74 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 149 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 141 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 34 of file parse.c.

Referenced by caseStr().

◆ col0

int col0 = 1
static

Definition at line 30 of file parse.c.

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

◆ kwLine

int kwLine = 1
static

Definition at line 32 of file parse.c.

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

◆ lineno

int lineno = 1
static

◆ startLine

int startLine = 1
static

Definition at line 31 of file parse.c.

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