Mercurial > projects > dil
diff trunk/src/Parser.d @ 161:82c5cfc7d6d3
- Started implementation of parsing statements.
- Fix: was calling wrong method in parseDeclarationDefinitions().
- Added code for parsing LabeledStatement.
- Added class stubs for all statements in the NonEmptyStatement rule.
author | aziz |
---|---|
date | Fri, 13 Jul 2007 20:49:01 +0000 |
parents | c21192e8be2b |
children | c7b250662c74 |
line wrap: on
line diff
--- a/trunk/src/Parser.d Fri Jul 13 15:23:02 2007 +0000 +++ b/trunk/src/Parser.d Fri Jul 13 20:49:01 2007 +0000 @@ -84,7 +84,7 @@ { Declaration[] decls; while (token.type != T.RBrace && token.type != T.EOF) - decls ~= parseDeclarationDefinitions(); + decls ~= parseDeclarationDefinition(); return decls; } @@ -227,11 +227,6 @@ return decls; } - Statement[] parseStatements() - { - return null; - } - Declaration parseAttributeSpecifier() { Declaration decl; @@ -1109,6 +1104,44 @@ } /+++++++++++++++++++++++++++++ + + Statement parsing methods + + +++++++++++++++++++++++++++++/ + + Statements parseStatements() + { + Statements statements; + while (token.type != T.RBrace && token.type != T.EOF) + statements ~= parseStatement(); + return statements; + } + + Statement parseStatement() + { + Statement s; + switch (token.type) + { + case T.Identifier: + Token next; + lx.peek(next); + if (next.type == T.Colon) + { + string ident = token.identifier; + nT(); // Skip Identifier + nT(); // Skip : + s = parseStatements(); + s = new LabeledStatement(ident, s); + break; + } + goto case_Declaration; + case_Declaration: + // TODO: parse Declaration + break; + default: + } + return s; + } + + /+++++++++++++++++++++++++++++ + Expression parsing methods + +++++++++++++++++++++++++++++/