mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-02-09 20:30:42 +00:00
small change so associativity of powerof operator can be made configurable later on
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@189 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
d407faab1c
commit
64a4b336b0
@ -103,8 +103,7 @@ enum op_id {
|
||||
OPID_ATINDEX, // v[w]
|
||||
};
|
||||
struct op {
|
||||
#define IS_RIGHT_ASSOCIATIVE(prio) ((prio) & 1)
|
||||
int priority; // lsb holds "is_right_associative" info!
|
||||
int priority;
|
||||
enum op_group group;
|
||||
enum op_id id;
|
||||
const char *text_version;
|
||||
@ -144,7 +143,8 @@ static struct op ops_intdiv = {34, OPGROUP_DYADIC, OPID_INTDIV, "integer divisi
|
||||
static struct op ops_modulo = {34, OPGROUP_DYADIC, OPID_MODULO, "modulo" };
|
||||
// highest "real" priorities
|
||||
static struct op ops_negate = {36, OPGROUP_MONADIC, OPID_NEGATE, "negation" };
|
||||
static struct op ops_powerof = {37, OPGROUP_DYADIC, OPID_POWEROF, "power of" }; // right-associative!
|
||||
#define PRIO_POWEROF 37 // the single right-associative operator, so this gets checked explicitly
|
||||
static struct op ops_powerof = {PRIO_POWEROF, OPGROUP_DYADIC, OPID_POWEROF, "power of" };
|
||||
static struct op ops_not = {38, OPGROUP_MONADIC, OPID_NOT, "logical not" };
|
||||
static struct op ops_atindex = {40, OPGROUP_DYADIC, OPID_ATINDEX, "indexing" };
|
||||
// function calls act as if they were monadic operators.
|
||||
@ -1888,7 +1888,8 @@ static void try_to_reduce_stacks(struct expression *expression)
|
||||
|
||||
// previous operator has same priority as current one? then check associativity
|
||||
if ((previous_op->priority == current_op->priority)
|
||||
&& IS_RIGHT_ASSOCIATIVE(current_op->priority)) {
|
||||
&& (current_op->priority == PRIO_POWEROF)
|
||||
&& (config.right_associative_powerof)) {
|
||||
alu_state = STATE_EXPECT_ARG_OR_MONADIC_OP;
|
||||
return;
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ void config_default(struct config *conf)
|
||||
conf->format_msvc = FALSE; // enabled by --msvc
|
||||
conf->format_color = FALSE; // enabled by --color
|
||||
conf->msg_stream = stderr; // set to stdout by --use-stdout
|
||||
conf->right_associative_powerof = TRUE; // TODO - add switch to disable
|
||||
conf->honor_leading_zeroes = TRUE; // disabled by --ignore-zeroes
|
||||
conf->segment_warning_is_error = FALSE; // enabled by --strict-segments TODO - toggle default?
|
||||
conf->test_new_features = FALSE; // enabled by --test
|
||||
|
@ -72,6 +72,7 @@ struct config {
|
||||
boolean format_msvc; // enabled by --msvc
|
||||
boolean format_color; // enabled by --color
|
||||
FILE *msg_stream; // defaults to stderr, changed to stdout by --use-stdout
|
||||
boolean right_associative_powerof; // TRUE (TODO - add switch to disable)
|
||||
boolean honor_leading_zeroes; // TRUE, disabled by --ignore-zeroes
|
||||
boolean segment_warning_is_error; // FALSE, enabled by --strict-segments
|
||||
boolean test_new_features; // FALSE, enabled by --test
|
||||
|
Loading…
x
Reference in New Issue
Block a user