Commit 8141d7f8 authored by Fred Eisele's avatar Fred Eisele
Browse files

set up data structures for parser

parent 80fda2ea
......@@ -76,7 +76,14 @@ public class Program<X> implements Prog {
public Program(List<Triple<String, Integer, X>> decls, String text) {
this(decls, text, Collections.emptyList(), x -> "");
}
/**
* The main program constructor.
*
* @param decls
* @param text
* @param options
* @param k
*/
public Program(List<Triple<String, Integer, X>> decls, String text,
List<Pair<String, String>> options, Function<X, String> k) {
this.text = text;
......
package catdata.aql.exp;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.antlr.v4.misc.OrderedHashMap;
import org.antlr.v4.runtime.CommonTokenStream;
......@@ -10,8 +13,10 @@ import org.antlr.v4.runtime.tree.ParseTreeProperty;
import org.jparsec.error.ParserException;
import catdata.aql.grammar.AqlParserBaseListener;
import catdata.Pair;
import catdata.ParseException;
import catdata.Program;
import catdata.Triple;
import catdata.aql.grammar.AqlLexerRules;
import catdata.aql.grammar.AqlParser;
......@@ -32,15 +37,22 @@ public class AqlLoader extends AqlParserBaseListener {
this.tokens = new CommonTokenStream(lexer);
this.parser = new AqlParser(tokens);
this.tree = parser.program();
this.decls = new LinkedList<Triple<String, Integer, Exp<?>>>();
this.text = "";
this.options = new LinkedList<Pair<String, String>>();
this.k = q -> q.kind().toString();
}
Map<String,String> props = new OrderedHashMap<String, String>();
//Program<Exp<?>> program = new Program;
ParseTreeProperty<String> values = new ParseTreeProperty<String>();
// Map<String,String> props = new OrderedHashMap<String, String>();
final List<Triple<String, Integer, Exp<?>>> decls;
String text;
final List<Pair<String, String>> options;
Function<Exp<?>, String> k;
public Program<Exp<?>> parseProgram() throws ParseException {
try {
return null; // program(s).from(TOKENIZER, IGNORED).parse(s);
return new Program<>(decls, text, options, k);
} catch (ParserException e) {
throw new ParseException(e.getLocation().column, e.getLocation().line, e);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment