librdesc
Loading...
Searching...
No Matches
Macros | Enumerations | Variables
pm_grammar.h File Reference
#include <rdesc/grammar.h>
Include dependency graph for pm_grammar.h:

Go to the source code of this file.

Macros

#define PM_PRODUCTION_COUNT   9
 [Grammar declaration]
 
#define PM_MAX_ALTERNATIVE_COUNT   2
 
#define PM_MAX_ALTERNATIVE_SIZE   4
 

Enumerations

enum  pm_tk {
  TK_NUM , TK_IDENT , TK_LPAREN , TK_RPAREN ,
  TK_PIPE , TK_CARET , TK_COMMA , TK_SEMI
}
 [Grammar declaration] More...
 
enum  pm_nt {
  NT_STMT , NT_EXPR , NT_EXPONENTIATION_EXPR , NT_EXPONENTIATION_EXPR_REST ,
  NT_PIPE_EXPR , NT_PIPE_EXPR_REST , NT_FUNCTION_ARG_LS , NT_FUNCTION_ARG_LS_REST ,
  NT_FUNCTION_CALL
}
 [Token definition] More...
 

Variables

struct rdesc_grammar_symbol pm_grammar [PM_PRODUCTION_COUNT][PM_MAX_ALTERNATIVE_COUNT+1][PM_MAX_ALTERNATIVE_SIZE+1]
 Pipe-Math grammar definition.
 

Macro Definition Documentation

◆ PM_MAX_ALTERNATIVE_COUNT

#define PM_MAX_ALTERNATIVE_COUNT   2

max alternative count

◆ PM_MAX_ALTERNATIVE_SIZE

#define PM_MAX_ALTERNATIVE_SIZE   4

max alternative size

◆ PM_PRODUCTION_COUNT

#define PM_PRODUCTION_COUNT   9

[Grammar declaration]

production count

Enumeration Type Documentation

◆ pm_nt

enum pm_nt

[Token definition]

[Nonterminal definition] nonterminal enum

◆ pm_tk

enum pm_tk

[Grammar declaration]

[Token definition] token enum

Variable Documentation

◆ pm_grammar

Pipe-Math grammar definition.

/* <stmt> ::= */ r(
NT(EXPR), TK(SEMI)
),
/* <expr> ::= */ r(
NT(EXPONENTIATION_EXPR), TK(PIPE), NT(PIPE_EXPR)
alt NT(EXPONENTIATION_EXPR)
)
,
/* <exponentiation_expr> ::= */
rrr(EXPONENTIATION_EXPR, (TK(NUM)), (TK(CARET), TK(NUM))),
/* this also expands to <exponentiation_expr_rest> */
/* <pipe_expr> ::= */
rrr(PIPE_EXPR, (NT(FUNCTION_CALL)), (TK(PIPE), NT(FUNCTION_CALL))),
/* similarly, this also expands to <pipe_expr_rest> */
/* <function_arg_ls> ::= */
rrr(FUNCTION_ARG_LS, (NT(EXPR)), (TK(COMMA), NT(EXPR)))
/* <function_arg_ls_rest> */
,
/* <function_call> ::= */ r(
TK(IDENT), TK(LPAREN), NT(FUNCTION_ARG_LS), TK(RPAREN)
alt TK(IDENT)
)
#define rrr(head, base, suffix)
Defines right-recursive list rules. base and suffix parameters should wrapped with parenthesis (()).
Definition rule_macros.h:121
#define NT(nt)
Macro to create a nonterminal production symbol.
Definition rule_macros.h:58
#define TK(tk)
Macro to create a terminal (token) production symbol.
Definition rule_macros.h:56
#define r(...)
Macro to define a grammar rule. Adds end of alternative and end of production body sentinels to gramm...
Definition rule_macros.h:72
#define alt
Separates grammar alternatives (alternative separator).
Definition rule_macros.h:133