From 13f0bdba097375e9fbeae814085c4cdcd14e8102 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Wed, 24 Jul 2019 15:27:58 +0200
Subject: [PATCH] Remove '^', '&', '|', '&&' and '||' constructions from
 PEGGrammar

In view of future use of '^' for powers and to simplify reading one will have to
use 'xor', 'and' and 'or'.

Bit-wise operators ('bitand' and 'bitor') will be suppressed in a following commit.
---
 src/language/PEGGrammar.hpp | 10 +++++-----
 tests/test_ASTBuilder.cpp   |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/language/PEGGrammar.hpp b/src/language/PEGGrammar.hpp
index 60f23afd6..56a650baa 100644
--- a/src/language/PEGGrammar.hpp
+++ b/src/language/PEGGrammar.hpp
@@ -148,12 +148,12 @@ struct postfix_expression : seq< primary_expression, star<postfix_operator> > {}
 struct unary_expression : sor< seq< unary_operator, unary_expression >,
                                postfix_expression > {};
 
-struct and_op : seq< sor<TAO_PEGTL_STRING("&&"), and_kw>, ignored > {};
-struct or_op : seq< sor<TAO_PEGTL_STRING("||"), or_kw>, ignored > {};
+struct and_op : seq< and_kw, ignored > {};
+struct or_op : seq< or_kw, ignored > {};
 
-struct xor_op : seq< sor< one< '^' >, xor_kw>, ignored >{};
-struct bitand_op : seq< sor< seq< one< '&' >, not_at< one< '&' > > >, bitand_kw>, ignored >{};
-struct bitor_op : seq< sor< seq< one< '|' >, not_at< one< '|' > > >, bitor_kw>, ignored >{};
+struct xor_op : seq< xor_kw, ignored >{};
+struct bitand_op : seq< bitand_kw, ignored >{};
+struct bitor_op : seq< bitor_kw, ignored >{};
 
 struct eqeq_op : seq< TAO_PEGTL_STRING("=="), ignored > {};
 struct not_eq_op : seq< TAO_PEGTL_STRING("!="), ignored > {};
diff --git a/tests/test_ASTBuilder.cpp b/tests/test_ASTBuilder.cpp
index 56d398395..8807bfc68 100644
--- a/tests/test_ASTBuilder.cpp
+++ b/tests/test_ASTBuilder.cpp
@@ -165,7 +165,7 @@ string s; s = "foo";
       SECTION("all operators mix")
       {
         std::string_view data = R"(
-1+2 and 3<= 2 * 4 - 1 == 2 or 2>=1 / 5 ^ 6 & 7 && 2 || 1 | 2 <3 >7 xor -2 bitand 2 bitor + true - not false;
+1+2 and 3<= 2 * 4 - 1 == 2 or 2>=1 / 5 xor 6 bitand 7 and 2 or 1 bitor 2 <3 >7 xor -2 bitand 2 bitor + true - not false;
 )";
 
         std::string_view result = R"(
-- 
GitLab