Skip to content

Commit

Permalink
#23, #25: Whitespace handling & distinguishing between lexer and parser
Browse files Browse the repository at this point in the history
mode. Still unimplemented methods in Quantifier parser.
  • Loading branch information
danieldietrich committed Sep 9, 2014
1 parent 3ea32a6 commit f6a1093
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 184 deletions.
6 changes: 4 additions & 2 deletions src/main/java/javaslang/parser/Grammar.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static javaslang.Requirements.requireNonNull;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -137,9 +138,10 @@ public Grammar(Supplier<Parser.Rule> startRuleSupplier) {
* @return A concrete syntax tree of the text on parse success or a failure if a parse error occured.
*/
public Try<Tree<Token>> parse(String text) {
final Either<Integer, Node<Token>> parseResult = startRule.parse(text, 0, false);
final Either<Integer, List<Node<Token>>> parseResult = startRule.parse(text, 0, false);
if (parseResult.isRight()) {
final Tree<Token> concreteSyntaxTree = parseResult.right().get().asTree();
// DEV-NODE: a Rule returns a CST with one node => head() is result
final Tree<Token> concreteSyntaxTree = parseResult.get().get(0).asTree();
return new Success<>(concreteSyntaxTree);
} else {
final int index = parseResult.left().get();
Expand Down

0 comments on commit f6a1093

Please sign in to comment.