Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X3 examples sio fixes #334

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/x3/calc/calc7/expression_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace client
{
calculator_grammar::expression_type expression()
{
return calculator_grammar::expression;
return {"expression"};
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/x3/calc/calc8/expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace client
BOOST_SPIRIT_DECLARE(expression_type);
}

parser::expression_type const& expression();
parser::expression_type expression();
}

#endif
4 changes: 2 additions & 2 deletions example/x3/calc/calc8/expression_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ namespace client { namespace parser

namespace client
{
parser::expression_type const& expression()
parser::expression_type expression()
{
return parser::expression;
return {"expression"};
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/x3/calc/calc8/statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace client
BOOST_SPIRIT_DECLARE(statement_type);
}

parser::statement_type const& statement();
parser::statement_type statement();
}

#endif
4 changes: 2 additions & 2 deletions example/x3/calc/calc8/statement_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace client { namespace parser
variable_type const variable = "variable";

// Import the expression rule
namespace { auto const& expression = client::expression(); }
namespace { auto expression = client::expression(); }

auto const statement_list_def =
+(variable_declaration | assignment)
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace client { namespace parser

namespace client
{
parser::statement_type const& statement()
parser::statement_type statement()
{
return parser::statement;
}
Expand Down
2 changes: 1 addition & 1 deletion example/x3/calc/calc9/expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace client
BOOST_SPIRIT_DECLARE(expression_type);
}

parser::expression_type const& expression();
parser::expression_type expression();
}

#endif
100 changes: 50 additions & 50 deletions example/x3/calc/calc9/expression_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,54 +36,55 @@ namespace client { namespace parser
x3::symbols<ast::optoken> unary_op;
x3::symbols<> keywords;

void add_keywords()
namespace
{
static bool once = false;
if (once)
return;
once = true;

logical_op.add
("&&", ast::op_and)
("||", ast::op_or)
;

equality_op.add
("==", ast::op_equal)
("!=", ast::op_not_equal)
;

relational_op.add
("<", ast::op_less)
("<=", ast::op_less_equal)
(">", ast::op_greater)
(">=", ast::op_greater_equal)
;

additive_op.add
("+", ast::op_plus)
("-", ast::op_minus)
;

multiplicative_op.add
("*", ast::op_times)
("/", ast::op_divide)
;

unary_op.add
("+", ast::op_positive)
("-", ast::op_negative)
("!", ast::op_not)
;

keywords.add
("var")
("true")
("false")
("if")
("else")
("while")
;
struct add_keywords
{
add_keywords() {
logical_op.add
("&&", ast::op_and)
("||", ast::op_or)
;

equality_op.add
("==", ast::op_equal)
("!=", ast::op_not_equal)
;

relational_op.add
("<", ast::op_less)
("<=", ast::op_less_equal)
(">", ast::op_greater)
(">=", ast::op_greater_equal)
;

additive_op.add
("+", ast::op_plus)
("-", ast::op_minus)
;

multiplicative_op.add
("*", ast::op_times)
("/", ast::op_divide)
;

unary_op.add
("+", ast::op_positive)
("-", ast::op_negative)
("!", ast::op_not)
;

keywords.add
("var")
("true")
("false")
("if")
("else")
("while")
;
}

} init_helper;
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -172,10 +173,9 @@ namespace client { namespace parser

namespace client
{
parser::expression_type const& expression()
parser::expression_type expression()
{
parser::add_keywords();
return parser::expression;
return {"expression"};
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/x3/calc/calc9/statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace client
BOOST_SPIRIT_DECLARE(statement_type);
}

parser::statement_type const& statement();
parser::statement_type statement();
}

#endif
7 changes: 4 additions & 3 deletions example/x3/calc/calc9/statement_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace client { namespace parser
variable_type const variable("variable");

// Import the expression rule
namespace { auto const& expression = client::expression(); }
namespace { auto expression = client::expression(); }

auto const statement_list_def =
+(variable_declaration | assignment)
Expand Down Expand Up @@ -75,9 +75,10 @@ namespace client { namespace parser

namespace client
{
parser::statement_type const& statement()
parser::statement_type statement()
{
return parser::statement;
//return parser::statement;
return {"statement"};
}
}

Expand Down