6#ifndef BC_INTERPRETER_H
7#define BC_INTERPRETER_H
9#include "../../include/cst_macros.h"
10#include "../../include/rdesc.h"
11#include "../../include/util.h"
12#include "../../src/common.h"
14#include "../grammar/bc.h"
38 char **decimal_part, **floating_part;
47 converted = strtod(*decimal_part, NULL);
54 converted = strtod(*floating_part, NULL) /
63 converted = strtod(*decimal_part, NULL) +
64 strtod(*floating_part, NULL) /
73 return (alt_idx == 0) ? -1 : 1;
120 unreachable();
return 0;
128 memcpy(&seminfo, seminfo_,
sizeof(
void *));
static double bc_interpreter(struct rdesc *p, struct rdesc_node *n)
Interprets CST of bc.
Definition bc_interpreter.h:33
static void bc_tk_destroyer(uint16_t tk, void *seminfo_)
Frees seminfo of a bc token.
Definition bc_interpreter.h:124
static double bc_pow10(int i)
Raises 10 to the power of i.
Definition bc_interpreter.h:22
#define rid(node)
Returns the 15-bit identifier for underlying token/nonterminal.
Definition cst_macros.h:77
#define rchild(p, nt_node, child_idx)
Returns child of the node by its index.
Definition cst_macros.h:115
#define ralt_idx(nt_node)
Returns index of the nonterminal alternative in production rule.
Definition cst_macros.h:84
#define rseminfo(tk_node)
Returns a reference to the token's seminfo field.
Definition cst_macros.h:99
#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
Recursive descent parser state.
Definition rdesc.h:42
void rdesc_flip_left(struct rdesc *parser, struct rdesc_node *parent, uint16_t child_index)
Rotates a right-recursive concrete syntax tree into a left-recursive form.