3#include <rdesc/grammar.h>
4#include <rdesc/rule_macros.h>
13 [PM_MAX_ALTERNATIVE_COUNT + 1]
14 [PM_MAX_ALTERNATIVE_SIZE + 1] = {
20 NT(EXPONENTIATION_EXPR),
TK(PIPE),
NT(PIPE_EXPR)
21alt NT(EXPONENTIATION_EXPR)
27 rrr(EXPONENTIATION_EXPR, (
TK(NUM)), (
TK(CARET),
TK(NUM))),
31 rrr(PIPE_EXPR, (
NT(FUNCTION_CALL)), (
TK(PIPE),
NT(FUNCTION_CALL))),
35 rrr(FUNCTION_ARG_LS, (
NT(EXPR)), (
TK(COMMA),
NT(EXPR)))
41 TK(IDENT),
TK(LPAREN),
NT(FUNCTION_ARG_LS),
TK(RPAREN)
49const char *tk_names[] = {
53 "(",
")",
"|",
"^",
",",
";",
57const char *nt_names[] = {
60 "exponentiation_expr",
"exponentiation_expr_rest",
61 "pipe_expr",
"pipe_expr_rest",
63 "function_arg_ls",
"function_arg_ls_rest",
70const char exblex_tks[] = {
73 '(',
')',
'|',
'^',
',',
';',
80void tk_destroyer(uint16_t
id,
void *seminfo)
82 if (
id == TK_NUM ||
id == TK_IDENT) {
88 memcpy(&
string, seminfo,
sizeof(
char *));
97#include <rdesc/cst_macros.h>
99void node_printer(FILE *out,
const struct rdesc_node *node)
102 if (
rid(node) == TK_NUM ||
rid(node) == TK_IDENT) {
105 memcpy(&
string,
rseminfo(node),
sizeof(
char *));
107 fprintf(out,
"[shape=box,label=<%s>]",
string);
109 fprintf(out,
"[shape=box,label=<%s>]", tk_names[
rid(node)]);
112 fprintf(out,
"[label=\"%s\"]", nt_names[
rid(node)]);
#define rid(node)
Returns the 15-bit identifier for underlying token/nonterminal.
#define rtype(node)
Returns node type (RDESC_TOKEN or RDESC_NONTERMINAL).
#define rseminfo(tk_node)
Returns a reference to the token's seminfo field.
#define rrr(head, base, suffix)
Defines right-recursive list rules. base and suffix parameters should wrapped with parenthesis (()).
#define NT(nt)
Macro to create a nonterminal production symbol.
#define TK(tk)
Macro to create a terminal (token) production symbol.
#define r(...)
Macro to define a grammar rule. Adds end of alternative and end of production body sentinels to gramm...
#define alt
Separates grammar alternatives (alternative separator).
A terminal or nonterminal representing the body (right side) of a production rule.