diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp
index db5862f1c1..6306f7afc3 100644
--- a/src/App/Expression.cpp
+++ b/src/App/Expression.cpp
@@ -52,6 +52,7 @@
#include
#include
#include
+#include
#include "ExpressionParser.h"
@@ -168,6 +169,15 @@ static inline T &&cast(App::any &&value) {
#endif
}
+namespace
+{
+
+inline bool asBool(double value) {
+ return std::fabs(value) >= Base::Precision::Confusion();
+}
+
+}
+
std::string unquote(const std::string & input)
{
assert(input.size() >= 4);
@@ -1745,6 +1755,7 @@ FunctionExpression::FunctionExpression(const DocumentObject *_owner, Function _f
case TANH:
case TRUNC:
case VNORMALIZE:
+ case NOT:
if (args.size() != 1)
ARGUMENT_THROW("exactly one required.");
break;
@@ -1810,6 +1821,8 @@ FunctionExpression::FunctionExpression(const DocumentObject *_owner, Function _f
case MIN:
case STDDEV:
case SUM:
+ case AND:
+ case OR:
if (args.empty())
ARGUMENT_THROW("at least one required.");
break;
@@ -1973,6 +1986,36 @@ public:
}
};
+class AndCollector : public Collector {
+public:
+ void collect(Quantity value) override
+ {
+ if (first) {
+ q = Quantity(asBool(value.getValue()) ? 1 : 0);
+ first = false;
+ return;
+ }
+ if (!asBool(value.getValue())) {
+ q = Quantity(0);
+ }
+ }
+};
+
+class OrCollector : public Collector {
+public:
+ void collect(Quantity value) override
+ {
+ if (first) {
+ q = Quantity(asBool(value.getValue()) ? 1 : 0);
+ first = false;
+ return;
+ }
+ if (asBool(value.getValue())) {
+ q = Quantity(1);
+ }
+ }
+};
+
Py::Object FunctionExpression::evalAggregate(
const Expression *owner, int f, const std::vector &args)
{
@@ -1997,6 +2040,12 @@ Py::Object FunctionExpression::evalAggregate(
case MAX:
c = std::make_unique();
break;
+ case AND:
+ c = std::make_unique();
+ break;
+ case OR:
+ c = std::make_unique();
+ break;
default:
assert(false);
}
@@ -2499,6 +2548,9 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
if (v1.isDimensionlessOrUnit(Unit::Length) && v2.isDimensionlessOrUnit(Unit::Length) && v3.isDimensionlessOrUnit(Unit::Length))
break;
_EXPR_THROW("Translation units must be a length or dimensionless.", expr);
+ case NOT:
+ unit = Unit();
+ break;
default:
_EXPR_THROW("Unknown function: " << f,0);
}
@@ -2590,6 +2642,9 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
value)));
case TRANSLATIONM:
return translationMatrix(v1.getValue(), v2.getValue(), v3.getValue());
+ case NOT:
+ output = asBool(value) ? 0 : 1;
+ break;
default:
_EXPR_THROW("Unknown function: " << f,0);
}
@@ -2773,6 +2828,12 @@ void FunctionExpression::_toString(std::ostream &ss, bool persistent,int) const
ss << "stddev("; break;;
case SUM:
ss << "sum("; break;;
+ case AND:
+ ss << "and("; break;;
+ case OR:
+ ss << "or("; break;;
+ case NOT:
+ ss << "not("; break;;
default:
ss << fname << "("; break;;
}
@@ -3662,6 +3723,8 @@ static void initParser(const App::DocumentObject *owner)
registered_functions["hiddenref"] = FunctionExpression::HIDDENREF;
registered_functions["href"] = FunctionExpression::HREF;
+ registered_functions["not"] = FunctionExpression::NOT;
+
// Aggregates
registered_functions["average"] = FunctionExpression::AVERAGE;
registered_functions["count"] = FunctionExpression::COUNT;
@@ -3669,6 +3732,8 @@ static void initParser(const App::DocumentObject *owner)
registered_functions["min"] = FunctionExpression::MIN;
registered_functions["stddev"] = FunctionExpression::STDDEV;
registered_functions["sum"] = FunctionExpression::SUM;
+ registered_functions["and"] = FunctionExpression::AND;
+ registered_functions["or"] = FunctionExpression::OR;
has_registered_functions = true;
}
diff --git a/src/App/Expression.lex.c b/src/App/Expression.lex.c
index c01442d52b..9672886e89 100644
--- a/src/App/Expression.lex.c
+++ b/src/App/Expression.lex.c
@@ -294,7 +294,7 @@
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
+ * if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
@@ -311,7 +311,7 @@ typedef uint32_t flex_uint32_t;
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
+typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
@@ -422,10 +422,10 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
-
+
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
-
+
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
@@ -8669,7 +8669,7 @@ extern int yywrap ( void );
#endif
#ifndef YY_NO_UNPUT
-
+
#endif
#ifndef yytext_ptr
@@ -8796,7 +8796,7 @@ YY_DECL
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
-
+
if ( !(yy_init) )
{
(yy_init) = 1;
@@ -9936,7 +9936,7 @@ static int yy_get_next_buffer (void)
{
yy_state_type yy_current_state;
char *yy_cp;
-
+
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
@@ -9967,7 +9967,7 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
int yy_is_jam;
- char *yy_cp = (yy_c_buf_p);
+ char *yy_cp = (yy_c_buf_p);
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
@@ -10000,7 +10000,7 @@ static int yy_get_next_buffer (void)
{
int c;
-
+
*(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
@@ -10067,12 +10067,12 @@ static int yy_get_next_buffer (void)
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
- *
+ *
* @note This function does not reset the start condition to @c INITIAL .
*/
void yyrestart (FILE * input_file )
{
-
+
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
@@ -10085,11 +10085,11 @@ static int yy_get_next_buffer (void)
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
- *
+ *
*/
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
-
+
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
@@ -10120,7 +10120,7 @@ static int yy_get_next_buffer (void)
static void yy_load_buffer_state (void)
{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
(yy_hold_char) = *(yy_c_buf_p);
@@ -10129,13 +10129,13 @@ static void yy_load_buffer_state (void)
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
+ *
* @return the allocated buffer state.
*/
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
-
+
b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -10158,11 +10158,11 @@ static void yy_load_buffer_state (void)
/** Destroy the buffer.
* @param b a buffer created with yy_create_buffer()
- *
+ *
*/
void yy_delete_buffer (YY_BUFFER_STATE b )
{
-
+
if ( ! b )
return;
@@ -10183,7 +10183,7 @@ static void yy_load_buffer_state (void)
{
int oerrno = errno;
-
+
yy_flush_buffer( b );
b->yy_input_file = file;
@@ -10199,17 +10199,17 @@ static void yy_load_buffer_state (void)
}
b->yy_is_interactive = 0;
-
+
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
+ *
*/
void yy_flush_buffer (YY_BUFFER_STATE b )
{
- if ( ! b )
+ if ( ! b )
return;
b->yy_n_chars = 0;
@@ -10234,11 +10234,11 @@ static void yy_load_buffer_state (void)
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
- *
+ *
*/
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
{
- if (new_buffer == NULL)
+ if (new_buffer == NULL)
return;
yyensure_buffer_stack();
@@ -10264,11 +10264,11 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
- *
+ *
*/
void yypop_buffer_state (void)
{
- if (!YY_CURRENT_BUFFER)
+ if (!YY_CURRENT_BUFFER)
return;
yy_delete_buffer(YY_CURRENT_BUFFER );
@@ -10288,7 +10288,7 @@ void yypop_buffer_state (void)
static void yyensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
-
+
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
@@ -10331,13 +10331,13 @@ static void yyensure_buffer_stack (void)
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
- *
+ *
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
-
+
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
@@ -10366,14 +10366,14 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
- *
+ *
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (const char * yystr )
{
-
+
return yy_scan_bytes( yystr, (int) strlen(yystr) );
}
@@ -10381,7 +10381,7 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr )
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
+ *
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
@@ -10390,7 +10390,7 @@ YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
char *buf;
yy_size_t n;
int i;
-
+
/* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2);
buf = (char *) yyalloc( n );
@@ -10444,16 +10444,16 @@ static void yynoreturn yy_fatal_error (const char* msg )
/* Accessor methods (get/set functions) to struct members. */
/** Get the current line number.
- *
+ *
*/
int yyget_lineno (void)
{
-
+
return yylineno;
}
/** Get the input stream.
- *
+ *
*/
FILE *yyget_in (void)
{
@@ -10461,7 +10461,7 @@ FILE *yyget_in (void)
}
/** Get the output stream.
- *
+ *
*/
FILE *yyget_out (void)
{
@@ -10469,7 +10469,7 @@ FILE *yyget_out (void)
}
/** Get the length of the current token.
- *
+ *
*/
int yyget_leng (void)
{
@@ -10477,7 +10477,7 @@ int yyget_leng (void)
}
/** Get the current token.
- *
+ *
*/
char *yyget_text (void)
@@ -10487,18 +10487,18 @@ char *yyget_text (void)
/** Set the current line number.
* @param _line_number line number
- *
+ *
*/
void yyset_lineno (int _line_number )
{
-
+
yylineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param _in_str A readable stream.
- *
+ *
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * _in_str )
@@ -10552,7 +10552,7 @@ static int yy_init_globals (void)
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (void)
{
-
+
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer( YY_CURRENT_BUFFER );
@@ -10578,7 +10578,7 @@ int yylex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, const char * s2, int n )
{
-
+
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
@@ -10603,7 +10603,7 @@ void *yyalloc (yy_size_t size )
void *yyrealloc (void * ptr, yy_size_t size )
{
-
+
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
diff --git a/src/App/Expression.tab.c b/src/App/Expression.tab.c
index d25df1e97b..20d6188fc1 100644
--- a/src/App/Expression.tab.c
+++ b/src/App/Expression.tab.c
@@ -491,18 +491,18 @@ union yyalloc
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 42
+#define YYFINAL 43
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 425
+#define YYLAST 409
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 42
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 19
/* YYNRULES -- Number of rules. */
-#define YYNRULES 77
+#define YYNRULES 80
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 143
+#define YYNSTATES 146
/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK 281
@@ -557,11 +557,12 @@ static const yytype_uint8 yyrline[] =
0, 81, 81, 82, 85, 86, 89, 90, 91, 92,
93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
103, 104, 105, 108, 109, 110, 111, 113, 114, 115,
- 116, 117, 118, 121, 124, 125, 126, 127, 128, 129,
- 130, 133, 134, 136, 137, 138, 139, 140, 141, 142,
- 145, 146, 150, 151, 155, 156, 160, 165, 170, 176,
- 183, 190, 197, 201, 202, 203, 204, 205, 206, 207,
- 208, 212, 213, 214, 218, 219, 223, 224
+ 116, 117, 118, 119, 120, 121, 124, 127, 128, 129,
+ 130, 131, 132, 133, 136, 137, 139, 140, 141, 142,
+ 143, 144, 145, 148, 149, 153, 154, 158, 159, 163,
+ 168, 173, 179, 186, 193, 200, 204, 205, 206, 207,
+ 208, 209, 210, 211, 215, 216, 217, 221, 222, 226,
+ 227
};
#endif
@@ -595,12 +596,12 @@ yysymbol_name (yysymbol_kind_t yysymbol)
}
#endif
-#define YYPACT_NINF (-18)
+#define YYPACT_NINF (-34)
#define yypact_value_is_default(Yyn) \
((Yyn) == YYPACT_NINF)
-#define YYTABLE_NINF (-78)
+#define YYTABLE_NINF (-81)
#define yytable_value_is_error(Yyn) \
0
@@ -609,21 +610,21 @@ yysymbol_name (yysymbol_kind_t yysymbol)
STATE-NUM. */
static const yytype_int16 yypact[] =
{
- 103, 206, -18, -18, 9, -18, -18, -18, -18, -18,
- 1, 206, 206, 103, 10, 57, -18, 395, 7, 29,
- -18, -18, 38, 54, 60, 64, 34, 66, 88, 206,
- 395, -7, -18, -16, -18, -18, 354, 82, 23, -18,
- 91, -18, -18, 206, 206, 206, 206, 206, 206, 206,
- 206, 206, 103, 206, 206, 7, 84, 100, 206, 7,
- 7, 8, 160, -18, 126, 127, -18, 25, 40, -18,
- 206, 206, 26, -18, -18, -18, 26, 395, 395, 395,
- 395, 395, 395, 97, 97, 104, 104, 100, 104, -18,
- 129, 376, 100, 100, -18, -18, 51, -18, 183, 221,
- -18, -18, -18, -18, 101, 102, -18, 395, -18, 395,
- -18, -18, -18, -18, 206, -18, 206, 240, 0, -18,
- 41, 26, 71, 278, 206, -18, 206, -18, 259, 105,
- -18, -18, -18, 297, 316, 206, -18, 26, -18, -18,
- 335, -18, -18
+ 106, 209, -34, -34, -33, -34, -34, -34, -34, -34,
+ 0, 209, 209, 106, 30, 28, -34, 379, -3, -16,
+ -34, -34, 129, 35, -5, 37, -13, 27, 55, 209,
+ 379, 70, -34, -16, -21, -34, -34, 357, 17, 131,
+ -34, 56, -34, -34, 209, 209, 209, 209, 209, 209,
+ 209, 209, 209, 106, 209, 209, -3, 174, 26, 209,
+ -3, -3, 3, 163, -34, 63, 89, -34, 31, 46,
+ -34, 209, 209, 15, -34, -34, -34, 15, 379, 379,
+ 379, 379, 379, 379, 100, 100, 71, 71, 26, 71,
+ -34, 110, 121, 26, 26, -34, -34, 50, -34, 186,
+ 224, -34, -34, -34, -34, 81, 82, -34, 379, -34,
+ -16, 379, -34, -16, -34, -34, -34, 209, -34, 209,
+ 243, 5, -34, 47, 15, 72, 281, 209, -34, 209,
+ -34, 262, 83, -34, -34, -34, 300, 319, 209, -34,
+ 15, -34, -34, 338, -34, -34
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -631,35 +632,35 @@ static const yytype_int16 yypact[] =
means the default is an error. */
static const yytype_int8 yydefact[] =
{
- 0, 0, 23, 24, 52, 42, 41, 25, 26, 53,
+ 0, 0, 23, 24, 55, 45, 44, 25, 26, 56,
8, 0, 0, 0, 0, 0, 7, 2, 6, 0,
- 44, 43, 3, 54, 9, 55, 19, 0, 0, 0,
- 27, 0, 28, 54, 10, 11, 0, 0, 0, 52,
- 0, 57, 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 44, 4, 0, 0,
- 0, 0, 0, 71, 0, 0, 72, 0, 0, 20,
- 0, 0, 0, 22, 40, 49, 0, 34, 35, 36,
- 37, 38, 39, 13, 12, 14, 15, 17, 16, 18,
- 0, 0, 46, 45, 51, 50, 0, 47, 0, 0,
- 62, 73, 76, 77, 0, 0, 59, 29, 31, 30,
- 32, 33, 56, 5, 0, 48, 0, 0, 0, 63,
- 0, 0, 21, 0, 0, 65, 0, 64, 0, 0,
- 60, 58, 66, 0, 0, 0, 67, 0, 69, 68,
- 0, 61, 70
+ 47, 46, 3, 57, 9, 58, 19, 0, 0, 0,
+ 27, 0, 28, 29, 57, 10, 11, 0, 0, 0,
+ 55, 0, 60, 1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 47, 4, 0,
+ 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
+ 20, 0, 0, 0, 22, 43, 52, 0, 37, 38,
+ 39, 40, 41, 42, 13, 12, 14, 15, 17, 16,
+ 18, 0, 0, 49, 48, 54, 53, 0, 50, 0,
+ 0, 65, 76, 79, 80, 0, 0, 62, 30, 32,
+ 34, 31, 33, 35, 36, 59, 5, 0, 51, 0,
+ 0, 0, 66, 0, 0, 21, 0, 0, 68, 0,
+ 67, 0, 0, 63, 61, 69, 0, 0, 0, 70,
+ 0, 72, 71, 0, 64, 73
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -18, -18, -18, 33, 79, -18, 47, -6, -17, -18,
- 2, 46, -1, -18, -18, 118, -18, -18, 78
+ -34, -34, -34, 33, 51, -34, -11, 18, -17, -34,
+ 2, 32, -1, -34, -34, 116, -34, -34, 75
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- 0, 15, 16, 36, 18, 31, 32, 19, 20, 21,
- 38, 97, 23, 24, 25, 63, 26, 27, 28
+ 0, 15, 16, 37, 18, 31, 32, 19, 20, 21,
+ 39, 98, 23, 24, 25, 64, 26, 27, 28
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -667,96 +668,92 @@ static const yytype_int8 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
- 33, 56, 22, 1, 2, 3, 4, 37, 72, 7,
- 8, 9, 94, 41, 5, 6, 39, 95, 10, 11,
- 57, 9, -77, 37, 126, 12, 69, 96, 40, 70,
- 71, 39, 39, 17, 30, 29, 9, 9, 14, -76,
- -74, 127, 55, 102, 34, 35, 39, 39, -75, 59,
- 60, 9, 9, 61, 87, 94, 75, 42, 105, 129,
- 95, 92, 93, 58, 59, 60, 103, 106, 61, 33,
- 33, 111, 65, 113, 62, 112, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 88, 89, 2, 3,
- 49, 91, -77, 7, 8, 99, 50, 51, 52, 53,
- 62, 54, 64, 107, 109, 67, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 74, 58, 108, 110, 130,
- 131, 10, 11, 51, 52, 53, 68, 54, 12, 76,
- 61, 117, 100, 101, 54, 90, 141, 6, 13, 120,
- 121, 14, 115, 137, 66, 104, 0, 122, 0, 123,
- 0, 128, 0, 0, 0, 0, 0, 133, 0, 134,
- 0, 0, 0, 1, 2, 3, 4, 0, 140, 7,
- 8, 9, 0, 0, 0, 0, 0, 0, 10, 11,
- 0, 0, 0, 0, 98, 12, 1, 2, 3, 4,
- 0, 0, 7, 8, 9, 29, 0, 0, 14, 0,
- 0, 10, 11, 0, 0, 0, 0, 116, 12, 1,
+ 34, 57, 22, 73, 5, 6, -78, 95, 1, 2,
+ 3, 4, 96, 42, 7, 8, 9, -80, 59, 33,
+ 58, 40, 97, 10, 11, 66, 9, 63, 43, 129,
+ 12, 38, 56, 17, 30, 63, 40, 40, -79, -77,
+ 29, 9, 9, 14, 35, 36, 130, 38, 41, 103,
+ 75, 59, 40, 40, 95, 88, 62, 9, 9, 96,
+ 109, 112, 93, 94, 106, 132, 68, 104, 107, 101,
+ 34, 34, 114, -80, 116, 65, 115, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 89, 90, 110,
+ 113, 50, 92, 69, 77, 102, 100, 51, 52, 53,
+ 54, 55, 55, 70, 108, 111, 71, 72, 91, 1,
+ 2, 3, 4, 5, 6, 7, 8, 9, 6, 123,
+ 124, 140, 133, 134, 10, 11, 52, 53, 54, 118,
+ 55, 12, 120, 44, 45, 46, 47, 48, 49, 144,
+ 50, 13, 67, 105, 14, 117, 51, 52, 53, 54,
+ 125, 55, 126, 0, 131, 60, 61, 60, 61, 62,
+ 136, 62, 137, 0, 76, 0, 1, 2, 3, 4,
+ 0, 143, 7, 8, 9, 0, 0, 0, 2, 3,
+ 0, 10, 11, 7, 8, 0, 0, 99, 12, 1,
2, 3, 4, 0, 0, 7, 8, 9, 29, 0,
0, 14, 0, 0, 10, 11, 0, 0, 0, 0,
- 0, 12, 0, 43, 44, 45, 46, 47, 48, 0,
- 49, 29, 0, 0, 14, 118, 50, 51, 52, 53,
- 0, 54, 43, 44, 45, 46, 47, 48, 0, 49,
- 0, 0, 119, 0, 124, 50, 51, 52, 53, 0,
- 54, 43, 44, 45, 46, 47, 48, 0, 49, 0,
- 0, 125, 0, 135, 50, 51, 52, 53, 0, 54,
- 43, 44, 45, 46, 47, 48, 0, 49, 0, 0,
- 136, 0, 0, 50, 51, 52, 53, 0, 54, 43,
- 44, 45, 46, 47, 48, 0, 49, 0, 0, 132,
- 0, 0, 50, 51, 52, 53, 0, 54, 43, 44,
- 45, 46, 47, 48, 0, 49, 0, 0, 138, 0,
- 0, 50, 51, 52, 53, 0, 54, 43, 44, 45,
- 46, 47, 48, 0, 49, 0, 0, 139, 0, 0,
- 50, 51, 52, 53, 0, 54, 43, 44, 45, 46,
- 47, 48, 0, 49, 0, 0, 142, 0, 0, 50,
- 51, 52, 53, 0, 54, 0, 0, 73, 43, 44,
- 45, 46, 47, 48, 0, 49, 0, 0, 0, 0,
- 114, 50, 51, 52, 53, 0, 54, 43, 44, 45,
- 46, 47, 48, 0, 49, 0, 0, 0, 0, 0,
- 50, 51, 52, 53, 0, 54
+ 119, 12, 1, 2, 3, 4, 0, 0, 7, 8,
+ 9, 29, 0, 0, 14, 0, 0, 10, 11, 0,
+ 0, 0, 0, 0, 12, 0, 44, 45, 46, 47,
+ 48, 49, 0, 50, 29, 0, 0, 14, 121, 51,
+ 52, 53, 54, 0, 55, 44, 45, 46, 47, 48,
+ 49, 0, 50, 0, 0, 122, 0, 127, 51, 52,
+ 53, 54, 0, 55, 44, 45, 46, 47, 48, 49,
+ 0, 50, 0, 0, 128, 0, 138, 51, 52, 53,
+ 54, 0, 55, 44, 45, 46, 47, 48, 49, 0,
+ 50, 0, 0, 139, 0, 0, 51, 52, 53, 54,
+ 0, 55, 44, 45, 46, 47, 48, 49, 0, 50,
+ 0, 0, 135, 0, 0, 51, 52, 53, 54, 0,
+ 55, 44, 45, 46, 47, 48, 49, 0, 50, 0,
+ 0, 141, 0, 0, 51, 52, 53, 54, 0, 55,
+ 44, 45, 46, 47, 48, 49, 0, 50, 0, 0,
+ 142, 0, 0, 51, 52, 53, 54, 0, 55, 44,
+ 45, 46, 47, 48, 49, 0, 50, 0, 0, 145,
+ 0, 0, 51, 52, 53, 54, 0, 55, 0, 0,
+ 74, 44, 45, 46, 47, 48, 49, 0, 50, 0,
+ 0, 0, 0, 0, 51, 52, 53, 54, 0, 55
};
static const yytype_int16 yycheck[] =
{
- 1, 18, 0, 3, 4, 5, 6, 13, 24, 9,
- 10, 11, 4, 14, 7, 8, 6, 9, 18, 19,
- 18, 11, 38, 29, 24, 25, 33, 19, 18, 36,
- 37, 6, 6, 0, 1, 35, 11, 11, 38, 38,
- 39, 41, 35, 18, 11, 12, 6, 6, 39, 26,
- 27, 11, 11, 30, 52, 4, 33, 0, 18, 18,
- 9, 59, 60, 34, 26, 27, 67, 68, 30, 70,
- 71, 72, 38, 90, 40, 76, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 4, 5,
- 19, 58, 38, 9, 10, 62, 25, 26, 27, 28,
- 40, 30, 38, 70, 71, 39, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 33, 34, 70, 71, 120,
- 121, 18, 19, 26, 27, 28, 38, 30, 25, 38,
- 30, 98, 6, 6, 30, 56, 137, 8, 35, 38,
- 38, 38, 96, 38, 26, 67, -1, 114, -1, 116,
- -1, 118, -1, -1, -1, -1, -1, 124, -1, 126,
- -1, -1, -1, 3, 4, 5, 6, -1, 135, 9,
- 10, 11, -1, -1, -1, -1, -1, -1, 18, 19,
- -1, -1, -1, -1, 24, 25, 3, 4, 5, 6,
- -1, -1, 9, 10, 11, 35, -1, -1, 38, -1,
- -1, 18, 19, -1, -1, -1, -1, 24, 25, 3,
+ 1, 18, 0, 24, 7, 8, 39, 4, 3, 4,
+ 5, 6, 9, 14, 9, 10, 11, 38, 34, 1,
+ 18, 6, 19, 18, 19, 38, 11, 40, 0, 24,
+ 25, 13, 35, 0, 1, 40, 6, 6, 38, 39,
+ 35, 11, 11, 38, 11, 12, 41, 29, 18, 18,
+ 33, 34, 6, 6, 4, 53, 30, 11, 11, 9,
+ 71, 72, 60, 61, 18, 18, 39, 68, 69, 6,
+ 71, 72, 73, 38, 91, 38, 77, 44, 45, 46,
+ 47, 48, 49, 50, 51, 52, 53, 54, 55, 71,
+ 72, 19, 59, 38, 38, 6, 63, 25, 26, 27,
+ 28, 30, 30, 33, 71, 72, 36, 37, 57, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 8, 38,
+ 38, 38, 123, 124, 18, 19, 26, 27, 28, 97,
+ 30, 25, 99, 12, 13, 14, 15, 16, 17, 140,
+ 19, 35, 26, 68, 38, 24, 25, 26, 27, 28,
+ 117, 30, 119, -1, 121, 26, 27, 26, 27, 30,
+ 127, 30, 129, -1, 33, -1, 3, 4, 5, 6,
+ -1, 138, 9, 10, 11, -1, -1, -1, 4, 5,
+ -1, 18, 19, 9, 10, -1, -1, 24, 25, 3,
4, 5, 6, -1, -1, 9, 10, 11, 35, -1,
-1, 38, -1, -1, 18, 19, -1, -1, -1, -1,
- -1, 25, -1, 12, 13, 14, 15, 16, 17, -1,
- 19, 35, -1, -1, 38, 24, 25, 26, 27, 28,
+ 24, 25, 3, 4, 5, 6, -1, -1, 9, 10,
+ 11, 35, -1, -1, 38, -1, -1, 18, 19, -1,
+ -1, -1, -1, -1, 25, -1, 12, 13, 14, 15,
+ 16, 17, -1, 19, 35, -1, -1, 38, 24, 25,
+ 26, 27, 28, -1, 30, 12, 13, 14, 15, 16,
+ 17, -1, 19, -1, -1, 41, -1, 24, 25, 26,
+ 27, 28, -1, 30, 12, 13, 14, 15, 16, 17,
+ -1, 19, -1, -1, 41, -1, 24, 25, 26, 27,
+ 28, -1, 30, 12, 13, 14, 15, 16, 17, -1,
+ 19, -1, -1, 41, -1, -1, 25, 26, 27, 28,
-1, 30, 12, 13, 14, 15, 16, 17, -1, 19,
- -1, -1, 41, -1, 24, 25, 26, 27, 28, -1,
+ -1, -1, 41, -1, -1, 25, 26, 27, 28, -1,
30, 12, 13, 14, 15, 16, 17, -1, 19, -1,
- -1, 41, -1, 24, 25, 26, 27, 28, -1, 30,
+ -1, 41, -1, -1, 25, 26, 27, 28, -1, 30,
12, 13, 14, 15, 16, 17, -1, 19, -1, -1,
41, -1, -1, 25, 26, 27, 28, -1, 30, 12,
13, 14, 15, 16, 17, -1, 19, -1, -1, 41,
- -1, -1, 25, 26, 27, 28, -1, 30, 12, 13,
- 14, 15, 16, 17, -1, 19, -1, -1, 41, -1,
- -1, 25, 26, 27, 28, -1, 30, 12, 13, 14,
- 15, 16, 17, -1, 19, -1, -1, 41, -1, -1,
- 25, 26, 27, 28, -1, 30, 12, 13, 14, 15,
- 16, 17, -1, 19, -1, -1, 41, -1, -1, 25,
- 26, 27, 28, -1, 30, -1, -1, 33, 12, 13,
- 14, 15, 16, 17, -1, 19, -1, -1, -1, -1,
- 24, 25, 26, 27, 28, -1, 30, 12, 13, 14,
- 15, 16, 17, -1, 19, -1, -1, -1, -1, -1,
- 25, 26, 27, 28, -1, 30
+ -1, -1, 25, 26, 27, 28, -1, 30, -1, -1,
+ 33, 12, 13, 14, 15, 16, 17, -1, 19, -1,
+ -1, -1, -1, -1, 25, 26, 27, 28, -1, 30
};
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
@@ -766,18 +763,18 @@ static const yytype_int8 yystos[] =
0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
18, 19, 25, 35, 38, 43, 44, 45, 46, 49,
50, 51, 52, 54, 55, 56, 58, 59, 60, 35,
- 45, 47, 48, 54, 45, 45, 45, 49, 52, 6,
- 18, 54, 0, 12, 13, 14, 15, 16, 17, 19,
- 25, 26, 27, 28, 30, 35, 50, 52, 34, 26,
- 27, 30, 40, 57, 38, 38, 57, 39, 38, 33,
- 36, 37, 24, 33, 33, 33, 38, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 52, 45, 45,
- 46, 45, 52, 52, 4, 9, 19, 53, 24, 45,
- 6, 6, 18, 54, 60, 18, 54, 45, 48, 45,
- 48, 54, 54, 50, 24, 53, 24, 45, 24, 41,
- 38, 38, 45, 45, 24, 41, 24, 41, 45, 18,
- 54, 54, 41, 45, 45, 24, 41, 38, 41, 41,
- 45, 54, 41
+ 45, 47, 48, 49, 54, 45, 45, 45, 49, 52,
+ 6, 18, 54, 0, 12, 13, 14, 15, 16, 17,
+ 19, 25, 26, 27, 28, 30, 35, 50, 52, 34,
+ 26, 27, 30, 40, 57, 38, 38, 57, 39, 38,
+ 33, 36, 37, 24, 33, 33, 33, 38, 45, 45,
+ 45, 45, 45, 45, 45, 45, 45, 45, 52, 45,
+ 45, 46, 45, 52, 52, 4, 9, 19, 53, 24,
+ 45, 6, 6, 18, 54, 60, 18, 54, 45, 48,
+ 49, 45, 48, 49, 54, 54, 50, 24, 53, 24,
+ 45, 24, 41, 38, 38, 45, 45, 24, 41, 24,
+ 41, 45, 18, 54, 54, 41, 45, 45, 24, 41,
+ 38, 41, 41, 45, 54, 41
};
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
@@ -786,11 +783,12 @@ static const yytype_int8 yyr1[] =
0, 42, 43, 43, 44, 44, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 46, 46, 46, 46, 47, 47, 47,
- 47, 47, 47, 48, 49, 49, 49, 49, 49, 49,
- 49, 50, 51, 52, 52, 52, 52, 52, 52, 52,
- 53, 53, 54, 54, 55, 55, 56, 56, 56, 56,
- 56, 56, 56, 57, 57, 57, 57, 57, 57, 57,
- 57, 58, 58, 58, 59, 59, 60, 60
+ 47, 47, 47, 47, 47, 47, 48, 49, 49, 49,
+ 49, 49, 49, 49, 50, 51, 52, 52, 52, 52,
+ 52, 52, 52, 53, 53, 54, 54, 55, 55, 56,
+ 56, 56, 56, 56, 56, 56, 57, 57, 57, 57,
+ 57, 57, 57, 57, 58, 58, 58, 59, 59, 60,
+ 60
};
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
@@ -798,12 +796,13 @@ static const yytype_int8 yyr2[] =
{
0, 2, 1, 1, 2, 4, 1, 1, 1, 1,
2, 2, 3, 3, 3, 3, 3, 3, 3, 1,
- 3, 5, 3, 1, 1, 1, 1, 1, 1, 3,
+ 3, 5, 3, 1, 1, 1, 1, 1, 1, 1,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 1, 1, 1, 1, 3, 3, 3, 4, 3,
- 1, 1, 1, 1, 1, 1, 4, 2, 5, 3,
- 5, 7, 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 2, 2, 3, 1, 1, 1, 1
+ 3, 3, 3, 3, 1, 1, 1, 1, 3, 3,
+ 3, 4, 3, 1, 1, 1, 1, 1, 1, 4,
+ 2, 5, 3, 5, 7, 3, 3, 4, 4, 5,
+ 5, 6, 6, 7, 2, 2, 3, 1, 1, 1,
+ 1
};
@@ -1009,49 +1008,49 @@ yydestruct (const char *yymsg,
case YYSYMBOL_exp: /* exp */
#line 73 "Expression.y"
{ delete ((*yyvaluep).expr); }
-#line 1012 "Expression.tab.c"
+#line 1011 "Expression.tab.c"
break;
case YYSYMBOL_num: /* num */
#line 73 "Expression.y"
{ delete ((*yyvaluep).expr); }
-#line 1018 "Expression.tab.c"
+#line 1017 "Expression.tab.c"
break;
case YYSYMBOL_args: /* args */
#line 75 "Expression.y"
{ std::vector::const_iterator i = ((*yyvaluep).arguments).begin(); while (i != ((*yyvaluep).arguments).end()) { delete *i; ++i; } }
-#line 1024 "Expression.tab.c"
+#line 1023 "Expression.tab.c"
break;
case YYSYMBOL_range: /* range */
#line 73 "Expression.y"
{ delete ((*yyvaluep).expr); }
-#line 1030 "Expression.tab.c"
+#line 1029 "Expression.tab.c"
break;
case YYSYMBOL_cond: /* cond */
#line 73 "Expression.y"
{ delete ((*yyvaluep).expr); }
-#line 1036 "Expression.tab.c"
+#line 1035 "Expression.tab.c"
break;
case YYSYMBOL_unit_exp: /* unit_exp */
#line 73 "Expression.y"
{ delete ((*yyvaluep).expr); }
-#line 1042 "Expression.tab.c"
+#line 1041 "Expression.tab.c"
break;
case YYSYMBOL_indexer: /* indexer */
#line 74 "Expression.y"
{ delete ((*yyvaluep).component); }
-#line 1048 "Expression.tab.c"
+#line 1047 "Expression.tab.c"
break;
case YYSYMBOL_indexable: /* indexable */
#line 73 "Expression.y"
{ delete ((*yyvaluep).expr); }
-#line 1054 "Expression.tab.c"
+#line 1053 "Expression.tab.c"
break;
default:
@@ -1321,491 +1320,509 @@ yyreduce:
case 2: /* input: exp */
#line 81 "Expression.y"
{ ScanResult = (yyvsp[0].expr); valueExpression = true; }
-#line 1324 "Expression.tab.c"
+#line 1323 "Expression.tab.c"
break;
case 3: /* input: unit_exp */
#line 82 "Expression.y"
{ ScanResult = (yyvsp[0].expr); unitExpression = true; }
-#line 1330 "Expression.tab.c"
+#line 1329 "Expression.tab.c"
break;
case 4: /* unit_num: num unit_exp */
#line 85 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-1].expr), OperatorExpression::UNIT, (yyvsp[0].expr)); }
-#line 1336 "Expression.tab.c"
+#line 1335 "Expression.tab.c"
break;
case 5: /* unit_num: num us_building_unit num us_building_unit */
#line 86 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, new OperatorExpression(DocumentObject, (yyvsp[-3].expr), OperatorExpression::UNIT, (yyvsp[-2].expr)), OperatorExpression::ADD, new OperatorExpression(DocumentObject, (yyvsp[-1].expr), OperatorExpression::UNIT, (yyvsp[0].expr)));}
-#line 1342 "Expression.tab.c"
+#line 1341 "Expression.tab.c"
break;
case 6: /* exp: num */
#line 89 "Expression.y"
{ (yyval.expr) = (yyvsp[0].expr); }
-#line 1348 "Expression.tab.c"
+#line 1347 "Expression.tab.c"
break;
case 7: /* exp: unit_num */
#line 90 "Expression.y"
{ (yyval.expr) = (yyvsp[0].expr); }
-#line 1354 "Expression.tab.c"
+#line 1353 "Expression.tab.c"
break;
case 8: /* exp: STRING */
#line 91 "Expression.y"
{ (yyval.expr) = new StringExpression(DocumentObject, (yyvsp[0].string)); }
-#line 1360 "Expression.tab.c"
+#line 1359 "Expression.tab.c"
break;
case 9: /* exp: identifier */
#line 92 "Expression.y"
{ (yyval.expr) = new VariableExpression(DocumentObject, (yyvsp[0].path)); }
-#line 1366 "Expression.tab.c"
+#line 1365 "Expression.tab.c"
break;
case 10: /* exp: MINUSSIGN exp */
#line 93 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[0].expr), OperatorExpression::NEG, new NumberExpression(DocumentObject, Quantity(-1))); }
-#line 1372 "Expression.tab.c"
+#line 1371 "Expression.tab.c"
break;
case 11: /* exp: '+' exp */
#line 94 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[0].expr), OperatorExpression::POS, new NumberExpression(DocumentObject, Quantity(1))); }
-#line 1378 "Expression.tab.c"
+#line 1377 "Expression.tab.c"
break;
case 12: /* exp: exp '+' exp */
#line 95 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::ADD, (yyvsp[0].expr)); }
-#line 1384 "Expression.tab.c"
+#line 1383 "Expression.tab.c"
break;
case 13: /* exp: exp MINUSSIGN exp */
#line 96 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::SUB, (yyvsp[0].expr)); }
-#line 1390 "Expression.tab.c"
+#line 1389 "Expression.tab.c"
break;
case 14: /* exp: exp '*' exp */
#line 97 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MUL, (yyvsp[0].expr)); }
-#line 1396 "Expression.tab.c"
+#line 1395 "Expression.tab.c"
break;
case 15: /* exp: exp '/' exp */
#line 98 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
-#line 1402 "Expression.tab.c"
+#line 1401 "Expression.tab.c"
break;
case 16: /* exp: exp '%' exp */
#line 99 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MOD, (yyvsp[0].expr)); }
-#line 1408 "Expression.tab.c"
+#line 1407 "Expression.tab.c"
break;
case 17: /* exp: exp '/' unit_exp */
#line 100 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
-#line 1414 "Expression.tab.c"
+#line 1413 "Expression.tab.c"
break;
case 18: /* exp: exp '^' exp */
#line 101 "Expression.y"
{ (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::POW, (yyvsp[0].expr)); }
-#line 1420 "Expression.tab.c"
+#line 1419 "Expression.tab.c"
break;
case 19: /* exp: indexable */
#line 102 "Expression.y"
{ (yyval.expr) = (yyvsp[0].expr); }
-#line 1426 "Expression.tab.c"
+#line 1425 "Expression.tab.c"
break;
case 20: /* exp: FUNC args ')' */
#line 103 "Expression.y"
{ (yyval.expr) = new FunctionExpression(DocumentObject, (yyvsp[-2].func).first, std::move((yyvsp[-2].func).second), (yyvsp[-1].arguments));}
-#line 1432 "Expression.tab.c"
+#line 1431 "Expression.tab.c"
break;
case 21: /* exp: cond '?' exp ':' exp */
#line 104 "Expression.y"
{ (yyval.expr) = new ConditionalExpression(DocumentObject, (yyvsp[-4].expr), (yyvsp[-2].expr), (yyvsp[0].expr)); }
-#line 1438 "Expression.tab.c"
+#line 1437 "Expression.tab.c"
break;
case 22: /* exp: '(' exp ')' */
#line 105 "Expression.y"
{ (yyval.expr) = (yyvsp[-1].expr); }
-#line 1444 "Expression.tab.c"
+#line 1443 "Expression.tab.c"
break;
case 23: /* num: ONE */
#line 108 "Expression.y"
{ (yyval.expr) = new NumberExpression(DocumentObject, Quantity((yyvsp[0].fvalue))); }
-#line 1450 "Expression.tab.c"
+#line 1449 "Expression.tab.c"
break;
case 24: /* num: NUM */
#line 109 "Expression.y"
{ (yyval.expr) = new NumberExpression(DocumentObject, Quantity((yyvsp[0].fvalue))); }
-#line 1456 "Expression.tab.c"
+#line 1455 "Expression.tab.c"
break;
case 25: /* num: INTEGER */
#line 110 "Expression.y"
{ (yyval.expr) = new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue))); }
-#line 1462 "Expression.tab.c"
+#line 1461 "Expression.tab.c"
break;
case 26: /* num: CONSTANT */
#line 111 "Expression.y"
{ (yyval.expr) = new ConstantExpression(DocumentObject, (yyvsp[0].constant).name, Quantity((yyvsp[0].constant).fvalue)); }
-#line 1468 "Expression.tab.c"
+#line 1467 "Expression.tab.c"
break;
case 27: /* args: exp */
#line 113 "Expression.y"
{ (yyval.arguments).push_back((yyvsp[0].expr)); }
-#line 1474 "Expression.tab.c"
+#line 1473 "Expression.tab.c"
break;
case 28: /* args: range */
#line 114 "Expression.y"
{ (yyval.arguments).push_back((yyvsp[0].expr)); }
-#line 1480 "Expression.tab.c"
+#line 1479 "Expression.tab.c"
break;
- case 29: /* args: args ',' exp */
+ case 29: /* args: cond */
#line 115 "Expression.y"
- { (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
-#line 1486 "Expression.tab.c"
+ { (yyval.arguments).push_back((yyvsp[0].expr)); }
+#line 1485 "Expression.tab.c"
break;
- case 30: /* args: args ';' exp */
+ case 30: /* args: args ',' exp */
#line 116 "Expression.y"
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
-#line 1492 "Expression.tab.c"
+#line 1491 "Expression.tab.c"
break;
- case 31: /* args: args ',' range */
+ case 31: /* args: args ';' exp */
#line 117 "Expression.y"
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
-#line 1498 "Expression.tab.c"
+#line 1497 "Expression.tab.c"
break;
- case 32: /* args: args ';' range */
+ case 32: /* args: args ',' range */
#line 118 "Expression.y"
{ (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
-#line 1504 "Expression.tab.c"
+#line 1503 "Expression.tab.c"
break;
- case 33: /* range: id_or_cell ':' id_or_cell */
+ case 33: /* args: args ';' range */
+#line 119 "Expression.y"
+ { (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
+#line 1509 "Expression.tab.c"
+ break;
+
+ case 34: /* args: args ',' cond */
+#line 120 "Expression.y"
+ { (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
+#line 1515 "Expression.tab.c"
+ break;
+
+ case 35: /* args: args ';' cond */
#line 121 "Expression.y"
- { (yyval.expr) = new RangeExpression(DocumentObject, (yyvsp[-2].string), (yyvsp[0].string)); }
-#line 1510 "Expression.tab.c"
+ { (yyvsp[-2].arguments).push_back((yyvsp[0].expr)); (yyval.arguments) = (yyvsp[-2].arguments); }
+#line 1521 "Expression.tab.c"
break;
- case 34: /* cond: exp EQ exp */
+ case 36: /* range: id_or_cell ':' id_or_cell */
#line 124 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::EQ, (yyvsp[0].expr)); }
-#line 1516 "Expression.tab.c"
+ { (yyval.expr) = new RangeExpression(DocumentObject, (yyvsp[-2].string), (yyvsp[0].string)); }
+#line 1527 "Expression.tab.c"
break;
- case 35: /* cond: exp NEQ exp */
-#line 125 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::NEQ, (yyvsp[0].expr)); }
-#line 1522 "Expression.tab.c"
- break;
-
- case 36: /* cond: exp LT exp */
-#line 126 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::LT, (yyvsp[0].expr)); }
-#line 1528 "Expression.tab.c"
- break;
-
- case 37: /* cond: exp GT exp */
+ case 37: /* cond: exp EQ exp */
#line 127 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::GT, (yyvsp[0].expr)); }
-#line 1534 "Expression.tab.c"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::EQ, (yyvsp[0].expr)); }
+#line 1533 "Expression.tab.c"
break;
- case 38: /* cond: exp GTE exp */
+ case 38: /* cond: exp NEQ exp */
#line 128 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::GTE, (yyvsp[0].expr)); }
-#line 1540 "Expression.tab.c"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::NEQ, (yyvsp[0].expr)); }
+#line 1539 "Expression.tab.c"
break;
- case 39: /* cond: exp LTE exp */
+ case 39: /* cond: exp LT exp */
#line 129 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::LTE, (yyvsp[0].expr)); }
-#line 1546 "Expression.tab.c"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::LT, (yyvsp[0].expr)); }
+#line 1545 "Expression.tab.c"
break;
- case 40: /* cond: '(' cond ')' */
+ case 40: /* cond: exp GT exp */
#line 130 "Expression.y"
- { (yyval.expr) = (yyvsp[-1].expr); }
-#line 1552 "Expression.tab.c"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::GT, (yyvsp[0].expr)); }
+#line 1551 "Expression.tab.c"
break;
- case 41: /* us_building_unit: USUNIT */
+ case 41: /* cond: exp GTE exp */
+#line 131 "Expression.y"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::GTE, (yyvsp[0].expr)); }
+#line 1557 "Expression.tab.c"
+ break;
+
+ case 42: /* cond: exp LTE exp */
+#line 132 "Expression.y"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::LTE, (yyvsp[0].expr)); }
+#line 1563 "Expression.tab.c"
+ break;
+
+ case 43: /* cond: '(' cond ')' */
#line 133 "Expression.y"
- { (yyval.expr) = new UnitExpression(DocumentObject, (yyvsp[0].quantity).scaler, (yyvsp[0].quantity).unitStr ); }
-#line 1558 "Expression.tab.c"
+ { (yyval.expr) = (yyvsp[-1].expr); }
+#line 1569 "Expression.tab.c"
break;
- case 42: /* other_unit: UNIT */
-#line 134 "Expression.y"
- { (yyval.expr) = new UnitExpression(DocumentObject, (yyvsp[0].quantity).scaler, (yyvsp[0].quantity).unitStr ); }
-#line 1564 "Expression.tab.c"
- break;
-
- case 43: /* unit_exp: other_unit */
+ case 44: /* us_building_unit: USUNIT */
#line 136 "Expression.y"
- { (yyval.expr) = (yyvsp[0].expr); }
-#line 1570 "Expression.tab.c"
+ { (yyval.expr) = new UnitExpression(DocumentObject, (yyvsp[0].quantity).scaler, (yyvsp[0].quantity).unitStr ); }
+#line 1575 "Expression.tab.c"
break;
- case 44: /* unit_exp: us_building_unit */
+ case 45: /* other_unit: UNIT */
#line 137 "Expression.y"
- { (yyval.expr) = (yyvsp[0].expr); }
-#line 1576 "Expression.tab.c"
+ { (yyval.expr) = new UnitExpression(DocumentObject, (yyvsp[0].quantity).scaler, (yyvsp[0].quantity).unitStr ); }
+#line 1581 "Expression.tab.c"
break;
- case 45: /* unit_exp: unit_exp '/' unit_exp */
-#line 138 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
-#line 1582 "Expression.tab.c"
- break;
-
- case 46: /* unit_exp: unit_exp '*' unit_exp */
+ case 46: /* unit_exp: other_unit */
#line 139 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MUL, (yyvsp[0].expr)); }
-#line 1588 "Expression.tab.c"
+ { (yyval.expr) = (yyvsp[0].expr); }
+#line 1587 "Expression.tab.c"
break;
- case 47: /* unit_exp: unit_exp '^' integer */
+ case 47: /* unit_exp: us_building_unit */
#line 140 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::POW, new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue)))); }
-#line 1594 "Expression.tab.c"
+ { (yyval.expr) = (yyvsp[0].expr); }
+#line 1593 "Expression.tab.c"
break;
- case 48: /* unit_exp: unit_exp '^' MINUSSIGN integer */
+ case 48: /* unit_exp: unit_exp '/' unit_exp */
#line 141 "Expression.y"
- { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-3].expr), OperatorExpression::POW, new OperatorExpression(DocumentObject, new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue))), OperatorExpression::NEG, new NumberExpression(DocumentObject, Quantity(-1)))); }
-#line 1600 "Expression.tab.c"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::DIV, (yyvsp[0].expr)); }
+#line 1599 "Expression.tab.c"
break;
- case 49: /* unit_exp: '(' unit_exp ')' */
+ case 49: /* unit_exp: unit_exp '*' unit_exp */
#line 142 "Expression.y"
- { (yyval.expr) = (yyvsp[-1].expr); }
-#line 1606 "Expression.tab.c"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::MUL, (yyvsp[0].expr)); }
+#line 1605 "Expression.tab.c"
break;
- case 50: /* integer: INTEGER */
+ case 50: /* unit_exp: unit_exp '^' integer */
+#line 143 "Expression.y"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-2].expr), OperatorExpression::POW, new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue)))); }
+#line 1611 "Expression.tab.c"
+ break;
+
+ case 51: /* unit_exp: unit_exp '^' MINUSSIGN integer */
+#line 144 "Expression.y"
+ { (yyval.expr) = new OperatorExpression(DocumentObject, (yyvsp[-3].expr), OperatorExpression::POW, new OperatorExpression(DocumentObject, new NumberExpression(DocumentObject, Quantity((double)(yyvsp[0].ivalue))), OperatorExpression::NEG, new NumberExpression(DocumentObject, Quantity(-1)))); }
+#line 1617 "Expression.tab.c"
+ break;
+
+ case 52: /* unit_exp: '(' unit_exp ')' */
#line 145 "Expression.y"
+ { (yyval.expr) = (yyvsp[-1].expr); }
+#line 1623 "Expression.tab.c"
+ break;
+
+ case 53: /* integer: INTEGER */
+#line 148 "Expression.y"
{ (yyval.ivalue) = (yyvsp[0].ivalue); }
-#line 1612 "Expression.tab.c"
+#line 1629 "Expression.tab.c"
break;
- case 51: /* integer: ONE */
-#line 146 "Expression.y"
+ case 54: /* integer: ONE */
+#line 149 "Expression.y"
{ (yyval.ivalue) = (yyvsp[0].fvalue); }
-#line 1618 "Expression.tab.c"
+#line 1635 "Expression.tab.c"
break;
- case 52: /* id_or_cell: IDENTIFIER */
-#line 150 "Expression.y"
+ case 55: /* id_or_cell: IDENTIFIER */
+#line 153 "Expression.y"
{ (yyval.string) = std::move((yyvsp[0].string)); }
-#line 1624 "Expression.tab.c"
+#line 1641 "Expression.tab.c"
break;
- case 53: /* id_or_cell: CELLADDRESS */
-#line 151 "Expression.y"
+ case 56: /* id_or_cell: CELLADDRESS */
+#line 154 "Expression.y"
{ (yyval.string) = std::move((yyvsp[0].string)); }
-#line 1630 "Expression.tab.c"
+#line 1647 "Expression.tab.c"
break;
- case 54: /* identifier: id_or_cell */
-#line 155 "Expression.y"
+ case 57: /* identifier: id_or_cell */
+#line 158 "Expression.y"
{ (yyval.path) = ObjectIdentifier(DocumentObject); (yyval.path) << ObjectIdentifier::SimpleComponent((yyvsp[0].string)); }
-#line 1636 "Expression.tab.c"
+#line 1653 "Expression.tab.c"
break;
- case 55: /* identifier: iden */
-#line 156 "Expression.y"
+ case 58: /* identifier: iden */
+#line 159 "Expression.y"
{ (yyval.path) = std::move((yyvsp[0].path)); }
-#line 1642 "Expression.tab.c"
+#line 1659 "Expression.tab.c"
break;
- case 56: /* iden: '.' STRING '.' id_or_cell */
-#line 160 "Expression.y"
- { /* Path to property of a sub-object of the current object*/
- (yyval.path) = ObjectIdentifier(DocumentObject,true);
- (yyval.path).setDocumentObjectName(DocumentObject,false,ObjectIdentifier::String(std::move((yyvsp[-2].string)),true),true);
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
+ case 59: /* iden: '.' STRING '.' id_or_cell */
+#line 163 "Expression.y"
+ { /* Path to property of a sub-object of the current object*/
+ (yyval.path) = ObjectIdentifier(DocumentObject,true);
+ (yyval.path).setDocumentObjectName(DocumentObject,false,ObjectIdentifier::String(std::move((yyvsp[-2].string)),true),true);
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
}
-#line 1652 "Expression.tab.c"
+#line 1669 "Expression.tab.c"
break;
- case 57: /* iden: '.' id_or_cell */
-#line 165 "Expression.y"
- { /* Path to property of the current document object */
- (yyval.path) = ObjectIdentifier(DocumentObject,true);
- (yyval.path).setDocumentObjectName(DocumentObject);
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
+ case 60: /* iden: '.' id_or_cell */
+#line 168 "Expression.y"
+ { /* Path to property of the current document object */
+ (yyval.path) = ObjectIdentifier(DocumentObject,true);
+ (yyval.path).setDocumentObjectName(DocumentObject);
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
}
-#line 1662 "Expression.tab.c"
+#line 1679 "Expression.tab.c"
break;
- case 58: /* iden: object '.' STRING '.' id_or_cell */
-#line 170 "Expression.y"
- { /* Path to property of a sub-object */
- (yyval.path) = ObjectIdentifier(DocumentObject);
- (yyval.path).setDocumentObjectName(std::move((yyvsp[-4].string_or_identifier)), true, ObjectIdentifier::String(std::move((yyvsp[-2].string)),true),true);
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
- (yyval.path).resolveAmbiguity();
+ case 61: /* iden: object '.' STRING '.' id_or_cell */
+#line 173 "Expression.y"
+ { /* Path to property of a sub-object */
+ (yyval.path) = ObjectIdentifier(DocumentObject);
+ (yyval.path).setDocumentObjectName(std::move((yyvsp[-4].string_or_identifier)), true, ObjectIdentifier::String(std::move((yyvsp[-2].string)),true),true);
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
+ (yyval.path).resolveAmbiguity();
}
-#line 1673 "Expression.tab.c"
+#line 1690 "Expression.tab.c"
break;
- case 59: /* iden: object '.' id_or_cell */
-#line 176 "Expression.y"
- { /* Path to property of a given document object */
- (yyval.path) = ObjectIdentifier(DocumentObject);
- (yyvsp[-2].string_or_identifier).checkImport(DocumentObject);
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[-2].string_or_identifier)));
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
- (yyval.path).resolveAmbiguity();
+ case 62: /* iden: object '.' id_or_cell */
+#line 179 "Expression.y"
+ { /* Path to property of a given document object */
+ (yyval.path) = ObjectIdentifier(DocumentObject);
+ (yyvsp[-2].string_or_identifier).checkImport(DocumentObject);
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[-2].string_or_identifier)));
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
+ (yyval.path).resolveAmbiguity();
}
-#line 1685 "Expression.tab.c"
+#line 1702 "Expression.tab.c"
break;
- case 60: /* iden: document '#' object '.' id_or_cell */
-#line 183 "Expression.y"
- { /* Path to property from an external document, within a named document object */
- (yyval.path) = ObjectIdentifier(DocumentObject);
- (yyval.path).setDocumentName(std::move((yyvsp[-4].string_or_identifier)), true);
- (yyval.path).setDocumentObjectName(std::move((yyvsp[-2].string_or_identifier)), true);
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
- (yyval.path).resolveAmbiguity();
+ case 63: /* iden: document '#' object '.' id_or_cell */
+#line 186 "Expression.y"
+ { /* Path to property from an external document, within a named document object */
+ (yyval.path) = ObjectIdentifier(DocumentObject);
+ (yyval.path).setDocumentName(std::move((yyvsp[-4].string_or_identifier)), true);
+ (yyval.path).setDocumentObjectName(std::move((yyvsp[-2].string_or_identifier)), true);
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
+ (yyval.path).resolveAmbiguity();
}
-#line 1697 "Expression.tab.c"
- break;
-
- case 61: /* iden: document '#' object '.' STRING '.' id_or_cell */
-#line 191 "Expression.y"
- { (yyval.path) = ObjectIdentifier(DocumentObject);
- (yyval.path).setDocumentName(std::move((yyvsp[-6].string_or_identifier)), true);
- (yyval.path).setDocumentObjectName(std::move((yyvsp[-4].string_or_identifier)), true, ObjectIdentifier::String(std::move((yyvsp[-2].string)),true));
- (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
- (yyval.path).resolveAmbiguity();
- }
-#line 1708 "Expression.tab.c"
- break;
-
- case 62: /* iden: iden '.' IDENTIFIER */
-#line 197 "Expression.y"
- { (yyval.path)= std::move((yyvsp[-2].path)); (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string))); }
#line 1714 "Expression.tab.c"
break;
- case 63: /* indexer: '[' exp ']' */
-#line 201 "Expression.y"
- { (yyval.component) = Expression::createComponent((yyvsp[-1].expr)); }
-#line 1720 "Expression.tab.c"
+ case 64: /* iden: document '#' object '.' STRING '.' id_or_cell */
+#line 194 "Expression.y"
+ { (yyval.path) = ObjectIdentifier(DocumentObject);
+ (yyval.path).setDocumentName(std::move((yyvsp[-6].string_or_identifier)), true);
+ (yyval.path).setDocumentObjectName(std::move((yyvsp[-4].string_or_identifier)), true, ObjectIdentifier::String(std::move((yyvsp[-2].string)),true));
+ (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string)));
+ (yyval.path).resolveAmbiguity();
+ }
+#line 1725 "Expression.tab.c"
break;
- case 64: /* indexer: '[' exp ':' ']' */
-#line 202 "Expression.y"
- { (yyval.component) = Expression::createComponent((yyvsp[-2].expr),0,0,true); }
-#line 1726 "Expression.tab.c"
+ case 65: /* iden: iden '.' IDENTIFIER */
+#line 200 "Expression.y"
+ { (yyval.path)= std::move((yyvsp[-2].path)); (yyval.path).addComponent(ObjectIdentifier::SimpleComponent((yyvsp[0].string))); }
+#line 1731 "Expression.tab.c"
break;
- case 65: /* indexer: '[' ':' exp ']' */
-#line 203 "Expression.y"
- { (yyval.component) = Expression::createComponent(0,(yyvsp[-1].expr)); }
-#line 1732 "Expression.tab.c"
- break;
-
- case 66: /* indexer: '[' ':' ':' exp ']' */
+ case 66: /* indexer: '[' exp ']' */
#line 204 "Expression.y"
- { (yyval.component) = Expression::createComponent(0,0,(yyvsp[-1].expr)); }
-#line 1738 "Expression.tab.c"
+ { (yyval.component) = Expression::createComponent((yyvsp[-1].expr)); }
+#line 1737 "Expression.tab.c"
break;
- case 67: /* indexer: '[' exp ':' exp ']' */
+ case 67: /* indexer: '[' exp ':' ']' */
#line 205 "Expression.y"
- { (yyval.component) = Expression::createComponent((yyvsp[-3].expr),(yyvsp[-1].expr));}
-#line 1744 "Expression.tab.c"
+ { (yyval.component) = Expression::createComponent((yyvsp[-2].expr),0,0,true); }
+#line 1743 "Expression.tab.c"
break;
- case 68: /* indexer: '[' exp ':' ':' exp ']' */
+ case 68: /* indexer: '[' ':' exp ']' */
#line 206 "Expression.y"
- { (yyval.component) = Expression::createComponent((yyvsp[-4].expr),0,(yyvsp[-1].expr)); }
-#line 1750 "Expression.tab.c"
+ { (yyval.component) = Expression::createComponent(0,(yyvsp[-1].expr)); }
+#line 1749 "Expression.tab.c"
break;
- case 69: /* indexer: '[' ':' exp ':' exp ']' */
+ case 69: /* indexer: '[' ':' ':' exp ']' */
#line 207 "Expression.y"
- { (yyval.component) = Expression::createComponent(0,(yyvsp[-3].expr),(yyvsp[-1].expr)); }
-#line 1756 "Expression.tab.c"
+ { (yyval.component) = Expression::createComponent(0,0,(yyvsp[-1].expr)); }
+#line 1755 "Expression.tab.c"
break;
- case 70: /* indexer: '[' exp ':' exp ':' exp ']' */
+ case 70: /* indexer: '[' exp ':' exp ']' */
#line 208 "Expression.y"
+ { (yyval.component) = Expression::createComponent((yyvsp[-3].expr),(yyvsp[-1].expr));}
+#line 1761 "Expression.tab.c"
+ break;
+
+ case 71: /* indexer: '[' exp ':' ':' exp ']' */
+#line 209 "Expression.y"
+ { (yyval.component) = Expression::createComponent((yyvsp[-4].expr),0,(yyvsp[-1].expr)); }
+#line 1767 "Expression.tab.c"
+ break;
+
+ case 72: /* indexer: '[' ':' exp ':' exp ']' */
+#line 210 "Expression.y"
+ { (yyval.component) = Expression::createComponent(0,(yyvsp[-3].expr),(yyvsp[-1].expr)); }
+#line 1773 "Expression.tab.c"
+ break;
+
+ case 73: /* indexer: '[' exp ':' exp ':' exp ']' */
+#line 211 "Expression.y"
{ (yyval.component) = Expression::createComponent((yyvsp[-5].expr),(yyvsp[-3].expr),(yyvsp[-1].expr));}
-#line 1762 "Expression.tab.c"
+#line 1779 "Expression.tab.c"
break;
- case 71: /* indexable: identifier indexer */
-#line 212 "Expression.y"
+ case 74: /* indexable: identifier indexer */
+#line 215 "Expression.y"
{ (yyval.expr) = new VariableExpression(DocumentObject,(yyvsp[-1].path)); (yyval.expr)->addComponent((yyvsp[0].component)); }
-#line 1768 "Expression.tab.c"
+#line 1785 "Expression.tab.c"
break;
- case 72: /* indexable: indexable indexer */
-#line 213 "Expression.y"
+ case 75: /* indexable: indexable indexer */
+#line 216 "Expression.y"
{ (yyvsp[-1].expr)->addComponent(std::move((yyvsp[0].component))); (yyval.expr) = (yyvsp[-1].expr); }
-#line 1774 "Expression.tab.c"
+#line 1791 "Expression.tab.c"
break;
- case 73: /* indexable: indexable '.' IDENTIFIER */
-#line 214 "Expression.y"
+ case 76: /* indexable: indexable '.' IDENTIFIER */
+#line 217 "Expression.y"
{ (yyvsp[-2].expr)->addComponent(Expression::createComponent((yyvsp[0].string))); (yyval.expr) = (yyvsp[-2].expr); }
-#line 1780 "Expression.tab.c"
+#line 1797 "Expression.tab.c"
break;
- case 74: /* document: STRING */
-#line 218 "Expression.y"
+ case 77: /* document: STRING */
+#line 221 "Expression.y"
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), true); }
-#line 1786 "Expression.tab.c"
+#line 1803 "Expression.tab.c"
break;
- case 75: /* document: IDENTIFIER */
-#line 219 "Expression.y"
+ case 78: /* document: IDENTIFIER */
+#line 222 "Expression.y"
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), false, true);}
-#line 1792 "Expression.tab.c"
+#line 1809 "Expression.tab.c"
break;
- case 76: /* object: STRING */
-#line 223 "Expression.y"
+ case 79: /* object: STRING */
+#line 226 "Expression.y"
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), true); }
-#line 1798 "Expression.tab.c"
+#line 1815 "Expression.tab.c"
break;
- case 77: /* object: id_or_cell */
-#line 224 "Expression.y"
+ case 80: /* object: id_or_cell */
+#line 227 "Expression.y"
{ (yyval.string_or_identifier) = ObjectIdentifier::String(std::move((yyvsp[0].string)), false);}
-#line 1804 "Expression.tab.c"
+#line 1821 "Expression.tab.c"
break;
-#line 1808 "Expression.tab.c"
+#line 1825 "Expression.tab.c"
default: break;
}
@@ -1998,4 +2015,5 @@ yyreturnlab:
return yyresult;
}
-#line 227 "Expression.y"
+#line 230 "Expression.y"
+
diff --git a/src/App/Expression.y b/src/App/Expression.y
index e1a90ebf56..d88be0d2c7 100644
--- a/src/App/Expression.y
+++ b/src/App/Expression.y
@@ -82,7 +82,7 @@ input: exp { ScanResult = $1; valueExpressi
| unit_exp { ScanResult = $1; unitExpression = true; }
;
-unit_num: num unit_exp %prec NUM_AND_UNIT { $$ = new OperatorExpression(DocumentObject, $1, OperatorExpression::UNIT, $2); }
+unit_num: num unit_exp %prec NUM_AND_UNIT { $$ = new OperatorExpression(DocumentObject, $1, OperatorExpression::UNIT, $2); }
| num us_building_unit num us_building_unit %prec NUM_AND_UNIT { $$ = new OperatorExpression(DocumentObject, new OperatorExpression(DocumentObject, $1, OperatorExpression::UNIT, $2), OperatorExpression::ADD, new OperatorExpression(DocumentObject, $3, OperatorExpression::UNIT, $4));}
;
@@ -112,10 +112,13 @@ num: ONE { $$ = new NumberExpression(Docu
args: exp { $$.push_back($1); }
| range { $$.push_back($1); }
+ | cond { $$.push_back($1); }
| args ',' exp { $1.push_back($3); $$ = $1; }
| args ';' exp { $1.push_back($3); $$ = $1; }
| args ',' range { $1.push_back($3); $$ = $1; }
| args ';' range { $1.push_back($3); $$ = $1; }
+ | args ',' cond { $1.push_back($3); $$ = $1; }
+ | args ';' cond { $1.push_back($3); $$ = $1; }
;
range: id_or_cell ':' id_or_cell { $$ = new RangeExpression(DocumentObject, $1, $3); }
diff --git a/src/App/ExpressionParser.h b/src/App/ExpressionParser.h
index c4ac14d33d..457fe1325c 100644
--- a/src/App/ExpressionParser.h
+++ b/src/App/ExpressionParser.h
@@ -365,6 +365,9 @@ public:
HIDDENREF, // hidden reference that has no dependency check
HREF, // deprecated alias of HIDDENREF
+ // Non aggregated logical
+ NOT, // logical NOT
+
// Aggregates
AGGREGATES,
@@ -375,6 +378,10 @@ public:
STDDEV,
SUM,
+ // Logical aggregates, evaluates to {0,1}
+ AND, // logical AND
+ OR, // logical OR
+
// Last one
LAST,
};
diff --git a/src/Mod/Spreadsheet/TestSpreadsheet.py b/src/Mod/Spreadsheet/TestSpreadsheet.py
index 98b5e27e8d..961de5f282 100644
--- a/src/Mod/Spreadsheet/TestSpreadsheet.py
+++ b/src/Mod/Spreadsheet/TestSpreadsheet.py
@@ -219,6 +219,97 @@ class SpreadsheetAggregates(unittest.TestCase):
)
)
+ def test_and(self):
+ self.sheet.set("C20", "4")
+ self.sheet.set("C21", "5")
+ self.sheet.set("C22", "6")
+ self.sheet.set("C23", "0")
+
+ self.sheet.set("A1", "=and(1)")
+ self.sheet.set("A2", "=and(1;2)")
+ self.sheet.set("A3", "=and(1;2;3)")
+ self.sheet.set("A4", "=and(1;2;3;C20)")
+ self.sheet.set("A5", "=and(1;2;3;C20:C22)")
+ self.sheet.set("A6", "=and(1;2;3;C20:C23)")
+
+ self.sheet.set("B1", "=and(0)")
+ self.sheet.set("B2", "=and(0;1;2)")
+ self.sheet.set("B3", "=and(0;1;2;3)")
+ self.sheet.set("B4", "=and(1;2;0)")
+ self.sheet.set("B5", "=and(1;2;3;0)")
+ self.sheet.set("B6", "=and(1;0;2)")
+ self.sheet.set("B6", "=and(1;0;2;0;3)")
+
+ self.doc.recompute()
+
+ self.assertEqual(self.sheet.A1, 1)
+ self.assertEqual(self.sheet.A2, 1)
+ self.assertEqual(self.sheet.A3, 1)
+ self.assertEqual(self.sheet.A4, 1)
+ self.assertEqual(self.sheet.A5, 1)
+ self.assertEqual(self.sheet.A6, 0)
+
+ self.assertEqual(self.sheet.B1, 0)
+ self.assertEqual(self.sheet.B2, 0)
+ self.assertEqual(self.sheet.B3, 0)
+ self.assertEqual(self.sheet.B4, 0)
+ self.assertEqual(self.sheet.B5, 0)
+ self.assertEqual(self.sheet.B6, 0)
+
+ def test_or(self):
+ self.sheet.set("C20", "4")
+ self.sheet.set("C21", "5")
+ self.sheet.set("C22", "6")
+ self.sheet.set("C23", "0")
+ self.sheet.set("C24", "0")
+
+ self.sheet.set("A1", "=or(1)")
+ self.sheet.set("A2", "=or(1;2)")
+ self.sheet.set("A3", "=or(1;2;3)")
+ self.sheet.set("A4", "=or(1;2;3;C20)")
+ self.sheet.set("A5", "=or(1;2;3;C20:C22)")
+ self.sheet.set("A6", "=or(1;2;3;C20:C23)")
+
+ self.sheet.set("B1", "=or(0)")
+ self.sheet.set("B2", "=or(0;1;2)")
+ self.sheet.set("B3", "=or(0;1;2;3)")
+ self.sheet.set("B4", "=or(1;2;0)")
+ self.sheet.set("B5", "=or(1;2;3;0)")
+ self.sheet.set("B6", "=or(1;0;2)")
+ self.sheet.set("B6", "=or(1;0;2;0;3)")
+
+ self.sheet.set("C1", "=or(0)")
+ self.sheet.set("C2", "=or(0;0)")
+ self.sheet.set("C3", "=or(0mm;0;0)")
+ self.sheet.set("C4", "=or(0;0;0;C23)")
+ self.sheet.set("C5", "=or(0;0;0;C23:C24)")
+ self.sheet.set("C6", "=or(C23:C24)")
+ self.sheet.set("C7", "=or(C22:C24)")
+
+ self.doc.recompute()
+
+ self.assertEqual(self.sheet.A1, 1)
+ self.assertEqual(self.sheet.A2, 1)
+ self.assertEqual(self.sheet.A3, 1)
+ self.assertEqual(self.sheet.A4, 1)
+ self.assertEqual(self.sheet.A5, 1)
+ self.assertEqual(self.sheet.A6, 1)
+
+ self.assertEqual(self.sheet.B1, 0)
+ self.assertEqual(self.sheet.B2, 1)
+ self.assertEqual(self.sheet.B3, 1)
+ self.assertEqual(self.sheet.B4, 1)
+ self.assertEqual(self.sheet.B5, 1)
+ self.assertEqual(self.sheet.B6, 1)
+
+ self.assertEqual(self.sheet.C1, 0)
+ self.assertEqual(self.sheet.C2, 0)
+ self.assertEqual(self.sheet.C3, 0)
+ self.assertEqual(self.sheet.C4, 0)
+ self.assertEqual(self.sheet.C5, 0)
+ self.assertEqual(self.sheet.C6, 0)
+ self.assertEqual(self.sheet.C7, 1)
+
#############################################################################################
class SpreadsheetFunction(unittest.TestCase):
@@ -547,6 +638,35 @@ class SpreadsheetFunction(unittest.TestCase):
self.assertTrue(self.sheet.C27.startswith("ERR: Units must be equal"))
self.assertMostlyEqual(self.sheet.D27, Units.Quantity("3 mm"))
+ def test_not(self):
+ self.sheet.set("A20", "=not(3)")
+ self.sheet.set("B20", "=not(-3)")
+ self.sheet.set("C20", "=not(-3.5)")
+ self.sheet.set("D20", "=not(3mm)")
+ self.sheet.set("E20", "=not(3.5mm)")
+ self.sheet.set("F20", "=not(-3.5mm)")
+ self.sheet.set("G20", "=not(0)")
+ self.sheet.set("H20", "=not(0mm)")
+ self.sheet.set("I20", "=not(1)")
+
+ self.doc.recompute()
+
+ self.assertEqual(self.sheet.A20, 0)
+ self.assertEqual(self.sheet.B20, 0)
+ self.assertEqual(self.sheet.C20, 0)
+ self.assertEqual(self.sheet.D20, 0)
+ self.assertEqual(self.sheet.E20, 0)
+ self.assertEqual(self.sheet.F20, 0)
+ self.assertEqual(self.sheet.G20, 1)
+ self.assertEqual(self.sheet.H20, 1)
+ self.assertEqual(self.sheet.I20, 0)
+
+ self.sheet.set("J21", f"=not(not({1e-7}))")
+ self.sheet.set("J22", f"=not(not({1e-8}))")
+ self.doc.recompute()
+ self.assertEqual(self.sheet.J21, 1)
+ self.assertEqual(self.sheet.J22, 0)
+
#############################################################################################
class SpreadsheetCases(unittest.TestCase):
diff --git a/tests/src/App/Expression.cpp b/tests/src/App/Expression.cpp
index 39c3c4fb15..f3196bf322 100644
--- a/tests/src/App/Expression.cpp
+++ b/tests/src/App/Expression.cpp
@@ -5,6 +5,10 @@
#include "App/ExpressionParser.h"
#include "App/ExpressionTokenizer.h"
+// +------------------------------------------------+
+// | Note: For more expression related tests, see: |
+// | src/Mod/Spreadsheet/TestSpreadsheet.py |
+// +------------------------------------------------+
class Expression: public ::testing::Test
{