Finished condition parser, I think.

This commit is contained in:
WrinklyNinja
2013-01-07 21:04:17 +00:00
parent 7ca6becb50
commit b4202b7703
2 changed files with 6 additions and 4 deletions
+1
View File
@@ -310,6 +310,7 @@ becomes
<tr><td><code>C or C and C or C</code><td><code>( ( C or ( C and C ) ) or C )</code>
<tr><td><code>C or C and C and C</code><td><code>( C or ( ( C and C ) and C ) )</code>
</table>
<p>You can also explicitly enclose any condition in brackets to override the evaluation order, eg. <code>C and ( C or C )</code> is evaluated as <code>C and ( C or C )</code> (contrast with the unbracketed string above).
<h2>Language Codes</h2>
<p>BOSS supports the following languages and language codes:
+5 -4
View File
@@ -300,18 +300,19 @@ namespace boss {
condition_grammar() : condition_grammar::base_type(expression, "condition grammar") {
expression =
andStatement
>> *(qi::lit("or") >> andStatement)
andStatement [qi::labels::_val = qi::labels::_1]
>> *((qi::lit("or") >> andStatement) [qi::labels::_val = qi::labels::_val || qi::labels::_1])
;
andStatement =
condition
>> *(qi::lit("and") >> condition)
condition [qi::labels::_val = qi::labels::_1]
>> *((qi::lit("and") >> condition) [qi::labels::_val = qi::labels::_val && qi::labels::_1])
;
condition =
( qi::lit("if") >> type ) [qi::labels::_val = qi::labels::_1]
| ( qi::lit("ifnot") >> type ) [qi::labels::_val = !qi::labels::_1]
| ( '(' >> expression >> ')' ) [qi::labels::_val = qi::labels::_1] //This *should* handle the "brackets override operators" rule.
;
type =