Skip to content
Browse files

Changing stuff again

  • Loading branch information...
1 parent 367a969 commit f203065469ff2d1016d22ad51747d19a14706c21 @javawizard committed Mar 20, 2012
View
8 afn/java/src/afn/parcon/Parsers.java → afn/java/src/afn/parcon/Functions.java
@@ -1,6 +1,6 @@
package afn.parcon;
-public class Parsers {
+public class Functions {
public static Literal literal(String text) {
return new Literal(text);
}
@@ -16,4 +16,10 @@ public static Literal significant(String text) {
public static First first(Parser... parsers) {
return new First(parsers);
}
+
+ public static Parser promote(Object o) {
+ if (o instanceof String)
+ return literal((String) o);
+ return (Parser) o;
+ }
}
View
42 afn/java/src/afn/parcon/InfixExpr.java
@@ -0,0 +1,42 @@
+package afn.parcon;
+
+import static afn.parcon.Functions.literal;
+
+public class InfixExpr extends Parser {
+ public static class Operator {
+ public Parser parser;
+ public TwoFunction function;
+
+ public Operator(Parser parser, TwoFunction function) {
+ this.parser = parser;
+ this.function = function;
+ }
+
+ public Operator(String text, TwoFunction function) {
+ this(literal(text), function);
+ }
+ }
+
+ public static Operator op(Parser parser, TwoFunction function) {
+ return new Operator(parser, function);
+ }
+
+ public static Operator op(String text, TwoFunction function) {
+ return new Operator(text, function);
+ }
+
+ private Parser component;
+ private Operator[] operators;
+
+ public InfixExpr(Parser component, Operator... operators) {
+ this.component = component;
+ this.operators = operators;
+ }
+
+ @Override
+ public Result parse(String text, int position, int end, Parser space) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
View
2 afn/java/src/afn/parcon/examples/Test1.java
@@ -1,6 +1,6 @@
package afn.parcon.examples;
-import static afn.parcon.Parsers.*;
+import static afn.parcon.Functions.*;
import afn.parcon.Parser;
public class Test1 {

0 comments on commit f203065

Please sign in to comment.
Something went wrong with that request. Please try again.