mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Finished condition parser, I think.
This commit is contained in:
@@ -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
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user