Added Kleene star, plus, and optional

This commit is contained in:
Jonathan Turner
2009-05-28 12:49:17 +00:00
parent 5f6ec9521b
commit af9bd41221
3 changed files with 114 additions and 7 deletions

View File

@@ -65,11 +65,11 @@ void parse(std::vector<TokenPtr> &tokens) {
//Example: "def add(x,y)"
//To do the params for real we need kleene star and other looping parsers
Rule params;
Rule rule(TokenType::Function_Def);
rule = Ign(Str("def")) << Id(TokenType::Identifier) << Ign(Str("(")) << params << Ign(Str(")"));
params = Id(TokenType::Identifier) << Ign(Str(",")) << Id(TokenType::Identifier);
rule = Ign(Str("def")) << Id(TokenType::Identifier) << ~(Ign(Str("(")) << ~params << Ign(Str(")")));
params = Id(TokenType::Identifier) << *(Ign(Str(",")) << Id(TokenType::Identifier));
Token_Iterator iter = tokens.begin(), end = tokens.end();
TokenPtr parent(new Token("Root", 0, "test"));