Flipped shift operator direction to match spirit
This commit is contained in:
parent
f0088d8ade
commit
fc3b9de2d2
@ -67,7 +67,7 @@ std::vector<TokenPtr> Lexer::lex(const std::string &input, const char *filename)
|
||||
}
|
||||
if ((!found_eoc) && (input_iter != input_end)) {
|
||||
++input_iter;
|
||||
current_col += 1;
|
||||
++current_col;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ struct Rule {
|
||||
return Rule(boost::bind(Or_Rule, _1, _2, _3, _4, _5, *this, rhs));
|
||||
}
|
||||
|
||||
Rule operator<<(const Rule &rhs) {
|
||||
Rule operator>>(const Rule &rhs) {
|
||||
return Rule(boost::bind(And_Rule, _1, _2, _3, _4, _5, *this, rhs));
|
||||
}
|
||||
|
||||
|
@ -53,14 +53,14 @@ void parse(std::vector<TokenPtr> &tokens, const char *filename) {
|
||||
/*
|
||||
Rule lhs;
|
||||
Rule rhs;
|
||||
Rule rule = lhs << rhs;
|
||||
Rule rule = lhs >> rhs;
|
||||
lhs = Str("def", true);
|
||||
rhs = Id(TokenType::Identifier, true);
|
||||
|
||||
//Rule rule(TokenType::Function_Def);
|
||||
//rule = Str("def") | Str("int");
|
||||
|
||||
//Rule rule = Str("def", false) << Id(TokenType::Identifier);
|
||||
//Rule rule = Str("def", false) >> Id(TokenType::Identifier);
|
||||
*/
|
||||
|
||||
|
||||
@ -73,11 +73,11 @@ void parse(std::vector<TokenPtr> &tokens, const char *filename) {
|
||||
Rule return_statement(TokenType::Return);
|
||||
Rule add(TokenType::Add);
|
||||
|
||||
rule = Ign(Str("def")) << Id(TokenType::Identifier) << ~(Ign(Str("(")) << ~params << Ign(Str(")"))) << block;
|
||||
params = Id(TokenType::Identifier) << *(Ign(Str(",")) << Id(TokenType::Identifier));
|
||||
block = Ign(Str("{")) << ~return_statement << Ign(Str("}"));
|
||||
return_statement = Ign(Str("return")) << add;
|
||||
add = Id(TokenType::Identifier) << Ign(Str("+")) << Id(TokenType::Identifier);
|
||||
rule = Ign(Str("def")) >> Id(TokenType::Identifier) >> ~(Ign(Str("(")) >> ~params >> Ign(Str(")"))) >> block;
|
||||
params = Id(TokenType::Identifier) >> *(Ign(Str(",")) >> Id(TokenType::Identifier));
|
||||
block = Ign(Str("{")) >> ~return_statement >> Ign(Str("}"));
|
||||
return_statement = Ign(Str("return")) >> add;
|
||||
add = Id(TokenType::Identifier) >> Ign(Str("+")) >> Id(TokenType::Identifier);
|
||||
|
||||
|
||||
/*
|
||||
@ -93,12 +93,12 @@ void parse(std::vector<TokenPtr> &tokens, const char *filename) {
|
||||
|
||||
/*
|
||||
Rule rule(3);
|
||||
rule = Ign(Str("Bob")) << Str("Fred");
|
||||
rule = Ign(Str("Bob")) >> Str("Fred");
|
||||
*/
|
||||
|
||||
/*
|
||||
statement = equation;
|
||||
equation = Id(TokenType::Identifier) << Str("+") << Id(TokenType::Identifier);
|
||||
equation = Id(TokenType::Identifier) >> Str("+") >> Id(TokenType::Identifier);
|
||||
*/
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user