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;
48 converted = strtod(decimal_part, NULL);
56 converted = strtod(floating_part, NULL) /
67 converted = strtod(decimal_part, NULL) +
68 strtod(floating_part, NULL) /
77 return (alt_idx == 0) ? -1 : 1;
124 unreachable();
return 0;
132 memcpy(&seminfo, seminfo_,
sizeof(
void *));
static double bc_interpreter(struct rdesc *p, struct rdesc_node *n)
Interprets CST of bc.
static void bc_tk_destroyer(uint16_t tk, void *seminfo_)
Frees seminfo of a bc token.
static double bc_pow10(int i)
Raises 10 to the power of i.
#define rid(node)
Returns the 15-bit identifier for underlying token/nonterminal.
#define rchild(p, nt_node, child_idx)
Returns child of the node by its index.
#define ralt_idx(nt_node)
Returns index of the nonterminal alternative in production rule.
#define rseminfo(tk_node)
Returns a reference to the token's seminfo field.
#define r(...)
Macro to define a grammar rule. Adds end of alternative and end of production body sentinels to gramm...
Recursive descent parser state.
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.