diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e92f57 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tags diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..25720ea --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +language: java +script: ant test diff --git a/README.md b/README.md index 100f3de..5717b84 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,268 @@ -wdl -=== +Workflow Description Language (wdl) +=================================== -Workflow Description Language \ No newline at end of file +The Workflow Description Language is a language for describing dependency trees of tasks (algorithms) in a concise and clear syntax. + +Installation +============ + +Generating the JAR +------------------ + +To build the JAR file, run: + +``` +$ mvn package +``` + +Which will create a file target/Wdl-${version}.jar as an executable JAR. To invoke the CLI: + +``` +$ java -jar target/Wdl-0.0.1.jar examples/0.wdl ast +``` + +Generating the parser code +-------------------------- + +Use the Hermes parser generator (http://github.com/scottfrazer/hermes). From the root of this repository, run: + +``` +$ hermes generate grammars/composite_task.zgr --directory=src/main/java/org/broadinstitute/compositetask --language=java --java-package=org.broadinstitute.compositetask +``` + +Or, run the Ant target `generate-parser` which will run the command above: + +``` +$ ant generate-parser +``` + +Usage +===== + +Java API +-------- + +From Java code, the main interface is the CompositeTask, which can be used in this example to print out the immediate children nodes of this composite task: + +```java +CompositeTask ct = new CompositeTask(new File(args[0])); +for ( CompositeTaskNode entry : ct.getNodes() ) { + System.out.println("Node: " + entry); +} +``` + +Command-line Interface +---------------------- + +The data file we'll use is: + +``` +$ cat examples/7.wdl +composite_task test { + step s0[version=0] { + output: File("abc") as foo; + } + + for (I in L) { + for (J in M) { + step s1[version=0] { + input: p0=I, p1=J, p2=foo; + output: File("def") as bar; + } + } + } + + step s2[version=0] { + input: p0=bar; + } +} +``` + +Get the abstract syntax tree: + +``` +$ java -jar dist/Wdl-0.0.1.jar examples/7.wdl ast +(CompositeTask: + body=[ + (Step: + body=[ + (StepOutputList: + outputs=[ + (StepFileOutput: + as=(Variable: + member=None, + name=identifier + ), + file=string + ) + ] + ) + ], + task=(Task: + attributes=[ + (TaskAttribute: + value=number, + key=identifier + ) + ], + name=identifier + ), + name=None + ), + (ForLoop: + body=[ + (ForLoop: + body=[ + (Step: + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + member=None, + name=identifier + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + member=None, + name=identifier + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + member=None, + name=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepFileOutput: + as=(Variable: + member=None, + name=identifier + ), + file=string + ) + ] + ) + ], + task=(Task: + attributes=[ + (TaskAttribute: + value=number, + key=identifier + ) + ], + name=identifier + ), + name=None + ) + ], + item=identifier, + collection=identifier + ) + ], + item=identifier, + collection=identifier + ), + (Step: + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + member=None, + name=identifier + ) + ) + ] + ) + ], + task=(Task: + attributes=[ + (TaskAttribute: + value=number, + key=identifier + ) + ], + name=identifier + ), + name=None + ) + ], + name=identifier +) +``` + +Get a view of the graph + +``` +$ java -jar dist/Wdl-0.0.1.jar examples/7.wdl graph +VERTICIES +--------- +[Step: name=s1] +[Variable: name=J] +[Variable: name=M] +[Variable: name=I] +[Variable: name=L] +[Variable: name=foo] +[Step: name=s0] +[Variable: name=bar] +[Step: name=s2] +[CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1] + +EDGES +----- +[Edge + from: [Step: name=s1] + to: [Variable: name=bar] +] +[Edge + from: [Variable: name=L] + to: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] +] +[Edge + from: [Variable: name=bar] + to: [Step: name=s2] +] +[Edge + from: [Variable: name=foo] + to: [Step: name=s1] +] +[Edge + from: [Step: name=s0] + to: [Variable: name=foo] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1] + to: [Variable: name=J] +] +[Edge + from: [Variable: name=J] + to: [Step: name=s1] +] +[Edge + from: [Variable: name=M] + to: [CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] + to: [Step: name=s2] +] +[Edge + from: [Variable: name=I] + to: [Step: name=s1] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] + to: [Variable: name=I] +] +``` diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..53fba5e --- /dev/null +++ b/build.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/examples/CopyNumberQC.wdl b/examples/CopyNumberQC.wdl new file mode 100644 index 0000000..7200425 --- /dev/null +++ b/examples/CopyNumberQC.wdl @@ -0,0 +1,18 @@ +composite_task CopyNumberQC { + step LaneBlackList[version=6] { + output: File("lane_blacklist.txt") as lane_blacklist; + } + for ( sample in samples ) { + step RegionCovPerLane[version=16] { + input: bam_file=sample.bam, sample_id=sample.id; + output: File("${sample.id}.rcl") into rcl; + } + step MakeLaneList[version=11] { + input: bam_file=sample.bam, sample_id=sample.id; + output: File("${sample.id}.lanelist") into lanelist; + } + } + step CopyNumberQC[version=25] { + input: lanes_list=lanelist, rcl_list=rcl, lane_blacklist=lane_blacklist; + } +} diff --git a/examples/MutSig.wdl b/examples/MutSig.wdl new file mode 100644 index 0000000..7ae645c --- /dev/null +++ b/examples/MutSig.wdl @@ -0,0 +1,27 @@ +/* inputs: + * 1) MutSigPreprocess.{individual_set_id, maf1, maf2, maf3, maf4, maflabel1, maflabel2, maflabel3, maflabel4, wig1, wig2, wig3, wig4, build, context65_dir, build_dir, num_categories, target_list, paramfile} + * 2) ProcessCoverageForMutSig has no variables. All inputs come from prior step. + * 3) MutSigRun.{individual_set_id, gene_list, build, geneset_file, cosmic_file, refseq_file, build_dir, param_file, jobcount} + */ + +composite_task MutSig { + + step MutSigPreprocess[version=86] { + output: File("coverage.prepare.txt") as coverage_prepare_file, + File("patients.txt") as patient_list, + File("${individual_set_id}.maf") as mutation_list, + File("mutation_preprocessing_report.txt") as mutation_preprocessing_report; + } + + step ProcessCoverageForMutSig[version=75] { + input: coverage=coverage_prepare_file, patients=patient_list, mutations=mutation_list; + output: File("coverage.mat") as coverage_file, + File("mutcategs.txt") as category_file; + } + + step MutSigRun[version=157] as MutSig { + input: mutation_list=mutation_list, coverage_file=coverage_file, patients=patient_list, category_file=category_file, mutation_preprocessing_report=foobar; + output: File("bargraphs.png") as graphs; + } + +} diff --git a/grammars/composite_task.zgr b/grammars/composite_task.zgr new file mode 100644 index 0000000..2e08bad --- /dev/null +++ b/grammars/composite_task.zgr @@ -0,0 +1,28 @@ +{ + "ll1": { + "start": "wdl", + "rules": [ + "wdl := list(wdl_entity)", + "wdl_entity := composite_task", + "composite_task := 'composite_task' + 'identifier' + 'lbrace' + list(composite_task_entity) + 'rbrace' -> CompositeTask( name=$1, body=$3 )", + "composite_task_entity := step | for_loop | composite_task", + "for_loop := 'for' + 'lparen' + 'identifier' + 'in' + 'identifier' + 'rparen' + 'lbrace' + list(composite_task_entity) + 'rbrace' -> ForLoop( collection=$4, item=$2, body=$7 )", + "step := 'step' + task_identifier + optional(step_name) + 'lbrace' + list(step_attr) + 'rbrace' -> Step( task=$1, name=$2, body=$4 )", + "task_identifier := 'identifier' + optional(task_attrs) -> Task(name=$0, attributes=$1)", + "task_attrs := 'lsquare' + list(task_attr) + 'rsquare' -> $1", + "task_attr := 'identifier' + 'assign' + task_attr_value -> TaskAttribute(key=$0, value=$2)", + "task_attr_value := 'identifier' | 'string' | 'number'", + "step_name := 'as' + 'identifier' -> $1", + "step_attr := step_input_list | step_output_list", + "step_input_list := 'input' + 'colon' + list(step_input, 'comma') + 'semi' -> StepInputList( inputs=$2 )", + "step_input := 'identifier' + 'assign' + variable -> StepInput(parameter=$0, value=$2)", + "step_output_list := 'output' + 'colon' + list(step_output, 'comma') + 'semi' -> StepOutputList( outputs=$2 )", + "step_output := step_output_mode + 'lparen' + 'string' + 'rparen' + step_output_location -> StepOutput( mode=$0, expression=$2, var=$4 )", + "step_output_mode := 'file' | 'first_line'", + "step_output_location := 'as' + variable -> OutputVariable( var=$1 )", + "step_output_location := 'into' + variable -> OutputListAppend( var=$1 )", + "variable := 'identifier' + optional(variable_member) -> Variable(name=$0, member=$1)", + "variable_member := 'dot' + 'identifier -> $1" + ] + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..259f3ad --- /dev/null +++ b/pom.xml @@ -0,0 +1,59 @@ + + + + UTF-8 + + + 4.0.0 + org.broadinstitute.compositetask + Wdl + jar + 0.0.2 + Wdl + http://github.com/broadinstitute/wdl + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + + org.broadinstitute.compositetask.Main + + + + + + + org.codehaus.mojo + versions-maven-plugin + 1.3.1 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + private + true + + + + + + + + org.testng + testng + 6.8 + test + + + + diff --git a/src/main/java/org/broadinstitute/compositetask/AnsiColorizer.java b/src/main/java/org/broadinstitute/compositetask/AnsiColorizer.java new file mode 100644 index 0000000..e291203 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/AnsiColorizer.java @@ -0,0 +1,27 @@ +package org.broadinstitute.compositetask; + +public class AnsiColorizer implements CompositeTaskColorizer { + public String preamble() { + return ""; + } + + public String postamble() { + return ""; + } + + public String keyword(String str) { + return "\033[38;5;109m" + str + "\033[0m"; + } + + public String string(String str) { + return "\033[38;5;222m" + str + "\033[0m"; + } + + public String variable(String str) { + return "\033[38;5;143m" + str + "\033[0m"; + } + + public String task(String str) { + return "\033[38;5;139m" + str + "\033[0m"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/ColorTheme.java b/src/main/java/org/broadinstitute/compositetask/ColorTheme.java new file mode 100644 index 0000000..bab51f8 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/ColorTheme.java @@ -0,0 +1,9 @@ +package org.broadinstitute.compositetask; + +import java.awt.Color; + +import org.broadinstitute.parser.Terminal; + +public interface ColorTheme { + Color getColor(Terminal terminal); +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTask.java b/src/main/java/org/broadinstitute/compositetask/CompositeTask.java new file mode 100644 index 0000000..c1abb17 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTask.java @@ -0,0 +1,407 @@ +package org.broadinstitute.compositetask; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.HashMap; +import java.util.Iterator; + +import org.broadinstitute.parser.Ast; +import org.broadinstitute.parser.AstNode; +import org.broadinstitute.parser.AstList; +import org.broadinstitute.parser.ParseTree; +import org.broadinstitute.parser.ParseTreeNode; +import org.broadinstitute.parser.SourceCode; +import org.broadinstitute.parser.Terminal; +import org.broadinstitute.parser.SyntaxError; +import org.broadinstitute.parser.CompositeTaskParser; +import org.broadinstitute.parser.TokenStream; + +public class CompositeTask implements CompositeTaskScope { + + private ParseTree parse_tree; + private Ast ast; + private WdlSyntaxErrorFormatter error_formatter; + private Set nodes; + private String name; + private CompositeTaskScope parent; + + private class CompositeTaskAstVerifier { + private WdlSyntaxErrorFormatter syntaxErrorFormatter; + private Map variables; + private Map output_variables; + private Map output_files; + private Map step_names; + + CompositeTaskAstVerifier(WdlSyntaxErrorFormatter syntaxErrorFormatter) { + this.syntaxErrorFormatter = syntaxErrorFormatter; + this.variables = new HashMap(); + this.output_variables = new HashMap(); + this.output_files = new HashMap(); + this.step_names = new HashMap(); + } + + public Ast verify(AstNode wdl_ast) throws SyntaxError { + Ast composite_task = null; + + if ( wdl_ast instanceof AstList ) { + if ( ((AstList) wdl_ast).size() != 1 ) { + throw new SyntaxError("Source code must contain only one top level composite_task definition."); + } + + composite_task = (Ast) ((AstList) wdl_ast).get(0); + } else if (wdl_ast instanceof Ast) { + composite_task = (Ast) wdl_ast; + String node_type = composite_task.getName(); + if (!node_type.equals("CompositeTask")) { + throw new SyntaxError("Source code does not contain a composite task definition"); + } + } else { + throw new SyntaxError("Unknown syntax error"); + } + + AstList ctNodes = (AstList) composite_task.getAttribute("body"); + CompositeTask.this.nodes = new LinkedHashSet(); + CompositeTask.this.name = ((Terminal) composite_task.getAttribute("name")).getSourceString(); + + for ( AstNode ctNode : ctNodes ) { + Ast node = (Ast) ctNode; + CompositeTask.this.nodes.add(verify(node)); + } + + set_parents(CompositeTask.this); + + return composite_task; + } + + private void set_parents(CompositeTaskScope scope) { + for ( CompositeTaskNode node : scope.getNodes() ) { + node.setParent(scope); + if ( node instanceof CompositeTaskScope ) { + set_parents((CompositeTaskScope) node); + } + } + } + + private CompositeTaskVariable make_variable(String name, String member) { + String key = name + ((member == null) ? "" : member); + if ( !this.variables.containsKey(key) ) { + this.variables.put(key, new CompositeTaskVariable(name, member)); + } + return this.variables.get(key); + } + + private CompositeTaskVariable ast_to_variable(Ast ast) { + Terminal name = (Terminal) ast.getAttribute("name"); + Terminal member = (Terminal) ast.getAttribute("member"); + return make_variable(name.getSourceString(), (member == null) ? null : member.getSourceString()); + } + + private CompositeTaskNode verify(Ast ast) throws SyntaxError { + if ( ast.getName().equals("Step") ) { + return verify_step(ast); + } else if ( ast.getName().equals("ForLoop") ) { + return verify_for(ast); + } else if ( ast.getName().equals("CompositeTask") ) { + return verify_composite_task(ast); + } else { + throw new SyntaxError("Unknown node found in abstract syntax tree."); + } + } + + private CompositeTaskStep verify_step(Ast step) throws SyntaxError { + Ast task = (Ast) step.getAttribute("task"); + Terminal task_name = getTaskName(task); + Terminal task_version = getTaskVersion(task); + + if ( task_version == null ) { + throw new SyntaxError(this.syntaxErrorFormatter.missing_version(task_name)); + } + + CompositeTaskSubTask subtask = new CompositeTaskSubTask( + task_name.getSourceString(), + task_version.getSourceString() + ); + + Terminal name_terminal; + if ( step.getAttribute("name") != null ) { + name_terminal = (Terminal) step.getAttribute("name"); + } else { + name_terminal = task_name; + } + + String name = name_terminal.getSourceString(); + if ( this.step_names.containsKey(name) ) { + throw new SyntaxError(this.syntaxErrorFormatter.duplicate_step_names(name_terminal, this.step_names.get(name))); + } + this.step_names.put(name, name_terminal); + + Set step_inputs = new LinkedHashSet(); + Set step_outputs = new LinkedHashSet(); + + AstList body = (AstList) step.getAttribute("body"); + + if ( body != null ) { + for ( AstNode entry : body ) { + Ast entry_ast = (Ast) entry; + + if ( entry_ast.getName().equals("StepInputList") ) { + AstList input_list = (AstList) entry_ast.getAttribute("inputs"); + for ( AstNode input_node : input_list ) { + Ast input = (Ast) input_node; + Terminal parameter = (Terminal) input.getAttribute("parameter"); + CompositeTaskVariable variable = ast_to_variable((Ast) input.getAttribute("value")); + step_inputs.add( new CompositeTaskStepInput(parameter.getSourceString(), variable) ); + } + } + + if ( entry_ast.getName().equals("StepOutputList") ) { + AstList output_list = (AstList) entry_ast.getAttribute("outputs"); + for ( AstNode output_node : output_list ) { + Ast output = (Ast) output_node; + Terminal filepath = (Terminal) output.getAttribute("expression"); + Ast step_output = (Ast) output.getAttribute("var"); + String mode = ((Terminal) output.getAttribute("mode")).getSourceString(); + + CompositeTaskVariable variable = ast_to_variable((Ast) step_output.getAttribute("var")); + Terminal variable_terminal = (Terminal) ((Ast) ((Ast) output.getAttribute("var")).getAttribute("var")).getAttribute("name"); + String method = null; + + if ( step_output.getName().equals("OutputVariable") ) { + method = "assign"; + } else if ( step_output.getName().equals("OutputListAppend") ) { + method = "append"; + } + + if (this.output_variables.containsKey(variable)) { + throw new SyntaxError(this.syntaxErrorFormatter.duplicate_output_variable(variable_terminal, this.output_variables.get(variable))); + } else { + this.output_variables.put(variable, variable_terminal); + } + + if (this.output_files.containsKey(filepath.getSourceString())) { + // We don't need this syntax error anymore, but perhaps useful in the future. */ + /* throw new SyntaxError( + this.syntaxErrorFormatter.duplicate_output_file(filepath, this.output_files.get(filepath.getSourceString()))); + */ + } else { + this.output_files.put(filepath.getSourceString(), filepath); + } + + step_outputs.add( new CompositeTaskStepOutput(mode, method, filepath.getSourceString(), variable) ); + } + } + } + } + + return new CompositeTaskStep(name, subtask, step_inputs, step_outputs); + } + + private CompositeTaskForLoop verify_for(Ast for_node_ast) throws SyntaxError { + Set nodes = new LinkedHashSet(); + + String collection = ((Terminal) for_node_ast.getAttribute("collection")).getSourceString(); + String item = ((Terminal) for_node_ast.getAttribute("item")).getSourceString(); + CompositeTaskVariable collection_var = make_variable(collection, null); + CompositeTaskVariable item_var = make_variable(item, null); + + for ( AstNode for_sub_node : (AstList) for_node_ast.getAttribute("body") ) { + CompositeTaskNode sub_node = verify((Ast) for_sub_node); + + if ( sub_node instanceof CompositeTaskStep ) { + CompositeTaskStep step = (CompositeTaskStep) sub_node; + boolean found = false; + for ( CompositeTaskStepInput input : step.getInputs() ) { + if (input.getVariable().getName().equals(item_var.getName())) { + found = true; + } + } + + if ( !found ) { + throw new SyntaxError(this.syntaxErrorFormatter.step_doesnt_use_loop_iterator((Terminal) for_node_ast.getAttribute("item"), this.step_names.get(step.getName()))); + } + } + + nodes.add(sub_node); + } + + return new CompositeTaskForLoop(collection_var, item_var, nodes); + } + + private CompositeTask verify_composite_task(Ast ast) throws SyntaxError { + Set nodes = new LinkedHashSet(); + Terminal ctName = (Terminal) ast.getAttribute("name"); + + for ( AstNode sub : (AstList) ast.getAttribute("body") ) { + nodes.add( verify((Ast) sub) ); + } + + return new CompositeTask(ctName.getSourceString(), nodes); + } + + private Terminal getTaskName(Ast task) { + return (Terminal) task.getAttribute("name"); + } + + private Terminal getTaskVersion(Ast task) { + AstList task_attrs = (AstList) task.getAttribute("attributes"); + + if ( task_attrs != null ) { + for ( AstNode task_attr : task_attrs ) { + Terminal key = (Terminal) ((Ast) task_attr).getAttribute("key"); + Terminal value = (Terminal) ((Ast) task_attr).getAttribute("value"); + if ( key.getSourceString().equals("version") ) { + return value; + } + } + } + + return null; + } + } + + /** Constructors **/ + + private CompositeTask(String name, Set nodes) { + this.name = name; + this.nodes = nodes; + this.parent = null; + } + + public CompositeTask(SourceCode source_code) throws SyntaxError { + this.error_formatter = new WdlSyntaxErrorFormatter(); + this.error_formatter.setSourceCode(source_code); + ParseTreeNode node = getParseTree(source_code); + this.parse_tree = (ParseTree) node; + AstList ast_list = (AstList) node.toAst(); + CompositeTaskAstVerifier verifier = new CompositeTaskAstVerifier(this.error_formatter); + this.ast = verifier.verify(ast_list); + this.parent = null; + } + + public CompositeTask(File source_code, String resource) throws SyntaxError, IOException { + this(new CompositeTaskSourceCode(source_code, resource)); + } + + public CompositeTask(File source_code) throws SyntaxError, IOException { + this(new CompositeTaskSourceCode(source_code)); + } + + public CompositeTask(String source_code, String resource) throws SyntaxError { + this(new CompositeTaskSourceCode(source_code, resource)); + } + + /** Public Methods **/ + + public ParseTree getParseTree() { + return this.parse_tree; + } + + public String getName() { + return this.name; + } + + public Set getNodes() { + return this.nodes; + } + + public CompositeTaskGraph getGraph() { + return new CompositeTaskGraph(this); + } + + public CompositeTaskStep getStep(String name) { + return getStep(this, name); + } + + public Set getTasks() { + return getTasks(this); + } + + public Ast getAst() { + return this.ast; + } + + public void setName(String name) { + this.name = name; + } + + public void addNode(CompositeTaskNode node) { + } + + public void setParent(CompositeTaskScope parent) { + this.parent = parent; + } + + public CompositeTaskScope getParent() { + return this.parent; + } + + public boolean contains(CompositeTaskNode node) { + for ( CompositeTaskNode sub_node : this.nodes ) { + if ( node.equals(sub_node) ) { + return true; + } + + if ( sub_node instanceof CompositeTaskScope ) { + CompositeTaskScope scope = (CompositeTaskScope) sub_node; + if ( scope.contains(node) ) { + return true; + } + } + } + return false; + } + + public int compareTo(CompositeTaskVertex other) { + return this.toString().compareTo(other.toString()); + } + + public String toString() { + return "[CompositeTask name="+this.name+"]"; + } + + /** Private methods **/ + + private ParseTreeNode getParseTree(SourceCode source_code) throws SyntaxError { + CompositeTaskParser parser = new CompositeTaskParser(this.error_formatter); + Lexer lexer = new Lexer(); + List terminals = lexer.getTokens(source_code); + TokenStream tokens = new TokenStream(terminals); + return parser.parse(tokens); + } + + private static Set getTasks(CompositeTaskScope scope) { + Set tasks = new HashSet(); + for ( CompositeTaskNode node : scope.getNodes() ) { + if ( node instanceof CompositeTaskStep ) { + CompositeTaskStep step = (CompositeTaskStep) node; + tasks.add(step.getTask()); + } else if ( node instanceof CompositeTaskScope ) { + CompositeTaskScope subScope = (CompositeTaskScope) node; + tasks.addAll( getTasks(subScope) ); + } + } + return tasks; + } + + private static CompositeTaskStep getStep(CompositeTaskScope scope, String name) { + for ( CompositeTaskNode node : scope.getNodes() ) { + if ( node instanceof CompositeTaskStep ) { + CompositeTaskStep step = (CompositeTaskStep) node; + if ( step.getName().equals(name) ) { + return step; + } + } else if ( node instanceof CompositeTaskScope ) { + CompositeTaskStep step = getStep((CompositeTaskScope) node, name); + if ( step != null ) { + return step; + } + } + } + return null; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskColorizer.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskColorizer.java new file mode 100644 index 0000000..4d6ea8d --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskColorizer.java @@ -0,0 +1,10 @@ +package org.broadinstitute.compositetask; + +public interface CompositeTaskColorizer { + public String preamble(); + public String postamble(); + public String keyword(String str); + public String string(String str); + public String variable(String str); + public String task(String str); +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskEdge.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskEdge.java new file mode 100644 index 0000000..0ae13c4 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskEdge.java @@ -0,0 +1,35 @@ +package org.broadinstitute.compositetask; + +public class CompositeTaskEdge implements Comparable { + private CompositeTaskVertex start; + private CompositeTaskVertex end; + + CompositeTaskEdge(CompositeTaskVertex start, CompositeTaskVertex end) { + this.start = start; + this.end = end; + } + + public CompositeTaskVertex getStart() { + return this.start; + } + + public CompositeTaskVertex getEnd() { + return this.end; + } + + public void setStart(CompositeTaskVertex start) { + this.start = start; + } + + public void setEnd(CompositeTaskVertex end) { + this.end = end; + } + + public int compareTo(CompositeTaskEdge other) { + return this.toString().compareTo(other.toString()); + } + + public String toString() { + return "[Edge\n from: "+this.start+"\n to: "+this.end+"\n]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskEdgeFactory.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskEdgeFactory.java new file mode 100644 index 0000000..4282cf8 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskEdgeFactory.java @@ -0,0 +1,8 @@ +package org.broadinstitute.compositetask; + +public class CompositeTaskEdgeFactory implements EdgeFactory +{ + public CompositeTaskEdge createEdge(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + return new CompositeTaskEdge(sourceVertex, targetVertex); + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskForLoop.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskForLoop.java new file mode 100644 index 0000000..36cedc2 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskForLoop.java @@ -0,0 +1,68 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +import org.broadinstitute.parser.Ast; +import org.broadinstitute.parser.AstList; + +public class CompositeTaskForLoop implements CompositeTaskScope { + private CompositeTaskVariable collection; + private CompositeTaskVariable var; + private Set nodes; + private CompositeTaskScope parent; + + public CompositeTaskForLoop(CompositeTaskVariable collection, CompositeTaskVariable var, Set nodes) { + this.collection = collection; + this.var = var; + this.nodes = nodes; + this.parent = null; + } + + public Ast getAst() { + return null; + } + + public CompositeTaskVariable getCollection() { + return this.collection; + } + + public CompositeTaskVariable getVariable() { + return this.var; + } + + public Set getNodes() { + return this.nodes; + } + + public void setParent(CompositeTaskScope parent) { + this.parent = parent; + } + + public CompositeTaskScope getParent() { + return this.parent; + } + + public int compareTo(CompositeTaskVertex other) { + return this.toString().compareTo(other.toString()); + } + + public boolean contains(CompositeTaskNode node) { + for ( CompositeTaskNode sub_node : this.nodes ) { + if ( node.equals(sub_node) ) { + return true; + } + + if ( sub_node instanceof CompositeTaskScope ) { + CompositeTaskScope scope = (CompositeTaskScope) sub_node; + if ( scope.contains(node) ) { + return true; + } + } + } + return false; + } + + public String toString() { + return "[CompositeTaskForScope: collection=" + this.collection + ", var=" + this.var + ", # nodes=" + this.nodes.size()+ "]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskGraph.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskGraph.java new file mode 100644 index 0000000..60b45a9 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskGraph.java @@ -0,0 +1,364 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; +import java.util.Collection; +import java.util.Map; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Comparator; +import java.util.Collections; +import java.util.Iterator; + +public class CompositeTaskGraph implements DirectedGraph +{ + private Map> scope_output_map; + private Set verticies; + private Set edges; + private CompositeTaskEdgeFactory edge_factory; + + public CompositeTaskGraph(CompositeTask composite_task) { + this.scope_output_map = new HashMap>(); + this.edge_factory = new CompositeTaskEdgeFactory(); + this.verticies = new LinkedHashSet(); + this.edges = new LinkedHashSet(); + + generate_scope_output(composite_task); + generate_graph(composite_task); + } + + private void generate_graph(CompositeTaskScope scope) { + for ( CompositeTaskNode node : scope.getNodes() ) { + if ( node instanceof CompositeTaskStep ) { + CompositeTaskStep step = (CompositeTaskStep) node; + addVertex(step); + for ( CompositeTaskStepInput input : step.getInputs() ) { + CompositeTaskVariable var = input.getVariable(); + addVertex(var); + addEdge(var, step); + + if ( this.scope_output_map.containsKey(var) ) { + CompositeTaskScope closest = closest_scope(step, this.scope_output_map.get(var)); + if ( !closest.contains(step) ) { + addVertex(closest); + addEdge(closest, step); + } + } + } + + for ( CompositeTaskStepOutput output : step.getOutputs() ) { + CompositeTaskVariable var = output.getVariable(); + addVertex(var); + addEdge(step, var); + } + } + + if ( node instanceof CompositeTaskForLoop ) { + CompositeTaskForLoop loop = (CompositeTaskForLoop) node; + addVertex(loop); + addVertex(loop.getCollection()); + addVertex(loop.getVariable()); + addEdge(loop.getCollection(), loop); + addEdge(loop, loop.getVariable()); + generate_graph(loop); + } + } + } + + private class ScopeDepthComparator implements Comparator { + public int compare(CompositeTaskScope s1, CompositeTaskScope s2) { + int s1_depth, s2_depth; + CompositeTaskScope tmp; + + for (tmp=s1.getParent(), s1_depth=0; tmp != null; tmp = tmp.getParent(), s1_depth++); + for (tmp=s2.getParent(), s2_depth=0; tmp != null; tmp = tmp.getParent(), s2_depth++); + + if ( s1_depth < s2_depth ) return -1; + else if ( s1_depth > s2_depth ) return 1; + else return 0; + } + } + + private CompositeTaskScope closest_scope(CompositeTaskNode node, Set scopes) { + Set matches = new LinkedHashSet(); + for ( CompositeTaskScope scope : scopes ) { + if ( node.getParent().contains(scope) ) { + matches.add(scope); + } + } + + if (matches.size() > 0) { + return Collections.min(matches, new ScopeDepthComparator()); + } + return closest_scope(node.getParent(), scopes); + } + + private void generate_scope_output(CompositeTaskScope scope) { + for ( CompositeTaskNode node : scope.getNodes() ) { + if ( node instanceof CompositeTaskScope ) { + CompositeTaskScope sub_scope = (CompositeTaskScope) node; + Set scope_outputs = get_outputs(sub_scope); + for ( CompositeTaskVariable variable : scope_outputs ) { + if ( !scope_output_map.containsKey(variable) ) { + scope_output_map.put(variable, new LinkedHashSet()); + } + scope_output_map.get(variable).add(sub_scope); + generate_scope_output(sub_scope); + } + } + } + } + + private Set get_outputs(CompositeTaskScope scope) { + Set outputs = new LinkedHashSet(); + for ( CompositeTaskNode node : scope.getNodes() ) { + if ( node instanceof CompositeTaskStep ) { + CompositeTaskStep step = (CompositeTaskStep) node; + for ( CompositeTaskStepOutput step_output : step.getOutputs() ) { + outputs.add( step_output.getVariable() ); + } + } + + if ( node instanceof CompositeTaskScope ) { + outputs.addAll( get_outputs((CompositeTaskScope) node) ); + } + } + return outputs; + } + + public Set getAllEdges(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + return this.edges; + } + + public CompositeTaskEdge getEdge(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + for ( CompositeTaskEdge edge : this.edges ) { + if ( edge.getStart().equals(sourceVertex) && edge.getEnd().equals(targetVertex) ) { + return edge; + } + } + return null; + } + + public EdgeFactory getEdgeFactory() { + return this.edge_factory; + } + + public CompositeTaskEdge addEdge(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + if ( getEdge(sourceVertex, targetVertex) != null ) { + return null; + } + + if ( !containsVertex(sourceVertex) || !containsVertex(targetVertex) ) { + return null; + } + + CompositeTaskEdge edge = this.edge_factory.createEdge(sourceVertex, targetVertex); + this.edges.add(edge); + return edge; + } + + public boolean addEdge(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex, CompositeTaskEdge e) { + return false; + } + + public boolean addVertex(CompositeTaskVertex v) { + if ( containsVertex(v) ) { + return false; + } + + this.verticies.add(v); + return true; + } + + public boolean containsEdge(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + return false; + } + + public boolean containsEdge(CompositeTaskEdge e) { + return false; + } + + public boolean containsVertex(CompositeTaskVertex v) { + for ( CompositeTaskVertex vertex : this.verticies ) { + if ( v.equals(vertex) ) { + return true; + } + } + return false; + } + + public Set edgeSet() { + return this.edges; + } + + public Set edgesOf(CompositeTaskVertex vertex) { + if ( vertex == null ) { + throw new NullPointerException("edgesOf(): null vertex"); + } + + if ( !containsVertex(vertex) ) { + throw new IllegalArgumentException("edgesOf(): vertex is not in graph"); + } + + Set edges = new LinkedHashSet(); + for ( CompositeTaskEdge edge : this.edges ) { + if ( edge.getStart().equals(vertex) || edge.getEnd().equals(vertex) ) { + edges.add(edge); + } + } + return edges; + } + + public boolean removeAllEdges(Collection edges) { + if ( edges == null ) { + throw new NullPointerException("removeAllEdges(): null edge collection"); + } + + Set removed_edges = new LinkedHashSet(); + for ( CompositeTaskEdge edge : this.edges ) { + if (edges.contains(edge)) { + removed_edges.add(edge); + } + } + + boolean changed = false; + for ( CompositeTaskEdge edge : removed_edges ) { + /* Interface says you need to call removeEdge for each edge you're going to remove */ + removeEdge(edge); + changed = true; + } + + return changed; + } + + public Set removeAllEdges(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + if (!containsVertex(sourceVertex) || !containsVertex(targetVertex)) { + return null; + } + + Set edges = new LinkedHashSet(); + while ( true ) { + CompositeTaskEdge removed_edge = removeEdge(sourceVertex, targetVertex); + if ( removed_edge == null ) { + break; + } + edges.add(removed_edge); + } + return edges; + } + + public boolean removeAllVertices(Collection vertices) { + if ( verticies == null ) { + throw new NullPointerException("removeAllVerticies(): null edge collection"); + } + + Set removed_verticies = new LinkedHashSet(); + for ( CompositeTaskVertex vertex : this.verticies ) { + if (verticies.contains(vertex)) { + removed_verticies.add(vertex); + } + } + + boolean changed = false; + for ( CompositeTaskVertex vertex : removed_verticies ) { + /* Interface says you need to call removeVertex for each edge you're going to remove */ + removeVertex(vertex); + changed = true; + } + + return changed; + } + + public CompositeTaskEdge removeEdge(CompositeTaskVertex sourceVertex, CompositeTaskVertex targetVertex) { + for ( Iterator i = this.edges.iterator(); i.hasNext(); ) { + CompositeTaskEdge edge = i.next(); + if ( edge.getStart().equals(sourceVertex) && edge.getEnd().equals(targetVertex) ) { + removeEdge(edge); + return edge; + } + } + + return null; + } + + public boolean removeEdge(CompositeTaskEdge e) { + if ( e == null ) { + return false; + } + + for ( Iterator i = this.edges.iterator(); i.hasNext(); ) { + CompositeTaskEdge edge = i.next(); + if ( edge.equals(edge) ) { + removeEdge(edge); + return true; + } + } + + return false; + } + + public boolean removeVertex(CompositeTaskVertex v) { + if ( !containsVertex(v) ) { + return false; + } + + + + return false; + } + + public Set vertexSet() { + return this.verticies; + } + + public CompositeTaskVertex getEdgeSource(CompositeTaskEdge e) { + return e.getStart(); + } + + public CompositeTaskVertex getEdgeTarget(CompositeTaskEdge e) { + return e.getEnd(); + } + + public double getEdgeWeight(CompositeTaskEdge e) { + return 1.0; + } + + public int inDegreeOf(CompositeTaskVertex vertex) { + int degree = 0; + for ( CompositeTaskEdge edge : this.edges ) { + if ( edge.getEnd().equals(vertex) ) { + degree += 1; + } + } + return degree; + } + + public Set incomingEdgesOf(CompositeTaskVertex vertex) { + Set incoming = new LinkedHashSet(); + for ( CompositeTaskEdge edge : this.edges ) { + if ( edge.getEnd().equals(vertex) ) { + incoming.add(edge); + } + } + return incoming; + } + + public int outDegreeOf(CompositeTaskVertex vertex) { + int degree = 0; + for ( CompositeTaskEdge edge : this.edges ) { + if ( edge.getStart().equals(vertex) ) { + degree += 1; + } + } + return degree; + } + + public Set outgoingEdgesOf(CompositeTaskVertex vertex) { + Set outgoing = new LinkedHashSet(); + for ( CompositeTaskEdge edge : this.edges ) { + if ( edge.getStart().equals(vertex) ) { + outgoing.add(edge); + } + } + return outgoing; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskNode.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskNode.java new file mode 100644 index 0000000..36eddb5 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskNode.java @@ -0,0 +1,9 @@ +package org.broadinstitute.compositetask; + +import org.broadinstitute.parser.Ast; + +public interface CompositeTaskNode { + public Ast getAst(); + public void setParent(CompositeTaskScope parent); + public CompositeTaskScope getParent(); +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskScope.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskScope.java new file mode 100644 index 0000000..ec172c7 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskScope.java @@ -0,0 +1,9 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +public interface CompositeTaskScope extends CompositeTaskNode, CompositeTaskVertex { + public Set getNodes(); + public boolean contains(CompositeTaskNode node); + public int compareTo(CompositeTaskVertex other); +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCode.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCode.java new file mode 100644 index 0000000..b9b423c --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCode.java @@ -0,0 +1,98 @@ +package org.broadinstitute.compositetask; + +import java.io.File; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.nio.channels.FileChannel; +import java.nio.MappedByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.CharBuffer; +import java.util.ArrayList; +import java.util.List; +import java.io.FileInputStream; + +import org.broadinstitute.parser.SourceCode; + +public class CompositeTaskSourceCode implements SourceCode { + private File source; + private String resource; + private String contents; + private int line; + private int col; + private StringBuilder currentLine; + private List lines; + + CompositeTaskSourceCode(String source, String resource) { + init(source, resource); + } + + CompositeTaskSourceCode(File source) throws IOException { + this(source, "utf-8", source.getCanonicalPath()); + } + + CompositeTaskSourceCode(File source, String resource) throws IOException { + this(source, "utf-8", resource); + } + + CompositeTaskSourceCode(File source, String encoding, String resource) throws IOException, FileNotFoundException { + FileInputStream in = new FileInputStream(source); + FileChannel channel = in.getChannel(); + MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); + Charset cs = Charset.forName(encoding); + CharsetDecoder cd = cs.newDecoder(); + CharBuffer cb = cd.decode(buffer); + in.close(); + + init(cb.toString(), resource); + } + + private void init(String contents, String resource) { + this.contents = contents; + this.resource = resource; + this.line = 1; + this.col = 1; + this.lines = new ArrayList(); + this.currentLine = new StringBuilder(); + } + + public void advance(int amount) { + String str = this.contents.substring(0, amount); + for ( byte b : str.getBytes() ) { + if ( b == (byte) '\n' || b == (byte) '\r' ) { + this.lines.add(this.currentLine.toString()); + this.currentLine = new StringBuilder(); + this.line++; + this.col = 1; + } else { + this.currentLine.append((char)b); + this.col++; + } + } + this.contents = this.contents.substring(amount); + } + + public String getString() { + return this.contents; + } + + public String getResource() { + return this.resource; + } + + public int getLine() { + return this.line; + } + + public int getColumn() { + return this.col; + } + + public String getLine(int lineno) { + return this.lines.get(lineno-1); + } + + public List getLines() { + return this.lines; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCodeFormatter.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCodeFormatter.java new file mode 100644 index 0000000..9af6334 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskSourceCodeFormatter.java @@ -0,0 +1,80 @@ +package org.broadinstitute.compositetask; + +import java.util.ArrayList; +import java.util.List; + +import org.broadinstitute.parser.Utility; + +public class CompositeTaskSourceCodeFormatter { + private CompositeTaskColorizer colorizer; + + public CompositeTaskSourceCodeFormatter(CompositeTaskColorizer colorizer) { + this.colorizer = colorizer; + } + + public CompositeTaskSourceCodeFormatter() { + this(new NullColorizer()); + } + + public String format(CompositeTask ctask) { + return format(ctask, 0); + } + + private String format(CompositeTaskNode node, int indent) { + StringBuilder builder = new StringBuilder(); + String indent_str = Utility.getIndentString(indent); + if ( node instanceof CompositeTask ) { + CompositeTask ctask = (CompositeTask) node; + builder.append(indent_str + this.colorizer.keyword("composite_task") + " " + ctask.getName() + " {\n"); + for ( CompositeTaskNode sub_node : ctask.getNodes() ) { + builder.append( format(sub_node, indent + 2) ); + } + builder.append(indent_str + "}\n"); + } else if ( node instanceof CompositeTaskForLoop ) { + CompositeTaskForLoop loop = (CompositeTaskForLoop) node; + builder.append( indent_str + this.colorizer.keyword("for") + " ( " + this.colorizer.variable(variable_to_string(loop.getVariable())) + " " + this.colorizer.keyword("in") + " " + this.colorizer.variable(variable_to_string(loop.getCollection())) + " ) {\n" ); + for ( CompositeTaskNode sub_node : loop.getNodes() ) { + builder.append( format(sub_node, indent + 2) ); + } + builder.append( indent_str + "}\n" ); + } else if ( node instanceof CompositeTaskStep ) { + CompositeTaskStep step = (CompositeTaskStep) node; + CompositeTaskSubTask task = step.getTask(); + String rename = ""; + if ( !step.getName().equals(task.getTaskName()) ) { + rename = " " + this.colorizer.keyword("as") + " " + step.getName(); + } + builder.append( indent_str + this.colorizer.keyword("step") + " " + this.colorizer.task(task.getTaskName()) + "[version=" + task.getVersion() + "]" + rename + " {\n" ); + + if ( step.getInputs().size() > 0 ) { + List parameters = new ArrayList(); + for ( CompositeTaskStepInput input : step.getInputs() ) { + parameters.add(input.getParameter() + "=" + this.colorizer.variable(variable_to_string(input.getVariable()))); + } + + builder.append(indent_str + " " + this.colorizer.keyword("input") + ": " + Utility.join(parameters, ", ") + ";\n"); + } + + if ( step.getOutputs().size() > 0 ) { + List outputs = new ArrayList(); + for ( CompositeTaskStepOutput output : step.getOutputs() ) { + outputs.add(output.getType() + "(\"" + this.colorizer.string(output.getPath()) + "\") " + this.colorizer.keyword("as") + " " + this.colorizer.variable(variable_to_string(output.getVariable()))); + } + + builder.append(indent_str + " " + this.colorizer.keyword("output") + ": " + Utility.join(outputs, ", ") + ";\n"); + } + + builder.append( indent_str + "}\n" ); + } + return builder.toString(); + } + + private String variable_to_string(CompositeTaskVariable var) { + if ( var.getMember() != null ) { + return var.getName() + "." + var.getMember(); + } + else { + return var.getName(); + } + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskStep.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskStep.java new file mode 100644 index 0000000..987bb4b --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskStep.java @@ -0,0 +1,65 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +import org.broadinstitute.parser.Ast; + +public class CompositeTaskStep implements CompositeTaskNode, CompositeTaskVertex { + private CompositeTaskSubTask task; + private String name; + private Set inputs; + private Set outputs; + private CompositeTaskScope parent; + + public CompositeTaskStep(String name, CompositeTaskSubTask task, Set inputs, Set outputs) { + this.task = task; + this.name = name; + this.inputs = inputs; + this.outputs = outputs; + this.parent = null; + } + + public Ast getAst() { + return null; + } + + public String getName() { + return this.name; + } + + public CompositeTaskSubTask getTask() { + return this.task; + } + + public Set getOutputs() { + return this.outputs; + } + + public Set getInputs() { + return this.inputs; + } + + public void setParent(CompositeTaskScope parent) { + this.parent = parent; + } + + public CompositeTaskScope getParent() { + return this.parent; + } + + public int hashCode() { + return 0; + } + + public boolean equals(CompositeTaskStep other) { + return false; + } + + public int compareTo(CompositeTaskVertex other) { + return this.toString().compareTo(other.toString()); + } + + public String toString() { + return "[Step: name=" + this.name + "]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskStepInput.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskStepInput.java new file mode 100644 index 0000000..ca3b450 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskStepInput.java @@ -0,0 +1,42 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +import org.broadinstitute.parser.Ast; + +public class CompositeTaskStepInput { + private String parameter; + private CompositeTaskVariable variable; + + public CompositeTaskStepInput(String parameter, CompositeTaskVariable variable) { + this.parameter = parameter; + this.variable = variable; + } + + public CompositeTaskStepInput(Ast ast) { + } + + public Ast getAst() { + return null; + } + + public String getParameter() { + return this.parameter; + } + + public CompositeTaskVariable getVariable() { + return this.variable; + } + + public int hashCode() { + return 0; + } + + public boolean equals(CompositeTaskStepInput other) { + return false; + } + + public String toString() { + return "[StepInput: parameter=" + this.parameter + "]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskStepOutput.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskStepOutput.java new file mode 100644 index 0000000..2a590be --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskStepOutput.java @@ -0,0 +1,51 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +import org.broadinstitute.parser.Ast; + +public class CompositeTaskStepOutput { + private String type; + private String method; + private String path; + private CompositeTaskVariable variable; + + public CompositeTaskStepOutput(String type, String method, String path, CompositeTaskVariable variable) { + this.type = type; + this.method = method; + this.path = path; + this.variable = variable; + } + + public Ast getAst() { + return null; + } + + public String getPath() { + return this.path.replaceAll("^\"|\"$", ""); + } + + public String getMethod() { + return this.method; + } + + public String getType() { + return this.type; + } + + public CompositeTaskVariable getVariable() { + return this.variable; + } + + public int hashCode() { + return 0; + } + + public boolean equals(CompositeTaskStepOutput other) { + return false; + } + + public String toString() { + return "[StepOutput: path=" + this.path + "]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskSubTask.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskSubTask.java new file mode 100644 index 0000000..7d59315 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskSubTask.java @@ -0,0 +1,37 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +public class CompositeTaskSubTask { + private String name; + private String version; + + public CompositeTaskSubTask(String name, String version) { + this.name = name; + this.version = version; + } + + public String getTaskName() { + return this.name; + } + + public String getVersion() { + return this.version; + } + + public Set getInputs() { + /* TODO: implement */ + return null; + } + + public boolean equals(CompositeTaskSubTask other) { + if (other.getTaskName().equals(this.name) && other.getVersion().equals(this.version)) { + return true; + } + return false; + } + + public String toString() { + return "[Task: name="+this.name+", version="+this.version+"]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskToDotCompiler.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskToDotCompiler.java new file mode 100644 index 0000000..182fbdf --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskToDotCompiler.java @@ -0,0 +1,7 @@ +package org.broadinstitute.compositetask; + +public class CompositeTaskToDotCompiler { + public String compile(CompositeTask task) { + return null; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskVariable.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskVariable.java new file mode 100644 index 0000000..a40de2e --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskVariable.java @@ -0,0 +1,56 @@ +package org.broadinstitute.compositetask; + +import java.util.Set; + +import org.broadinstitute.parser.Ast; + +public class CompositeTaskVariable implements CompositeTaskVertex { + private String name; + private String member; + + public CompositeTaskVariable(String name, String member) { + this.name = name; + this.member = member; + } + + public CompositeTaskVariable(String name) { + this.name = name; + } + + public Ast getAst() { + return null; + } + + public String getName() { + return this.name; + } + + public String getMember() { + return this.member; + } + + public int hashCode() { + return 0; + } + + public int compareTo(CompositeTaskVertex other) { + return this.toString().compareTo(other.toString()); + } + + public boolean equals(CompositeTaskVariable other) { + if ( other.getName().equals(this.name) ) { + if ( other.getMember() == null && this.member == null ) { + return true; + } + + if ( other.getMember() != null && other.getMember().equals(this.member) ) { + return true; + } + } + return false; + } + + public String toString() { + return "[Variable: name=" + this.name + (this.member == null ? "" : ", member=" + this.member) + "]"; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/CompositeTaskVertex.java b/src/main/java/org/broadinstitute/compositetask/CompositeTaskVertex.java new file mode 100644 index 0000000..0c1af8e --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/CompositeTaskVertex.java @@ -0,0 +1,3 @@ +package org.broadinstitute.compositetask; + +public interface CompositeTaskVertex extends Comparable {} diff --git a/src/main/java/org/broadinstitute/compositetask/DirectedGraph.java b/src/main/java/org/broadinstitute/compositetask/DirectedGraph.java new file mode 100644 index 0000000..6f0fc5d --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/DirectedGraph.java @@ -0,0 +1,108 @@ +/* ========================================== + * JGraphT : a free Java graph-theory library + * ========================================== + * + * Project Info: http://jgrapht.sourceforge.net/ + * Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh) + * + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ +/* ------------------ + * DirectedGraph.java + * ------------------ + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * Original Author: Barak Naveh + * Contributor(s): Christian Hammer + * + * $Id$ + * + * Changes + * ------- + * 24-Jul-2003 : Initial revision (BN); + * 11-Mar-2004 : Made generic (CH); + * 07-May-2006 : Changed from List to Set (JVS); + * + */ + +package org.broadinstitute.compositetask; + +import java.util.*; + +/** + * A graph whose all edges are directed. This is the root interface of all + * directed graphs. + * + *

See + * http://mathworld.wolfram.com/DirectedGraph.html for more on directed + * graphs.

+ * + * @author Barak Naveh + * @since Jul 14, 2003 + */ +public interface DirectedGraph + extends Graph +{ + //~ Methods ---------------------------------------------------------------- + + /** + * Returns the "in degree" of the specified vertex. An in degree of a vertex + * in a directed graph is the number of inward directed edges from that + * vertex. See + * http://mathworld.wolfram.com/Indegree.html. + * + * @param vertex vertex whose degree is to be calculated. + * + * @return the degree of the specified vertex. + */ + public int inDegreeOf(V vertex); + + /** + * Returns a set of all edges incoming into the specified vertex. + * + * @param vertex the vertex for which the list of incoming edges to be + * returned. + * + * @return a set of all edges incoming into the specified vertex. + */ + public Set incomingEdgesOf(V vertex); + + /** + * Returns the "out degree" of the specified vertex. An out degree of a + * vertex in a directed graph is the number of outward directed edges from + * that vertex. See + * http://mathworld.wolfram.com/Outdegree.html. + * + * @param vertex vertex whose degree is to be calculated. + * + * @return the degree of the specified vertex. + */ + public int outDegreeOf(V vertex); + + /** + * Returns a set of all edges outgoing from the specified vertex. + * + * @param vertex the vertex for which the list of outgoing edges to be + * returned. + * + * @return a set of all edges outgoing from the specified vertex. + */ + public Set outgoingEdgesOf(V vertex); +} + +// End DirectedGraph.java diff --git a/src/main/java/org/broadinstitute/compositetask/EdgeFactory.java b/src/main/java/org/broadinstitute/compositetask/EdgeFactory.java new file mode 100644 index 0000000..6a0b4cc --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/EdgeFactory.java @@ -0,0 +1,67 @@ +/* ========================================== + * JGraphT : a free Java graph-theory library + * ========================================== + * + * Project Info: http://jgrapht.sourceforge.net/ + * Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh) + * + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ +/* ---------------- + * EdgeFactory.java + * ---------------- + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * Original Author: Barak Naveh + * Contributor(s): Christian Hammer + * + * $Id$ + * + * Changes + * ------- + * 24-Jul-2003 : Initial revision (BN); + * 11-Mar-2004 : Made generic (CH); + * + */ + +package org.broadinstitute.compositetask; + +/** + * An edge factory used by graphs for creating new edges. + * + * @author Barak Naveh + * @since Jul 14, 2003 + */ +public interface EdgeFactory +{ + //~ Methods ---------------------------------------------------------------- + + /** + * Creates a new edge whose endpoints are the specified source and target + * vertices. + * + * @param sourceVertex the source vertex. + * @param targetVertex the target vertex. + * + * @return a new edge whose endpoints are the specified source and target + * vertices. + */ + public E createEdge(V sourceVertex, V targetVertex); +} + +// End EdgeFactory.java diff --git a/src/main/java/org/broadinstitute/compositetask/Graph.java b/src/main/java/org/broadinstitute/compositetask/Graph.java new file mode 100644 index 0000000..29e6810 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/Graph.java @@ -0,0 +1,435 @@ +/* ========================================== + * JGraphT : a free Java graph-theory library + * ========================================== + * + * Project Info: http://jgrapht.sourceforge.net/ + * Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh) + * + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ +/* ---------- + * Graph.java + * ---------- + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * Original Author: Barak Naveh + * Contributor(s): John V. Sichi + * Christian Hammer + * + * $Id$ + * + * Changes + * ------- + * 24-Jul-2003 : Initial revision (BN); + * 06-Nov-2003 : Change edge sharing semantics (JVS); + * 11-Mar-2004 : Made generic (CH); + * 07-May-2006 : Changed from List to Set (JVS); + * 28-May-2006 : Moved connectivity info from edge to graph (JVS); + * + */ + +package org.broadinstitute.compositetask; + +import java.util.*; + +/** + * The root interface in the graph hierarchy. A mathematical graph-theory graph + * object G(V,E) contains a set V of vertices and a set + * E of edges. Each edge e=(v1,v2) in E connects vertex v1 to vertex v2. + * for more information about graphs and their related definitions see + * http://mathworld.wolfram.com/Graph.html. + * + *

This library generally follows the terminology found at: + * http://mathworld.wolfram.com/topics/GraphTheory.html. Implementation of + * this interface can provide simple-graphs, multigraphs, pseudographs etc. The + * package org.jgrapht.graph provides a gallery of abstract and + * concrete graph implementations.

+ * + *

This library works best when vertices represent arbitrary objects and + * edges represent the relationships between them. Vertex and edge instances may + * be shared by more than one graph.

+ * + *

Through generics, a graph can be typed to specific classes for vertices + * V and edges E<T>. Such a graph can contain + * vertices of type V and all sub-types and Edges of type + * E and all sub-types.

+ * + *

For guidelines on vertex and edge classes, see this wiki + * page. + * + * @author Barak Naveh + * @since Jul 14, 2003 + */ +public interface Graph +{ + //~ Methods ---------------------------------------------------------------- + + /** + * Returns a set of all edges connecting source vertex to target vertex if + * such vertices exist in this graph. If any of the vertices does not exist + * or is null, returns null. If both vertices + * exist but no edges found, returns an empty set. + * + *

In undirected graphs, some of the returned edges may have their source + * and target vertices in the opposite order. In simple graphs the returned + * set is either singleton set or empty set.

+ * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * + * @return a set of all edges connecting source vertex to target vertex. + */ + public Set getAllEdges(V sourceVertex, V targetVertex); + + /** + * Returns an edge connecting source vertex to target vertex if such + * vertices and such edge exist in this graph. Otherwise returns + * null. If any of the specified vertices is null + * returns null + * + *

In undirected graphs, the returned edge may have its source and target + * vertices in the opposite order.

+ * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * + * @return an edge connecting source vertex to target vertex. + */ + public E getEdge(V sourceVertex, V targetVertex); + + /** + * Returns the edge factory using which this graph creates new edges. The + * edge factory is defined when the graph is constructed and must not be + * modified. + * + * @return the edge factory using which this graph creates new edges. + */ + public EdgeFactory getEdgeFactory(); + + /** + * Creates a new edge in this graph, going from the source vertex to the + * target vertex, and returns the created edge. Some graphs do not allow + * edge-multiplicity. In such cases, if the graph already contains an edge + * from the specified source to the specified target, than this method does + * not change the graph and returns null. + * + *

The source and target vertices must already be contained in this + * graph. If they are not found in graph IllegalArgumentException is + * thrown.

+ * + *

This method creates the new edge e using this graph's + * EdgeFactory. For the new edge to be added e + * must not be equal to any other edge the graph (even if the graph + * allows edge-multiplicity). More formally, the graph must not contain any + * edge e2 such that e2.equals(e). If such + * e2 is found then the newly created edge e is + * abandoned, the method leaves this graph unchanged returns + * null.

+ * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * + * @return The newly created edge if added to the graph, otherwise + * null. + * + * @throws IllegalArgumentException if source or target vertices are not + * found in the graph. + * @throws NullPointerException if any of the specified vertices is + * null. + * + * @see #getEdgeFactory() + */ + public E addEdge(V sourceVertex, V targetVertex); + + /** + * Adds the specified edge to this graph, going from the source vertex to + * the target vertex. More formally, adds the specified edge, + * e, to this graph if this graph contains no edge e2 + * such that e2.equals(e). If this graph already contains such + * an edge, the call leaves this graph unchanged and returns false. + * Some graphs do not allow edge-multiplicity. In such cases, if the graph + * already contains an edge from the specified source to the specified + * target, than this method does not change the graph and returns + * false. If the edge was added to the graph, returns + * true. + * + *

The source and target vertices must already be contained in this + * graph. If they are not found in graph IllegalArgumentException is + * thrown.

+ * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * @param e edge to be added to this graph. + * + * @return true if this graph did not already contain the specified + * edge. + * + * @throws IllegalArgumentException if source or target vertices are not + * found in the graph. + * @throws ClassCastException if the specified edge is not assignment + * compatible with the class of edges produced by the edge factory of this + * graph. + * @throws NullPointerException if any of the specified vertices is + * null. + * + * @see #addEdge(Object, Object) + * @see #getEdgeFactory() + */ + public boolean addEdge(V sourceVertex, V targetVertex, E e); + + /** + * Adds the specified vertex to this graph if not already present. More + * formally, adds the specified vertex, v, to this graph if + * this graph contains no vertex u such that + * u.equals(v). If this graph already contains such vertex, the call + * leaves this graph unchanged and returns false. In combination + * with the restriction on constructors, this ensures that graphs never + * contain duplicate vertices. + * + * @param v vertex to be added to this graph. + * + * @return true if this graph did not already contain the specified + * vertex. + * + * @throws NullPointerException if the specified vertex is + * null. + */ + public boolean addVertex(V v); + + /** + * Returns true if and only if this graph contains an edge going + * from the source vertex to the target vertex. In undirected graphs the + * same result is obtained when source and target are inverted. If any of + * the specified vertices does not exist in the graph, or if is + * null, returns false. + * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * + * @return true if this graph contains the specified edge. + */ + public boolean containsEdge(V sourceVertex, V targetVertex); + + /** + * Returns true if this graph contains the specified edge. More + * formally, returns true if and only if this graph contains an + * edge e2 such that e.equals(e2). If the + * specified edge is null returns false. + * + * @param e edge whose presence in this graph is to be tested. + * + * @return true if this graph contains the specified edge. + */ + public boolean containsEdge(E e); + + /** + * Returns true if this graph contains the specified vertex. More + * formally, returns true if and only if this graph contains a + * vertex u such that u.equals(v). If the + * specified vertex is null returns false. + * + * @param v vertex whose presence in this graph is to be tested. + * + * @return true if this graph contains the specified vertex. + */ + public boolean containsVertex(V v); + + /** + * Returns a set of the edges contained in this graph. The set is backed by + * the graph, so changes to the graph are reflected in the set. If the graph + * is modified while an iteration over the set is in progress, the results + * of the iteration are undefined. + * + *

The graph implementation may maintain a particular set ordering (e.g. + * via {@link java.util.LinkedHashSet}) for deterministic iteration, but + * this is not required. It is the responsibility of callers who rely on + * this behavior to only use graph implementations which support it.

+ * + * @return a set of the edges contained in this graph. + */ + public Set edgeSet(); + + /** + * Returns a set of all edges touching the specified vertex. If no edges are + * touching the specified vertex returns an empty set. + * + * @param vertex the vertex for which a set of touching edges is to be + * returned. + * + * @return a set of all edges touching the specified vertex. + * + * @throws IllegalArgumentException if vertex is not found in the graph. + * @throws NullPointerException if vertex is null. + */ + public Set edgesOf(V vertex); + + /** + * Removes all the edges in this graph that are also contained in the + * specified edge collection. After this call returns, this graph will + * contain no edges in common with the specified edges. This method will + * invoke the {@link #removeEdge(Object)} method. + * + * @param edges edges to be removed from this graph. + * + * @return true if this graph changed as a result of the call + * + * @throws NullPointerException if the specified edge collection is + * null. + * + * @see #removeEdge(Object) + * @see #containsEdge(Object) + */ + public boolean removeAllEdges(Collection edges); + + /** + * Removes all the edges going from the specified source vertex to the + * specified target vertex, and returns a set of all removed edges. Returns + * null if any of the specified vertices does not exist in the + * graph. If both vertices exist but no edge is found, returns an empty set. + * This method will either invoke the {@link #removeEdge(Object)} method, or + * the {@link #removeEdge(Object, Object)} method. + * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * + * @return the removed edges, or null if no either vertex not + * part of graph + */ + public Set removeAllEdges(V sourceVertex, V targetVertex); + + /** + * Removes all the vertices in this graph that are also contained in the + * specified vertex collection. After this call returns, this graph will + * contain no vertices in common with the specified vertices. This method + * will invoke the {@link #removeVertex(Object)} method. + * + * @param vertices vertices to be removed from this graph. + * + * @return true if this graph changed as a result of the call + * + * @throws NullPointerException if the specified vertex collection is + * null. + * + * @see #removeVertex(Object) + * @see #containsVertex(Object) + */ + public boolean removeAllVertices(Collection vertices); + + /** + * Removes an edge going from source vertex to target vertex, if such + * vertices and such edge exist in this graph. Returns the edge if removed + * or null otherwise. + * + * @param sourceVertex source vertex of the edge. + * @param targetVertex target vertex of the edge. + * + * @return The removed edge, or null if no edge removed. + */ + public E removeEdge(V sourceVertex, V targetVertex); + + /** + * Removes the specified edge from the graph. Removes the specified edge + * from this graph if it is present. More formally, removes an edge + * e2 such that e2.equals(e), if the graph contains such + * edge. Returns true if the graph contained the specified edge. + * (The graph will not contain the specified edge once the call returns). + * + *

If the specified edge is null returns + * false.

+ * + * @param e edge to be removed from this graph, if present. + * + * @return true if and only if the graph contained the + * specified edge. + */ + public boolean removeEdge(E e); + + /** + * Removes the specified vertex from this graph including all its touching + * edges if present. More formally, if the graph contains a vertex + * u such that u.equals(v), the call removes all edges + * that touch u and then removes u itself. If no + * such u is found, the call leaves the graph unchanged. + * Returns true if the graph contained the specified vertex. (The + * graph will not contain the specified vertex once the call returns). + * + *

If the specified vertex is null returns + * false.

+ * + * @param v vertex to be removed from this graph, if present. + * + * @return true if the graph contained the specified vertex; + * false otherwise. + */ + public boolean removeVertex(V v); + + /** + * Returns a set of the vertices contained in this graph. The set is backed + * by the graph, so changes to the graph are reflected in the set. If the + * graph is modified while an iteration over the set is in progress, the + * results of the iteration are undefined. + * + *

The graph implementation may maintain a particular set ordering (e.g. + * via {@link java.util.LinkedHashSet}) for deterministic iteration, but + * this is not required. It is the responsibility of callers who rely on + * this behavior to only use graph implementations which support it.

+ * + * @return a set view of the vertices contained in this graph. + */ + public Set vertexSet(); + + /** + * Returns the source vertex of an edge. For an undirected graph, source and + * target are distinguishable designations (but without any mathematical + * meaning). + * + * @param e edge of interest + * + * @return source vertex + */ + public V getEdgeSource(E e); + + /** + * Returns the target vertex of an edge. For an undirected graph, source and + * target are distinguishable designations (but without any mathematical + * meaning). + * + * @param e edge of interest + * + * @return target vertex + */ + public V getEdgeTarget(E e); + + /** + * Returns the weight assigned to a given edge. Unweighted graphs return 1.0 + * (as defined by {@link WeightedGraph#DEFAULT_EDGE_WEIGHT}), allowing + * weighted-graph algorithms to apply to them where meaningful. + * + * @param e edge of interest + * + * @return edge weight + * + * @see WeightedGraph + */ + public double getEdgeWeight(E e); +} + +// End Graph.java diff --git a/src/main/java/org/broadinstitute/compositetask/HtmlColorizer.java b/src/main/java/org/broadinstitute/compositetask/HtmlColorizer.java new file mode 100644 index 0000000..c47db4c --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/HtmlColorizer.java @@ -0,0 +1,27 @@ +package org.broadinstitute.compositetask; + +public class HtmlColorizer implements CompositeTaskColorizer { + public String preamble() { + return ""; + } + + public String postamble() { + return ""; + } + + public String keyword(String str) { + return "" + str + ""; + } + + public String string(String str) { + return "" + str + ""; + } + + public String variable(String str) { + return "" + str + ""; + } + + public String task(String str) { + return "" + str + ""; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/Lexer.java b/src/main/java/org/broadinstitute/compositetask/Lexer.java new file mode 100644 index 0000000..3784700 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/Lexer.java @@ -0,0 +1,121 @@ +package org.broadinstitute.compositetask; + +import java.util.regex.*; +import java.util.ArrayList; +import java.util.List; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.util.Arrays; +import java.nio.*; +import java.nio.charset.*; +import java.nio.channels.*; + +import org.broadinstitute.parser.*; + +class LexerMatch { + private Terminal terminal; + LexerMatch() { this.terminal = null; } + LexerMatch(Terminal terminal) { this.terminal = terminal; } + public Terminal getTerminal() { return this.terminal; } +} + +class TokenLexer { + private Pattern regex; + private CompositeTaskParser.TerminalId terminal; + + TokenLexer(Pattern regex, CompositeTaskParser.TerminalId terminal) { + this.regex = regex; + this.terminal = terminal; + } + + LexerMatch match(SourceCode source) { + Matcher m = this.regex.matcher(source.getString()); + LexerMatch rval = null; + if ( m.find() ) { + String sourceString = m.group(); + if (this.terminal != null) + rval = new LexerMatch(new Terminal(this.terminal.id(), this.terminal.string(), sourceString, source.getResource(), source.getLine(), source.getColumn())); + else + rval = new LexerMatch(); + + source.advance(sourceString.length()); + } + return rval; + } + + public String toString() { + return "[TokenLexer regex="+regex+", terminal="+terminal+"]"; + } +} + +public class Lexer { + + private ArrayList regex; + + Lexer() { + this.regex = new ArrayList(); + this.regex.add( new TokenLexer(Pattern.compile("^/\\*.*?\\*/", Pattern.DOTALL), null) ); + this.regex.add( new TokenLexer(Pattern.compile("^//.*"), null) ); + this.regex.add( new TokenLexer(Pattern.compile("^composite_task(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_COMPOSITE_TASK) ); + this.regex.add( new TokenLexer(Pattern.compile("^output(?=(\\s*:)|$)"), CompositeTaskParser.TerminalId.TERMINAL_OUTPUT) ); + this.regex.add( new TokenLexer(Pattern.compile("^input(?=(\\s*:)|$)"), CompositeTaskParser.TerminalId.TERMINAL_INPUT) ); + this.regex.add( new TokenLexer(Pattern.compile("^step(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_STEP) ); + this.regex.add( new TokenLexer(Pattern.compile("^File(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_FILE) ); + this.regex.add( new TokenLexer(Pattern.compile("^FirstLine(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_FIRST_LINE) ); + this.regex.add( new TokenLexer(Pattern.compile("^for(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_FOR) ); + this.regex.add( new TokenLexer(Pattern.compile("^as(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_AS) ); + this.regex.add( new TokenLexer(Pattern.compile("^into(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_INTO) ); + this.regex.add( new TokenLexer(Pattern.compile("^in(?=[^a-zA-Z0-9_]|$)"), CompositeTaskParser.TerminalId.TERMINAL_IN) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\."), CompositeTaskParser.TerminalId.TERMINAL_DOT) ); + this.regex.add( new TokenLexer(Pattern.compile("^,"), CompositeTaskParser.TerminalId.TERMINAL_COMMA) ); + this.regex.add( new TokenLexer(Pattern.compile("^:"), CompositeTaskParser.TerminalId.TERMINAL_COLON) ); + this.regex.add( new TokenLexer(Pattern.compile("^;"), CompositeTaskParser.TerminalId.TERMINAL_SEMI) ); + this.regex.add( new TokenLexer(Pattern.compile("^="), CompositeTaskParser.TerminalId.TERMINAL_ASSIGN) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\["), CompositeTaskParser.TerminalId.TERMINAL_LSQUARE) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\]"), CompositeTaskParser.TerminalId.TERMINAL_RSQUARE) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\{"), CompositeTaskParser.TerminalId.TERMINAL_LBRACE) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\}"), CompositeTaskParser.TerminalId.TERMINAL_RBRACE) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\("), CompositeTaskParser.TerminalId.TERMINAL_LPAREN) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\)"), CompositeTaskParser.TerminalId.TERMINAL_RPAREN) ); + this.regex.add( new TokenLexer(Pattern.compile("^\"([^\\\\\"\\n]|\\[\\\"'nrbtfav\\?]|\\[0-7]{1,3}|\\\\x[0-9a-fA-F]+|\\\\[uU]([0-9a-fA-F]{4})([0-9a-fA-F]{4})?)*\""), CompositeTaskParser.TerminalId.TERMINAL_STRING) ); + this.regex.add( new TokenLexer(Pattern.compile("^([a-zA-Z0-9_\\.])+(?=\\s*=)"), CompositeTaskParser.TerminalId.TERMINAL_IDENTIFIER) ); + this.regex.add( new TokenLexer(Pattern.compile("^([a-zA-Z_]|\\\\[uU]([0-9a-fA-F]{4})([0-9a-fA-F]{4})?)([a-zA-Z_0-9]|\\\\[uU]([0-9a-fA-F]{4})([0-9a-fA-F]{4})?)*"), CompositeTaskParser.TerminalId.TERMINAL_IDENTIFIER) ); + this.regex.add( new TokenLexer(Pattern.compile("^[-]?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)"), CompositeTaskParser.TerminalId.TERMINAL_NUMBER) ); + this.regex.add( new TokenLexer(Pattern.compile("^\\s+"), null) ); + } + + public List getTokens(SourceCode code) { + ArrayList tokens = new ArrayList(); + boolean progress = true; + + while (progress) { + progress = false; + for ( TokenLexer lexer : regex ) { + LexerMatch match = lexer.match(code); + if (match != null) { + progress = true; + if (match.getTerminal() != null) { + tokens.add(match.getTerminal()); + } + break; + } + } + } + + return tokens; + } + public static void main(String[] args) { + try { + SourceCode code = new CompositeTaskSourceCode(new File(args[0])); + Lexer lexer = new Lexer(); + List terminals = lexer.getTokens(code); + System.out.println("["); + System.out.println(Utility.join(terminals, ",\n")); + System.out.println("]"); + } catch( IOException e ) { + System.err.println(e); + } + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/Main.java b/src/main/java/org/broadinstitute/compositetask/Main.java new file mode 100644 index 0000000..6296054 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/Main.java @@ -0,0 +1,112 @@ +package org.broadinstitute.compositetask; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.broadinstitute.parser.Utility; +import org.broadinstitute.parser.Ast; +import org.broadinstitute.parser.ParseTree; +import org.broadinstitute.parser.SyntaxError; +import org.broadinstitute.parser.Terminal; + +public class Main { + + public static void usage() { + System.err.println("Usage: <.wdl file> "); + System.err.println(); + System.err.println("Actions:"); + System.err.println(" tokens: tokenize the source code"); + System.err.println(" ast: parse source code and output an abstract syntax tree"); + System.err.println(" parsetree: parse source code and output a parsetree"); + System.err.println(" entities: output an abbreviated view of all entities and which scope they're nested in"); + System.err.println(" graph: output the set of verticies and edges for the directed acyclic graph"); + System.err.println(" format: reformat source code"); + System.err.println(" format-ansi: reformat source code and colorize for the terminal"); + System.err.println(" format-html: reformat source code and add HTML span tags"); + System.exit(-1); + } + + public static void main(String[] args) { + + if (args.length < 2) { + usage(); + } + + try { + + if ( args[1].equals("tokens") ) { + Lexer lexer = new Lexer(); + List terminals = lexer.getTokens(new CompositeTaskSourceCode(new File(args[0]))); + for ( Terminal terminal : terminals ) { + System.out.println(terminal); + } + System.exit(0); + } + + CompositeTask ctask = new CompositeTask(new File(args[0])); + + if ( args[1].equals("ast") ) { + Ast ast = ctask.getAst(); + System.out.println(ast.toPrettyString()); + } else if ( args[1].equals("parsetree") ) { + ParseTree tree = ctask.getParseTree(); + System.out.println(tree.toPrettyString()); + } else if ( args[1].equals("entities") ) { + print_tree(ctask); + } else if ( args[1].equals("graph") ) { + CompositeTaskGraph graph = ctask.getGraph(); + + System.out.println("VERTICIES"); + System.out.println("---------"); + for ( CompositeTaskVertex v : graph.vertexSet() ) { + System.out.println(v); + } + System.out.println(""); + + System.out.println("EDGES"); + System.out.println("-----"); + for ( CompositeTaskEdge v : graph.edgeSet() ) { + System.out.println(v); + } + + } else if ( args[1].equals("format-ansi") ) { + CompositeTaskSourceCodeFormatter formatter = new CompositeTaskSourceCodeFormatter(new AnsiColorizer()); + String formatted = formatter.format(ctask); + System.out.println(formatted); + } else if ( args[1].equals("format-html") ) { + CompositeTaskSourceCodeFormatter formatter = new CompositeTaskSourceCodeFormatter(new HtmlColorizer()); + String formatted = formatter.format(ctask); + System.out.println(formatted); + } else if ( args[1].equals("format") ) { + CompositeTaskSourceCodeFormatter formatter = new CompositeTaskSourceCodeFormatter(); + String formatted = formatter.format(ctask); + System.out.println(formatted); + } else { + usage(); + } + } catch (IOException error) { + System.err.println(error); + System.exit(-1); + } catch (SyntaxError error) { + System.err.println(error); + System.exit(-1); + } + } + + public static void print_tree(CompositeTask ctask) { + print_tree(ctask, 0); + } + + public static void print_tree(CompositeTaskScope scope, int depth) { + Set nodes = scope.getNodes(); + for ( CompositeTaskNode node : nodes ) { + System.out.println(Utility.getIndentString(depth) + node); + if ( node instanceof CompositeTaskScope ) { + print_tree((CompositeTaskScope) node, depth + 2); + } + } + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/NullColorizer.java b/src/main/java/org/broadinstitute/compositetask/NullColorizer.java new file mode 100644 index 0000000..40b801e --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/NullColorizer.java @@ -0,0 +1,27 @@ +package org.broadinstitute.compositetask; + +public class NullColorizer implements CompositeTaskColorizer { + public String preamble() { + return ""; + } + + public String postamble() { + return ""; + } + + public String keyword(String str) { + return str; + } + + public String string(String str) { + return str; + } + + public String variable(String str) { + return str; + } + + public String task(String str) { + return str; + } +} diff --git a/src/main/java/org/broadinstitute/compositetask/WdlSyntaxErrorFormatter.java b/src/main/java/org/broadinstitute/compositetask/WdlSyntaxErrorFormatter.java new file mode 100644 index 0000000..fdb53f8 --- /dev/null +++ b/src/main/java/org/broadinstitute/compositetask/WdlSyntaxErrorFormatter.java @@ -0,0 +1,102 @@ +package org.broadinstitute.compositetask; + +import java.util.ArrayList; +import java.util.List; + +import org.broadinstitute.parser.SyntaxErrorFormatter; +import org.broadinstitute.parser.SourceCode; +import org.broadinstitute.parser.Terminal; +import org.broadinstitute.parser.TerminalIdentifier; +import org.broadinstitute.parser.Utility; + +public class WdlSyntaxErrorFormatter implements SyntaxErrorFormatter { + private SourceCode code; + public void setSourceCode(SourceCode code) { + this.code = code; + } + + public String unexpected_eof(String method, List expected, List nt_rules) { + ArrayList expected_terminals = new ArrayList(); + if ( expected != null && expected.size() > 0 ) { + for ( TerminalIdentifier e : expected ) { + expected_terminals.add(e.string()); + } + } + return "Unexpected end of file when parsing " + method + "\n\nExpecting one of: " + Utility.join(expected_terminals, ", ") + "\nPossible rules:\n" + Utility.join(nt_rules, "\n"); + } + + public String excess_tokens(String method, Terminal terminal) { + String msg = "Finished parsing without consuming all tokens"; + msg += "\nLocation: " + terminal.getResource() + " @ line " + terminal.getLine() + ", column " + terminal.getColumn(); + return msg; + } + + public String unexpected_symbol(String method, Terminal actual, List expected, String rule) { + String msg = "Unexpected symbol " + actual.getTerminalStr(); + + if ( expected != null && expected.size() > 0 ) { + ArrayList expected_terminals = new ArrayList(); + for ( TerminalIdentifier e : expected ) { + expected_terminals.add(e.string()); + } + msg += ". Expecting " + Utility.join(expected_terminals, ", ") + "."; + } + + msg += "\nRule: " + rule; + msg += "\nLocation: " + actual.getResource() + " @ line " + actual.getLine() + ", column " + actual.getColumn() + ":\n\n"; + msg += code.getLine(actual.getLine()) + "\n"; + msg += Utility.getIndentString(actual.getColumn()-1) + "^\n"; + return msg; + } + + public String no_more_tokens(String method, TerminalIdentifier expecting, Terminal last) { + return "No more tokens when parsing " + method + "\n" + + "Expecting: " + expecting.string() + "\n" + + "Location: " + last.getResource() + " @ line " + last.getLine() + ", column " + last.getColumn() + ":\n\n" + + this.code.getLine(last.getLine()) + "\n" + + Utility.getIndentString(last.getColumn()-1) + "^\n"; + } + + public String invalid_terminal(String method, Terminal invalid) { + return "Invalid symbol ID: "+invalid.getId()+" ("+invalid.getTerminalStr()+")"; + } + + public String missing_version(Terminal task_name) { + return "Version information missing for task " + task_name.getSourceString() + "\n" + + "Location: " + task_name.getResource() + " @ line " + task_name.getLine() + ", column " + task_name.getColumn() + ":\n\n" + + this.code.getLine(task_name.getLine()) + "\n" + Utility.getIndentString(task_name.getColumn()-1) + "^\n"; + } + + public String duplicate_output_variable(Terminal duplicate, Terminal previous) { + return "Two steps output to the same variable: " + duplicate.getSourceString() + "\n" + + "Location: " + duplicate.getResource() + " @ line " + duplicate.getLine() + ", column " + duplicate.getColumn() + ":\n\n" + + this.code.getLine(duplicate.getLine()) + "\n" + Utility.getIndentString(duplicate.getColumn()-1) + "^\n" + + "Previous output for variable was @ line " + previous.getLine() + ", column " + previous.getColumn() + ":\n\n" + + this.code.getLine(previous.getLine()) + "\n" + Utility.getIndentString(previous.getColumn()-1) + "^\n"; + } + + public String duplicate_output_file(Terminal duplicate, Terminal previous) { + return "Two steps output to the same file: " + duplicate.getSourceString() + "\n" + + "Location: " + duplicate.getResource() + " @ line " + duplicate.getLine() + ", column " + duplicate.getColumn() + ":\n\n" + + this.code.getLine(duplicate.getLine()) + "\n" + Utility.getIndentString(duplicate.getColumn()-1) + "^\n" + + "Previous output for file was @ line " + previous.getLine() + ", column " + previous.getColumn() + ":\n\n" + + this.code.getLine(previous.getLine()) + "\n" + Utility.getIndentString(previous.getColumn()-1) + "^\n"; + } + + public String duplicate_step_names(Terminal duplicate, Terminal previous) { + return "Two steps have the same name: " + duplicate.getSourceString() + "\n" + + "Location: " + duplicate.getResource() + " @ line " + duplicate.getLine() + ", column " + duplicate.getColumn() + ":\n\n" + + this.code.getLine(duplicate.getLine()) + "\n" + Utility.getIndentString(duplicate.getColumn()-1) + "^\n" + + "Previous step was defined @ line " + previous.getLine() + ", column " + previous.getColumn() + ":\n\n" + + this.code.getLine(previous.getLine()) + "\n" + Utility.getIndentString(previous.getColumn()-1) + "^\n"; + } + + public String step_doesnt_use_loop_iterator(Terminal loop_iterator, Terminal step_name) { + return "Step '" + step_name.getSourceString() + "' inside for loop doesn't use loop iterator: " + loop_iterator.getSourceString() + "\n" + + "Location: " + step_name.getResource() + " @ line " + step_name.getLine() + ", column " + step_name.getColumn() + ":\n\n" + + this.code.getLine(step_name.getLine()) + "\n" + Utility.getIndentString(step_name.getColumn()-1) + "^\n" + + "Loop iterator is declared @ line " + loop_iterator.getLine() + ", column " + loop_iterator.getColumn() + ":\n\n" + + this.code.getLine(loop_iterator.getLine()) + "\n" + Utility.getIndentString(loop_iterator.getColumn()-1) + "^\n"; + } + +} diff --git a/src/main/java/org/broadinstitute/parser/Ast.java b/src/main/java/org/broadinstitute/parser/Ast.java new file mode 100644 index 0000000..98c53a8 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/Ast.java @@ -0,0 +1,48 @@ + +package org.broadinstitute.parser; +import java.util.Map; +import java.util.LinkedList; +import java.util.Formatter; +import java.util.Locale; +import java.util.ArrayList; +public class Ast implements AstNode { + private String name; + private Map attributes; + Ast(String name, Map attributes) { + this.name = name; + this.attributes = attributes; + } + public AstNode getAttribute(String name) { + return this.attributes.get(name); + } + public Map getAttributes() { + return this.attributes; + } + public String getName() { + return this.name; + } + public String toString() { + Formatter formatter = new Formatter(new StringBuilder(), Locale.US); + LinkedList attributes = new LinkedList(); + for (final Map.Entry attribute : this.attributes.entrySet()) { + final String name = attribute.getKey(); + final AstNode node = attribute.getValue(); + final String nodeStr = (node == null) ? "None" : node.toString(); + attributes.add(name + "=" + nodeStr); + } + formatter.format("(%s: %s)", this.name, Utility.join(attributes, ", ")); + return formatter.toString(); + } + public String toPrettyString() { + return toPrettyString(0); + } + public String toPrettyString(int indent) { + String spaces = Utility.getIndentString(indent); + ArrayList children = new ArrayList(); + for( Map.Entry attribute : this.attributes.entrySet() ) { + String valueString = attribute.getValue() == null ? "None" : attribute.getValue().toPrettyString(indent + 2).trim(); + children.add(spaces + " " + attribute.getKey() + "=" + valueString); + } + return spaces + "(" + this.name + ":\n" + Utility.join(children, ",\n") + "\n" + spaces + ")"; + } +} diff --git a/src/main/java/org/broadinstitute/parser/AstList.java b/src/main/java/org/broadinstitute/parser/AstList.java new file mode 100644 index 0000000..fb6ca4d --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/AstList.java @@ -0,0 +1,22 @@ + +package org.broadinstitute.parser; +import java.util.ArrayList; +public class AstList extends ArrayList implements AstNode { + public String toString() { + return "[" + Utility.join(this, ", ") + "]"; + } + public String toPrettyString() { + return toPrettyString(0); + } + public String toPrettyString(int indent) { + String spaces = Utility.getIndentString(indent); + if (this.size() == 0) { + return spaces + "[]"; + } + ArrayList elements = new ArrayList(); + for ( AstNode node : this ) { + elements.add(node.toPrettyString(indent + 2)); + } + return spaces + "[\n" + Utility.join(elements, ",\n") + "\n" + spaces + "]"; + } +} diff --git a/src/main/java/org/broadinstitute/parser/AstNode.java b/src/main/java/org/broadinstitute/parser/AstNode.java new file mode 100644 index 0000000..2023534 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/AstNode.java @@ -0,0 +1,7 @@ + +package org.broadinstitute.parser; +public interface AstNode { + public String toString(); + public String toPrettyString(); + public String toPrettyString(int indent); +} diff --git a/src/main/java/org/broadinstitute/parser/AstTransform.java b/src/main/java/org/broadinstitute/parser/AstTransform.java new file mode 100644 index 0000000..7ca7cce --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/AstTransform.java @@ -0,0 +1,3 @@ + +package org.broadinstitute.parser; +public interface AstTransform {} diff --git a/src/main/java/org/broadinstitute/parser/AstTransformNodeCreator.java b/src/main/java/org/broadinstitute/parser/AstTransformNodeCreator.java new file mode 100644 index 0000000..8ecf41d --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/AstTransformNodeCreator.java @@ -0,0 +1,26 @@ + +package org.broadinstitute.parser; +import java.util.LinkedList; +import java.util.Map; +import java.util.LinkedHashMap; +public class AstTransformNodeCreator implements AstTransform { + private String name; + private LinkedHashMap parameters; + AstTransformNodeCreator(String name, LinkedHashMap parameters) { + this.name = name; + this.parameters = parameters; + } + public Map getParameters() { + return this.parameters; + } + public String getName() { + return this.name; + } + public String toString() { + LinkedList items = new LinkedList(); + for (final Map.Entry entry : this.parameters.entrySet()) { + items.add(entry.getKey() + "=$" + entry.getValue().toString()); + } + return "AstNodeCreator: " + this.name + "( " + Utility.join(items, ", ") + " )"; + } +} diff --git a/src/main/java/org/broadinstitute/parser/AstTransformSubstitution.java b/src/main/java/org/broadinstitute/parser/AstTransformSubstitution.java new file mode 100644 index 0000000..f4dcbcb --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/AstTransformSubstitution.java @@ -0,0 +1,14 @@ + +package org.broadinstitute.parser; +public class AstTransformSubstitution implements AstTransform { + private int index; + AstTransformSubstitution(int index) { + this.index = index; + } + public int getIndex() { + return this.index; + } + public String toString() { + return "AstSubstitution: $" + Integer.toString(this.index); + } +} diff --git a/src/main/java/org/broadinstitute/parser/CompositeTaskParser.java b/src/main/java/org/broadinstitute/parser/CompositeTaskParser.java new file mode 100644 index 0000000..734866d --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/CompositeTaskParser.java @@ -0,0 +1,1363 @@ + +package org.broadinstitute.parser; +import java.util.*; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Arrays; +public class CompositeTaskParser implements Parser { + private TokenStream tokens; + private HashMap expressionParsers; + private SyntaxErrorFormatter syntaxErrorFormatter; + private Map first; + private Map follow; + private Map> nonterminal_rules; + private Map rules; + /* table[nonterminal][terminal] = rule */ + private static final int[][] table = { + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, -1 }, + { -1, -1, -1, -1, -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, -1, -1, -1, -1, -1 }, + { 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, -1, -1, 42, -1 }, + { -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, 0, -1, 40, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, -1, 8, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, -1 }, + { -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, -1, -1 }, + { -1, 43, -1, -1, -1, -1, -1, -1, 16, -1, 16, -1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, 13, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 18, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20 }, + { -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, 41, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, -1, -1, -1, -1 }, + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + { -1, -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, -1, -1, -1, -1, -1, -1 }, + { -1, -1, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, + }; + public enum TerminalId implements TerminalIdentifier { + TERMINAL_RSQUARE(0, "rsquare"), + TERMINAL_RBRACE(1, "rbrace"), + TERMINAL_DOT(2, "dot"), + TERMINAL_FILE(3, "file"), + TERMINAL_COMMA(4, "comma"), + TERMINAL_OUTPUT(5, "output"), + TERMINAL_LBRACE(6, "lbrace"), + TERMINAL_INTO(7, "into"), + TERMINAL_FOR(8, "for"), + TERMINAL_STRING(9, "string"), + TERMINAL_COMPOSITE_TASK(10, "composite_task"), + TERMINAL_IDENTIFIER(11, "identifier"), + TERMINAL_IN(12, "in"), + TERMINAL_RPAREN(13, "rparen"), + TERMINAL_STEP(14, "step"), + TERMINAL_NUMBER(15, "number"), + TERMINAL_LPAREN(16, "lparen"), + TERMINAL_SEMI(17, "semi"), + TERMINAL_FIRST_LINE(18, "first_line"), + TERMINAL_LSQUARE(19, "lsquare"), + TERMINAL_COLON(20, "colon"), + TERMINAL_ASSIGN(21, "assign"), + TERMINAL_AS(22, "as"), + TERMINAL_INPUT(23, "input"); + private final int id; + private final String string; + TerminalId(int id, String string) { + this.id = id; + this.string = string; + } + public int id() {return id;} + public String string() {return string;} + } + private class CompositeTaskTerminalMap implements TerminalMap { + private Map id_to_str; + private Map str_to_id; + CompositeTaskTerminalMap(TerminalId[] terminals) { + id_to_str = new HashMap(); + str_to_id = new HashMap(); + for( TerminalId terminal : terminals ) { + Integer id = new Integer(terminal.id()); + String str = terminal.string(); + id_to_str.put(id, str); + str_to_id.put(str, id); + } + } + public int get(String string) { return this.str_to_id.get(string); } + public String get(int id) { return this.id_to_str.get(id); } + public boolean isValid(String string) { return this.str_to_id.containsKey(string); } + public boolean isValid(int id) { return this.id_to_str.containsKey(id); } + } + public CompositeTaskParser(SyntaxErrorFormatter syntaxErrorFormatter) { + this.syntaxErrorFormatter = syntaxErrorFormatter; + this.expressionParsers = new HashMap(); + this.first = new HashMap(); + this.follow = new HashMap(); + this.nonterminal_rules = new HashMap>(); + this.rules = new HashMap(); + ArrayList list; + String rule; + this.nonterminal_rules.put("_gen6", new ArrayList()); + this.nonterminal_rules.put("step_name", new ArrayList()); + this.nonterminal_rules.put("_gen2", new ArrayList()); + this.nonterminal_rules.put("task_attr", new ArrayList()); + this.nonterminal_rules.put("variable", new ArrayList()); + this.nonterminal_rules.put("step_output", new ArrayList()); + this.nonterminal_rules.put("_gen5", new ArrayList()); + this.nonterminal_rules.put("_gen4", new ArrayList()); + this.nonterminal_rules.put("step_output_list", new ArrayList()); + this.nonterminal_rules.put("_gen10", new ArrayList()); + this.nonterminal_rules.put("step", new ArrayList()); + this.nonterminal_rules.put("task_attr_value", new ArrayList()); + this.nonterminal_rules.put("wdl_entity", new ArrayList()); + this.nonterminal_rules.put("step_output_location", new ArrayList()); + this.nonterminal_rules.put("step_attr", new ArrayList()); + this.nonterminal_rules.put("_gen0", new ArrayList()); + this.nonterminal_rules.put("step_output_mode", new ArrayList()); + this.nonterminal_rules.put("_gen1", new ArrayList()); + this.nonterminal_rules.put("wdl", new ArrayList()); + this.nonterminal_rules.put("composite_task_entity", new ArrayList()); + this.nonterminal_rules.put("step_input", new ArrayList()); + this.nonterminal_rules.put("_gen8", new ArrayList()); + this.nonterminal_rules.put("step_input_list", new ArrayList()); + this.nonterminal_rules.put("_gen9", new ArrayList()); + this.nonterminal_rules.put("for_loop", new ArrayList()); + this.nonterminal_rules.put("task_identifier", new ArrayList()); + this.nonterminal_rules.put("_gen3", new ArrayList()); + this.nonterminal_rules.put("task_attrs", new ArrayList()); + this.nonterminal_rules.put("composite_task", new ArrayList()); + this.nonterminal_rules.put("_gen7", new ArrayList()); + this.nonterminal_rules.put("variable_member", new ArrayList()); + rule = "_gen10 := variable_member"; + this.nonterminal_rules.get("_gen10").add(rule); + this.rules.put(new Integer(0), rule); + rule = "step_output_list := 'output' 'colon' _gen8 'semi' -> StepOutputList( outputs=$2 )"; + this.nonterminal_rules.get("step_output_list").add(rule); + this.rules.put(new Integer(1), rule); + rule = "step_input := 'identifier' 'assign' variable -> StepInput( parameter=$0, value=$2 )"; + this.nonterminal_rules.get("step_input").add(rule); + this.rules.put(new Integer(2), rule); + rule = "_gen4 := task_attrs"; + this.nonterminal_rules.get("_gen4").add(rule); + this.rules.put(new Integer(3), rule); + rule = "wdl_entity := composite_task"; + this.nonterminal_rules.get("wdl_entity").add(rule); + this.rules.put(new Integer(4), rule); + rule = "step := 'step' task_identifier _gen2 'lbrace' _gen3 'rbrace' -> Step( task=$1, name=$2, body=$4 )"; + this.nonterminal_rules.get("step").add(rule); + this.rules.put(new Integer(5), rule); + rule = "step_output_location := 'as' variable -> OutputVariable( var=$1 )"; + this.nonterminal_rules.get("step_output_location").add(rule); + this.rules.put(new Integer(6), rule); + rule = "_gen5 := task_attr _gen5"; + this.nonterminal_rules.get("_gen5").add(rule); + this.rules.put(new Integer(7), rule); + rule = "task_attr_value := 'identifier'"; + this.nonterminal_rules.get("task_attr_value").add(rule); + this.rules.put(new Integer(8), rule); + rule = "_gen3 := step_attr _gen3"; + this.nonterminal_rules.get("_gen3").add(rule); + this.rules.put(new Integer(9), rule); + rule = "step_output := step_output_mode 'lparen' 'string' 'rparen' step_output_location -> StepOutput( mode=$0, expression=$2, var=$4 )"; + this.nonterminal_rules.get("step_output").add(rule); + this.rules.put(new Integer(10), rule); + rule = "_gen5 := ε"; + this.nonterminal_rules.get("_gen5").add(rule); + this.rules.put(new Integer(11), rule); + rule = "task_identifier := 'identifier' _gen4 -> Task( name=$0, attributes=$1 )"; + this.nonterminal_rules.get("task_identifier").add(rule); + this.rules.put(new Integer(12), rule); + rule = "composite_task_entity := composite_task"; + this.nonterminal_rules.get("composite_task_entity").add(rule); + this.rules.put(new Integer(13), rule); + rule = "composite_task_entity := for_loop"; + this.nonterminal_rules.get("composite_task_entity").add(rule); + this.rules.put(new Integer(14), rule); + rule = "task_attr_value := 'number'"; + this.nonterminal_rules.get("task_attr_value").add(rule); + this.rules.put(new Integer(15), rule); + rule = "_gen1 := composite_task_entity _gen1"; + this.nonterminal_rules.get("_gen1").add(rule); + this.rules.put(new Integer(16), rule); + rule = "step_name := 'as' 'identifier' -> $1"; + this.nonterminal_rules.get("step_name").add(rule); + this.rules.put(new Integer(17), rule); + rule = "_gen8 := step_output _gen9"; + this.nonterminal_rules.get("_gen8").add(rule); + this.rules.put(new Integer(18), rule); + rule = "variable := 'identifier' _gen10 -> Variable( name=$0, member=$1 )"; + this.nonterminal_rules.get("variable").add(rule); + this.rules.put(new Integer(19), rule); + rule = "step_input_list := 'input' 'colon' _gen6 'semi' -> StepInputList( inputs=$2 )"; + this.nonterminal_rules.get("step_input_list").add(rule); + this.rules.put(new Integer(20), rule); + rule = "task_attrs := 'lsquare' _gen5 'rsquare' -> $1"; + this.nonterminal_rules.get("task_attrs").add(rule); + this.rules.put(new Integer(21), rule); + rule = "_gen9 := 'comma' step_output _gen9"; + this.nonterminal_rules.get("_gen9").add(rule); + this.rules.put(new Integer(22), rule); + rule = "for_loop := 'for' 'lparen' 'identifier' 'in' 'identifier' 'rparen' 'lbrace' _gen1 'rbrace' -> ForLoop( collection=$4, item=$2, body=$7 )"; + this.nonterminal_rules.get("for_loop").add(rule); + this.rules.put(new Integer(23), rule); + rule = "task_attr := 'identifier' 'assign' task_attr_value -> TaskAttribute( key=$0, value=$2 )"; + this.nonterminal_rules.get("task_attr").add(rule); + this.rules.put(new Integer(24), rule); + rule = "wdl := _gen0"; + this.nonterminal_rules.get("wdl").add(rule); + this.rules.put(new Integer(25), rule); + rule = "_gen9 := ε"; + this.nonterminal_rules.get("_gen9").add(rule); + this.rules.put(new Integer(26), rule); + rule = "_gen0 := wdl_entity _gen0"; + this.nonterminal_rules.get("_gen0").add(rule); + this.rules.put(new Integer(27), rule); + rule = "_gen6 := step_input _gen7"; + this.nonterminal_rules.get("_gen6").add(rule); + this.rules.put(new Integer(28), rule); + rule = "composite_task := 'composite_task' 'identifier' 'lbrace' _gen1 'rbrace' -> CompositeTask( name=$1, body=$3 )"; + this.nonterminal_rules.get("composite_task").add(rule); + this.rules.put(new Integer(29), rule); + rule = "_gen8 := ε"; + this.nonterminal_rules.get("_gen8").add(rule); + this.rules.put(new Integer(30), rule); + rule = "step_output_location := 'into' variable -> OutputListAppend( var=$1 )"; + this.nonterminal_rules.get("step_output_location").add(rule); + this.rules.put(new Integer(31), rule); + rule = "variable_member := 'dot' 'identifier' -> $1"; + this.nonterminal_rules.get("variable_member").add(rule); + this.rules.put(new Integer(32), rule); + rule = "composite_task_entity := step"; + this.nonterminal_rules.get("composite_task_entity").add(rule); + this.rules.put(new Integer(33), rule); + rule = "_gen7 := ε"; + this.nonterminal_rules.get("_gen7").add(rule); + this.rules.put(new Integer(34), rule); + rule = "_gen6 := ε"; + this.nonterminal_rules.get("_gen6").add(rule); + this.rules.put(new Integer(35), rule); + rule = "step_output_mode := 'first_line'"; + this.nonterminal_rules.get("step_output_mode").add(rule); + this.rules.put(new Integer(36), rule); + rule = "_gen0 := ε"; + this.nonterminal_rules.get("_gen0").add(rule); + this.rules.put(new Integer(37), rule); + rule = "step_output_mode := 'file'"; + this.nonterminal_rules.get("step_output_mode").add(rule); + this.rules.put(new Integer(38), rule); + rule = "_gen2 := step_name"; + this.nonterminal_rules.get("_gen2").add(rule); + this.rules.put(new Integer(39), rule); + rule = "_gen10 := ε"; + this.nonterminal_rules.get("_gen10").add(rule); + this.rules.put(new Integer(40), rule); + rule = "_gen3 := ε"; + this.nonterminal_rules.get("_gen3").add(rule); + this.rules.put(new Integer(41), rule); + rule = "_gen4 := ε"; + this.nonterminal_rules.get("_gen4").add(rule); + this.rules.put(new Integer(42), rule); + rule = "_gen1 := ε"; + this.nonterminal_rules.get("_gen1").add(rule); + this.rules.put(new Integer(43), rule); + rule = "task_attr_value := 'string'"; + this.nonterminal_rules.get("task_attr_value").add(rule); + this.rules.put(new Integer(44), rule); + rule = "step_attr := step_input_list"; + this.nonterminal_rules.get("step_attr").add(rule); + this.rules.put(new Integer(45), rule); + rule = "step_attr := step_output_list"; + this.nonterminal_rules.get("step_attr").add(rule); + this.rules.put(new Integer(46), rule); + rule = "_gen2 := ε"; + this.nonterminal_rules.get("_gen2").add(rule); + this.rules.put(new Integer(47), rule); + rule = "_gen7 := 'comma' step_input _gen7"; + this.nonterminal_rules.get("_gen7").add(rule); + this.rules.put(new Integer(48), rule); + this.first.put("_gen6", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER }); + this.first.put("step_name", new TerminalId[] { TerminalId.TERMINAL_AS }); + this.first.put("_gen2", new TerminalId[] { TerminalId.TERMINAL_AS }); + this.first.put("task_attr", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER }); + this.first.put("variable", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER }); + this.first.put("step_output", new TerminalId[] { TerminalId.TERMINAL_FILE, TerminalId.TERMINAL_FIRST_LINE }); + this.first.put("_gen5", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER }); + this.first.put("_gen4", new TerminalId[] { TerminalId.TERMINAL_LSQUARE }); + this.first.put("step_output_list", new TerminalId[] { TerminalId.TERMINAL_OUTPUT }); + this.first.put("_gen10", new TerminalId[] { TerminalId.TERMINAL_DOT }); + this.first.put("step", new TerminalId[] { TerminalId.TERMINAL_STEP }); + this.first.put("task_attr_value", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER, TerminalId.TERMINAL_NUMBER, TerminalId.TERMINAL_STRING }); + this.first.put("wdl_entity", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK }); + this.first.put("step_output_location", new TerminalId[] { TerminalId.TERMINAL_INTO, TerminalId.TERMINAL_AS }); + this.first.put("step_attr", new TerminalId[] { TerminalId.TERMINAL_INPUT, TerminalId.TERMINAL_OUTPUT }); + this.first.put("_gen0", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK }); + this.first.put("step_output_mode", new TerminalId[] { TerminalId.TERMINAL_FILE, TerminalId.TERMINAL_FIRST_LINE }); + this.first.put("_gen1", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK, TerminalId.TERMINAL_FOR, TerminalId.TERMINAL_STEP }); + this.first.put("wdl", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK }); + this.first.put("composite_task_entity", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK, TerminalId.TERMINAL_FOR, TerminalId.TERMINAL_STEP }); + this.first.put("step_input", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER }); + this.first.put("_gen8", new TerminalId[] { TerminalId.TERMINAL_FILE, TerminalId.TERMINAL_FIRST_LINE }); + this.first.put("step_input_list", new TerminalId[] { TerminalId.TERMINAL_INPUT }); + this.first.put("_gen9", new TerminalId[] { TerminalId.TERMINAL_COMMA }); + this.first.put("for_loop", new TerminalId[] { TerminalId.TERMINAL_FOR }); + this.first.put("task_identifier", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER }); + this.first.put("_gen3", new TerminalId[] { TerminalId.TERMINAL_INPUT, TerminalId.TERMINAL_OUTPUT }); + this.first.put("task_attrs", new TerminalId[] { TerminalId.TERMINAL_LSQUARE }); + this.first.put("composite_task", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK }); + this.first.put("_gen7", new TerminalId[] { TerminalId.TERMINAL_COMMA }); + this.first.put("variable_member", new TerminalId[] { TerminalId.TERMINAL_DOT }); + this.follow.put("_gen6", new TerminalId[] { TerminalId.TERMINAL_SEMI }); + this.follow.put("step_name", new TerminalId[] { TerminalId.TERMINAL_LBRACE }); + this.follow.put("_gen2", new TerminalId[] { TerminalId.TERMINAL_LBRACE }); + this.follow.put("task_attr", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER, TerminalId.TERMINAL_RSQUARE }); + this.follow.put("variable", new TerminalId[] { TerminalId.TERMINAL_SEMI, TerminalId.TERMINAL_COMMA }); + this.follow.put("step_output", new TerminalId[] { TerminalId.TERMINAL_SEMI, TerminalId.TERMINAL_COMMA }); + this.follow.put("_gen5", new TerminalId[] { TerminalId.TERMINAL_RSQUARE }); + this.follow.put("_gen4", new TerminalId[] { TerminalId.TERMINAL_AS }); + this.follow.put("step_output_list", new TerminalId[] { TerminalId.TERMINAL_INPUT, TerminalId.TERMINAL_OUTPUT, TerminalId.TERMINAL_RBRACE }); + this.follow.put("_gen10", new TerminalId[] { TerminalId.TERMINAL_SEMI, TerminalId.TERMINAL_COMMA }); + this.follow.put("step", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK, TerminalId.TERMINAL_FOR, TerminalId.TERMINAL_STEP, TerminalId.TERMINAL_RBRACE }); + this.follow.put("task_attr_value", new TerminalId[] { TerminalId.TERMINAL_IDENTIFIER, TerminalId.TERMINAL_RSQUARE }); + this.follow.put("wdl_entity", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK }); + this.follow.put("step_output_location", new TerminalId[] { TerminalId.TERMINAL_SEMI, TerminalId.TERMINAL_COMMA }); + this.follow.put("step_attr", new TerminalId[] { TerminalId.TERMINAL_INPUT, TerminalId.TERMINAL_OUTPUT, TerminalId.TERMINAL_RBRACE }); + this.follow.put("_gen0", new TerminalId[] { }); + this.follow.put("step_output_mode", new TerminalId[] { TerminalId.TERMINAL_LPAREN }); + this.follow.put("_gen1", new TerminalId[] { TerminalId.TERMINAL_RBRACE }); + this.follow.put("wdl", new TerminalId[] { }); + this.follow.put("composite_task_entity", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK, TerminalId.TERMINAL_FOR, TerminalId.TERMINAL_STEP, TerminalId.TERMINAL_RBRACE }); + this.follow.put("step_input", new TerminalId[] { TerminalId.TERMINAL_SEMI, TerminalId.TERMINAL_COMMA }); + this.follow.put("_gen8", new TerminalId[] { TerminalId.TERMINAL_SEMI }); + this.follow.put("step_input_list", new TerminalId[] { TerminalId.TERMINAL_INPUT, TerminalId.TERMINAL_OUTPUT, TerminalId.TERMINAL_RBRACE }); + this.follow.put("_gen9", new TerminalId[] { TerminalId.TERMINAL_SEMI }); + this.follow.put("for_loop", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK, TerminalId.TERMINAL_FOR, TerminalId.TERMINAL_STEP, TerminalId.TERMINAL_RBRACE }); + this.follow.put("task_identifier", new TerminalId[] { TerminalId.TERMINAL_AS }); + this.follow.put("_gen3", new TerminalId[] { TerminalId.TERMINAL_RBRACE }); + this.follow.put("task_attrs", new TerminalId[] { TerminalId.TERMINAL_AS }); + this.follow.put("composite_task", new TerminalId[] { TerminalId.TERMINAL_COMPOSITE_TASK, TerminalId.TERMINAL_FOR, TerminalId.TERMINAL_STEP, TerminalId.TERMINAL_RBRACE }); + this.follow.put("_gen7", new TerminalId[] { TerminalId.TERMINAL_SEMI }); + this.follow.put("variable_member", new TerminalId[] { TerminalId.TERMINAL_SEMI, TerminalId.TERMINAL_COMMA }); + } + public TerminalMap getTerminalMap() { + return new CompositeTaskTerminalMap(TerminalId.values()); + } + public ParseTree parse(TokenStream tokens) throws SyntaxError { + this.tokens = tokens; + this.tokens.setSyntaxErrorFormatter(this.syntaxErrorFormatter); + this.tokens.setTerminalMap(this.getTerminalMap()); + ParseTree tree = this.parse_wdl(); + if (this.tokens.current() != null) { + StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + throw new SyntaxError(this.syntaxErrorFormatter.excess_tokens(stack[1].getMethodName(), this.tokens.current())); + } + return tree; + } + private boolean isTerminal(TerminalId terminal) { + return (0 <= terminal.id() && terminal.id() <= 23); + } + private boolean isNonTerminal(TerminalId terminal) { + return (24 <= terminal.id() && terminal.id() <= 54); + } + private boolean isTerminal(int terminal) { + return (0 <= terminal && terminal <= 23); + } + private boolean isNonTerminal(int terminal) { + return (24 <= terminal && terminal <= 54); + } + private ParseTree parse__gen6() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[0][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(24, "_gen6")); + tree.setList("slist"); + if ( current != null ) { + if (current.getId() == 17) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 28) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step_input(); + tree.add( subtree); + subtree = this.parse__gen7(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_step_name() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[1][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(25, "step_name")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_name", + Arrays.asList(this.first.get("step_name")), + this.nonterminal_rules.get("step_name") + )); + } + if (rule == 17) { + tree.setAstTransformation(new AstTransformSubstitution(1)); + next = this.tokens.expect(TerminalId.TERMINAL_AS, "step_name", this.rules.get(17)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "step_name", this.rules.get(17)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_name")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_name", + current, + Arrays.asList(this.first.get("step_name")), + this.rules.get(17) + )); + } + private ParseTree parse__gen2() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[2][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(26, "_gen2")); + tree.setList(null); + if ( current != null ) { + if (current.getId() == 6) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 39) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step_name(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_task_attr() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[3][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(27, "task_attr")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "task_attr", + Arrays.asList(this.first.get("task_attr")), + this.nonterminal_rules.get("task_attr") + )); + } + if (rule == 24) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("key", 0); + parameters.put("value", 2); + tree.setAstTransformation(new AstTransformNodeCreator("TaskAttribute", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "task_attr", this.rules.get(24)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_ASSIGN, "task_attr", this.rules.get(24)); + tree.add(next); + subtree = this.parse_task_attr_value(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("task_attr")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "task_attr", + current, + Arrays.asList(this.first.get("task_attr")), + this.rules.get(24) + )); + } + private ParseTree parse_variable() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[4][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(28, "variable")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "variable", + Arrays.asList(this.first.get("variable")), + this.nonterminal_rules.get("variable") + )); + } + if (rule == 19) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("name", 0); + parameters.put("member", 1); + tree.setAstTransformation(new AstTransformNodeCreator("Variable", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "variable", this.rules.get(19)); + tree.add(next); + subtree = this.parse__gen10(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("variable")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "variable", + current, + Arrays.asList(this.first.get("variable")), + this.rules.get(19) + )); + } + private ParseTree parse_step_output() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[5][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(29, "step_output")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_output", + Arrays.asList(this.first.get("step_output")), + this.nonterminal_rules.get("step_output") + )); + } + if (rule == 10) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("mode", 0); + parameters.put("expression", 2); + parameters.put("var", 4); + tree.setAstTransformation(new AstTransformNodeCreator("StepOutput", parameters)); + subtree = this.parse_step_output_mode(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_LPAREN, "step_output", this.rules.get(10)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_STRING, "step_output", this.rules.get(10)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_RPAREN, "step_output", this.rules.get(10)); + tree.add(next); + subtree = this.parse_step_output_location(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_output")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_output", + current, + Arrays.asList(this.first.get("step_output")), + this.rules.get(10) + )); + } + private ParseTree parse__gen5() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[6][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(30, "_gen5")); + tree.setList("nlist"); + if ( current != null ) { + if (current.getId() == 0) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 7) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_task_attr(); + tree.add( subtree); + subtree = this.parse__gen5(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse__gen4() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[7][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(31, "_gen4")); + tree.setList(null); + if ( current != null ) { + if (current.getId() == 22) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 3) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_task_attrs(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_step_output_list() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[8][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(32, "step_output_list")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_output_list", + Arrays.asList(this.first.get("step_output_list")), + this.nonterminal_rules.get("step_output_list") + )); + } + if (rule == 1) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("outputs", 2); + tree.setAstTransformation(new AstTransformNodeCreator("StepOutputList", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_OUTPUT, "step_output_list", this.rules.get(1)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_COLON, "step_output_list", this.rules.get(1)); + tree.add(next); + subtree = this.parse__gen8(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_SEMI, "step_output_list", this.rules.get(1)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_output_list")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_output_list", + current, + Arrays.asList(this.first.get("step_output_list")), + this.rules.get(1) + )); + } + private ParseTree parse__gen10() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[9][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(33, "_gen10")); + tree.setList(null); + if ( current != null ) { + if (current.getId() == 17 || current.getId() == 4) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 0) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_variable_member(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_step() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[10][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(34, "step")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step", + Arrays.asList(this.first.get("step")), + this.nonterminal_rules.get("step") + )); + } + if (rule == 5) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("task", 1); + parameters.put("name", 2); + parameters.put("body", 4); + tree.setAstTransformation(new AstTransformNodeCreator("Step", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_STEP, "step", this.rules.get(5)); + tree.add(next); + subtree = this.parse_task_identifier(); + tree.add( subtree); + subtree = this.parse__gen2(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_LBRACE, "step", this.rules.get(5)); + tree.add(next); + subtree = this.parse__gen3(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_RBRACE, "step", this.rules.get(5)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("step")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step", + current, + Arrays.asList(this.first.get("step")), + this.rules.get(5) + )); + } + private ParseTree parse_task_attr_value() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[11][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(35, "task_attr_value")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "task_attr_value", + Arrays.asList(this.first.get("task_attr_value")), + this.nonterminal_rules.get("task_attr_value") + )); + } + if (rule == 8) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "task_attr_value", this.rules.get(8)); + tree.add(next); + return tree; + } + else if (rule == 15) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_NUMBER, "task_attr_value", this.rules.get(15)); + tree.add(next); + return tree; + } + else if (rule == 44) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_STRING, "task_attr_value", this.rules.get(44)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("task_attr_value")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "task_attr_value", + current, + Arrays.asList(this.first.get("task_attr_value")), + this.rules.get(44) + )); + } + private ParseTree parse_wdl_entity() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[12][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(36, "wdl_entity")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "wdl_entity", + Arrays.asList(this.first.get("wdl_entity")), + this.nonterminal_rules.get("wdl_entity") + )); + } + if (rule == 4) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_composite_task(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("wdl_entity")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "wdl_entity", + current, + Arrays.asList(this.first.get("wdl_entity")), + this.rules.get(4) + )); + } + private ParseTree parse_step_output_location() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[13][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(37, "step_output_location")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_output_location", + Arrays.asList(this.first.get("step_output_location")), + this.nonterminal_rules.get("step_output_location") + )); + } + if (rule == 6) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("var", 1); + tree.setAstTransformation(new AstTransformNodeCreator("OutputVariable", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_AS, "step_output_location", this.rules.get(6)); + tree.add(next); + subtree = this.parse_variable(); + tree.add( subtree); + return tree; + } + else if (rule == 31) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("var", 1); + tree.setAstTransformation(new AstTransformNodeCreator("OutputListAppend", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_INTO, "step_output_location", this.rules.get(31)); + tree.add(next); + subtree = this.parse_variable(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_output_location")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_output_location", + current, + Arrays.asList(this.first.get("step_output_location")), + this.rules.get(31) + )); + } + private ParseTree parse_step_attr() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[14][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(38, "step_attr")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_attr", + Arrays.asList(this.first.get("step_attr")), + this.nonterminal_rules.get("step_attr") + )); + } + if (rule == 45) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step_input_list(); + tree.add( subtree); + return tree; + } + else if (rule == 46) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step_output_list(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_attr")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_attr", + current, + Arrays.asList(this.first.get("step_attr")), + this.rules.get(46) + )); + } + private ParseTree parse__gen0() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[15][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(39, "_gen0")); + tree.setList("nlist"); + if ( current != null ) { + if (current.getId() == -1) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 27) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_wdl_entity(); + tree.add( subtree); + subtree = this.parse__gen0(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_step_output_mode() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[16][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(40, "step_output_mode")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_output_mode", + Arrays.asList(this.first.get("step_output_mode")), + this.nonterminal_rules.get("step_output_mode") + )); + } + if (rule == 36) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_FIRST_LINE, "step_output_mode", this.rules.get(36)); + tree.add(next); + return tree; + } + else if (rule == 38) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_FILE, "step_output_mode", this.rules.get(38)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_output_mode")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_output_mode", + current, + Arrays.asList(this.first.get("step_output_mode")), + this.rules.get(38) + )); + } + private ParseTree parse__gen1() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[17][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(41, "_gen1")); + tree.setList("nlist"); + if ( current != null ) { + if (current.getId() == 1) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 16) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_composite_task_entity(); + tree.add( subtree); + subtree = this.parse__gen1(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_wdl() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[18][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(42, "wdl")); + tree.setList(null); + if (current == null) { + return tree; + } + if (rule == 25) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse__gen0(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("wdl")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "wdl", + current, + Arrays.asList(this.first.get("wdl")), + this.rules.get(25) + )); + } + private ParseTree parse_composite_task_entity() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[19][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(43, "composite_task_entity")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "composite_task_entity", + Arrays.asList(this.first.get("composite_task_entity")), + this.nonterminal_rules.get("composite_task_entity") + )); + } + if (rule == 13) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_composite_task(); + tree.add( subtree); + return tree; + } + else if (rule == 14) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_for_loop(); + tree.add( subtree); + return tree; + } + else if (rule == 33) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("composite_task_entity")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "composite_task_entity", + current, + Arrays.asList(this.first.get("composite_task_entity")), + this.rules.get(33) + )); + } + private ParseTree parse_step_input() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[20][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(44, "step_input")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_input", + Arrays.asList(this.first.get("step_input")), + this.nonterminal_rules.get("step_input") + )); + } + if (rule == 2) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("parameter", 0); + parameters.put("value", 2); + tree.setAstTransformation(new AstTransformNodeCreator("StepInput", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "step_input", this.rules.get(2)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_ASSIGN, "step_input", this.rules.get(2)); + tree.add(next); + subtree = this.parse_variable(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_input")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_input", + current, + Arrays.asList(this.first.get("step_input")), + this.rules.get(2) + )); + } + private ParseTree parse__gen8() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[21][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(45, "_gen8")); + tree.setList("slist"); + if ( current != null ) { + if (current.getId() == 17) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 18) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step_output(); + tree.add( subtree); + subtree = this.parse__gen9(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_step_input_list() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[22][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(46, "step_input_list")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "step_input_list", + Arrays.asList(this.first.get("step_input_list")), + this.nonterminal_rules.get("step_input_list") + )); + } + if (rule == 20) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("inputs", 2); + tree.setAstTransformation(new AstTransformNodeCreator("StepInputList", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_INPUT, "step_input_list", this.rules.get(20)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_COLON, "step_input_list", this.rules.get(20)); + tree.add(next); + subtree = this.parse__gen6(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_SEMI, "step_input_list", this.rules.get(20)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("step_input_list")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "step_input_list", + current, + Arrays.asList(this.first.get("step_input_list")), + this.rules.get(20) + )); + } + private ParseTree parse__gen9() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[23][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(47, "_gen9")); + tree.setList("slist"); + if ( current != null ) { + if (current.getId() == 17) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 22) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_COMMA, "_gen9", this.rules.get(22)); + tree.add(next); + tree.setListSeparator(next); + subtree = this.parse_step_output(); + tree.add( subtree); + subtree = this.parse__gen9(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_for_loop() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[24][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(48, "for_loop")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "for_loop", + Arrays.asList(this.first.get("for_loop")), + this.nonterminal_rules.get("for_loop") + )); + } + if (rule == 23) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("collection", 4); + parameters.put("item", 2); + parameters.put("body", 7); + tree.setAstTransformation(new AstTransformNodeCreator("ForLoop", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_FOR, "for_loop", this.rules.get(23)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_LPAREN, "for_loop", this.rules.get(23)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "for_loop", this.rules.get(23)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_IN, "for_loop", this.rules.get(23)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "for_loop", this.rules.get(23)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_RPAREN, "for_loop", this.rules.get(23)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_LBRACE, "for_loop", this.rules.get(23)); + tree.add(next); + subtree = this.parse__gen1(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_RBRACE, "for_loop", this.rules.get(23)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("for_loop")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "for_loop", + current, + Arrays.asList(this.first.get("for_loop")), + this.rules.get(23) + )); + } + private ParseTree parse_task_identifier() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[25][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(49, "task_identifier")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "task_identifier", + Arrays.asList(this.first.get("task_identifier")), + this.nonterminal_rules.get("task_identifier") + )); + } + if (rule == 12) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("name", 0); + parameters.put("attributes", 1); + tree.setAstTransformation(new AstTransformNodeCreator("Task", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "task_identifier", this.rules.get(12)); + tree.add(next); + subtree = this.parse__gen4(); + tree.add( subtree); + return tree; + } + List terminals = Arrays.asList(this.first.get("task_identifier")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "task_identifier", + current, + Arrays.asList(this.first.get("task_identifier")), + this.rules.get(12) + )); + } + private ParseTree parse__gen3() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[26][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(50, "_gen3")); + tree.setList("nlist"); + if ( current != null ) { + if (current.getId() == 1) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 9) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + subtree = this.parse_step_attr(); + tree.add( subtree); + subtree = this.parse__gen3(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_task_attrs() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[27][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(51, "task_attrs")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "task_attrs", + Arrays.asList(this.first.get("task_attrs")), + this.nonterminal_rules.get("task_attrs") + )); + } + if (rule == 21) { + tree.setAstTransformation(new AstTransformSubstitution(1)); + next = this.tokens.expect(TerminalId.TERMINAL_LSQUARE, "task_attrs", this.rules.get(21)); + tree.add(next); + subtree = this.parse__gen5(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_RSQUARE, "task_attrs", this.rules.get(21)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("task_attrs")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "task_attrs", + current, + Arrays.asList(this.first.get("task_attrs")), + this.rules.get(21) + )); + } + private ParseTree parse_composite_task() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[28][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(52, "composite_task")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "composite_task", + Arrays.asList(this.first.get("composite_task")), + this.nonterminal_rules.get("composite_task") + )); + } + if (rule == 29) { + LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("name", 1); + parameters.put("body", 3); + tree.setAstTransformation(new AstTransformNodeCreator("CompositeTask", parameters)); + next = this.tokens.expect(TerminalId.TERMINAL_COMPOSITE_TASK, "composite_task", this.rules.get(29)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "composite_task", this.rules.get(29)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_LBRACE, "composite_task", this.rules.get(29)); + tree.add(next); + subtree = this.parse__gen1(); + tree.add( subtree); + next = this.tokens.expect(TerminalId.TERMINAL_RBRACE, "composite_task", this.rules.get(29)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("composite_task")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "composite_task", + current, + Arrays.asList(this.first.get("composite_task")), + this.rules.get(29) + )); + } + private ParseTree parse__gen7() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[29][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(53, "_gen7")); + tree.setList("slist"); + if ( current != null ) { + if (current.getId() == 17) { + return tree; + } + } + if (current == null) { + return tree; + } + if (rule == 48) { + tree.setAstTransformation(new AstTransformSubstitution(0)); + next = this.tokens.expect(TerminalId.TERMINAL_COMMA, "_gen7", this.rules.get(48)); + tree.add(next); + tree.setListSeparator(next); + subtree = this.parse_step_input(); + tree.add( subtree); + subtree = this.parse__gen7(); + tree.add( subtree); + return tree; + } + return tree; + } + private ParseTree parse_variable_member() throws SyntaxError { + Terminal current = this.tokens.current(); + Terminal next; + ParseTree subtree; + int rule = current != null ? this.table[30][current.getId()] : -1; + ParseTree tree = new ParseTree( new NonTerminal(54, "variable_member")); + tree.setList(null); + if (current == null) { + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_eof( + "variable_member", + Arrays.asList(this.first.get("variable_member")), + this.nonterminal_rules.get("variable_member") + )); + } + if (rule == 32) { + tree.setAstTransformation(new AstTransformSubstitution(1)); + next = this.tokens.expect(TerminalId.TERMINAL_DOT, "variable_member", this.rules.get(32)); + tree.add(next); + next = this.tokens.expect(TerminalId.TERMINAL_IDENTIFIER, "variable_member", this.rules.get(32)); + tree.add(next); + return tree; + } + List terminals = Arrays.asList(this.first.get("variable_member")); + throw new SyntaxError(this.syntaxErrorFormatter.unexpected_symbol( + "variable_member", + current, + Arrays.asList(this.first.get("variable_member")), + this.rules.get(32) + )); + } +} diff --git a/src/main/java/org/broadinstitute/parser/ExpressionParser.java b/src/main/java/org/broadinstitute/parser/ExpressionParser.java new file mode 100644 index 0000000..e27ca16 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/ExpressionParser.java @@ -0,0 +1,5 @@ + +package org.broadinstitute.parser; +public interface ExpressionParser extends Parser { + ParseTree parse(TokenStream tokens, int rbp) throws SyntaxError; +} diff --git a/src/main/java/org/broadinstitute/parser/NonTerminal.java b/src/main/java/org/broadinstitute/parser/NonTerminal.java new file mode 100644 index 0000000..613898f --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/NonTerminal.java @@ -0,0 +1,19 @@ + +package org.broadinstitute.parser; +public class NonTerminal { + private int id; + private String string; + NonTerminal(int id, String string) { + this.id = id; + this.string = string; + } + public int getId() { + return this.id; + } + public String getString() { + return this.string; + } + public String toString() { + return this.string; + } +} diff --git a/src/main/java/org/broadinstitute/parser/ParseTree.java b/src/main/java/org/broadinstitute/parser/ParseTree.java new file mode 100644 index 0000000..060dcb0 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/ParseTree.java @@ -0,0 +1,161 @@ + +package org.broadinstitute.parser; +import java.util.ArrayList; +import java.util.Map; +import java.util.List; +import java.util.LinkedHashMap; +public class ParseTree implements ParseTreeNode { + private NonTerminal nonterminal; + private ArrayList children; + private boolean isExpr, isNud, isPrefix, isInfix, isExprNud; + private int nudMorphemeCount; + private Terminal listSeparator; + private String list; + private AstTransform astTransform; + ParseTree(NonTerminal nonterminal) { + this.nonterminal = nonterminal; + this.children = new ArrayList(); + this.astTransform = null; + this.isExpr = false; + this.isNud = false; + this.isPrefix = false; + this.isInfix = false; + this.isExprNud = false; + this.nudMorphemeCount = 0; + this.listSeparator = null; + this.list = ""; + } + public void setExpr(boolean value) { this.isExpr = value; } + public void setNud(boolean value) { this.isNud = value; } + public void setPrefix(boolean value) { this.isPrefix = value; } + public void setInfix(boolean value) { this.isInfix = value; } + public void setExprNud(boolean value) { this.isExprNud = value; } + public void setAstTransformation(AstTransform value) { this.astTransform = value; } + public void setNudMorphemeCount(int value) { this.nudMorphemeCount = value; } + public void setList(String value) { this.list = value; } + public void setListSeparator(Terminal value) { this.listSeparator = value; } + public int getNudMorphemeCount() { return this.nudMorphemeCount; } + public List getChildren() { return this.children; } + public boolean isInfix() { return this.isInfix; } + public boolean isPrefix() { return this.isPrefix; } + public boolean isExpr() { return this.isExpr; } + public boolean isNud() { return this.isNud; } + public boolean isExprNud() { return this.isExprNud; } + public void add(ParseTreeNode tree) { + if (this.children == null) { + this.children = new ArrayList(); + } + this.children.add(tree); + } + private boolean isCompoundNud() { + if ( this.children.size() > 0 && this.children.get(0) instanceof ParseTree ) { + ParseTree child = (ParseTree) this.children.get(0); + if ( child.isNud() && !child.isPrefix() && !this.isExprNud() && !this.isInfix() ) { + return true; + } + } + return false; + } + public AstNode toAst() { + if ( this.list == "slist" || this.list == "nlist" ) { + int offset = (this.children.size() > 0 && this.children.get(0) == this.listSeparator) ? 1 : 0; + AstList astList = new AstList(); + if ( this.children.size() == 0 ) { + return astList; + } + astList.add(this.children.get(offset).toAst()); + astList.addAll((AstList) this.children.get(offset + 1).toAst()); + return astList; + } else if ( this.list == "tlist" ) { + AstList astList = new AstList(); + if ( this.children.size() == 0 ) { + return astList; + } + astList.add(this.children.get(0).toAst()); + astList.addAll((AstList) this.children.get(2).toAst()); + return astList; + } else if ( this.list == "mlist" ) { + AstList astList = new AstList(); + int lastElement = this.children.size() - 1; + if ( this.children.size() == 0 ) { + return astList; + } + for (int i = 0; i < lastElement; i++) { + astList.add(this.children.get(i).toAst()); + } + astList.addAll((AstList) this.children.get(this.children.size() - 1).toAst()); + return astList; + } else if ( this.isExpr ) { + if ( this.astTransform instanceof AstTransformSubstitution ) { + AstTransformSubstitution astSubstitution = (AstTransformSubstitution) astTransform; + return this.children.get(astSubstitution.getIndex()).toAst(); + } else if ( this.astTransform instanceof AstTransformNodeCreator ) { + AstTransformNodeCreator astNodeCreator = (AstTransformNodeCreator) this.astTransform; + LinkedHashMap parameters = new LinkedHashMap(); + ParseTreeNode child; + for ( final Map.Entry parameter : astNodeCreator.getParameters().entrySet() ) { + String name = parameter.getKey(); + int index = parameter.getValue().intValue(); + if ( index == '$' ) { + child = this.children.get(0); + } else if ( this.isCompoundNud() ) { + ParseTree firstChild = (ParseTree) this.children.get(0); + if ( index < firstChild.getNudMorphemeCount() ) { + child = firstChild.getChildren().get(index); + } else { + index = index - firstChild.getNudMorphemeCount() + 1; + child = this.children.get(index); + } + } else if ( this.children.size() == 1 && !(this.children.get(0) instanceof ParseTree) && !(this.children.get(0) instanceof List) ) { + // TODO: I don't think this should ever be called + child = this.children.get(0); + } else { + child = this.children.get(index); + } + parameters.put(name, child.toAst()); + } + return new Ast(astNodeCreator.getName(), parameters); + } + } else { + AstTransformSubstitution defaultAction = new AstTransformSubstitution(0); + AstTransform action = this.astTransform != null ? this.astTransform : defaultAction; + if (this.children.size() == 0) return null; + if (action instanceof AstTransformSubstitution) { + AstTransformSubstitution astSubstitution = (AstTransformSubstitution) action; + return this.children.get(astSubstitution.getIndex()).toAst(); + } else if (action instanceof AstTransformNodeCreator) { + AstTransformNodeCreator astNodeCreator = (AstTransformNodeCreator) action; + LinkedHashMap evaluatedParameters = new LinkedHashMap(); + for ( Map.Entry baseParameter : astNodeCreator.getParameters().entrySet() ) { + String name = baseParameter.getKey(); + int index2 = baseParameter.getValue().intValue(); + evaluatedParameters.put(name, this.children.get(index2).toAst()); + } + return new Ast(astNodeCreator.getName(), evaluatedParameters); + } + } + return null; + } + public String toString() { + ArrayList children = new ArrayList(); + for (ParseTreeNode child : this.children) { + children.add(child.toString()); + } + return "(" + this.nonterminal.getString() + ": " + Utility.join(children, ", ") + ")"; + } + public String toPrettyString() { + return toPrettyString(0); + } + public String toPrettyString(int indent) { + if (this.children.size() == 0) { + return "(" + this.nonterminal.toString() + ": )"; + } + String spaces = Utility.getIndentString(indent); + ArrayList children = new ArrayList(); + for ( ParseTreeNode node : this.children ) { + String sub = node.toPrettyString(indent + 2).trim(); + children.add(spaces + " " + sub); + } + return spaces + "(" + this.nonterminal.toString() + ":\n" + Utility.join(children, ",\n") + "\n" + spaces + ")"; + } +} diff --git a/src/main/java/org/broadinstitute/parser/ParseTreeNode.java b/src/main/java/org/broadinstitute/parser/ParseTreeNode.java new file mode 100644 index 0000000..a3a530e --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/ParseTreeNode.java @@ -0,0 +1,8 @@ + +package org.broadinstitute.parser; +public interface ParseTreeNode { + public AstNode toAst(); + public String toString(); + public String toPrettyString(); + public String toPrettyString(int indent); +} diff --git a/src/main/java/org/broadinstitute/parser/Parser.java b/src/main/java/org/broadinstitute/parser/Parser.java new file mode 100644 index 0000000..e83aa2e --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/Parser.java @@ -0,0 +1,6 @@ + +package org.broadinstitute.parser; +public interface Parser { + ParseTree parse(TokenStream tokens) throws SyntaxError; + TerminalMap getTerminalMap(); +} diff --git a/src/main/java/org/broadinstitute/parser/SourceCode.java b/src/main/java/org/broadinstitute/parser/SourceCode.java new file mode 100644 index 0000000..0e101ff --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/SourceCode.java @@ -0,0 +1,12 @@ + +package org.broadinstitute.parser; +import java.util.List; +public interface SourceCode { + public void advance(int amount); + public List getLines(); + public String getLine(int lineno); + public String getString(); + public int getLine(); + public int getColumn(); + public String getResource(); +} diff --git a/src/main/java/org/broadinstitute/parser/SyntaxError.java b/src/main/java/org/broadinstitute/parser/SyntaxError.java new file mode 100644 index 0000000..caae11e --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/SyntaxError.java @@ -0,0 +1,7 @@ + +package org.broadinstitute.parser; +public class SyntaxError extends Exception { + public SyntaxError(String message) { + super(message); + } +} diff --git a/src/main/java/org/broadinstitute/parser/SyntaxErrorFormatter.java b/src/main/java/org/broadinstitute/parser/SyntaxErrorFormatter.java new file mode 100644 index 0000000..aa6dda7 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/SyntaxErrorFormatter.java @@ -0,0 +1,15 @@ + +package org.broadinstitute.parser; +import java.util.List; +public interface SyntaxErrorFormatter { + /* Called when the parser runs out of tokens but isn't finished parsing. */ + String unexpected_eof(String method, List expected, List nt_rules); + /* Called when the parser finished parsing but there are still tokens left in the stream. */ + String excess_tokens(String method, Terminal terminal); + /* Called when the parser is expecting one token and gets another. */ + String unexpected_symbol(String method, Terminal actual, List expected, String rule); + /* Called when the parser is expecing a tokens but there are no more tokens. */ + String no_more_tokens(String method, TerminalIdentifier expecting, Terminal last); + /* Invalid terminal is found in the token stream. */ + String invalid_terminal(String method, Terminal invalid); +} diff --git a/src/main/java/org/broadinstitute/parser/Terminal.java b/src/main/java/org/broadinstitute/parser/Terminal.java new file mode 100644 index 0000000..28034f8 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/Terminal.java @@ -0,0 +1,53 @@ + +package org.broadinstitute.parser; +import java.util.Formatter; +import java.util.Locale; +public class Terminal implements AstNode, ParseTreeNode +{ + private int id; + private String terminal_str; + private String source_string; + private String resource; + private int line; + private int col; + public Terminal(int id, String terminal_str, String source_string, String resource, int line, int col) { + this.id = id; + this.terminal_str = terminal_str; + this.source_string = source_string; + this.resource = resource; + this.line = line; + this.col = col; + } + public int getId() { + return this.id; + } + public String getTerminalStr() { + return this.terminal_str; + } + public String getSourceString() { + return this.source_string; + } + public String getResource() { + return this.resource; + } + public int getLine() { + return this.line; + } + public int getColumn() { + return this.col; + } + public String toString() { + StringBuilder sb = new StringBuilder(); + Formatter formatter = new Formatter(sb, Locale.US); + formatter.format("{\"terminal\": \"%s\", \"line\": %d, \"col\": %d, \"resource\": \"%s\", \"source_string\": \"%s\"}", this.getTerminalStr(), this.getLine(), this.getColumn(), this.getResource(), Utility.base64_encode(this.getSourceString().getBytes())); + return formatter.toString(); + } + public String toPrettyString() { + return toPrettyString(0); + } + public String toPrettyString(int indent) { + String spaces = Utility.getIndentString(indent); + return spaces + this.getTerminalStr(); + } + public AstNode toAst() { return this; } +} diff --git a/src/main/java/org/broadinstitute/parser/TerminalIdentifier.java b/src/main/java/org/broadinstitute/parser/TerminalIdentifier.java new file mode 100644 index 0000000..5690697 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/TerminalIdentifier.java @@ -0,0 +1,6 @@ + +package org.broadinstitute.parser; +public interface TerminalIdentifier { + public int id(); + public String string(); +} diff --git a/src/main/java/org/broadinstitute/parser/TerminalMap.java b/src/main/java/org/broadinstitute/parser/TerminalMap.java new file mode 100644 index 0000000..3cf3fa4 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/TerminalMap.java @@ -0,0 +1,8 @@ + +package org.broadinstitute.parser; +public interface TerminalMap { + int get(String string); + String get(int id); + boolean isValid(String string); + boolean isValid(int id); +} diff --git a/src/main/java/org/broadinstitute/parser/TokenStream.java b/src/main/java/org/broadinstitute/parser/TokenStream.java new file mode 100644 index 0000000..5a81fa9 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/TokenStream.java @@ -0,0 +1,57 @@ + +package org.broadinstitute.parser; +import java.util.ArrayList; +import java.util.List; +import java.util.Formatter; +import java.util.Locale; +public class TokenStream extends ArrayList { + private int index; + private TerminalMap terminals; + private SyntaxErrorFormatter syntaxErrorFormatter; + public TokenStream(List terminals) { + super(terminals); + reset(); + } + public TokenStream() { + reset(); + } + public void setTerminalMap(TerminalMap terminals) { + this.terminals = terminals; + } + public void setSyntaxErrorFormatter(SyntaxErrorFormatter syntaxErrorFormatter) { + this.syntaxErrorFormatter = syntaxErrorFormatter; + } + public void reset() { + this.index = 0; + } + public Terminal advance() { + this.index += 1; + return this.current(); + } + public Terminal current() { + try { + return this.get(this.index); + } catch (IndexOutOfBoundsException e) { + return null; + } + } + public Terminal last() { + return this.get(this.size() - 1); + } + public Terminal expect(TerminalIdentifier expecting, String nonterminal, String rule) throws SyntaxError { + Terminal current = current(); + if (current == null) { + throw new SyntaxError(syntaxErrorFormatter.no_more_tokens(nonterminal, expecting, last())); + } + if (current.getId() != expecting.id()) { + ArrayList expectedList = new ArrayList(); + expectedList.add(expecting); + throw new SyntaxError(syntaxErrorFormatter.unexpected_symbol(nonterminal, current, expectedList, rule)); + } + Terminal next = advance(); + if ( next != null && !this.terminals.isValid(next.getId()) ) { + throw new SyntaxError(syntaxErrorFormatter.invalid_terminal(nonterminal, next)); + } + return current; + } +} diff --git a/src/main/java/org/broadinstitute/parser/Utility.java b/src/main/java/org/broadinstitute/parser/Utility.java new file mode 100644 index 0000000..0b87903 --- /dev/null +++ b/src/main/java/org/broadinstitute/parser/Utility.java @@ -0,0 +1,83 @@ + +package org.broadinstitute.parser; +import java.util.Collection; +import java.util.Iterator; +import java.io.IOException; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.nio.*; +import java.nio.channels.FileChannel; +import java.nio.charset.Charset; +public class Utility { + public static String join(Collection s, String delimiter) { + StringBuilder builder = new StringBuilder(); + Iterator iter = s.iterator(); + while (iter.hasNext()) { + builder.append(iter.next()); + if (!iter.hasNext()) { + break; + } + builder.append(delimiter); + } + return builder.toString(); + } + public static String getIndentString(int spaces) { + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < spaces; i++) { + sb.append(' '); + } + return sb.toString(); + } + public static String base64_encode(byte[] bytes) { + int b64_len = ((bytes.length + ( (bytes.length % 3 != 0) ? (3 - (bytes.length % 3)) : 0) ) / 3) * 4; + int cycle = 0, b64_index = 0; + byte[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes(); + byte[] b64 = new byte[b64_len]; + byte[] buffer = new byte[3]; + Arrays.fill(buffer, (byte) -1); + for (byte b : bytes) { + int index = cycle % 3; + buffer[index] = b; + boolean last = (cycle == (bytes.length - 1)); + if ( index == 2 || last ) { + if ( last ) { + if ( buffer[1] == -1 ) buffer[1] = 0; + if ( buffer[2] == -1 ) buffer[2] = 0; + } + b64[b64_index++] = alphabet[buffer[0] >> 2]; + b64[b64_index++] = alphabet[((buffer[0] & 0x3) << 4) | ((buffer[1] >> 4) & 0xf)]; + b64[b64_index++] = alphabet[((buffer[1] & 0xf) << 2) | ((buffer[2] >> 6) & 0x3)]; + b64[b64_index++] = alphabet[buffer[2] & 0x3f]; + if ( buffer[1] == 0 ) b64[b64_index - 2] = (byte) '='; + if ( buffer[2] == 0 ) b64[b64_index - 1] = (byte) '='; + Arrays.fill(buffer, (byte) -1); + } + cycle++; + } + return new String(b64); + } + public static String readStdin() throws IOException { + InputStreamReader stream = new InputStreamReader(System.in, "utf-8"); + char buffer[] = new char[System.in.available()]; + try { + stream.read(buffer, 0, System.in.available()); + } finally { + stream.close(); + } + return new String(buffer); + } + public static String readFile(String path) throws IOException { + FileInputStream stream = new FileInputStream(new File(path)); + try { + FileChannel fc = stream.getChannel(); + MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); + /* Instead of using default, pass in a decoder. */ + return Charset.defaultCharset().decode(bb).toString(); + } + finally { + stream.close(); + } + } +} diff --git a/src/test/java/org/broadinstitute/compositetask/ApiTest.java b/src/test/java/org/broadinstitute/compositetask/ApiTest.java new file mode 100644 index 0000000..133ede6 --- /dev/null +++ b/src/test/java/org/broadinstitute/compositetask/ApiTest.java @@ -0,0 +1,85 @@ +package org.broadinstitute.compositetask; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeClass; +import org.testng.Assert; + +import java.io.File; +import java.io.IOException; +import java.util.Set; + +import org.broadinstitute.parser.SyntaxError; + +import org.broadinstitute.compositetask.CompositeTask; + +public class ApiTest +{ + private CompositeTask task; + + @BeforeClass + private void createCompositeTaskObject() { + try { + File source = new File("test-files/api/0.wdl"); + String relative = new File(".").toURI().relativize(source.toURI()).getPath(); + this.task = new CompositeTask(source, relative); + } catch(IOException error) { + Assert.fail("IOException reading file: " + error); + } catch(SyntaxError error) { + Assert.fail("Not expecting syntax error: " + error); + } + } + + @Test + public void testGetNodesMethodReturnsTheRightNumberOfNodes() { + Assert.assertEquals(this.task.getNodes().size(), 2, "Expecting 2 nodes, found " + this.task.getNodes().size()); + } + + @Test + public void testGetStepMethodReturnsTheCorrectTopLevelStep() { + CompositeTaskStep step = this.task.getStep("atask"); + Assert.assertNotNull(step, "Expected one step with name 'atask'"); + Assert.assertEquals(step.getName(), "atask", "Expecting one step with name 'atask'"); + Assert.assertEquals(step.getParent(), this.task, "Expecting the parent of 'atask' step to be the composite task"); + } + + @Test + public void testTopLevelStepHasCorrectOutputMappingsToVariableX() { + CompositeTaskStep step = this.task.getStep("atask"); + boolean found = false; + for ( CompositeTaskStepOutput output : step.getOutputs() ) { + if ( output.getVariable().getName().equals("x") ) { + found = true; + Assert.assertEquals(output.getType(), "File", "Expected the variable 'x' to be a File mapping"); + Assert.assertEquals(output.getMethod(), "assign", "Expected the mapping method to be 'assign'"); + Assert.assertEquals(output.getPath(), "foo.txt", "Expected the output file path to be 'foo.txt'"); + } + } + if ( !found ) Assert.fail("Expected to find one output to 'atask' to variable 'x'"); + } + + @Test + public void testTopLevelStepHasCorrectOutputMappingsToVariableY() { + CompositeTaskStep step = this.task.getStep("atask"); + boolean found = false; + for ( CompositeTaskStepOutput output : step.getOutputs() ) { + if ( output.getVariable().getName().equals("y") ) { + found = true; + Assert.assertEquals(output.getType(), "FirstLine", "Expected the variable 'y' to be a File mapping"); + Assert.assertEquals(output.getMethod(), "assign", "Expected the mapping method to be 'assign'"); + Assert.assertEquals(output.getPath(), "bar.txt", "Expected the output file path to be 'bar.txt'"); + } + } + if ( !found ) Assert.fail("Expected to find one output to 'atask' to variable 'y'"); + } + + @Test + public void testSingleTopLevelForLoopExistsWithSubTask() { + Set nodes = this.task.getNodes(); + CompositeTaskStep innerStep = this.task.getStep("btask"); + Assert.assertNotNull(innerStep, "Expected a step with name 'btask' to exist"); + CompositeTaskForLoop loop = (CompositeTaskForLoop) innerStep.getParent(); + Assert.assertEquals(loop.getParent(), this.task, "Expected the loop's parent node to be the composite task"); + Assert.assertEquals(loop.getCollection().getName(), "foobar", "Expecting one loop with a collection called 'foobar'"); + Assert.assertEquals(loop.getVariable().getName(), "item", "Expecting one loop with a variable called 'item'"); + } +} diff --git a/src/test/java/org/broadinstitute/compositetask/ParsingTest.java b/src/test/java/org/broadinstitute/compositetask/ParsingTest.java new file mode 100644 index 0000000..452d404 --- /dev/null +++ b/src/test/java/org/broadinstitute/compositetask/ParsingTest.java @@ -0,0 +1,222 @@ +package org.broadinstitute.compositetask; + +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; +import org.testng.Assert; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Collection; +import java.util.ArrayList; +import java.util.List; + +import org.broadinstitute.parser.SyntaxError; +import org.broadinstitute.parser.SourceCode; +import org.broadinstitute.parser.Terminal; +import org.broadinstitute.parser.Utility; + +import org.broadinstitute.compositetask.CompositeTask; +import org.broadinstitute.compositetask.CompositeTaskSourceCode; +import org.broadinstitute.compositetask.Lexer; + +public class ParsingTest +{ + @DataProvider(name="parsingTests") + public Object[][] parsingTests() { + File parsingTestDir = new File("test-files", "parsing"); + Collection composite_tasks = new ArrayList(); + + for ( String subDir : parsingTestDir.list() ) { + File testDir = new File(parsingTestDir, subDir); + File skipFile = new File(testDir, "skip"); + if ( ! skipFile.exists() ) { + composite_tasks.add(new Object[] { testDir }); + } + } + + return composite_tasks.toArray(new Object[0][]); + } + + private CompositeTask getCompositeTask(File source) { + try { + String relative = new File(".").toURI().relativize(source.toURI()).getPath(); + return new CompositeTask(source, relative); + } catch(IOException error) { + Assert.fail("IOException reading file: " + error); + } catch(SyntaxError error) { + Assert.fail("Not expecting syntax error: " + error); + } + + return null; + } + + @Test(dataProvider="parsingTests") + public void testLexicalAnalysis(File dir) { + File tokens = new File(dir, "tokens"); + File source = new File(dir, "source.wdl"); + String actual = null; + + try { + String relative = new File(".").toURI().relativize(source.toURI()).getPath(); + SourceCode code = new CompositeTaskSourceCode(source, relative); + Lexer lexer = new Lexer(); + List terminals = lexer.getTokens(code); + actual = "[\n " + Utility.join(terminals, ",\n ") + "\n]\n"; + } catch (IOException error) { + Assert.fail("Could not read source code: " + error); + } + + if ( !tokens.exists() ) { + try { + FileWriter out = new FileWriter(tokens); + out.write(actual); + out.close(); + } catch (IOException error) { + Assert.fail("Could not write tokens file: " + error); + } + + System.out.println("Created " + tokens); + } + + try { + String expected = Utility.readFile(tokens.getAbsolutePath()); + Assert.assertEquals(actual, expected, "Tokens list did not match."); + } catch (IOException error) { + Assert.fail("Cannot read " + tokens.getAbsolutePath()); + } + } + + @Test(dataProvider="parsingTests") + public void testParseTreeIsGeneratedFromSourceCodeCorrectly(File dir) { + File source = new File(dir, "source.wdl"); + File parsetree = new File(dir, "parsetree"); + CompositeTask ctask = getCompositeTask(source); + String actual = ctask.getParseTree().toPrettyString(); + + if ( ctask == null ) { + Assert.fail("Null Composite Task"); + } + + if ( !parsetree.exists() ) { + try { + FileWriter out = new FileWriter(parsetree); + out.write(actual); + out.close(); + } catch (IOException error) { + Assert.fail("Could not write " + parsetree + ": " + error); + } + + System.out.println("Created " + parsetree); + } + + try { + String expected = Utility.readFile(parsetree.getAbsolutePath()); + Assert.assertEquals(actual, expected, "Parse trees did not match"); + } catch (IOException error) { + Assert.fail("Cannot read " + parsetree.getAbsolutePath()); + } + } + + @Test(dataProvider="parsingTests") + public void testAbstractSyntaxTreeIsGeneratedFromSourceCodeCorrectly(File dir) { + File source = new File(dir, "source.wdl"); + File ast = new File(dir, "ast"); + CompositeTask ctask = getCompositeTask(source); + String actual = ctask.getAst().toPrettyString(); + + if ( !ast.exists() ) { + try { + FileWriter out = new FileWriter(ast); + out.write(actual); + out.close(); + } catch (IOException error) { + Assert.fail("Could not write " + ast + ": " + error); + } + + System.out.println("Created " + ast); + } + + try { + String expected = Utility.readFile(ast.getAbsolutePath()); + Assert.assertEquals(actual, expected, "Abstract syntax trees did not match"); + } catch (IOException error) { + Assert.fail("Cannot read " + ast.getAbsolutePath()); + } + } + + @Test(dataProvider="parsingTests") + public void testSourceFormatterOutputsCorrectlyFormattedSourceCode(File dir) { + File source = new File(dir, "source.wdl"); + File formatted_file = new File(dir, "formatted"); + CompositeTask ctask = getCompositeTask(source); + CompositeTaskSourceCodeFormatter formatter = new CompositeTaskSourceCodeFormatter(); + String actual = formatter.format(ctask); + + if ( !formatted_file.exists() ) { + try { + FileWriter out = new FileWriter(formatted_file); + out.write(actual); + out.close(); + } catch (IOException error) { + Assert.fail("Could not write " + formatted_file + ": " + error); + } + + System.out.println("Created " + formatted_file); + } + + try { + String expected = Utility.readFile(formatted_file.getAbsolutePath()); + Assert.assertEquals(actual, expected, "Formatted source code files did not match"); + } catch (IOException error) { + Assert.fail("Cannot read " + formatted_file.getAbsolutePath()); + } + } + + public static > List asSortedList(Collection c) { + List list = new ArrayList(c); + java.util.Collections.sort(list); + return list; + } + + @Test(dataProvider="parsingTests") + public void testCompositeTaskGeneratesCorrectGraph(File dir) { + File source = new File(dir, "source.wdl"); + File graph_file = new File(dir, "graph"); + CompositeTask ctask = getCompositeTask(source); + CompositeTaskGraph graph = ctask.getGraph(); + + StringBuilder actual = new StringBuilder(); + actual.append("VERTICIES\n"); + actual.append("---------\n"); + for ( CompositeTaskVertex v : asSortedList(graph.vertexSet()) ) { + actual.append(v + "\n"); + } + actual.append("\n"); + + actual.append("EDGES\n"); + actual.append("-----\n"); + for ( CompositeTaskEdge v : asSortedList(graph.edgeSet()) ) { + actual.append(v + "\n"); + } + + if ( !graph_file.exists() ) { + try { + FileWriter out = new FileWriter(graph_file); + out.write(actual.toString()); + out.close(); + } catch (IOException error) { + Assert.fail("Could not write " + graph_file + ": " + error); + } + + System.out.println("Created " + graph_file); + } + + try { + String expected = Utility.readFile(graph_file.getAbsolutePath()); + Assert.assertEquals(actual.toString(), expected, "Graphs did not match"); + } catch (IOException error) { + Assert.fail("Cannot read " + graph_file.getAbsolutePath()); + } + } +} diff --git a/src/test/java/org/broadinstitute/compositetask/SyntaxErrorTest.java b/src/test/java/org/broadinstitute/compositetask/SyntaxErrorTest.java new file mode 100644 index 0000000..032a5ab --- /dev/null +++ b/src/test/java/org/broadinstitute/compositetask/SyntaxErrorTest.java @@ -0,0 +1,74 @@ +package org.broadinstitute.compositetask; + +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; +import org.testng.Assert; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Collection; +import java.util.ArrayList; + +import org.broadinstitute.parser.SyntaxError; +import org.broadinstitute.parser.Utility; + +import org.broadinstitute.compositetask.CompositeTask; + +public class SyntaxErrorTest +{ + @DataProvider(name="syntaxErrorTests") + public Object[][] parsingTests() { + File parsingTestDir = new File("test-files", "syntax-error"); + Collection composite_tasks = new ArrayList(); + + for ( String subDir : parsingTestDir.list() ) { + composite_tasks.add(new Object[] { new File(parsingTestDir, subDir) }); + } + + return composite_tasks.toArray(new Object[0][]); + } + + private CompositeTask getCompositeTask(File source) throws SyntaxError { + try { + String relative = new File(".").toURI().relativize(source.toURI()).getPath(); + return new CompositeTask(source, relative); + } catch(IOException error) { + Assert.fail("IOException reading file: " + error); + } + + return null; + } + + @Test(dataProvider="syntaxErrorTests") + public void testCompositeTaskReportsBackCorrectSyntaxErrors(File dir) { + File errors = new File(dir, "errors"); + File source = new File(dir, "source.wdl"); + String actual = null; + + try { + CompositeTask ctask = getCompositeTask(source); + } catch (SyntaxError syntax_error) { + actual = syntax_error.toString(); + } + + if ( !errors.exists() ) { + try { + FileWriter out = new FileWriter(errors); + out.write(actual); + out.close(); + } catch (IOException error) { + Assert.fail("Could not write errors file: " + error); + } + + System.out.println("Created " + errors); + } + + try { + String expected = Utility.readFile(errors.getAbsolutePath()); + Assert.assertEquals(actual, expected, "Syntax errors did not match"); + } catch (IOException error) { + Assert.fail("Cannot read " + errors.getAbsolutePath()); + } + } +} diff --git a/test-files/api/0.wdl b/test-files/api/0.wdl new file mode 100644 index 0000000..25880be --- /dev/null +++ b/test-files/api/0.wdl @@ -0,0 +1,15 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as x, + FirstLine("bar.txt") as y; + } + + for ( item in foobar ) { + step btask[version=0] { + input: p0=x, p1=item, p2=GLOBAL; + output: File("baz.txt") as z; + } + } + +} diff --git a/test-files/parsing/0/ast b/test-files/parsing/0/ast new file mode 100644 index 0000000..31c17f5 --- /dev/null +++ b/test-files/parsing/0/ast @@ -0,0 +1,198 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/0/formatted b/test-files/parsing/0/formatted new file mode 100644 index 0000000..64babc5 --- /dev/null +++ b/test-files/parsing/0/formatted @@ -0,0 +1,19 @@ +composite_task foo { + step atask[version=0] { + output: File("foo.txt") as x; + } + for ( item in foo ) { + step btask[version=0] { + input: p0=x, p1=item, p2=GLOBAL; + output: File("bar.txt") as y; + } + step ctask[version=0] { + input: p0=x, p1=item, p2=y; + output: File("quux.txt") as z; + } + } + step dtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } +} diff --git a/test-files/parsing/0/graph b/test-files/parsing/0/graph new file mode 100644 index 0000000..42e580c --- /dev/null +++ b/test-files/parsing/0/graph @@ -0,0 +1,81 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] +[Step: name=atask] +[Step: name=btask] +[Step: name=ctask] +[Step: name=dtask] +[Variable: name=GLOBAL] +[Variable: name=foo] +[Variable: name=item] +[Variable: name=r] +[Variable: name=x] +[Variable: name=y] +[Variable: name=z] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] + to: [Step: name=dtask] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=x] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=y] +] +[Edge + from: [Step: name=ctask] + to: [Variable: name=z] +] +[Edge + from: [Step: name=dtask] + to: [Variable: name=r] +] +[Edge + from: [Variable: name=GLOBAL] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=foo] + to: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] +] +[Edge + from: [Variable: name=item] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=z] + to: [Step: name=dtask] +] diff --git a/test-files/parsing/0/parsetree b/test-files/parsing/0/parsetree new file mode 100644 index 0000000..8aec879 --- /dev/null +++ b/test-files/parsing/0/parsetree @@ -0,0 +1,383 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/0/source.wdl b/test-files/parsing/0/source.wdl new file mode 100644 index 0000000..c994a2a --- /dev/null +++ b/test-files/parsing/0/source.wdl @@ -0,0 +1,24 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as x; + } + + for ( item in foo ) { + step btask[version=0] { + input: p0=x, p1=item, p2=GLOBAL; + output: File("bar.txt") as y; + } + + step ctask[version=0] { + input: p0=x, p1=item, p2=y; + output: File("quux.txt") as z; + } + } + + step dtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } + +} diff --git a/test-files/parsing/0/tokens b/test-files/parsing/0/tokens new file mode 100644 index 0000000..9c59940 --- /dev/null +++ b/test-files/parsing/0/tokens @@ -0,0 +1,128 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/0/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/0/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/0/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 3, "col": 3, "resource": "test-files/parsing/0/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 8, "resource": "test-files/parsing/0/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 3, "col": 13, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 14, "resource": "test-files/parsing/0/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 21, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 22, "resource": "test-files/parsing/0/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 3, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 25, "resource": "test-files/parsing/0/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 4, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 11, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 4, "col": 13, "resource": "test-files/parsing/0/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 4, "col": 17, "resource": "test-files/parsing/0/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 18, "resource": "test-files/parsing/0/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 4, "col": 27, "resource": "test-files/parsing/0/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 29, "resource": "test-files/parsing/0/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 32, "resource": "test-files/parsing/0/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 4, "col": 33, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 3, "resource": "test-files/parsing/0/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 7, "col": 3, "resource": "test-files/parsing/0/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 7, "col": 7, "resource": "test-files/parsing/0/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 7, "col": 9, "resource": "test-files/parsing/0/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 7, "col": 14, "resource": "test-files/parsing/0/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 7, "col": 17, "resource": "test-files/parsing/0/source.wdl", "source_string": "Zm9v"}, + {"terminal": "rparen", "line": 7, "col": 21, "resource": "test-files/parsing/0/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 7, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 8, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 8, "col": 10, "resource": "test-files/parsing/0/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 8, "col": 15, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 8, "col": 16, "resource": "test-files/parsing/0/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 8, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 8, "col": 24, "resource": "test-files/parsing/0/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 8, "col": 25, "resource": "test-files/parsing/0/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 8, "col": 27, "resource": "test-files/parsing/0/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 9, "col": 7, "resource": "test-files/parsing/0/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 9, "col": 12, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 9, "col": 14, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 9, "col": 16, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 17, "resource": "test-files/parsing/0/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 9, "col": 18, "resource": "test-files/parsing/0/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 9, "col": 20, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 9, "col": 22, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 9, "col": 27, "resource": "test-files/parsing/0/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 9, "col": 29, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 9, "col": 31, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 32, "resource": "test-files/parsing/0/source.wdl", "source_string": "R0xPQkFM"}, + {"terminal": "semi", "line": 9, "col": 38, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 10, "col": 7, "resource": "test-files/parsing/0/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 10, "col": 13, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 10, "col": 15, "resource": "test-files/parsing/0/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 10, "col": 19, "resource": "test-files/parsing/0/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 10, "col": 20, "resource": "test-files/parsing/0/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 10, "col": 29, "resource": "test-files/parsing/0/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 10, "col": 31, "resource": "test-files/parsing/0/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 10, "col": 34, "resource": "test-files/parsing/0/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 10, "col": 35, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 11, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 13, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 13, "col": 10, "resource": "test-files/parsing/0/source.wdl", "source_string": "Y3Rhc2s="}, + {"terminal": "lsquare", "line": 13, "col": 15, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 13, "col": 16, "resource": "test-files/parsing/0/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 13, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 13, "col": 24, "resource": "test-files/parsing/0/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 13, "col": 25, "resource": "test-files/parsing/0/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 13, "col": 27, "resource": "test-files/parsing/0/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 14, "col": 7, "resource": "test-files/parsing/0/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 14, "col": 12, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 14, "col": 14, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 14, "col": 16, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 17, "resource": "test-files/parsing/0/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 14, "col": 18, "resource": "test-files/parsing/0/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 14, "col": 20, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 14, "col": 22, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 14, "col": 27, "resource": "test-files/parsing/0/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 14, "col": 29, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 14, "col": 31, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 32, "resource": "test-files/parsing/0/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 14, "col": 33, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 15, "col": 7, "resource": "test-files/parsing/0/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 15, "col": 13, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 15, "col": 15, "resource": "test-files/parsing/0/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 15, "col": 19, "resource": "test-files/parsing/0/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 15, "col": 20, "resource": "test-files/parsing/0/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 15, "col": 30, "resource": "test-files/parsing/0/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 15, "col": 32, "resource": "test-files/parsing/0/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 15, "col": 35, "resource": "test-files/parsing/0/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 15, "col": 36, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 16, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 17, "col": 3, "resource": "test-files/parsing/0/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 19, "col": 3, "resource": "test-files/parsing/0/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 19, "col": 8, "resource": "test-files/parsing/0/source.wdl", "source_string": "ZHRhc2s="}, + {"terminal": "lsquare", "line": 19, "col": 13, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 19, "col": 14, "resource": "test-files/parsing/0/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 19, "col": 21, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 19, "col": 22, "resource": "test-files/parsing/0/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 19, "col": 23, "resource": "test-files/parsing/0/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 19, "col": 25, "resource": "test-files/parsing/0/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 20, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 20, "col": 10, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 20, "col": 12, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 20, "col": 14, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 15, "resource": "test-files/parsing/0/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 20, "col": 16, "resource": "test-files/parsing/0/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 20, "col": 18, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 20, "col": 20, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 21, "resource": "test-files/parsing/0/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 20, "col": 22, "resource": "test-files/parsing/0/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 20, "col": 24, "resource": "test-files/parsing/0/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 20, "col": 26, "resource": "test-files/parsing/0/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 27, "resource": "test-files/parsing/0/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 20, "col": 28, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 21, "col": 5, "resource": "test-files/parsing/0/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 21, "col": 11, "resource": "test-files/parsing/0/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 21, "col": 13, "resource": "test-files/parsing/0/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 21, "col": 17, "resource": "test-files/parsing/0/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 21, "col": 18, "resource": "test-files/parsing/0/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 21, "col": 30, "resource": "test-files/parsing/0/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 21, "col": 32, "resource": "test-files/parsing/0/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 21, "col": 35, "resource": "test-files/parsing/0/source.wdl", "source_string": "cg=="}, + {"terminal": "semi", "line": 21, "col": 36, "resource": "test-files/parsing/0/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 22, "col": 3, "resource": "test-files/parsing/0/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 24, "col": 1, "resource": "test-files/parsing/0/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/1/ast b/test-files/parsing/1/ast new file mode 100644 index 0000000..b372890 --- /dev/null +++ b/test-files/parsing/1/ast @@ -0,0 +1,215 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/1/formatted b/test-files/parsing/1/formatted new file mode 100644 index 0000000..33ae0f6 --- /dev/null +++ b/test-files/parsing/1/formatted @@ -0,0 +1,24 @@ +composite_task foo { + step atask[version=0] { + output: File("foo.txt") as x; + } + for ( item in foo ) { + step btask[version=0] { + input: p0=item, p1=global; + output: File("bar.txt") as y; + } + step ctask[version=0] { + input: p0=item, p1=y; + output: File("quux.txt") as z; + } + for ( alpha in beta ) { + step dtask[version=0] { + input: p0=alpha; + } + } + } + step gtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } +} diff --git a/test-files/parsing/1/graph b/test-files/parsing/1/graph new file mode 100644 index 0000000..e659dbb --- /dev/null +++ b/test-files/parsing/1/graph @@ -0,0 +1,89 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=beta], var=[Variable: name=alpha], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] +[Step: name=atask] +[Step: name=btask] +[Step: name=ctask] +[Step: name=dtask] +[Step: name=gtask] +[Variable: name=alpha] +[Variable: name=beta] +[Variable: name=foo] +[Variable: name=global] +[Variable: name=item] +[Variable: name=r] +[Variable: name=x] +[Variable: name=y] +[Variable: name=z] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=beta], var=[Variable: name=alpha], # nodes=1] + to: [Variable: name=alpha] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] + to: [Step: name=gtask] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=x] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=y] +] +[Edge + from: [Step: name=ctask] + to: [Variable: name=z] +] +[Edge + from: [Step: name=gtask] + to: [Variable: name=r] +] +[Edge + from: [Variable: name=alpha] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=beta] + to: [CompositeTaskForScope: collection=[Variable: name=beta], var=[Variable: name=alpha], # nodes=1] +] +[Edge + from: [Variable: name=foo] + to: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] +] +[Edge + from: [Variable: name=global] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=gtask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=gtask] +] +[Edge + from: [Variable: name=z] + to: [Step: name=gtask] +] diff --git a/test-files/parsing/1/parsetree b/test-files/parsing/1/parsetree new file mode 100644 index 0000000..182cbd3 --- /dev/null +++ b/test-files/parsing/1/parsetree @@ -0,0 +1,426 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/1/source.wdl b/test-files/parsing/1/source.wdl new file mode 100644 index 0000000..e92a322 --- /dev/null +++ b/test-files/parsing/1/source.wdl @@ -0,0 +1,30 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as x; + } + + for ( item in foo ) { + step btask[version=0] { + input: p0=item, p1=global; + output: File("bar.txt") as y; + } + + step ctask[version=0] { + input: p0=item, p1=y; + output: File("quux.txt") as z; + } + + for ( alpha in beta ) { + step dtask[version=0] { + input: p0=alpha; + } + } + } + + step gtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } + +} diff --git a/test-files/parsing/1/tokens b/test-files/parsing/1/tokens new file mode 100644 index 0000000..7c263c7 --- /dev/null +++ b/test-files/parsing/1/tokens @@ -0,0 +1,143 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/1/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 3, "col": 3, "resource": "test-files/parsing/1/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 8, "resource": "test-files/parsing/1/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 3, "col": 13, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 21, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 22, "resource": "test-files/parsing/1/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 3, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 4, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 11, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 4, "col": 13, "resource": "test-files/parsing/1/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 4, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 18, "resource": "test-files/parsing/1/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 4, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 29, "resource": "test-files/parsing/1/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 32, "resource": "test-files/parsing/1/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 4, "col": 33, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 3, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 7, "col": 3, "resource": "test-files/parsing/1/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 7, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 7, "col": 9, "resource": "test-files/parsing/1/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 7, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 7, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "Zm9v"}, + {"terminal": "rparen", "line": 7, "col": 21, "resource": "test-files/parsing/1/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 7, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 8, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 8, "col": 10, "resource": "test-files/parsing/1/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 8, "col": 15, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 8, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 8, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 8, "col": 24, "resource": "test-files/parsing/1/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 8, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 8, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 9, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 9, "col": 12, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 9, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 9, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 9, "col": 21, "resource": "test-files/parsing/1/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 9, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 9, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 26, "resource": "test-files/parsing/1/source.wdl", "source_string": "Z2xvYmFs"}, + {"terminal": "semi", "line": 9, "col": 32, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 10, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 10, "col": 13, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 10, "col": 15, "resource": "test-files/parsing/1/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 10, "col": 19, "resource": "test-files/parsing/1/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 10, "col": 20, "resource": "test-files/parsing/1/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 10, "col": 29, "resource": "test-files/parsing/1/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 10, "col": 31, "resource": "test-files/parsing/1/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 10, "col": 34, "resource": "test-files/parsing/1/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 10, "col": 35, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 11, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 13, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 13, "col": 10, "resource": "test-files/parsing/1/source.wdl", "source_string": "Y3Rhc2s="}, + {"terminal": "lsquare", "line": 13, "col": 15, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 13, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 13, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 13, "col": 24, "resource": "test-files/parsing/1/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 13, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 13, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 14, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 14, "col": 12, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 14, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 14, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 14, "col": 21, "resource": "test-files/parsing/1/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 14, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 14, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 26, "resource": "test-files/parsing/1/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 14, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 15, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 15, "col": 13, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 15, "col": 15, "resource": "test-files/parsing/1/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 15, "col": 19, "resource": "test-files/parsing/1/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 15, "col": 20, "resource": "test-files/parsing/1/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 15, "col": 30, "resource": "test-files/parsing/1/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 15, "col": 32, "resource": "test-files/parsing/1/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 15, "col": 35, "resource": "test-files/parsing/1/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 15, "col": 36, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 16, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 18, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 18, "col": 9, "resource": "test-files/parsing/1/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 18, "col": 11, "resource": "test-files/parsing/1/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "in", "line": 18, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 18, "col": 20, "resource": "test-files/parsing/1/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "rparen", "line": 18, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 18, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 19, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 19, "col": 12, "resource": "test-files/parsing/1/source.wdl", "source_string": "ZHRhc2s="}, + {"terminal": "lsquare", "line": 19, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 19, "col": 18, "resource": "test-files/parsing/1/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 19, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 19, "col": 26, "resource": "test-files/parsing/1/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 19, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 19, "col": 29, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 20, "col": 9, "resource": "test-files/parsing/1/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 20, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 20, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 20, "col": 18, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 19, "resource": "test-files/parsing/1/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 20, "col": 24, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 21, "col": 7, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 22, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 23, "col": 3, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 25, "col": 3, "resource": "test-files/parsing/1/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 25, "col": 8, "resource": "test-files/parsing/1/source.wdl", "source_string": "Z3Rhc2s="}, + {"terminal": "lsquare", "line": 25, "col": 13, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 25, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 25, "col": 21, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 25, "col": 22, "resource": "test-files/parsing/1/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 25, "col": 23, "resource": "test-files/parsing/1/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 25, "col": 25, "resource": "test-files/parsing/1/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 26, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 26, "col": 10, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 26, "col": 12, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 26, "col": 14, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 26, "col": 15, "resource": "test-files/parsing/1/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 26, "col": 16, "resource": "test-files/parsing/1/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 26, "col": 18, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 26, "col": 20, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 26, "col": 21, "resource": "test-files/parsing/1/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 26, "col": 22, "resource": "test-files/parsing/1/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 26, "col": 24, "resource": "test-files/parsing/1/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 26, "col": 26, "resource": "test-files/parsing/1/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 26, "col": 27, "resource": "test-files/parsing/1/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 26, "col": 28, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 27, "col": 5, "resource": "test-files/parsing/1/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 27, "col": 11, "resource": "test-files/parsing/1/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 27, "col": 13, "resource": "test-files/parsing/1/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 27, "col": 17, "resource": "test-files/parsing/1/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 27, "col": 18, "resource": "test-files/parsing/1/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 27, "col": 30, "resource": "test-files/parsing/1/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 27, "col": 32, "resource": "test-files/parsing/1/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 27, "col": 35, "resource": "test-files/parsing/1/source.wdl", "source_string": "cg=="}, + {"terminal": "semi", "line": 27, "col": 36, "resource": "test-files/parsing/1/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 28, "col": 3, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 30, "col": 1, "resource": "test-files/parsing/1/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/10/ast b/test-files/parsing/10/ast new file mode 100644 index 0000000..bfc0b8c --- /dev/null +++ b/test-files/parsing/10/ast @@ -0,0 +1,14 @@ +(CompositeTask: + name=identifier, + body=[ + (CompositeTask: + name=identifier, + body=[ + (CompositeTask: + name=identifier, + body=[] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/10/formatted b/test-files/parsing/10/formatted new file mode 100644 index 0000000..352e292 --- /dev/null +++ b/test-files/parsing/10/formatted @@ -0,0 +1,6 @@ +composite_task a { + composite_task b { + composite_task c { + } + } +} diff --git a/test-files/parsing/10/graph b/test-files/parsing/10/graph new file mode 100644 index 0000000..d612dd1 --- /dev/null +++ b/test-files/parsing/10/graph @@ -0,0 +1,5 @@ +VERTICIES +--------- + +EDGES +----- diff --git a/test-files/parsing/10/parsetree b/test-files/parsing/10/parsetree new file mode 100644 index 0000000..526495e --- /dev/null +++ b/test-files/parsing/10/parsetree @@ -0,0 +1,36 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/10/source.wdl b/test-files/parsing/10/source.wdl new file mode 100644 index 0000000..a12523a --- /dev/null +++ b/test-files/parsing/10/source.wdl @@ -0,0 +1 @@ +composite_task a{composite_task b{composite_task c {}}} diff --git a/test-files/parsing/10/tokens b/test-files/parsing/10/tokens new file mode 100644 index 0000000..2cc1b0b --- /dev/null +++ b/test-files/parsing/10/tokens @@ -0,0 +1,14 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/10/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/10/source.wdl", "source_string": "YQ=="}, + {"terminal": "lbrace", "line": 1, "col": 17, "resource": "test-files/parsing/10/source.wdl", "source_string": "ew=="}, + {"terminal": "composite_task", "line": 1, "col": 18, "resource": "test-files/parsing/10/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 33, "resource": "test-files/parsing/10/source.wdl", "source_string": "Yg=="}, + {"terminal": "lbrace", "line": 1, "col": 34, "resource": "test-files/parsing/10/source.wdl", "source_string": "ew=="}, + {"terminal": "composite_task", "line": 1, "col": 35, "resource": "test-files/parsing/10/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 50, "resource": "test-files/parsing/10/source.wdl", "source_string": "Yw=="}, + {"terminal": "lbrace", "line": 1, "col": 52, "resource": "test-files/parsing/10/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 1, "col": 53, "resource": "test-files/parsing/10/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 1, "col": 54, "resource": "test-files/parsing/10/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 1, "col": 55, "resource": "test-files/parsing/10/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/11/ast b/test-files/parsing/11/ast new file mode 100644 index 0000000..31c17f5 --- /dev/null +++ b/test-files/parsing/11/ast @@ -0,0 +1,198 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/11/formatted b/test-files/parsing/11/formatted new file mode 100644 index 0000000..64babc5 --- /dev/null +++ b/test-files/parsing/11/formatted @@ -0,0 +1,19 @@ +composite_task foo { + step atask[version=0] { + output: File("foo.txt") as x; + } + for ( item in foo ) { + step btask[version=0] { + input: p0=x, p1=item, p2=GLOBAL; + output: File("bar.txt") as y; + } + step ctask[version=0] { + input: p0=x, p1=item, p2=y; + output: File("quux.txt") as z; + } + } + step dtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } +} diff --git a/test-files/parsing/11/graph b/test-files/parsing/11/graph new file mode 100644 index 0000000..42e580c --- /dev/null +++ b/test-files/parsing/11/graph @@ -0,0 +1,81 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] +[Step: name=atask] +[Step: name=btask] +[Step: name=ctask] +[Step: name=dtask] +[Variable: name=GLOBAL] +[Variable: name=foo] +[Variable: name=item] +[Variable: name=r] +[Variable: name=x] +[Variable: name=y] +[Variable: name=z] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] + to: [Step: name=dtask] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=x] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=y] +] +[Edge + from: [Step: name=ctask] + to: [Variable: name=z] +] +[Edge + from: [Step: name=dtask] + to: [Variable: name=r] +] +[Edge + from: [Variable: name=GLOBAL] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=foo] + to: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=2] +] +[Edge + from: [Variable: name=item] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=z] + to: [Step: name=dtask] +] diff --git a/test-files/parsing/11/parsetree b/test-files/parsing/11/parsetree new file mode 100644 index 0000000..8aec879 --- /dev/null +++ b/test-files/parsing/11/parsetree @@ -0,0 +1,383 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/11/source.wdl b/test-files/parsing/11/source.wdl new file mode 100644 index 0000000..0989568 --- /dev/null +++ b/test-files/parsing/11/source.wdl @@ -0,0 +1,8 @@ +composite_task foo { + step atask[version=0] {output: File("foo.txt") as x;} + for ( item in foo ) { + step btask[version=0] {input: p0=x, p1=item, p2=GLOBAL; output: File("bar.txt") as y;} + step ctask[version=0] {input: p0=x, p1=item, p2=y; output: File("quux.txt") as z;} + } + step dtask[version=0] {input: p0=x, p1=y, p2=z; output: File("report.txt") as r;} +} diff --git a/test-files/parsing/11/tokens b/test-files/parsing/11/tokens new file mode 100644 index 0000000..7ad2c2b --- /dev/null +++ b/test-files/parsing/11/tokens @@ -0,0 +1,128 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/11/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/11/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/11/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 2, "col": 3, "resource": "test-files/parsing/11/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/11/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 2, "col": 13, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 2, "col": 14, "resource": "test-files/parsing/11/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 2, "col": 21, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 2, "col": 22, "resource": "test-files/parsing/11/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 2, "col": 23, "resource": "test-files/parsing/11/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 2, "col": 25, "resource": "test-files/parsing/11/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 2, "col": 26, "resource": "test-files/parsing/11/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 2, "col": 32, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 2, "col": 34, "resource": "test-files/parsing/11/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 2, "col": 38, "resource": "test-files/parsing/11/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 2, "col": 39, "resource": "test-files/parsing/11/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 2, "col": 48, "resource": "test-files/parsing/11/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 2, "col": 50, "resource": "test-files/parsing/11/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 2, "col": 53, "resource": "test-files/parsing/11/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 2, "col": 54, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 2, "col": 55, "resource": "test-files/parsing/11/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 3, "col": 3, "resource": "test-files/parsing/11/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 3, "col": 7, "resource": "test-files/parsing/11/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 3, "col": 9, "resource": "test-files/parsing/11/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 3, "col": 14, "resource": "test-files/parsing/11/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 3, "col": 17, "resource": "test-files/parsing/11/source.wdl", "source_string": "Zm9v"}, + {"terminal": "rparen", "line": 3, "col": 21, "resource": "test-files/parsing/11/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 3, "col": 23, "resource": "test-files/parsing/11/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 4, "col": 5, "resource": "test-files/parsing/11/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 4, "col": 10, "resource": "test-files/parsing/11/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 4, "col": 15, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 4, "col": 16, "resource": "test-files/parsing/11/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 4, "col": 23, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 4, "col": 24, "resource": "test-files/parsing/11/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 4, "col": 25, "resource": "test-files/parsing/11/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 4, "col": 27, "resource": "test-files/parsing/11/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 4, "col": 28, "resource": "test-files/parsing/11/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 4, "col": 33, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 4, "col": 35, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 4, "col": 37, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 4, "col": 38, "resource": "test-files/parsing/11/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 4, "col": 39, "resource": "test-files/parsing/11/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 4, "col": 41, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 4, "col": 43, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 4, "col": 44, "resource": "test-files/parsing/11/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 4, "col": 48, "resource": "test-files/parsing/11/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 4, "col": 50, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 4, "col": 52, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 4, "col": 53, "resource": "test-files/parsing/11/source.wdl", "source_string": "R0xPQkFM"}, + {"terminal": "semi", "line": 4, "col": 59, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 4, "col": 61, "resource": "test-files/parsing/11/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 67, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 4, "col": 69, "resource": "test-files/parsing/11/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 4, "col": 73, "resource": "test-files/parsing/11/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 74, "resource": "test-files/parsing/11/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 4, "col": 83, "resource": "test-files/parsing/11/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 85, "resource": "test-files/parsing/11/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 88, "resource": "test-files/parsing/11/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 4, "col": 89, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 4, "col": 90, "resource": "test-files/parsing/11/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 5, "col": 5, "resource": "test-files/parsing/11/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 5, "col": 10, "resource": "test-files/parsing/11/source.wdl", "source_string": "Y3Rhc2s="}, + {"terminal": "lsquare", "line": 5, "col": 15, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 5, "col": 16, "resource": "test-files/parsing/11/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 5, "col": 23, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 5, "col": 24, "resource": "test-files/parsing/11/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 5, "col": 25, "resource": "test-files/parsing/11/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 5, "col": 27, "resource": "test-files/parsing/11/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 5, "col": 28, "resource": "test-files/parsing/11/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 5, "col": 33, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 5, "col": 35, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 5, "col": 37, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 5, "col": 38, "resource": "test-files/parsing/11/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 5, "col": 39, "resource": "test-files/parsing/11/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 5, "col": 41, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 5, "col": 43, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 5, "col": 44, "resource": "test-files/parsing/11/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 5, "col": 48, "resource": "test-files/parsing/11/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 5, "col": 50, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 5, "col": 52, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 5, "col": 53, "resource": "test-files/parsing/11/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 5, "col": 54, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 5, "col": 56, "resource": "test-files/parsing/11/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 5, "col": 62, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 5, "col": 64, "resource": "test-files/parsing/11/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 5, "col": 68, "resource": "test-files/parsing/11/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 5, "col": 69, "resource": "test-files/parsing/11/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 5, "col": 79, "resource": "test-files/parsing/11/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 5, "col": 81, "resource": "test-files/parsing/11/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 5, "col": 84, "resource": "test-files/parsing/11/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 5, "col": 85, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 86, "resource": "test-files/parsing/11/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 6, "col": 3, "resource": "test-files/parsing/11/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 7, "col": 3, "resource": "test-files/parsing/11/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 7, "col": 8, "resource": "test-files/parsing/11/source.wdl", "source_string": "ZHRhc2s="}, + {"terminal": "lsquare", "line": 7, "col": 13, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 7, "col": 14, "resource": "test-files/parsing/11/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 7, "col": 21, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 7, "col": 22, "resource": "test-files/parsing/11/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 7, "col": 23, "resource": "test-files/parsing/11/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 7, "col": 25, "resource": "test-files/parsing/11/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 7, "col": 26, "resource": "test-files/parsing/11/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 7, "col": 31, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 7, "col": 33, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 7, "col": 35, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 36, "resource": "test-files/parsing/11/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 7, "col": 37, "resource": "test-files/parsing/11/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 7, "col": 39, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 7, "col": 41, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 42, "resource": "test-files/parsing/11/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 7, "col": 43, "resource": "test-files/parsing/11/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 7, "col": 45, "resource": "test-files/parsing/11/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 7, "col": 47, "resource": "test-files/parsing/11/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 48, "resource": "test-files/parsing/11/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 7, "col": 49, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 7, "col": 51, "resource": "test-files/parsing/11/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 7, "col": 57, "resource": "test-files/parsing/11/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 7, "col": 59, "resource": "test-files/parsing/11/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 7, "col": 63, "resource": "test-files/parsing/11/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 7, "col": 64, "resource": "test-files/parsing/11/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 7, "col": 76, "resource": "test-files/parsing/11/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 7, "col": 78, "resource": "test-files/parsing/11/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 7, "col": 81, "resource": "test-files/parsing/11/source.wdl", "source_string": "cg=="}, + {"terminal": "semi", "line": 7, "col": 82, "resource": "test-files/parsing/11/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 7, "col": 83, "resource": "test-files/parsing/11/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 8, "col": 1, "resource": "test-files/parsing/11/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/12/ast b/test-files/parsing/12/ast new file mode 100644 index 0000000..8891a37 --- /dev/null +++ b/test-files/parsing/12/ast @@ -0,0 +1,170 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputListAppend: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputListAppend: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/12/formatted b/test-files/parsing/12/formatted new file mode 100644 index 0000000..c61cb0d --- /dev/null +++ b/test-files/parsing/12/formatted @@ -0,0 +1,18 @@ +composite_task CopyNumberQC { + step LaneBlackList[version=6] { + output: File("lane_blacklist.txt") as lane_blacklist; + } + for ( sample in samples ) { + step RegionCovPerLane[version=16] { + input: bam_file=sample.bam, sample_id=sample.id; + output: File("${sample.id}.rcl") as rcl; + } + step MakeLaneList[version=11] { + input: bam_file=sample.bam, sample_id=sample.id; + output: File("${sample.id}.lanelist") as lanelist; + } + } + step CopyNumberQC[version=25] { + input: lanes_list=lanelist, rcl_list=rcl, lane_blacklist=lane_blacklist; + } +} diff --git a/test-files/parsing/12/graph b/test-files/parsing/12/graph new file mode 100644 index 0000000..132941f --- /dev/null +++ b/test-files/parsing/12/graph @@ -0,0 +1,69 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=samples], var=[Variable: name=sample], # nodes=2] +[Step: name=CopyNumberQC] +[Step: name=LaneBlackList] +[Step: name=MakeLaneList] +[Step: name=RegionCovPerLane] +[Variable: name=lane_blacklist] +[Variable: name=lanelist] +[Variable: name=rcl] +[Variable: name=sample, member=bam] +[Variable: name=sample, member=id] +[Variable: name=sample] +[Variable: name=samples] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=samples], var=[Variable: name=sample], # nodes=2] + to: [Step: name=CopyNumberQC] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=samples], var=[Variable: name=sample], # nodes=2] + to: [Variable: name=sample] +] +[Edge + from: [Step: name=LaneBlackList] + to: [Variable: name=lane_blacklist] +] +[Edge + from: [Step: name=MakeLaneList] + to: [Variable: name=lanelist] +] +[Edge + from: [Step: name=RegionCovPerLane] + to: [Variable: name=rcl] +] +[Edge + from: [Variable: name=lane_blacklist] + to: [Step: name=CopyNumberQC] +] +[Edge + from: [Variable: name=lanelist] + to: [Step: name=CopyNumberQC] +] +[Edge + from: [Variable: name=rcl] + to: [Step: name=CopyNumberQC] +] +[Edge + from: [Variable: name=sample, member=bam] + to: [Step: name=MakeLaneList] +] +[Edge + from: [Variable: name=sample, member=bam] + to: [Step: name=RegionCovPerLane] +] +[Edge + from: [Variable: name=sample, member=id] + to: [Step: name=MakeLaneList] +] +[Edge + from: [Variable: name=sample, member=id] + to: [Step: name=RegionCovPerLane] +] +[Edge + from: [Variable: name=samples] + to: [CompositeTaskForScope: collection=[Variable: name=samples], var=[Variable: name=sample], # nodes=2] +] diff --git a/test-files/parsing/12/parsetree b/test-files/parsing/12/parsetree new file mode 100644 index 0000000..cf99fa6 --- /dev/null +++ b/test-files/parsing/12/parsetree @@ -0,0 +1,354 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + into, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + into, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/12/source.wdl b/test-files/parsing/12/source.wdl new file mode 100644 index 0000000..7200425 --- /dev/null +++ b/test-files/parsing/12/source.wdl @@ -0,0 +1,18 @@ +composite_task CopyNumberQC { + step LaneBlackList[version=6] { + output: File("lane_blacklist.txt") as lane_blacklist; + } + for ( sample in samples ) { + step RegionCovPerLane[version=16] { + input: bam_file=sample.bam, sample_id=sample.id; + output: File("${sample.id}.rcl") into rcl; + } + step MakeLaneList[version=11] { + input: bam_file=sample.bam, sample_id=sample.id; + output: File("${sample.id}.lanelist") into lanelist; + } + } + step CopyNumberQC[version=25] { + input: lanes_list=lanelist, rcl_list=rcl, lane_blacklist=lane_blacklist; + } +} diff --git a/test-files/parsing/12/tokens b/test-files/parsing/12/tokens new file mode 100644 index 0000000..cfed795 --- /dev/null +++ b/test-files/parsing/12/tokens @@ -0,0 +1,119 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/12/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/12/source.wdl", "source_string": "Q29weU51bWJlclFD"}, + {"terminal": "lbrace", "line": 1, "col": 29, "resource": "test-files/parsing/12/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 2, "col": 3, "resource": "test-files/parsing/12/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/12/source.wdl", "source_string": "TGFuZUJsYWNrTGlzdA=="}, + {"terminal": "lsquare", "line": 2, "col": 21, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 2, "col": 22, "resource": "test-files/parsing/12/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 2, "col": 29, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 2, "col": 30, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ng=="}, + {"terminal": "rsquare", "line": 2, "col": 31, "resource": "test-files/parsing/12/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 2, "col": 33, "resource": "test-files/parsing/12/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 3, "col": 5, "resource": "test-files/parsing/12/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 3, "col": 11, "resource": "test-files/parsing/12/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 3, "col": 13, "resource": "test-files/parsing/12/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 3, "col": 17, "resource": "test-files/parsing/12/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 3, "col": 18, "resource": "test-files/parsing/12/source.wdl", "source_string": "ImxhbmVfYmxhY2tsaXN0LnR4dCI="}, + {"terminal": "rparen", "line": 3, "col": 38, "resource": "test-files/parsing/12/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 3, "col": 40, "resource": "test-files/parsing/12/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 3, "col": 43, "resource": "test-files/parsing/12/source.wdl", "source_string": "bGFuZV9ibGFja2xpc3Q="}, + {"terminal": "semi", "line": 3, "col": 57, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 4, "col": 3, "resource": "test-files/parsing/12/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 5, "col": 3, "resource": "test-files/parsing/12/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 5, "col": 7, "resource": "test-files/parsing/12/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 5, "col": 9, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxl"}, + {"terminal": "in", "line": 5, "col": 16, "resource": "test-files/parsing/12/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 5, "col": 19, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxlcw=="}, + {"terminal": "rparen", "line": 5, "col": 27, "resource": "test-files/parsing/12/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 5, "col": 29, "resource": "test-files/parsing/12/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 6, "col": 5, "resource": "test-files/parsing/12/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 6, "col": 10, "resource": "test-files/parsing/12/source.wdl", "source_string": "UmVnaW9uQ292UGVyTGFuZQ=="}, + {"terminal": "lsquare", "line": 6, "col": 26, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 6, "col": 27, "resource": "test-files/parsing/12/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 6, "col": 34, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 6, "col": 35, "resource": "test-files/parsing/12/source.wdl", "source_string": "MTY="}, + {"terminal": "rsquare", "line": 6, "col": 37, "resource": "test-files/parsing/12/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 6, "col": 39, "resource": "test-files/parsing/12/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 7, "col": 7, "resource": "test-files/parsing/12/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 7, "col": 12, "resource": "test-files/parsing/12/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 7, "col": 14, "resource": "test-files/parsing/12/source.wdl", "source_string": "YmFtX2ZpbGU="}, + {"terminal": "assign", "line": 7, "col": 22, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 23, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxl"}, + {"terminal": "dot", "line": 7, "col": 29, "resource": "test-files/parsing/12/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 7, "col": 30, "resource": "test-files/parsing/12/source.wdl", "source_string": "YmFt"}, + {"terminal": "comma", "line": 7, "col": 33, "resource": "test-files/parsing/12/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 7, "col": 35, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxlX2lk"}, + {"terminal": "assign", "line": 7, "col": 44, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 45, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxl"}, + {"terminal": "dot", "line": 7, "col": 51, "resource": "test-files/parsing/12/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 7, "col": 52, "resource": "test-files/parsing/12/source.wdl", "source_string": "aWQ="}, + {"terminal": "semi", "line": 7, "col": 54, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 8, "col": 7, "resource": "test-files/parsing/12/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 8, "col": 13, "resource": "test-files/parsing/12/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 8, "col": 15, "resource": "test-files/parsing/12/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 8, "col": 19, "resource": "test-files/parsing/12/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 8, "col": 20, "resource": "test-files/parsing/12/source.wdl", "source_string": "IiR7c2FtcGxlLmlkfS5yY2wi"}, + {"terminal": "rparen", "line": 8, "col": 38, "resource": "test-files/parsing/12/source.wdl", "source_string": "KQ=="}, + {"terminal": "into", "line": 8, "col": 40, "resource": "test-files/parsing/12/source.wdl", "source_string": "aW50bw=="}, + {"terminal": "identifier", "line": 8, "col": 45, "resource": "test-files/parsing/12/source.wdl", "source_string": "cmNs"}, + {"terminal": "semi", "line": 8, "col": 48, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 9, "col": 5, "resource": "test-files/parsing/12/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 10, "col": 5, "resource": "test-files/parsing/12/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 10, "col": 10, "resource": "test-files/parsing/12/source.wdl", "source_string": "TWFrZUxhbmVMaXN0"}, + {"terminal": "lsquare", "line": 10, "col": 22, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 10, "col": 23, "resource": "test-files/parsing/12/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 10, "col": 30, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 10, "col": 31, "resource": "test-files/parsing/12/source.wdl", "source_string": "MTE="}, + {"terminal": "rsquare", "line": 10, "col": 33, "resource": "test-files/parsing/12/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 10, "col": 35, "resource": "test-files/parsing/12/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 11, "col": 7, "resource": "test-files/parsing/12/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 11, "col": 12, "resource": "test-files/parsing/12/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 11, "col": 14, "resource": "test-files/parsing/12/source.wdl", "source_string": "YmFtX2ZpbGU="}, + {"terminal": "assign", "line": 11, "col": 22, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 11, "col": 23, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxl"}, + {"terminal": "dot", "line": 11, "col": 29, "resource": "test-files/parsing/12/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 11, "col": 30, "resource": "test-files/parsing/12/source.wdl", "source_string": "YmFt"}, + {"terminal": "comma", "line": 11, "col": 33, "resource": "test-files/parsing/12/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 11, "col": 35, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxlX2lk"}, + {"terminal": "assign", "line": 11, "col": 44, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 11, "col": 45, "resource": "test-files/parsing/12/source.wdl", "source_string": "c2FtcGxl"}, + {"terminal": "dot", "line": 11, "col": 51, "resource": "test-files/parsing/12/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 11, "col": 52, "resource": "test-files/parsing/12/source.wdl", "source_string": "aWQ="}, + {"terminal": "semi", "line": 11, "col": 54, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 12, "col": 7, "resource": "test-files/parsing/12/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 12, "col": 13, "resource": "test-files/parsing/12/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 12, "col": 15, "resource": "test-files/parsing/12/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 12, "col": 19, "resource": "test-files/parsing/12/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 12, "col": 20, "resource": "test-files/parsing/12/source.wdl", "source_string": "IiR7c2FtcGxlLmlkfS5sYW5lbGlzdCI="}, + {"terminal": "rparen", "line": 12, "col": 43, "resource": "test-files/parsing/12/source.wdl", "source_string": "KQ=="}, + {"terminal": "into", "line": 12, "col": 45, "resource": "test-files/parsing/12/source.wdl", "source_string": "aW50bw=="}, + {"terminal": "identifier", "line": 12, "col": 50, "resource": "test-files/parsing/12/source.wdl", "source_string": "bGFuZWxpc3Q="}, + {"terminal": "semi", "line": 12, "col": 58, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 13, "col": 5, "resource": "test-files/parsing/12/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 14, "col": 3, "resource": "test-files/parsing/12/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 15, "col": 3, "resource": "test-files/parsing/12/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 15, "col": 8, "resource": "test-files/parsing/12/source.wdl", "source_string": "Q29weU51bWJlclFD"}, + {"terminal": "lsquare", "line": 15, "col": 20, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 15, "col": 21, "resource": "test-files/parsing/12/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 15, "col": 28, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 15, "col": 29, "resource": "test-files/parsing/12/source.wdl", "source_string": "MjU="}, + {"terminal": "rsquare", "line": 15, "col": 31, "resource": "test-files/parsing/12/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 15, "col": 33, "resource": "test-files/parsing/12/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 16, "col": 5, "resource": "test-files/parsing/12/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 16, "col": 10, "resource": "test-files/parsing/12/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 16, "col": 12, "resource": "test-files/parsing/12/source.wdl", "source_string": "bGFuZXNfbGlzdA=="}, + {"terminal": "assign", "line": 16, "col": 22, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 16, "col": 23, "resource": "test-files/parsing/12/source.wdl", "source_string": "bGFuZWxpc3Q="}, + {"terminal": "comma", "line": 16, "col": 31, "resource": "test-files/parsing/12/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 16, "col": 33, "resource": "test-files/parsing/12/source.wdl", "source_string": "cmNsX2xpc3Q="}, + {"terminal": "assign", "line": 16, "col": 41, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 16, "col": 42, "resource": "test-files/parsing/12/source.wdl", "source_string": "cmNs"}, + {"terminal": "comma", "line": 16, "col": 45, "resource": "test-files/parsing/12/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 16, "col": 47, "resource": "test-files/parsing/12/source.wdl", "source_string": "bGFuZV9ibGFja2xpc3Q="}, + {"terminal": "assign", "line": 16, "col": 61, "resource": "test-files/parsing/12/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 16, "col": 62, "resource": "test-files/parsing/12/source.wdl", "source_string": "bGFuZV9ibGFja2xpc3Q="}, + {"terminal": "semi", "line": 16, "col": 76, "resource": "test-files/parsing/12/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 17, "col": 3, "resource": "test-files/parsing/12/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 18, "col": 1, "resource": "test-files/parsing/12/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/13/ast b/test-files/parsing/13/ast new file mode 100644 index 0000000..9ca8027 --- /dev/null +++ b/test-files/parsing/13/ast @@ -0,0 +1,35 @@ +(CompositeTask: + name=identifier, + body=[ + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (ForLoop: + collection=identifier, + item=identifier, + body=[] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/13/formatted b/test-files/parsing/13/formatted new file mode 100644 index 0000000..5624645 --- /dev/null +++ b/test-files/parsing/13/formatted @@ -0,0 +1,10 @@ +composite_task foo { + for ( a in b ) { + for ( c in d ) { + for ( e in f ) { + } + } + } + step x[version=1000] { + } +} diff --git a/test-files/parsing/13/graph b/test-files/parsing/13/graph new file mode 100644 index 0000000..3593193 --- /dev/null +++ b/test-files/parsing/13/graph @@ -0,0 +1,39 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=b], var=[Variable: name=a], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=d], var=[Variable: name=c], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=f], var=[Variable: name=e], # nodes=0] +[Step: name=x] +[Variable: name=a] +[Variable: name=b] +[Variable: name=c] +[Variable: name=d] +[Variable: name=e] +[Variable: name=f] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=b], var=[Variable: name=a], # nodes=1] + to: [Variable: name=a] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=d], var=[Variable: name=c], # nodes=1] + to: [Variable: name=c] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=f], var=[Variable: name=e], # nodes=0] + to: [Variable: name=e] +] +[Edge + from: [Variable: name=b] + to: [CompositeTaskForScope: collection=[Variable: name=b], var=[Variable: name=a], # nodes=1] +] +[Edge + from: [Variable: name=d] + to: [CompositeTaskForScope: collection=[Variable: name=d], var=[Variable: name=c], # nodes=1] +] +[Edge + from: [Variable: name=f] + to: [CompositeTaskForScope: collection=[Variable: name=f], var=[Variable: name=e], # nodes=0] +] diff --git a/test-files/parsing/13/parsetree b/test-files/parsing/13/parsetree new file mode 100644 index 0000000..c9da633 --- /dev/null +++ b/test-files/parsing/13/parsetree @@ -0,0 +1,89 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/13/source.wdl b/test-files/parsing/13/source.wdl new file mode 100644 index 0000000..6a30bf7 --- /dev/null +++ b/test-files/parsing/13/source.wdl @@ -0,0 +1,4 @@ +composite_task foo { + for (a in b) {for (c in d) {for ( e in f) {}}} + step x[version=1000] {} +} diff --git a/test-files/parsing/13/tokens b/test-files/parsing/13/tokens new file mode 100644 index 0000000..64adcdd --- /dev/null +++ b/test-files/parsing/13/tokens @@ -0,0 +1,39 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/13/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/13/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/13/source.wdl", "source_string": "ew=="}, + {"terminal": "for", "line": 2, "col": 3, "resource": "test-files/parsing/13/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 2, "col": 7, "resource": "test-files/parsing/13/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/13/source.wdl", "source_string": "YQ=="}, + {"terminal": "in", "line": 2, "col": 10, "resource": "test-files/parsing/13/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 2, "col": 13, "resource": "test-files/parsing/13/source.wdl", "source_string": "Yg=="}, + {"terminal": "rparen", "line": 2, "col": 14, "resource": "test-files/parsing/13/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 2, "col": 16, "resource": "test-files/parsing/13/source.wdl", "source_string": "ew=="}, + {"terminal": "for", "line": 2, "col": 17, "resource": "test-files/parsing/13/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 2, "col": 21, "resource": "test-files/parsing/13/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 2, "col": 22, "resource": "test-files/parsing/13/source.wdl", "source_string": "Yw=="}, + {"terminal": "in", "line": 2, "col": 24, "resource": "test-files/parsing/13/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 2, "col": 27, "resource": "test-files/parsing/13/source.wdl", "source_string": "ZA=="}, + {"terminal": "rparen", "line": 2, "col": 28, "resource": "test-files/parsing/13/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 2, "col": 30, "resource": "test-files/parsing/13/source.wdl", "source_string": "ew=="}, + {"terminal": "for", "line": 2, "col": 31, "resource": "test-files/parsing/13/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 2, "col": 35, "resource": "test-files/parsing/13/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 2, "col": 37, "resource": "test-files/parsing/13/source.wdl", "source_string": "ZQ=="}, + {"terminal": "in", "line": 2, "col": 39, "resource": "test-files/parsing/13/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 2, "col": 42, "resource": "test-files/parsing/13/source.wdl", "source_string": "Zg=="}, + {"terminal": "rparen", "line": 2, "col": 43, "resource": "test-files/parsing/13/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 2, "col": 45, "resource": "test-files/parsing/13/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 2, "col": 46, "resource": "test-files/parsing/13/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 2, "col": 47, "resource": "test-files/parsing/13/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 2, "col": 48, "resource": "test-files/parsing/13/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 3, "col": 3, "resource": "test-files/parsing/13/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 8, "resource": "test-files/parsing/13/source.wdl", "source_string": "eA=="}, + {"terminal": "lsquare", "line": 3, "col": 9, "resource": "test-files/parsing/13/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 10, "resource": "test-files/parsing/13/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 17, "resource": "test-files/parsing/13/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 18, "resource": "test-files/parsing/13/source.wdl", "source_string": "MTAwMA=="}, + {"terminal": "rsquare", "line": 3, "col": 22, "resource": "test-files/parsing/13/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 24, "resource": "test-files/parsing/13/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 3, "col": 25, "resource": "test-files/parsing/13/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 4, "col": 1, "resource": "test-files/parsing/13/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/14/ast b/test-files/parsing/14/ast new file mode 100644 index 0000000..6a9387d --- /dev/null +++ b/test-files/parsing/14/ast @@ -0,0 +1,193 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ), + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ), + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ), + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ), + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=identifier, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/14/formatted b/test-files/parsing/14/formatted new file mode 100644 index 0000000..45d5263 --- /dev/null +++ b/test-files/parsing/14/formatted @@ -0,0 +1,13 @@ +composite_task MutSig { + step MutSigPreprocess[version=86] { + output: File("coverage.prepare.txt") as coverage_prepare_file, File("patients.txt") as patient_list, File("${individual_set_id}.maf") as mutation_list, File("mutation_preprocessing_report.txt") as mutation_preprocessing_report; + } + step ProcessCoverageForMutSig[version=75] { + input: coverage=coverage_prepare_file, patients=patient_list, mutations=mutation_list; + output: File("coverage.mat") as coverage_file, File("mutcategs.txt") as category_file; + } + step MutSigRun[version=157] as MutSig { + input: mutation_list=mutation_list, coverage_file=coverage_file, patients=patient_list, category_file=category_file, mutation_preprocessing_report=foobar; + output: File("bargraphs.png") as graphs; + } +} diff --git a/test-files/parsing/14/graph b/test-files/parsing/14/graph new file mode 100644 index 0000000..58045d4 --- /dev/null +++ b/test-files/parsing/14/graph @@ -0,0 +1,76 @@ +VERTICIES +--------- +[Step: name=MutSigPreprocess] +[Step: name=MutSig] +[Step: name=ProcessCoverageForMutSig] +[Variable: name=category_file] +[Variable: name=coverage_file] +[Variable: name=coverage_prepare_file] +[Variable: name=foobar] +[Variable: name=graphs] +[Variable: name=mutation_list] +[Variable: name=mutation_preprocessing_report] +[Variable: name=patient_list] + +EDGES +----- +[Edge + from: [Step: name=MutSigPreprocess] + to: [Variable: name=coverage_prepare_file] +] +[Edge + from: [Step: name=MutSigPreprocess] + to: [Variable: name=mutation_list] +] +[Edge + from: [Step: name=MutSigPreprocess] + to: [Variable: name=mutation_preprocessing_report] +] +[Edge + from: [Step: name=MutSigPreprocess] + to: [Variable: name=patient_list] +] +[Edge + from: [Step: name=MutSig] + to: [Variable: name=graphs] +] +[Edge + from: [Step: name=ProcessCoverageForMutSig] + to: [Variable: name=category_file] +] +[Edge + from: [Step: name=ProcessCoverageForMutSig] + to: [Variable: name=coverage_file] +] +[Edge + from: [Variable: name=category_file] + to: [Step: name=MutSig] +] +[Edge + from: [Variable: name=coverage_file] + to: [Step: name=MutSig] +] +[Edge + from: [Variable: name=coverage_prepare_file] + to: [Step: name=ProcessCoverageForMutSig] +] +[Edge + from: [Variable: name=foobar] + to: [Step: name=MutSig] +] +[Edge + from: [Variable: name=mutation_list] + to: [Step: name=MutSig] +] +[Edge + from: [Variable: name=mutation_list] + to: [Step: name=ProcessCoverageForMutSig] +] +[Edge + from: [Variable: name=patient_list] + to: [Step: name=MutSig] +] +[Edge + from: [Variable: name=patient_list] + to: [Step: name=ProcessCoverageForMutSig] +] diff --git a/test-files/parsing/14/parsetree b/test-files/parsing/14/parsetree new file mode 100644 index 0000000..48ff5ed --- /dev/null +++ b/test-files/parsing/14/parsetree @@ -0,0 +1,368 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: + comma, + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: + comma, + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: + comma, + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ) + ) + ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: + comma, + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: + (step_name: + as, + identifier + ) + ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/14/source.wdl b/test-files/parsing/14/source.wdl new file mode 100644 index 0000000..7ae645c --- /dev/null +++ b/test-files/parsing/14/source.wdl @@ -0,0 +1,27 @@ +/* inputs: + * 1) MutSigPreprocess.{individual_set_id, maf1, maf2, maf3, maf4, maflabel1, maflabel2, maflabel3, maflabel4, wig1, wig2, wig3, wig4, build, context65_dir, build_dir, num_categories, target_list, paramfile} + * 2) ProcessCoverageForMutSig has no variables. All inputs come from prior step. + * 3) MutSigRun.{individual_set_id, gene_list, build, geneset_file, cosmic_file, refseq_file, build_dir, param_file, jobcount} + */ + +composite_task MutSig { + + step MutSigPreprocess[version=86] { + output: File("coverage.prepare.txt") as coverage_prepare_file, + File("patients.txt") as patient_list, + File("${individual_set_id}.maf") as mutation_list, + File("mutation_preprocessing_report.txt") as mutation_preprocessing_report; + } + + step ProcessCoverageForMutSig[version=75] { + input: coverage=coverage_prepare_file, patients=patient_list, mutations=mutation_list; + output: File("coverage.mat") as coverage_file, + File("mutcategs.txt") as category_file; + } + + step MutSigRun[version=157] as MutSig { + input: mutation_list=mutation_list, coverage_file=coverage_file, patients=patient_list, category_file=category_file, mutation_preprocessing_report=foobar; + output: File("bargraphs.png") as graphs; + } + +} diff --git a/test-files/parsing/14/tokens b/test-files/parsing/14/tokens new file mode 100644 index 0000000..6484c7f --- /dev/null +++ b/test-files/parsing/14/tokens @@ -0,0 +1,126 @@ +[ + {"terminal": "composite_task", "line": 7, "col": 1, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 7, "col": 16, "resource": "test-files/parsing/14/source.wdl", "source_string": "TXV0U2ln"}, + {"terminal": "lbrace", "line": 7, "col": 23, "resource": "test-files/parsing/14/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 9, "col": 3, "resource": "test-files/parsing/14/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 9, "col": 8, "resource": "test-files/parsing/14/source.wdl", "source_string": "TXV0U2lnUHJlcHJvY2Vzcw=="}, + {"terminal": "lsquare", "line": 9, "col": 24, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 9, "col": 25, "resource": "test-files/parsing/14/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 9, "col": 32, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 9, "col": 33, "resource": "test-files/parsing/14/source.wdl", "source_string": "ODY="}, + {"terminal": "rsquare", "line": 9, "col": 35, "resource": "test-files/parsing/14/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 9, "col": 37, "resource": "test-files/parsing/14/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 10, "col": 5, "resource": "test-files/parsing/14/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 10, "col": 11, "resource": "test-files/parsing/14/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 10, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 10, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 10, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "ImNvdmVyYWdlLnByZXBhcmUudHh0Ig=="}, + {"terminal": "rparen", "line": 10, "col": 40, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 10, "col": 42, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 10, "col": 45, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y292ZXJhZ2VfcHJlcGFyZV9maWxl"}, + {"terminal": "comma", "line": 10, "col": 66, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "file", "line": 11, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 11, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 11, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "InBhdGllbnRzLnR4dCI="}, + {"terminal": "rparen", "line": 11, "col": 32, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 11, "col": 34, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 11, "col": 37, "resource": "test-files/parsing/14/source.wdl", "source_string": "cGF0aWVudF9saXN0"}, + {"terminal": "comma", "line": 11, "col": 49, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "file", "line": 12, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 12, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 12, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "IiR7aW5kaXZpZHVhbF9zZXRfaWR9Lm1hZiI="}, + {"terminal": "rparen", "line": 12, "col": 44, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 12, "col": 46, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 12, "col": 49, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25fbGlzdA=="}, + {"terminal": "comma", "line": 12, "col": 62, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "file", "line": 13, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 13, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 13, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "Im11dGF0aW9uX3ByZXByb2Nlc3NpbmdfcmVwb3J0LnR4dCI="}, + {"terminal": "rparen", "line": 13, "col": 53, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 13, "col": 55, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 13, "col": 58, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25fcHJlcHJvY2Vzc2luZ19yZXBvcnQ="}, + {"terminal": "semi", "line": 13, "col": 87, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 14, "col": 3, "resource": "test-files/parsing/14/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 16, "col": 3, "resource": "test-files/parsing/14/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 16, "col": 8, "resource": "test-files/parsing/14/source.wdl", "source_string": "UHJvY2Vzc0NvdmVyYWdlRm9yTXV0U2ln"}, + {"terminal": "lsquare", "line": 16, "col": 32, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 16, "col": 33, "resource": "test-files/parsing/14/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 16, "col": 40, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 16, "col": 41, "resource": "test-files/parsing/14/source.wdl", "source_string": "NzU="}, + {"terminal": "rsquare", "line": 16, "col": 43, "resource": "test-files/parsing/14/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 16, "col": 45, "resource": "test-files/parsing/14/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 17, "col": 5, "resource": "test-files/parsing/14/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 17, "col": 10, "resource": "test-files/parsing/14/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 17, "col": 12, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y292ZXJhZ2U="}, + {"terminal": "assign", "line": 17, "col": 20, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 17, "col": 21, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y292ZXJhZ2VfcHJlcGFyZV9maWxl"}, + {"terminal": "comma", "line": 17, "col": 42, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 17, "col": 44, "resource": "test-files/parsing/14/source.wdl", "source_string": "cGF0aWVudHM="}, + {"terminal": "assign", "line": 17, "col": 52, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 17, "col": 53, "resource": "test-files/parsing/14/source.wdl", "source_string": "cGF0aWVudF9saXN0"}, + {"terminal": "comma", "line": 17, "col": 65, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 17, "col": 67, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25z"}, + {"terminal": "assign", "line": 17, "col": 76, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 17, "col": 77, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25fbGlzdA=="}, + {"terminal": "semi", "line": 17, "col": 90, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 18, "col": 5, "resource": "test-files/parsing/14/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 18, "col": 11, "resource": "test-files/parsing/14/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 18, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 18, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 18, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "ImNvdmVyYWdlLm1hdCI="}, + {"terminal": "rparen", "line": 18, "col": 32, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 18, "col": 34, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 18, "col": 37, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y292ZXJhZ2VfZmlsZQ=="}, + {"terminal": "comma", "line": 18, "col": 50, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "file", "line": 19, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 19, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 19, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "Im11dGNhdGVncy50eHQi"}, + {"terminal": "rparen", "line": 19, "col": 33, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 19, "col": 35, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 19, "col": 38, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y2F0ZWdvcnlfZmlsZQ=="}, + {"terminal": "semi", "line": 19, "col": 51, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 20, "col": 3, "resource": "test-files/parsing/14/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 22, "col": 3, "resource": "test-files/parsing/14/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 22, "col": 8, "resource": "test-files/parsing/14/source.wdl", "source_string": "TXV0U2lnUnVu"}, + {"terminal": "lsquare", "line": 22, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 22, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 22, "col": 25, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 22, "col": 26, "resource": "test-files/parsing/14/source.wdl", "source_string": "MTU3"}, + {"terminal": "rsquare", "line": 22, "col": 29, "resource": "test-files/parsing/14/source.wdl", "source_string": "XQ=="}, + {"terminal": "as", "line": 22, "col": 31, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 22, "col": 34, "resource": "test-files/parsing/14/source.wdl", "source_string": "TXV0U2ln"}, + {"terminal": "lbrace", "line": 22, "col": 41, "resource": "test-files/parsing/14/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 23, "col": 5, "resource": "test-files/parsing/14/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 23, "col": 10, "resource": "test-files/parsing/14/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 23, "col": 12, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25fbGlzdA=="}, + {"terminal": "assign", "line": 23, "col": 25, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 23, "col": 26, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25fbGlzdA=="}, + {"terminal": "comma", "line": 23, "col": 39, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 23, "col": 41, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y292ZXJhZ2VfZmlsZQ=="}, + {"terminal": "assign", "line": 23, "col": 54, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 23, "col": 55, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y292ZXJhZ2VfZmlsZQ=="}, + {"terminal": "comma", "line": 23, "col": 68, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 23, "col": 70, "resource": "test-files/parsing/14/source.wdl", "source_string": "cGF0aWVudHM="}, + {"terminal": "assign", "line": 23, "col": 78, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 23, "col": 79, "resource": "test-files/parsing/14/source.wdl", "source_string": "cGF0aWVudF9saXN0"}, + {"terminal": "comma", "line": 23, "col": 91, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 23, "col": 93, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y2F0ZWdvcnlfZmlsZQ=="}, + {"terminal": "assign", "line": 23, "col": 106, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 23, "col": 107, "resource": "test-files/parsing/14/source.wdl", "source_string": "Y2F0ZWdvcnlfZmlsZQ=="}, + {"terminal": "comma", "line": 23, "col": 120, "resource": "test-files/parsing/14/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 23, "col": 122, "resource": "test-files/parsing/14/source.wdl", "source_string": "bXV0YXRpb25fcHJlcHJvY2Vzc2luZ19yZXBvcnQ="}, + {"terminal": "assign", "line": 23, "col": 151, "resource": "test-files/parsing/14/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 23, "col": 152, "resource": "test-files/parsing/14/source.wdl", "source_string": "Zm9vYmFy"}, + {"terminal": "semi", "line": 23, "col": 158, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 24, "col": 5, "resource": "test-files/parsing/14/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 24, "col": 11, "resource": "test-files/parsing/14/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 24, "col": 13, "resource": "test-files/parsing/14/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 24, "col": 17, "resource": "test-files/parsing/14/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 24, "col": 18, "resource": "test-files/parsing/14/source.wdl", "source_string": "ImJhcmdyYXBocy5wbmci"}, + {"terminal": "rparen", "line": 24, "col": 33, "resource": "test-files/parsing/14/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 24, "col": 35, "resource": "test-files/parsing/14/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 24, "col": 38, "resource": "test-files/parsing/14/source.wdl", "source_string": "Z3JhcGhz"}, + {"terminal": "semi", "line": 24, "col": 44, "resource": "test-files/parsing/14/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 25, "col": 3, "resource": "test-files/parsing/14/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 27, "col": 1, "resource": "test-files/parsing/14/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/15/ast b/test-files/parsing/15/ast new file mode 100644 index 0000000..fd9db57 --- /dev/null +++ b/test-files/parsing/15/ast @@ -0,0 +1,4 @@ +(CompositeTask: + name=identifier, + body=[] +) \ No newline at end of file diff --git a/test-files/parsing/15/formatted b/test-files/parsing/15/formatted new file mode 100644 index 0000000..60fcec3 --- /dev/null +++ b/test-files/parsing/15/formatted @@ -0,0 +1,2 @@ +composite_task x { +} diff --git a/test-files/parsing/15/graph b/test-files/parsing/15/graph new file mode 100644 index 0000000..d612dd1 --- /dev/null +++ b/test-files/parsing/15/graph @@ -0,0 +1,5 @@ +VERTICIES +--------- + +EDGES +----- diff --git a/test-files/parsing/15/parsetree b/test-files/parsing/15/parsetree new file mode 100644 index 0000000..01245bb --- /dev/null +++ b/test-files/parsing/15/parsetree @@ -0,0 +1,14 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/15/source.wdl b/test-files/parsing/15/source.wdl new file mode 100644 index 0000000..178675b --- /dev/null +++ b/test-files/parsing/15/source.wdl @@ -0,0 +1,4 @@ +composite_task x { + /* step y[version=8989] {} */ + // step z[version=9090] {} +} diff --git a/test-files/parsing/15/tokens b/test-files/parsing/15/tokens new file mode 100644 index 0000000..a1d1a66 --- /dev/null +++ b/test-files/parsing/15/tokens @@ -0,0 +1,6 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/15/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/15/source.wdl", "source_string": "eA=="}, + {"terminal": "lbrace", "line": 1, "col": 18, "resource": "test-files/parsing/15/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 4, "col": 1, "resource": "test-files/parsing/15/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/16/ast b/test-files/parsing/16/ast new file mode 100644 index 0000000..564d566 --- /dev/null +++ b/test-files/parsing/16/ast @@ -0,0 +1,18 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/16/formatted b/test-files/parsing/16/formatted new file mode 100644 index 0000000..fcfa7d3 --- /dev/null +++ b/test-files/parsing/16/formatted @@ -0,0 +1,4 @@ +composite_task y { + step gamma[version=4] { + } +} diff --git a/test-files/parsing/16/graph b/test-files/parsing/16/graph new file mode 100644 index 0000000..98a171e --- /dev/null +++ b/test-files/parsing/16/graph @@ -0,0 +1,6 @@ +VERTICIES +--------- +[Step: name=gamma] + +EDGES +----- diff --git a/test-files/parsing/16/parsetree b/test-files/parsing/16/parsetree new file mode 100644 index 0000000..e6366b8 --- /dev/null +++ b/test-files/parsing/16/parsetree @@ -0,0 +1,44 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/16/source.wdl b/test-files/parsing/16/source.wdl new file mode 100644 index 0000000..fa5b09e --- /dev/null +++ b/test-files/parsing/16/source.wdl @@ -0,0 +1,11 @@ +/* +pre +*/ +composite_task /*x*/ y /*z*/ { + // step alpha {} + //step beta {} // /**/ + step gamma /* step epsilon {} */[version=/*3*/4] { /*{*/ } +} +/* +post +*/ diff --git a/test-files/parsing/16/tokens b/test-files/parsing/16/tokens new file mode 100644 index 0000000..9b880f9 --- /dev/null +++ b/test-files/parsing/16/tokens @@ -0,0 +1,15 @@ +[ + {"terminal": "composite_task", "line": 4, "col": 1, "resource": "test-files/parsing/16/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 4, "col": 22, "resource": "test-files/parsing/16/source.wdl", "source_string": "eQ=="}, + {"terminal": "lbrace", "line": 4, "col": 30, "resource": "test-files/parsing/16/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 7, "col": 3, "resource": "test-files/parsing/16/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 7, "col": 8, "resource": "test-files/parsing/16/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "lsquare", "line": 7, "col": 35, "resource": "test-files/parsing/16/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 7, "col": 36, "resource": "test-files/parsing/16/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 7, "col": 43, "resource": "test-files/parsing/16/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 7, "col": 49, "resource": "test-files/parsing/16/source.wdl", "source_string": "NA=="}, + {"terminal": "rsquare", "line": 7, "col": 50, "resource": "test-files/parsing/16/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 7, "col": 52, "resource": "test-files/parsing/16/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 7, "col": 60, "resource": "test-files/parsing/16/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 8, "col": 1, "resource": "test-files/parsing/16/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/17/ast b/test-files/parsing/17/ast new file mode 100644 index 0000000..7978b86 --- /dev/null +++ b/test-files/parsing/17/ast @@ -0,0 +1,96 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=string + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=string + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputListAppend: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/17/formatted b/test-files/parsing/17/formatted new file mode 100644 index 0000000..2f1abf4 --- /dev/null +++ b/test-files/parsing/17/formatted @@ -0,0 +1,12 @@ +composite_task x { + step a[version="1.5.6"] { + input: in0=global; + output: File("a_out.txt") as a_out; + } + for ( b in c ) { + step d[version="1.0.2"] { + input: in0=a_out, in1=b.x; + output: File("d_out.txt") as d_out; + } + } +} diff --git a/test-files/parsing/17/graph b/test-files/parsing/17/graph new file mode 100644 index 0000000..1ca6bdb --- /dev/null +++ b/test-files/parsing/17/graph @@ -0,0 +1,42 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=c], var=[Variable: name=b], # nodes=1] +[Step: name=a] +[Step: name=d] +[Variable: name=a_out] +[Variable: name=b, member=x] +[Variable: name=b] +[Variable: name=c] +[Variable: name=d_out] +[Variable: name=global] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=c], var=[Variable: name=b], # nodes=1] + to: [Variable: name=b] +] +[Edge + from: [Step: name=a] + to: [Variable: name=a_out] +] +[Edge + from: [Step: name=d] + to: [Variable: name=d_out] +] +[Edge + from: [Variable: name=a_out] + to: [Step: name=d] +] +[Edge + from: [Variable: name=b, member=x] + to: [Step: name=d] +] +[Edge + from: [Variable: name=c] + to: [CompositeTaskForScope: collection=[Variable: name=c], var=[Variable: name=b], # nodes=1] +] +[Edge + from: [Variable: name=global] + to: [Step: name=a] +] diff --git a/test-files/parsing/17/parsetree b/test-files/parsing/17/parsetree new file mode 100644 index 0000000..3881773 --- /dev/null +++ b/test-files/parsing/17/parsetree @@ -0,0 +1,199 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + string + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + string + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + into, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/17/source.wdl b/test-files/parsing/17/source.wdl new file mode 100644 index 0000000..7f3db7e --- /dev/null +++ b/test-files/parsing/17/source.wdl @@ -0,0 +1,10 @@ +composite_task x { + step a[version="1.5.6"] { + input: in0=global; output: File("a_out.txt") as a_out; + } + for ( b in c ) { + step d[version="1.0.2"] { + input: in0=a_out, in1=b.x; output: File("d_out.txt") into d_out; + } + } +} diff --git a/test-files/parsing/17/tokens b/test-files/parsing/17/tokens new file mode 100644 index 0000000..6d39aaa --- /dev/null +++ b/test-files/parsing/17/tokens @@ -0,0 +1,68 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/17/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/17/source.wdl", "source_string": "eA=="}, + {"terminal": "lbrace", "line": 1, "col": 18, "resource": "test-files/parsing/17/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 2, "col": 3, "resource": "test-files/parsing/17/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/17/source.wdl", "source_string": "YQ=="}, + {"terminal": "lsquare", "line": 2, "col": 9, "resource": "test-files/parsing/17/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 2, "col": 10, "resource": "test-files/parsing/17/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 2, "col": 17, "resource": "test-files/parsing/17/source.wdl", "source_string": "PQ=="}, + {"terminal": "string", "line": 2, "col": 18, "resource": "test-files/parsing/17/source.wdl", "source_string": "IjEuNS42Ig=="}, + {"terminal": "rsquare", "line": 2, "col": 25, "resource": "test-files/parsing/17/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 2, "col": 27, "resource": "test-files/parsing/17/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 3, "col": 5, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 3, "col": 10, "resource": "test-files/parsing/17/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 3, "col": 12, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW4w"}, + {"terminal": "assign", "line": 3, "col": 15, "resource": "test-files/parsing/17/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 3, "col": 16, "resource": "test-files/parsing/17/source.wdl", "source_string": "Z2xvYmFs"}, + {"terminal": "semi", "line": 3, "col": 22, "resource": "test-files/parsing/17/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 3, "col": 24, "resource": "test-files/parsing/17/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 3, "col": 30, "resource": "test-files/parsing/17/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 3, "col": 32, "resource": "test-files/parsing/17/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 3, "col": 36, "resource": "test-files/parsing/17/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 3, "col": 37, "resource": "test-files/parsing/17/source.wdl", "source_string": "ImFfb3V0LnR4dCI="}, + {"terminal": "rparen", "line": 3, "col": 48, "resource": "test-files/parsing/17/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 3, "col": 50, "resource": "test-files/parsing/17/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 3, "col": 53, "resource": "test-files/parsing/17/source.wdl", "source_string": "YV9vdXQ="}, + {"terminal": "semi", "line": 3, "col": 58, "resource": "test-files/parsing/17/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 4, "col": 3, "resource": "test-files/parsing/17/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 5, "col": 3, "resource": "test-files/parsing/17/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 5, "col": 7, "resource": "test-files/parsing/17/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 5, "col": 9, "resource": "test-files/parsing/17/source.wdl", "source_string": "Yg=="}, + {"terminal": "in", "line": 5, "col": 11, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 5, "col": 14, "resource": "test-files/parsing/17/source.wdl", "source_string": "Yw=="}, + {"terminal": "rparen", "line": 5, "col": 16, "resource": "test-files/parsing/17/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 5, "col": 18, "resource": "test-files/parsing/17/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 6, "col": 5, "resource": "test-files/parsing/17/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 6, "col": 10, "resource": "test-files/parsing/17/source.wdl", "source_string": "ZA=="}, + {"terminal": "lsquare", "line": 6, "col": 11, "resource": "test-files/parsing/17/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 6, "col": 12, "resource": "test-files/parsing/17/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 6, "col": 19, "resource": "test-files/parsing/17/source.wdl", "source_string": "PQ=="}, + {"terminal": "string", "line": 6, "col": 20, "resource": "test-files/parsing/17/source.wdl", "source_string": "IjEuMC4yIg=="}, + {"terminal": "rsquare", "line": 6, "col": 27, "resource": "test-files/parsing/17/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 6, "col": 29, "resource": "test-files/parsing/17/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 7, "col": 7, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 7, "col": 12, "resource": "test-files/parsing/17/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 7, "col": 14, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW4w"}, + {"terminal": "assign", "line": 7, "col": 17, "resource": "test-files/parsing/17/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 18, "resource": "test-files/parsing/17/source.wdl", "source_string": "YV9vdXQ="}, + {"terminal": "comma", "line": 7, "col": 23, "resource": "test-files/parsing/17/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 7, "col": 25, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW4x"}, + {"terminal": "assign", "line": 7, "col": 28, "resource": "test-files/parsing/17/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 7, "col": 29, "resource": "test-files/parsing/17/source.wdl", "source_string": "Yg=="}, + {"terminal": "dot", "line": 7, "col": 30, "resource": "test-files/parsing/17/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 7, "col": 31, "resource": "test-files/parsing/17/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 7, "col": 32, "resource": "test-files/parsing/17/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 7, "col": 34, "resource": "test-files/parsing/17/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 7, "col": 40, "resource": "test-files/parsing/17/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 7, "col": 42, "resource": "test-files/parsing/17/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 7, "col": 46, "resource": "test-files/parsing/17/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 7, "col": 47, "resource": "test-files/parsing/17/source.wdl", "source_string": "ImRfb3V0LnR4dCI="}, + {"terminal": "rparen", "line": 7, "col": 58, "resource": "test-files/parsing/17/source.wdl", "source_string": "KQ=="}, + {"terminal": "into", "line": 7, "col": 60, "resource": "test-files/parsing/17/source.wdl", "source_string": "aW50bw=="}, + {"terminal": "identifier", "line": 7, "col": 65, "resource": "test-files/parsing/17/source.wdl", "source_string": "ZF9vdXQ="}, + {"terminal": "semi", "line": 7, "col": 70, "resource": "test-files/parsing/17/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 8, "col": 5, "resource": "test-files/parsing/17/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 9, "col": 3, "resource": "test-files/parsing/17/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 10, "col": 1, "resource": "test-files/parsing/17/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/18/ast b/test-files/parsing/18/ast new file mode 100644 index 0000000..9a866e0 --- /dev/null +++ b/test-files/parsing/18/ast @@ -0,0 +1,96 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=string + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=first_line, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=string + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputListAppend: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/18/formatted b/test-files/parsing/18/formatted new file mode 100644 index 0000000..d615938 --- /dev/null +++ b/test-files/parsing/18/formatted @@ -0,0 +1,12 @@ +composite_task x { + step a[version="1.5.6"] { + input: in0=global; + output: FirstLine("a_out.txt") as a_out; + } + for ( b in c ) { + step d[version="1.0.2"] { + input: in0=a_out, in1=b.x; + output: File("d_out.txt") as d_out; + } + } +} diff --git a/test-files/parsing/18/graph b/test-files/parsing/18/graph new file mode 100644 index 0000000..1ca6bdb --- /dev/null +++ b/test-files/parsing/18/graph @@ -0,0 +1,42 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=c], var=[Variable: name=b], # nodes=1] +[Step: name=a] +[Step: name=d] +[Variable: name=a_out] +[Variable: name=b, member=x] +[Variable: name=b] +[Variable: name=c] +[Variable: name=d_out] +[Variable: name=global] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=c], var=[Variable: name=b], # nodes=1] + to: [Variable: name=b] +] +[Edge + from: [Step: name=a] + to: [Variable: name=a_out] +] +[Edge + from: [Step: name=d] + to: [Variable: name=d_out] +] +[Edge + from: [Variable: name=a_out] + to: [Step: name=d] +] +[Edge + from: [Variable: name=b, member=x] + to: [Step: name=d] +] +[Edge + from: [Variable: name=c] + to: [CompositeTaskForScope: collection=[Variable: name=c], var=[Variable: name=b], # nodes=1] +] +[Edge + from: [Variable: name=global] + to: [Step: name=a] +] diff --git a/test-files/parsing/18/parsetree b/test-files/parsing/18/parsetree new file mode 100644 index 0000000..df73aa8 --- /dev/null +++ b/test-files/parsing/18/parsetree @@ -0,0 +1,199 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + string + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + first_line + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + string + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + into, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/18/source.wdl b/test-files/parsing/18/source.wdl new file mode 100644 index 0000000..d85e951 --- /dev/null +++ b/test-files/parsing/18/source.wdl @@ -0,0 +1,11 @@ +composite_task x { + step a[version="1.5.6"] { + input: in0=global; + output: FirstLine("a_out.txt") as a_out; + } + for ( b in c ) { + step d[version="1.0.2"] { + input: in0=a_out, in1=b.x; output: File("d_out.txt") into d_out; + } + } +} diff --git a/test-files/parsing/18/tokens b/test-files/parsing/18/tokens new file mode 100644 index 0000000..cfff2f3 --- /dev/null +++ b/test-files/parsing/18/tokens @@ -0,0 +1,68 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/18/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/18/source.wdl", "source_string": "eA=="}, + {"terminal": "lbrace", "line": 1, "col": 18, "resource": "test-files/parsing/18/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 2, "col": 3, "resource": "test-files/parsing/18/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/18/source.wdl", "source_string": "YQ=="}, + {"terminal": "lsquare", "line": 2, "col": 9, "resource": "test-files/parsing/18/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 2, "col": 10, "resource": "test-files/parsing/18/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 2, "col": 17, "resource": "test-files/parsing/18/source.wdl", "source_string": "PQ=="}, + {"terminal": "string", "line": 2, "col": 18, "resource": "test-files/parsing/18/source.wdl", "source_string": "IjEuNS42Ig=="}, + {"terminal": "rsquare", "line": 2, "col": 25, "resource": "test-files/parsing/18/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 2, "col": 27, "resource": "test-files/parsing/18/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 3, "col": 5, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 3, "col": 10, "resource": "test-files/parsing/18/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 3, "col": 12, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW4w"}, + {"terminal": "assign", "line": 3, "col": 15, "resource": "test-files/parsing/18/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 3, "col": 16, "resource": "test-files/parsing/18/source.wdl", "source_string": "Z2xvYmFs"}, + {"terminal": "semi", "line": 3, "col": 22, "resource": "test-files/parsing/18/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 4, "col": 5, "resource": "test-files/parsing/18/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 11, "resource": "test-files/parsing/18/source.wdl", "source_string": "Og=="}, + {"terminal": "first_line", "line": 4, "col": 13, "resource": "test-files/parsing/18/source.wdl", "source_string": "Rmlyc3RMaW5l"}, + {"terminal": "lparen", "line": 4, "col": 22, "resource": "test-files/parsing/18/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 23, "resource": "test-files/parsing/18/source.wdl", "source_string": "ImFfb3V0LnR4dCI="}, + {"terminal": "rparen", "line": 4, "col": 34, "resource": "test-files/parsing/18/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 36, "resource": "test-files/parsing/18/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 39, "resource": "test-files/parsing/18/source.wdl", "source_string": "YV9vdXQ="}, + {"terminal": "semi", "line": 4, "col": 44, "resource": "test-files/parsing/18/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 3, "resource": "test-files/parsing/18/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 6, "col": 3, "resource": "test-files/parsing/18/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 6, "col": 7, "resource": "test-files/parsing/18/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 6, "col": 9, "resource": "test-files/parsing/18/source.wdl", "source_string": "Yg=="}, + {"terminal": "in", "line": 6, "col": 11, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 6, "col": 14, "resource": "test-files/parsing/18/source.wdl", "source_string": "Yw=="}, + {"terminal": "rparen", "line": 6, "col": 16, "resource": "test-files/parsing/18/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 6, "col": 18, "resource": "test-files/parsing/18/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 7, "col": 5, "resource": "test-files/parsing/18/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 7, "col": 10, "resource": "test-files/parsing/18/source.wdl", "source_string": "ZA=="}, + {"terminal": "lsquare", "line": 7, "col": 11, "resource": "test-files/parsing/18/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 7, "col": 12, "resource": "test-files/parsing/18/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 7, "col": 19, "resource": "test-files/parsing/18/source.wdl", "source_string": "PQ=="}, + {"terminal": "string", "line": 7, "col": 20, "resource": "test-files/parsing/18/source.wdl", "source_string": "IjEuMC4yIg=="}, + {"terminal": "rsquare", "line": 7, "col": 27, "resource": "test-files/parsing/18/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 7, "col": 29, "resource": "test-files/parsing/18/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 8, "col": 7, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 8, "col": 12, "resource": "test-files/parsing/18/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 8, "col": 14, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW4w"}, + {"terminal": "assign", "line": 8, "col": 17, "resource": "test-files/parsing/18/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 8, "col": 18, "resource": "test-files/parsing/18/source.wdl", "source_string": "YV9vdXQ="}, + {"terminal": "comma", "line": 8, "col": 23, "resource": "test-files/parsing/18/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 8, "col": 25, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW4x"}, + {"terminal": "assign", "line": 8, "col": 28, "resource": "test-files/parsing/18/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 8, "col": 29, "resource": "test-files/parsing/18/source.wdl", "source_string": "Yg=="}, + {"terminal": "dot", "line": 8, "col": 30, "resource": "test-files/parsing/18/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 8, "col": 31, "resource": "test-files/parsing/18/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 8, "col": 32, "resource": "test-files/parsing/18/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 8, "col": 34, "resource": "test-files/parsing/18/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 8, "col": 40, "resource": "test-files/parsing/18/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 8, "col": 42, "resource": "test-files/parsing/18/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 8, "col": 46, "resource": "test-files/parsing/18/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 8, "col": 47, "resource": "test-files/parsing/18/source.wdl", "source_string": "ImRfb3V0LnR4dCI="}, + {"terminal": "rparen", "line": 8, "col": 58, "resource": "test-files/parsing/18/source.wdl", "source_string": "KQ=="}, + {"terminal": "into", "line": 8, "col": 60, "resource": "test-files/parsing/18/source.wdl", "source_string": "aW50bw=="}, + {"terminal": "identifier", "line": 8, "col": 65, "resource": "test-files/parsing/18/source.wdl", "source_string": "ZF9vdXQ="}, + {"terminal": "semi", "line": 8, "col": 70, "resource": "test-files/parsing/18/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 9, "col": 5, "resource": "test-files/parsing/18/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 10, "col": 3, "resource": "test-files/parsing/18/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 11, "col": 1, "resource": "test-files/parsing/18/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/2/ast b/test-files/parsing/2/ast new file mode 100644 index 0000000..8b438df --- /dev/null +++ b/test-files/parsing/2/ast @@ -0,0 +1,305 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ), + (CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/2/formatted b/test-files/parsing/2/formatted new file mode 100644 index 0000000..77706f7 --- /dev/null +++ b/test-files/parsing/2/formatted @@ -0,0 +1,32 @@ +composite_task foo { + step atask[version=0] { + output: File("foo.txt") as x; + } + for ( item in foo ) { + step btask[version=0] { + input: p0=item, p1=global; + output: File("bar.txt") as y; + } + step ctask[version=0] { + input: p0=item, p1=y; + output: File("quux.txt") as z; + } + for ( alpha in beta ) { + step dtask[version=0] { + input: p0=y, p1=alpha; + } + composite_task foo_sub { + step etask[version=0] { + input: p0=global1, p1=y, p2=alpha; + } + step ftask[version=0] { + input: p0=global1, p1=z, p2=alpha; + } + } + } + } + step gtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } +} diff --git a/test-files/parsing/2/graph b/test-files/parsing/2/graph new file mode 100644 index 0000000..728028e --- /dev/null +++ b/test-files/parsing/2/graph @@ -0,0 +1,93 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=beta], var=[Variable: name=alpha], # nodes=2] +[CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] +[Step: name=atask] +[Step: name=btask] +[Step: name=ctask] +[Step: name=dtask] +[Step: name=gtask] +[Variable: name=alpha] +[Variable: name=beta] +[Variable: name=foo] +[Variable: name=global] +[Variable: name=item] +[Variable: name=r] +[Variable: name=x] +[Variable: name=y] +[Variable: name=z] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=beta], var=[Variable: name=alpha], # nodes=2] + to: [Variable: name=alpha] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] + to: [Step: name=gtask] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=x] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=y] +] +[Edge + from: [Step: name=ctask] + to: [Variable: name=z] +] +[Edge + from: [Step: name=gtask] + to: [Variable: name=r] +] +[Edge + from: [Variable: name=alpha] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=beta] + to: [CompositeTaskForScope: collection=[Variable: name=beta], var=[Variable: name=alpha], # nodes=2] +] +[Edge + from: [Variable: name=foo] + to: [CompositeTaskForScope: collection=[Variable: name=foo], var=[Variable: name=item], # nodes=3] +] +[Edge + from: [Variable: name=global] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=x] + to: [Step: name=gtask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=ctask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=dtask] +] +[Edge + from: [Variable: name=y] + to: [Step: name=gtask] +] +[Edge + from: [Variable: name=z] + to: [Step: name=gtask] +] diff --git a/test-files/parsing/2/parsetree b/test-files/parsing/2/parsetree new file mode 100644 index 0000000..cf162f2 --- /dev/null +++ b/test-files/parsing/2/parsetree @@ -0,0 +1,592 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/2/source.wdl b/test-files/parsing/2/source.wdl new file mode 100644 index 0000000..d85613b --- /dev/null +++ b/test-files/parsing/2/source.wdl @@ -0,0 +1,39 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as x; + } + + for ( item in foo ) { + step btask[version=0] { + input: p0=item, p1=global; + output: File("bar.txt") as y; + } + + step ctask[version=0] { + input: p0=item, p1=y; + output: File("quux.txt") as z; + } + + for ( alpha in beta ) { + step dtask[version=0] { + input: p0=y, p1=alpha; + } + + composite_task foo_sub { + step etask[version=0] { + input: p0=global1, p1=y, p2=alpha; + } + step ftask[version=0] { + input: p0=global1, p1=z, p2=alpha; + } + } + } + } + + step gtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } + +} diff --git a/test-files/parsing/2/tokens b/test-files/parsing/2/tokens new file mode 100644 index 0000000..7dfb38c --- /dev/null +++ b/test-files/parsing/2/tokens @@ -0,0 +1,197 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/2/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 3, "col": 3, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 8, "resource": "test-files/parsing/2/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 3, "col": 13, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 22, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 3, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 4, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 11, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 4, "col": 13, "resource": "test-files/parsing/2/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 4, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 4, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 29, "resource": "test-files/parsing/2/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 32, "resource": "test-files/parsing/2/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 4, "col": 33, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 3, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 7, "col": 3, "resource": "test-files/parsing/2/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 7, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 7, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 7, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 7, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "Zm9v"}, + {"terminal": "rparen", "line": 7, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 7, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 8, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 8, "col": 10, "resource": "test-files/parsing/2/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 8, "col": 15, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 8, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 8, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 8, "col": 24, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 8, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 8, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 9, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 9, "col": 12, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 9, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 9, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 9, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 9, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 9, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 26, "resource": "test-files/parsing/2/source.wdl", "source_string": "Z2xvYmFs"}, + {"terminal": "semi", "line": 9, "col": 32, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 10, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 10, "col": 13, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 10, "col": 15, "resource": "test-files/parsing/2/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 10, "col": 19, "resource": "test-files/parsing/2/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 10, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 10, "col": 29, "resource": "test-files/parsing/2/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 10, "col": 31, "resource": "test-files/parsing/2/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 10, "col": 34, "resource": "test-files/parsing/2/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 10, "col": 35, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 11, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 13, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 13, "col": 10, "resource": "test-files/parsing/2/source.wdl", "source_string": "Y3Rhc2s="}, + {"terminal": "lsquare", "line": 13, "col": 15, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 13, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 13, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 13, "col": 24, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 13, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 13, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 14, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 14, "col": 12, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 14, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 14, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "comma", "line": 14, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 14, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 14, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 14, "col": 26, "resource": "test-files/parsing/2/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 14, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 15, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 15, "col": 13, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 15, "col": 15, "resource": "test-files/parsing/2/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 15, "col": 19, "resource": "test-files/parsing/2/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 15, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 15, "col": 30, "resource": "test-files/parsing/2/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 15, "col": 32, "resource": "test-files/parsing/2/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 15, "col": 35, "resource": "test-files/parsing/2/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 15, "col": 36, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 16, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 18, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 18, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 18, "col": 11, "resource": "test-files/parsing/2/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "in", "line": 18, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 18, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "rparen", "line": 18, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 18, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 19, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 19, "col": 12, "resource": "test-files/parsing/2/source.wdl", "source_string": "ZHRhc2s="}, + {"terminal": "lsquare", "line": 19, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 19, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 19, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 19, "col": 26, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 19, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 19, "col": 29, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 20, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 20, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 20, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 20, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 19, "resource": "test-files/parsing/2/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 20, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 20, "col": 22, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 20, "col": 24, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 20, "col": 30, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 21, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "composite_task", "line": 23, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 23, "col": 22, "resource": "test-files/parsing/2/source.wdl", "source_string": "Zm9vX3N1Yg=="}, + {"terminal": "lbrace", "line": 23, "col": 30, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 24, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 24, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "ZXRhc2s="}, + {"terminal": "lsquare", "line": 24, "col": 19, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 24, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 24, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 24, "col": 28, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 24, "col": 29, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 24, "col": 31, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 25, "col": 11, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 25, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 25, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 25, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 25, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "Z2xvYmFsMQ=="}, + {"terminal": "comma", "line": 25, "col": 28, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 25, "col": 30, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 25, "col": 32, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 25, "col": 33, "resource": "test-files/parsing/2/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 25, "col": 34, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 25, "col": 36, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 25, "col": 38, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 25, "col": 39, "resource": "test-files/parsing/2/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 25, "col": 44, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 26, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 27, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 27, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "ZnRhc2s="}, + {"terminal": "lsquare", "line": 27, "col": 19, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 27, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 27, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 27, "col": 28, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 27, "col": 29, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 27, "col": 31, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 28, "col": 11, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 28, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 28, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 28, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 28, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "Z2xvYmFsMQ=="}, + {"terminal": "comma", "line": 28, "col": 28, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 28, "col": 30, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 28, "col": 32, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 28, "col": 33, "resource": "test-files/parsing/2/source.wdl", "source_string": "eg=="}, + {"terminal": "comma", "line": 28, "col": 34, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 28, "col": 36, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 28, "col": 38, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 28, "col": 39, "resource": "test-files/parsing/2/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 28, "col": 44, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 29, "col": 9, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 30, "col": 7, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 31, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 32, "col": 3, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 34, "col": 3, "resource": "test-files/parsing/2/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 34, "col": 8, "resource": "test-files/parsing/2/source.wdl", "source_string": "Z3Rhc2s="}, + {"terminal": "lsquare", "line": 34, "col": 13, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 34, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 34, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 34, "col": 22, "resource": "test-files/parsing/2/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 34, "col": 23, "resource": "test-files/parsing/2/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 34, "col": 25, "resource": "test-files/parsing/2/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 35, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 35, "col": 10, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 35, "col": 12, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 35, "col": 14, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 35, "col": 15, "resource": "test-files/parsing/2/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 35, "col": 16, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 35, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 35, "col": 20, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 35, "col": 21, "resource": "test-files/parsing/2/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 35, "col": 22, "resource": "test-files/parsing/2/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 35, "col": 24, "resource": "test-files/parsing/2/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 35, "col": 26, "resource": "test-files/parsing/2/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 35, "col": 27, "resource": "test-files/parsing/2/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 35, "col": 28, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 36, "col": 5, "resource": "test-files/parsing/2/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 36, "col": 11, "resource": "test-files/parsing/2/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 36, "col": 13, "resource": "test-files/parsing/2/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 36, "col": 17, "resource": "test-files/parsing/2/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 36, "col": 18, "resource": "test-files/parsing/2/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 36, "col": 30, "resource": "test-files/parsing/2/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 36, "col": 32, "resource": "test-files/parsing/2/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 36, "col": 35, "resource": "test-files/parsing/2/source.wdl", "source_string": "cg=="}, + {"terminal": "semi", "line": 36, "col": 36, "resource": "test-files/parsing/2/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 37, "col": 3, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 39, "col": 1, "resource": "test-files/parsing/2/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/3/ast b/test-files/parsing/3/ast new file mode 100644 index 0000000..fd9db57 --- /dev/null +++ b/test-files/parsing/3/ast @@ -0,0 +1,4 @@ +(CompositeTask: + name=identifier, + body=[] +) \ No newline at end of file diff --git a/test-files/parsing/3/formatted b/test-files/parsing/3/formatted new file mode 100644 index 0000000..6e746d5 --- /dev/null +++ b/test-files/parsing/3/formatted @@ -0,0 +1,2 @@ +composite_task foo { +} diff --git a/test-files/parsing/3/graph b/test-files/parsing/3/graph new file mode 100644 index 0000000..d612dd1 --- /dev/null +++ b/test-files/parsing/3/graph @@ -0,0 +1,5 @@ +VERTICIES +--------- + +EDGES +----- diff --git a/test-files/parsing/3/parsetree b/test-files/parsing/3/parsetree new file mode 100644 index 0000000..01245bb --- /dev/null +++ b/test-files/parsing/3/parsetree @@ -0,0 +1,14 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/3/source.wdl b/test-files/parsing/3/source.wdl new file mode 100644 index 0000000..93f0f92 --- /dev/null +++ b/test-files/parsing/3/source.wdl @@ -0,0 +1 @@ +composite_task foo {} diff --git a/test-files/parsing/3/tokens b/test-files/parsing/3/tokens new file mode 100644 index 0000000..b05c651 --- /dev/null +++ b/test-files/parsing/3/tokens @@ -0,0 +1,6 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/3/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/3/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/3/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 1, "col": 21, "resource": "test-files/parsing/3/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/4/ast b/test-files/parsing/4/ast new file mode 100644 index 0000000..09cb4f4 --- /dev/null +++ b/test-files/parsing/4/ast @@ -0,0 +1,205 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/4/formatted b/test-files/parsing/4/formatted new file mode 100644 index 0000000..08930c2 --- /dev/null +++ b/test-files/parsing/4/formatted @@ -0,0 +1,22 @@ +composite_task foo { + step short_task[version=0] { + output: File("foo.txt") as alpha; + } + step long_task[version=0] { + output: File("bar.txt") as beta; + } + for ( item in items ) { + step atask[version=0] { + input: p0=alpha, p1=item.x; + output: File("baz.txt") as gamma; + } + step btask[version=0] { + input: p0=beta, p1=item.y; + output: File("quux.txt") as epsilon; + } + } + step generate_report[version=0] { + input: p0=gamma, p1=epsilon; + output: File("report.txt") as report; + } +} diff --git a/test-files/parsing/4/graph b/test-files/parsing/4/graph new file mode 100644 index 0000000..bf0f29a --- /dev/null +++ b/test-files/parsing/4/graph @@ -0,0 +1,76 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=2] +[Step: name=atask] +[Step: name=btask] +[Step: name=generate_report] +[Step: name=long_task] +[Step: name=short_task] +[Variable: name=alpha] +[Variable: name=beta] +[Variable: name=epsilon] +[Variable: name=gamma] +[Variable: name=item, member=x] +[Variable: name=item, member=y] +[Variable: name=item] +[Variable: name=items] +[Variable: name=report] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=2] + to: [Step: name=generate_report] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=2] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=gamma] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=epsilon] +] +[Edge + from: [Step: name=generate_report] + to: [Variable: name=report] +] +[Edge + from: [Step: name=long_task] + to: [Variable: name=beta] +] +[Edge + from: [Step: name=short_task] + to: [Variable: name=alpha] +] +[Edge + from: [Variable: name=alpha] + to: [Step: name=atask] +] +[Edge + from: [Variable: name=beta] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=epsilon] + to: [Step: name=generate_report] +] +[Edge + from: [Variable: name=gamma] + to: [Step: name=generate_report] +] +[Edge + from: [Variable: name=item, member=x] + to: [Step: name=atask] +] +[Edge + from: [Variable: name=item, member=y] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=items] + to: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=2] +] diff --git a/test-files/parsing/4/parsetree b/test-files/parsing/4/parsetree new file mode 100644 index 0000000..f222a2d --- /dev/null +++ b/test-files/parsing/4/parsetree @@ -0,0 +1,417 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/4/source.wdl b/test-files/parsing/4/source.wdl new file mode 100644 index 0000000..19e7960 --- /dev/null +++ b/test-files/parsing/4/source.wdl @@ -0,0 +1,28 @@ +composite_task foo { + + step short_task[version=0] { + output: File("foo.txt") as alpha; + } + + step long_task[version=0] { + output: File("bar.txt") as beta; + } + + for ( item in items ) { + step atask[version=0] { + input: p0=alpha, p1=item.x; + output: File("baz.txt") as gamma; + } + + step btask[version=0] { + input: p0=beta, p1=item.y; + output: File("quux.txt") as epsilon; + } + } + + step generate_report[version=0] { + input: p0=gamma, p1=epsilon; + output: File("report.txt") as report; + } + +} diff --git a/test-files/parsing/4/tokens b/test-files/parsing/4/tokens new file mode 100644 index 0000000..1bdc6e3 --- /dev/null +++ b/test-files/parsing/4/tokens @@ -0,0 +1,138 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/4/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/4/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 3, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 8, "resource": "test-files/parsing/4/source.wdl", "source_string": "c2hvcnRfdGFzaw=="}, + {"terminal": "lsquare", "line": 3, "col": 18, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 19, "resource": "test-files/parsing/4/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 26, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 3, "col": 28, "resource": "test-files/parsing/4/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 30, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 4, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 11, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 4, "col": 13, "resource": "test-files/parsing/4/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 4, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 18, "resource": "test-files/parsing/4/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 4, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 29, "resource": "test-files/parsing/4/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 4, "col": 37, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 7, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 7, "col": 8, "resource": "test-files/parsing/4/source.wdl", "source_string": "bG9uZ190YXNr"}, + {"terminal": "lsquare", "line": 7, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 7, "col": 18, "resource": "test-files/parsing/4/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 7, "col": 25, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 7, "col": 26, "resource": "test-files/parsing/4/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 7, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 7, "col": 29, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 8, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 8, "col": 11, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 8, "col": 13, "resource": "test-files/parsing/4/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 8, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 8, "col": 18, "resource": "test-files/parsing/4/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 8, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 8, "col": 29, "resource": "test-files/parsing/4/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 8, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "semi", "line": 8, "col": 36, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 9, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 11, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 11, "col": 7, "resource": "test-files/parsing/4/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 11, "col": 9, "resource": "test-files/parsing/4/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 11, "col": 14, "resource": "test-files/parsing/4/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 11, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "aXRlbXM="}, + {"terminal": "rparen", "line": 11, "col": 23, "resource": "test-files/parsing/4/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 11, "col": 25, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 12, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 12, "col": 10, "resource": "test-files/parsing/4/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 12, "col": 15, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 12, "col": 16, "resource": "test-files/parsing/4/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 12, "col": 23, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 12, "col": 24, "resource": "test-files/parsing/4/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 12, "col": 25, "resource": "test-files/parsing/4/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 12, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 13, "col": 7, "resource": "test-files/parsing/4/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 13, "col": 12, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 13, "col": 14, "resource": "test-files/parsing/4/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 13, "col": 16, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 13, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "comma", "line": 13, "col": 22, "resource": "test-files/parsing/4/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 13, "col": 24, "resource": "test-files/parsing/4/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 13, "col": 26, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 13, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "dot", "line": 13, "col": 31, "resource": "test-files/parsing/4/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 13, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 13, "col": 33, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 14, "col": 7, "resource": "test-files/parsing/4/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 14, "col": 13, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 14, "col": 15, "resource": "test-files/parsing/4/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 14, "col": 19, "resource": "test-files/parsing/4/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 14, "col": 20, "resource": "test-files/parsing/4/source.wdl", "source_string": "ImJhei50eHQi"}, + {"terminal": "rparen", "line": 14, "col": 29, "resource": "test-files/parsing/4/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 14, "col": 31, "resource": "test-files/parsing/4/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 14, "col": 34, "resource": "test-files/parsing/4/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "semi", "line": 14, "col": 39, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 15, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 17, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 17, "col": 10, "resource": "test-files/parsing/4/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 17, "col": 15, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 17, "col": 16, "resource": "test-files/parsing/4/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 17, "col": 23, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 17, "col": 24, "resource": "test-files/parsing/4/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 17, "col": 25, "resource": "test-files/parsing/4/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 17, "col": 27, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 18, "col": 7, "resource": "test-files/parsing/4/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 18, "col": 12, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 18, "col": 14, "resource": "test-files/parsing/4/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 18, "col": 16, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 18, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "comma", "line": 18, "col": 21, "resource": "test-files/parsing/4/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 18, "col": 23, "resource": "test-files/parsing/4/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 18, "col": 25, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 18, "col": 26, "resource": "test-files/parsing/4/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "dot", "line": 18, "col": 30, "resource": "test-files/parsing/4/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 18, "col": 31, "resource": "test-files/parsing/4/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 18, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 19, "col": 7, "resource": "test-files/parsing/4/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 19, "col": 13, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 19, "col": 15, "resource": "test-files/parsing/4/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 19, "col": 19, "resource": "test-files/parsing/4/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 19, "col": 20, "resource": "test-files/parsing/4/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 19, "col": 30, "resource": "test-files/parsing/4/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 19, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 19, "col": 35, "resource": "test-files/parsing/4/source.wdl", "source_string": "ZXBzaWxvbg=="}, + {"terminal": "semi", "line": 19, "col": 42, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 20, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 21, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 23, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 23, "col": 8, "resource": "test-files/parsing/4/source.wdl", "source_string": "Z2VuZXJhdGVfcmVwb3J0"}, + {"terminal": "lsquare", "line": 23, "col": 23, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 23, "col": 24, "resource": "test-files/parsing/4/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 23, "col": 31, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 23, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 23, "col": 33, "resource": "test-files/parsing/4/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 23, "col": 35, "resource": "test-files/parsing/4/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 24, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 24, "col": 10, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 24, "col": 12, "resource": "test-files/parsing/4/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 24, "col": 14, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 24, "col": 15, "resource": "test-files/parsing/4/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "comma", "line": 24, "col": 20, "resource": "test-files/parsing/4/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 24, "col": 22, "resource": "test-files/parsing/4/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 24, "col": 24, "resource": "test-files/parsing/4/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 24, "col": 25, "resource": "test-files/parsing/4/source.wdl", "source_string": "ZXBzaWxvbg=="}, + {"terminal": "semi", "line": 24, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 25, "col": 5, "resource": "test-files/parsing/4/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 25, "col": 11, "resource": "test-files/parsing/4/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 25, "col": 13, "resource": "test-files/parsing/4/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 25, "col": 17, "resource": "test-files/parsing/4/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 25, "col": 18, "resource": "test-files/parsing/4/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 25, "col": 30, "resource": "test-files/parsing/4/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 25, "col": 32, "resource": "test-files/parsing/4/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 25, "col": 35, "resource": "test-files/parsing/4/source.wdl", "source_string": "cmVwb3J0"}, + {"terminal": "semi", "line": 25, "col": 41, "resource": "test-files/parsing/4/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 26, "col": 3, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 28, "col": 1, "resource": "test-files/parsing/4/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/5/ast b/test-files/parsing/5/ast new file mode 100644 index 0000000..ee1f50e --- /dev/null +++ b/test-files/parsing/5/ast @@ -0,0 +1,211 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/5/formatted b/test-files/parsing/5/formatted new file mode 100644 index 0000000..419c800 --- /dev/null +++ b/test-files/parsing/5/formatted @@ -0,0 +1,24 @@ +composite_task foo { + step short_task[version=0] { + output: File("foo.txt") as alpha; + } + step long_task[version=0] { + output: File("bar.txt") as beta; + } + for ( item in items ) { + step atask[version=0] { + input: p0=alpha, p1=item.x; + output: File("baz.txt") as gamma; + } + } + for ( item in items ) { + step btask[version=0] { + input: p0=beta, p2=item.y; + output: File("quux.txt") as epsilon; + } + } + step generate_report[version=0] { + input: p0=gamma, p1=epsilon; + output: File("report.txt") as report; + } +} diff --git a/test-files/parsing/5/graph b/test-files/parsing/5/graph new file mode 100644 index 0000000..738a48e --- /dev/null +++ b/test-files/parsing/5/graph @@ -0,0 +1,89 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +[Step: name=atask] +[Step: name=btask] +[Step: name=generate_report] +[Step: name=long_task] +[Step: name=short_task] +[Variable: name=alpha] +[Variable: name=beta] +[Variable: name=epsilon] +[Variable: name=gamma] +[Variable: name=item, member=x] +[Variable: name=item, member=y] +[Variable: name=item] +[Variable: name=items] +[Variable: name=report] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Step: name=generate_report] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Step: name=generate_report] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Variable: name=item] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=gamma] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=epsilon] +] +[Edge + from: [Step: name=generate_report] + to: [Variable: name=report] +] +[Edge + from: [Step: name=long_task] + to: [Variable: name=beta] +] +[Edge + from: [Step: name=short_task] + to: [Variable: name=alpha] +] +[Edge + from: [Variable: name=alpha] + to: [Step: name=atask] +] +[Edge + from: [Variable: name=beta] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=epsilon] + to: [Step: name=generate_report] +] +[Edge + from: [Variable: name=gamma] + to: [Step: name=generate_report] +] +[Edge + from: [Variable: name=item, member=x] + to: [Step: name=atask] +] +[Edge + from: [Variable: name=item, member=y] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=items] + to: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +] +[Edge + from: [Variable: name=items] + to: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +] diff --git a/test-files/parsing/5/parsetree b/test-files/parsing/5/parsetree new file mode 100644 index 0000000..ee82871 --- /dev/null +++ b/test-files/parsing/5/parsetree @@ -0,0 +1,432 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/5/source.wdl b/test-files/parsing/5/source.wdl new file mode 100644 index 0000000..f4d1d88 --- /dev/null +++ b/test-files/parsing/5/source.wdl @@ -0,0 +1,30 @@ +composite_task foo { + + step short_task[version=0] { + output: File("foo.txt") as alpha; + } + + step long_task[version=0] { + output: File("bar.txt") as beta; + } + + for ( item in items ) { + step atask[version=0] { + input: p0=alpha, p1=item.x; + output: File("baz.txt") as gamma; + } + } + + for ( item in items ) { + step btask[version=0] { + input: p0=beta, p2=item.y; + output: File("quux.txt") as epsilon; + } + } + + step generate_report[version=0] { + input: p0=gamma, p1=epsilon; + output: File("report.txt") as report; + } + +} diff --git a/test-files/parsing/5/tokens b/test-files/parsing/5/tokens new file mode 100644 index 0000000..5157abd --- /dev/null +++ b/test-files/parsing/5/tokens @@ -0,0 +1,146 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/5/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/5/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 3, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 8, "resource": "test-files/parsing/5/source.wdl", "source_string": "c2hvcnRfdGFzaw=="}, + {"terminal": "lsquare", "line": 3, "col": 18, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 19, "resource": "test-files/parsing/5/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 26, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 3, "col": 28, "resource": "test-files/parsing/5/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 30, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 4, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 4, "col": 11, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 4, "col": 13, "resource": "test-files/parsing/5/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 4, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 4, "col": 18, "resource": "test-files/parsing/5/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 4, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 4, "col": 29, "resource": "test-files/parsing/5/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 4, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 4, "col": 37, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 5, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 7, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 7, "col": 8, "resource": "test-files/parsing/5/source.wdl", "source_string": "bG9uZ190YXNr"}, + {"terminal": "lsquare", "line": 7, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 7, "col": 18, "resource": "test-files/parsing/5/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 7, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 7, "col": 26, "resource": "test-files/parsing/5/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 7, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 7, "col": 29, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 8, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 8, "col": 11, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 8, "col": 13, "resource": "test-files/parsing/5/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 8, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 8, "col": 18, "resource": "test-files/parsing/5/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 8, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 8, "col": 29, "resource": "test-files/parsing/5/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 8, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "semi", "line": 8, "col": 36, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 9, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 11, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 11, "col": 7, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 11, "col": 9, "resource": "test-files/parsing/5/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 11, "col": 14, "resource": "test-files/parsing/5/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 11, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "aXRlbXM="}, + {"terminal": "rparen", "line": 11, "col": 23, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 11, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 12, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 12, "col": 10, "resource": "test-files/parsing/5/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 12, "col": 15, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 12, "col": 16, "resource": "test-files/parsing/5/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 12, "col": 23, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 12, "col": 24, "resource": "test-files/parsing/5/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 12, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 12, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 13, "col": 7, "resource": "test-files/parsing/5/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 13, "col": 12, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 13, "col": 14, "resource": "test-files/parsing/5/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 13, "col": 16, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 13, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "comma", "line": 13, "col": 22, "resource": "test-files/parsing/5/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 13, "col": 24, "resource": "test-files/parsing/5/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 13, "col": 26, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 13, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "dot", "line": 13, "col": 31, "resource": "test-files/parsing/5/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 13, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "eA=="}, + {"terminal": "semi", "line": 13, "col": 33, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 14, "col": 7, "resource": "test-files/parsing/5/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 14, "col": 13, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 14, "col": 15, "resource": "test-files/parsing/5/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 14, "col": 19, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 14, "col": 20, "resource": "test-files/parsing/5/source.wdl", "source_string": "ImJhei50eHQi"}, + {"terminal": "rparen", "line": 14, "col": 29, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 14, "col": 31, "resource": "test-files/parsing/5/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 14, "col": 34, "resource": "test-files/parsing/5/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "semi", "line": 14, "col": 39, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 15, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 16, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 18, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 18, "col": 7, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 18, "col": 9, "resource": "test-files/parsing/5/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 18, "col": 14, "resource": "test-files/parsing/5/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 18, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "aXRlbXM="}, + {"terminal": "rparen", "line": 18, "col": 23, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 18, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 19, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 19, "col": 10, "resource": "test-files/parsing/5/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 19, "col": 15, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 19, "col": 16, "resource": "test-files/parsing/5/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 19, "col": 23, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 19, "col": 24, "resource": "test-files/parsing/5/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 19, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 19, "col": 27, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 20, "col": 7, "resource": "test-files/parsing/5/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 20, "col": 12, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 20, "col": 14, "resource": "test-files/parsing/5/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 20, "col": 16, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "comma", "line": 20, "col": 21, "resource": "test-files/parsing/5/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 20, "col": 23, "resource": "test-files/parsing/5/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 20, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 20, "col": 26, "resource": "test-files/parsing/5/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "dot", "line": 20, "col": 30, "resource": "test-files/parsing/5/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 20, "col": 31, "resource": "test-files/parsing/5/source.wdl", "source_string": "eQ=="}, + {"terminal": "semi", "line": 20, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 21, "col": 7, "resource": "test-files/parsing/5/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 21, "col": 13, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 21, "col": 15, "resource": "test-files/parsing/5/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 21, "col": 19, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 21, "col": 20, "resource": "test-files/parsing/5/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 21, "col": 30, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 21, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 21, "col": 35, "resource": "test-files/parsing/5/source.wdl", "source_string": "ZXBzaWxvbg=="}, + {"terminal": "semi", "line": 21, "col": 42, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 22, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 23, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 25, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 25, "col": 8, "resource": "test-files/parsing/5/source.wdl", "source_string": "Z2VuZXJhdGVfcmVwb3J0"}, + {"terminal": "lsquare", "line": 25, "col": 23, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 25, "col": 24, "resource": "test-files/parsing/5/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 25, "col": 31, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 25, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 25, "col": 33, "resource": "test-files/parsing/5/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 25, "col": 35, "resource": "test-files/parsing/5/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 26, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 26, "col": 10, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 26, "col": 12, "resource": "test-files/parsing/5/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 26, "col": 14, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 26, "col": 15, "resource": "test-files/parsing/5/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "comma", "line": 26, "col": 20, "resource": "test-files/parsing/5/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 26, "col": 22, "resource": "test-files/parsing/5/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 26, "col": 24, "resource": "test-files/parsing/5/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 26, "col": 25, "resource": "test-files/parsing/5/source.wdl", "source_string": "ZXBzaWxvbg=="}, + {"terminal": "semi", "line": 26, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 27, "col": 5, "resource": "test-files/parsing/5/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 27, "col": 11, "resource": "test-files/parsing/5/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 27, "col": 13, "resource": "test-files/parsing/5/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 27, "col": 17, "resource": "test-files/parsing/5/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 27, "col": 18, "resource": "test-files/parsing/5/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 27, "col": 30, "resource": "test-files/parsing/5/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 27, "col": 32, "resource": "test-files/parsing/5/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 27, "col": 35, "resource": "test-files/parsing/5/source.wdl", "source_string": "cmVwb3J0"}, + {"terminal": "semi", "line": 27, "col": 41, "resource": "test-files/parsing/5/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 28, "col": 3, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 30, "col": 1, "resource": "test-files/parsing/5/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/6/ast b/test-files/parsing/6/ast new file mode 100644 index 0000000..5207f57 --- /dev/null +++ b/test-files/parsing/6/ast @@ -0,0 +1,237 @@ +(CompositeTask: + name=identifier, + body=[ + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/6/formatted b/test-files/parsing/6/formatted new file mode 100644 index 0000000..3d4f700 --- /dev/null +++ b/test-files/parsing/6/formatted @@ -0,0 +1,28 @@ +composite_task foo { + for ( item in items ) { + step atask[version=0] { + input: p0=alpha, p1=item; + output: File("baz.txt") as gamma; + } + } + step short_task[version=0] { + output: File("foo.txt") as alpha; + } + step long_task[version=0] { + output: File("bar.txt") as beta; + } + step batman[version=0] { + } + step robin[version=0] { + } + step generate_report[version=0] { + input: p0=gamma, p1=epsilon; + output: File("report.txt") as report; + } + for ( item in items ) { + step btask[version=0] { + input: p0=beta, p1=item; + output: File("quux.txt") as epsilon; + } + } +} diff --git a/test-files/parsing/6/graph b/test-files/parsing/6/graph new file mode 100644 index 0000000..f95f44f --- /dev/null +++ b/test-files/parsing/6/graph @@ -0,0 +1,89 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +[Step: name=atask] +[Step: name=batman] +[Step: name=btask] +[Step: name=generate_report] +[Step: name=long_task] +[Step: name=robin] +[Step: name=short_task] +[Variable: name=alpha] +[Variable: name=beta] +[Variable: name=epsilon] +[Variable: name=gamma] +[Variable: name=item] +[Variable: name=items] +[Variable: name=report] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Step: name=generate_report] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Step: name=generate_report] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Variable: name=item] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] + to: [Variable: name=item] +] +[Edge + from: [Step: name=atask] + to: [Variable: name=gamma] +] +[Edge + from: [Step: name=btask] + to: [Variable: name=epsilon] +] +[Edge + from: [Step: name=generate_report] + to: [Variable: name=report] +] +[Edge + from: [Step: name=long_task] + to: [Variable: name=beta] +] +[Edge + from: [Step: name=short_task] + to: [Variable: name=alpha] +] +[Edge + from: [Variable: name=alpha] + to: [Step: name=atask] +] +[Edge + from: [Variable: name=beta] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=epsilon] + to: [Step: name=generate_report] +] +[Edge + from: [Variable: name=gamma] + to: [Step: name=generate_report] +] +[Edge + from: [Variable: name=item] + to: [Step: name=atask] +] +[Edge + from: [Variable: name=item] + to: [Step: name=btask] +] +[Edge + from: [Variable: name=items] + to: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +] +[Edge + from: [Variable: name=items] + to: [CompositeTaskForScope: collection=[Variable: name=items], var=[Variable: name=item], # nodes=1] +] diff --git a/test-files/parsing/6/parsetree b/test-files/parsing/6/parsetree new file mode 100644 index 0000000..5a803a8 --- /dev/null +++ b/test-files/parsing/6/parsetree @@ -0,0 +1,482 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ) + ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/6/source.wdl b/test-files/parsing/6/source.wdl new file mode 100644 index 0000000..443de10 --- /dev/null +++ b/test-files/parsing/6/source.wdl @@ -0,0 +1,33 @@ +composite_task foo { + + for ( item in items ) { + step atask[version=0] { + input: p0=alpha, p1=item; + output: File("baz.txt") as gamma; + } + } + + step short_task[version=0] { + output: File("foo.txt") as alpha; + } + + step long_task[version=0] { + output: File("bar.txt") as beta; + } + + step batman[version=0] {} + step robin[version=0] {} + + step generate_report[version=0] { + input: p0=gamma, p1=epsilon; + output: File("report.txt") as report; + } + + for ( item in items ) { + step btask[version=0] { + input: p0=beta, p1=item; + output: File("quux.txt") as epsilon; + } + } + +} diff --git a/test-files/parsing/6/tokens b/test-files/parsing/6/tokens new file mode 100644 index 0000000..836842a --- /dev/null +++ b/test-files/parsing/6/tokens @@ -0,0 +1,160 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/6/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/6/source.wdl", "source_string": "Zm9v"}, + {"terminal": "lbrace", "line": 1, "col": 20, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "for", "line": 3, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 3, "col": 7, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 3, "col": 9, "resource": "test-files/parsing/6/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 3, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 3, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "aXRlbXM="}, + {"terminal": "rparen", "line": 3, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 3, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 4, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 4, "col": 10, "resource": "test-files/parsing/6/source.wdl", "source_string": "YXRhc2s="}, + {"terminal": "lsquare", "line": 4, "col": 15, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 4, "col": 16, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 4, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 4, "col": 24, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 4, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 4, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 5, "col": 7, "resource": "test-files/parsing/6/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 5, "col": 12, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 5, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 5, "col": 16, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 5, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "comma", "line": 5, "col": 22, "resource": "test-files/parsing/6/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 5, "col": 24, "resource": "test-files/parsing/6/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 5, "col": 26, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 5, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "semi", "line": 5, "col": 31, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 6, "col": 7, "resource": "test-files/parsing/6/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 6, "col": 13, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 6, "col": 15, "resource": "test-files/parsing/6/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 6, "col": 19, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 6, "col": 20, "resource": "test-files/parsing/6/source.wdl", "source_string": "ImJhei50eHQi"}, + {"terminal": "rparen", "line": 6, "col": 29, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 6, "col": 31, "resource": "test-files/parsing/6/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 6, "col": 34, "resource": "test-files/parsing/6/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "semi", "line": 6, "col": 39, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 7, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 8, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 10, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 10, "col": 8, "resource": "test-files/parsing/6/source.wdl", "source_string": "c2hvcnRfdGFzaw=="}, + {"terminal": "lsquare", "line": 10, "col": 18, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 10, "col": 19, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 10, "col": 26, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 10, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 10, "col": 28, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 10, "col": 30, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 11, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 11, "col": 11, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 11, "col": 13, "resource": "test-files/parsing/6/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 11, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 11, "col": 18, "resource": "test-files/parsing/6/source.wdl", "source_string": "ImZvby50eHQi"}, + {"terminal": "rparen", "line": 11, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 11, "col": 29, "resource": "test-files/parsing/6/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 11, "col": 32, "resource": "test-files/parsing/6/source.wdl", "source_string": "YWxwaGE="}, + {"terminal": "semi", "line": 11, "col": 37, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 12, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 14, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 14, "col": 8, "resource": "test-files/parsing/6/source.wdl", "source_string": "bG9uZ190YXNr"}, + {"terminal": "lsquare", "line": 14, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 14, "col": 18, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 14, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 14, "col": 26, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 14, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 14, "col": 29, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 15, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 15, "col": 11, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 15, "col": 13, "resource": "test-files/parsing/6/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 15, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 15, "col": 18, "resource": "test-files/parsing/6/source.wdl", "source_string": "ImJhci50eHQi"}, + {"terminal": "rparen", "line": 15, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 15, "col": 29, "resource": "test-files/parsing/6/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 15, "col": 32, "resource": "test-files/parsing/6/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "semi", "line": 15, "col": 36, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 16, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 18, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 18, "col": 8, "resource": "test-files/parsing/6/source.wdl", "source_string": "YmF0bWFu"}, + {"terminal": "lsquare", "line": 18, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 18, "col": 15, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 18, "col": 22, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 18, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 18, "col": 24, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 18, "col": 26, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 18, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 19, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 19, "col": 8, "resource": "test-files/parsing/6/source.wdl", "source_string": "cm9iaW4="}, + {"terminal": "lsquare", "line": 19, "col": 13, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 19, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 19, "col": 21, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 19, "col": 22, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 19, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 19, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 19, "col": 26, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 21, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 21, "col": 8, "resource": "test-files/parsing/6/source.wdl", "source_string": "Z2VuZXJhdGVfcmVwb3J0"}, + {"terminal": "lsquare", "line": 21, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 21, "col": 24, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 21, "col": 31, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 21, "col": 32, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 21, "col": 33, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 21, "col": 35, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 22, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 22, "col": 10, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 22, "col": 12, "resource": "test-files/parsing/6/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 22, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 22, "col": 15, "resource": "test-files/parsing/6/source.wdl", "source_string": "Z2FtbWE="}, + {"terminal": "comma", "line": 22, "col": 20, "resource": "test-files/parsing/6/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 22, "col": 22, "resource": "test-files/parsing/6/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 22, "col": 24, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 22, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "ZXBzaWxvbg=="}, + {"terminal": "semi", "line": 22, "col": 32, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 23, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 23, "col": 11, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 23, "col": 13, "resource": "test-files/parsing/6/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 23, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 23, "col": 18, "resource": "test-files/parsing/6/source.wdl", "source_string": "InJlcG9ydC50eHQi"}, + {"terminal": "rparen", "line": 23, "col": 30, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 23, "col": 32, "resource": "test-files/parsing/6/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 23, "col": 35, "resource": "test-files/parsing/6/source.wdl", "source_string": "cmVwb3J0"}, + {"terminal": "semi", "line": 23, "col": 41, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 24, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 26, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 26, "col": 7, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 26, "col": 9, "resource": "test-files/parsing/6/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 26, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 26, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "aXRlbXM="}, + {"terminal": "rparen", "line": 26, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 26, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 27, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 27, "col": 10, "resource": "test-files/parsing/6/source.wdl", "source_string": "YnRhc2s="}, + {"terminal": "lsquare", "line": 27, "col": 15, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 27, "col": 16, "resource": "test-files/parsing/6/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 27, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 27, "col": 24, "resource": "test-files/parsing/6/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 27, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 27, "col": 27, "resource": "test-files/parsing/6/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 28, "col": 7, "resource": "test-files/parsing/6/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 28, "col": 12, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 28, "col": 14, "resource": "test-files/parsing/6/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 28, "col": 16, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 28, "col": 17, "resource": "test-files/parsing/6/source.wdl", "source_string": "YmV0YQ=="}, + {"terminal": "comma", "line": 28, "col": 21, "resource": "test-files/parsing/6/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 28, "col": 23, "resource": "test-files/parsing/6/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 28, "col": 25, "resource": "test-files/parsing/6/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 28, "col": 26, "resource": "test-files/parsing/6/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "semi", "line": 28, "col": 30, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 29, "col": 7, "resource": "test-files/parsing/6/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 29, "col": 13, "resource": "test-files/parsing/6/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 29, "col": 15, "resource": "test-files/parsing/6/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 29, "col": 19, "resource": "test-files/parsing/6/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 29, "col": 20, "resource": "test-files/parsing/6/source.wdl", "source_string": "InF1dXgudHh0Ig=="}, + {"terminal": "rparen", "line": 29, "col": 30, "resource": "test-files/parsing/6/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 29, "col": 32, "resource": "test-files/parsing/6/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 29, "col": 35, "resource": "test-files/parsing/6/source.wdl", "source_string": "ZXBzaWxvbg=="}, + {"terminal": "semi", "line": 29, "col": 42, "resource": "test-files/parsing/6/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 30, "col": 5, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 31, "col": 3, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 33, "col": 1, "resource": "test-files/parsing/6/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/7/ast b/test-files/parsing/7/ast new file mode 100644 index 0000000..2d2f32d --- /dev/null +++ b/test-files/parsing/7/ast @@ -0,0 +1,89 @@ +(CompositeTask: + name=identifier, + body=[ + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=identifier + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/7/formatted b/test-files/parsing/7/formatted new file mode 100644 index 0000000..0992189 --- /dev/null +++ b/test-files/parsing/7/formatted @@ -0,0 +1,11 @@ +composite_task test { + for ( item in collection ) { + step task[version=0] { + input: p0=x, p1=y, p2=item.z; + output: File("xyz") as list; + } + } + step task1[version=0] { + input: p0=list; + } +} diff --git a/test-files/parsing/7/graph b/test-files/parsing/7/graph new file mode 100644 index 0000000..1e8a0a4 --- /dev/null +++ b/test-files/parsing/7/graph @@ -0,0 +1,46 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=collection], var=[Variable: name=item], # nodes=1] +[Step: name=task1] +[Step: name=task] +[Variable: name=collection] +[Variable: name=item, member=z] +[Variable: name=item] +[Variable: name=list] +[Variable: name=x] +[Variable: name=y] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=collection], var=[Variable: name=item], # nodes=1] + to: [Step: name=task1] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=collection], var=[Variable: name=item], # nodes=1] + to: [Variable: name=item] +] +[Edge + from: [Step: name=task] + to: [Variable: name=list] +] +[Edge + from: [Variable: name=collection] + to: [CompositeTaskForScope: collection=[Variable: name=collection], var=[Variable: name=item], # nodes=1] +] +[Edge + from: [Variable: name=item, member=z] + to: [Step: name=task] +] +[Edge + from: [Variable: name=list] + to: [Step: name=task1] +] +[Edge + from: [Variable: name=x] + to: [Step: name=task] +] +[Edge + from: [Variable: name=y] + to: [Step: name=task] +] diff --git a/test-files/parsing/7/parsetree b/test-files/parsing/7/parsetree new file mode 100644 index 0000000..7e33866 --- /dev/null +++ b/test-files/parsing/7/parsetree @@ -0,0 +1,183 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: + (variable_member: + dot, + identifier + ) + ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/7/source.wdl b/test-files/parsing/7/source.wdl new file mode 100644 index 0000000..c4371f6 --- /dev/null +++ b/test-files/parsing/7/source.wdl @@ -0,0 +1,12 @@ +composite_task test { + for (item in collection) { + step task[version=0] { + input: p0=x, p1=y, p2=item.z; + output: File("xyz") as list; + } + } + + step task1[version=0] { + input: p0=list; + } +} diff --git a/test-files/parsing/7/tokens b/test-files/parsing/7/tokens new file mode 100644 index 0000000..b200998 --- /dev/null +++ b/test-files/parsing/7/tokens @@ -0,0 +1,63 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/7/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/7/source.wdl", "source_string": "dGVzdA=="}, + {"terminal": "lbrace", "line": 1, "col": 21, "resource": "test-files/parsing/7/source.wdl", "source_string": "ew=="}, + {"terminal": "for", "line": 2, "col": 3, "resource": "test-files/parsing/7/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 2, "col": 7, "resource": "test-files/parsing/7/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/7/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "in", "line": 2, "col": 13, "resource": "test-files/parsing/7/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 2, "col": 16, "resource": "test-files/parsing/7/source.wdl", "source_string": "Y29sbGVjdGlvbg=="}, + {"terminal": "rparen", "line": 2, "col": 26, "resource": "test-files/parsing/7/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 2, "col": 28, "resource": "test-files/parsing/7/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 3, "col": 5, "resource": "test-files/parsing/7/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 3, "col": 10, "resource": "test-files/parsing/7/source.wdl", "source_string": "dGFzaw=="}, + {"terminal": "lsquare", "line": 3, "col": 14, "resource": "test-files/parsing/7/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 3, "col": 15, "resource": "test-files/parsing/7/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 3, "col": 22, "resource": "test-files/parsing/7/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 3, "col": 23, "resource": "test-files/parsing/7/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 3, "col": 24, "resource": "test-files/parsing/7/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 3, "col": 26, "resource": "test-files/parsing/7/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 4, "col": 7, "resource": "test-files/parsing/7/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 4, "col": 12, "resource": "test-files/parsing/7/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 4, "col": 14, "resource": "test-files/parsing/7/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 4, "col": 16, "resource": "test-files/parsing/7/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 4, "col": 17, "resource": "test-files/parsing/7/source.wdl", "source_string": "eA=="}, + {"terminal": "comma", "line": 4, "col": 18, "resource": "test-files/parsing/7/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 4, "col": 20, "resource": "test-files/parsing/7/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 4, "col": 22, "resource": "test-files/parsing/7/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 4, "col": 23, "resource": "test-files/parsing/7/source.wdl", "source_string": "eQ=="}, + {"terminal": "comma", "line": 4, "col": 24, "resource": "test-files/parsing/7/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 4, "col": 26, "resource": "test-files/parsing/7/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 4, "col": 28, "resource": "test-files/parsing/7/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 4, "col": 29, "resource": "test-files/parsing/7/source.wdl", "source_string": "aXRlbQ=="}, + {"terminal": "dot", "line": 4, "col": 33, "resource": "test-files/parsing/7/source.wdl", "source_string": "Lg=="}, + {"terminal": "identifier", "line": 4, "col": 34, "resource": "test-files/parsing/7/source.wdl", "source_string": "eg=="}, + {"terminal": "semi", "line": 4, "col": 35, "resource": "test-files/parsing/7/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 5, "col": 7, "resource": "test-files/parsing/7/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 5, "col": 13, "resource": "test-files/parsing/7/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 5, "col": 15, "resource": "test-files/parsing/7/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 5, "col": 19, "resource": "test-files/parsing/7/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 5, "col": 20, "resource": "test-files/parsing/7/source.wdl", "source_string": "Inh5eiI="}, + {"terminal": "rparen", "line": 5, "col": 25, "resource": "test-files/parsing/7/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 5, "col": 27, "resource": "test-files/parsing/7/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 5, "col": 30, "resource": "test-files/parsing/7/source.wdl", "source_string": "bGlzdA=="}, + {"terminal": "semi", "line": 5, "col": 34, "resource": "test-files/parsing/7/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 6, "col": 5, "resource": "test-files/parsing/7/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 7, "col": 3, "resource": "test-files/parsing/7/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 9, "col": 3, "resource": "test-files/parsing/7/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 9, "col": 8, "resource": "test-files/parsing/7/source.wdl", "source_string": "dGFzazE="}, + {"terminal": "lsquare", "line": 9, "col": 13, "resource": "test-files/parsing/7/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 9, "col": 14, "resource": "test-files/parsing/7/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 9, "col": 21, "resource": "test-files/parsing/7/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 9, "col": 22, "resource": "test-files/parsing/7/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 9, "col": 23, "resource": "test-files/parsing/7/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 9, "col": 25, "resource": "test-files/parsing/7/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 10, "col": 5, "resource": "test-files/parsing/7/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 10, "col": 10, "resource": "test-files/parsing/7/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 10, "col": 12, "resource": "test-files/parsing/7/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 10, "col": 14, "resource": "test-files/parsing/7/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 10, "col": 15, "resource": "test-files/parsing/7/source.wdl", "source_string": "bGlzdA=="}, + {"terminal": "semi", "line": 10, "col": 19, "resource": "test-files/parsing/7/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 11, "col": 3, "resource": "test-files/parsing/7/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 12, "col": 1, "resource": "test-files/parsing/7/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/8/ast b/test-files/parsing/8/ast new file mode 100644 index 0000000..bab60a6 --- /dev/null +++ b/test-files/parsing/8/ast @@ -0,0 +1,123 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ), + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (ForLoop: + collection=identifier, + item=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ), + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ), + (StepOutputList: + outputs=[ + (StepOutput: + mode=file, + expression=string, + var=(OutputVariable: + var=(Variable: + name=identifier, + member=None + ) + ) + ) + ] + ) + ] + ) + ] + ) + ] + ), + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[ + (StepInputList: + inputs=[ + (StepInput: + parameter=identifier, + value=(Variable: + name=identifier, + member=None + ) + ) + ] + ) + ] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/8/formatted b/test-files/parsing/8/formatted new file mode 100644 index 0000000..de7a4ce --- /dev/null +++ b/test-files/parsing/8/formatted @@ -0,0 +1,16 @@ +composite_task test { + step s0[version=0] { + output: File("abc") as foo; + } + for ( I in L ) { + for ( J in M ) { + step s1[version=0] { + input: p0=I, p1=J, p2=foo; + output: File("def") as bar; + } + } + } + step s2[version=0] { + input: p0=bar; + } +} diff --git a/test-files/parsing/8/graph b/test-files/parsing/8/graph new file mode 100644 index 0000000..50cd25b --- /dev/null +++ b/test-files/parsing/8/graph @@ -0,0 +1,60 @@ +VERTICIES +--------- +[CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] +[CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1] +[Step: name=s0] +[Step: name=s1] +[Step: name=s2] +[Variable: name=I] +[Variable: name=J] +[Variable: name=L] +[Variable: name=M] +[Variable: name=bar] +[Variable: name=foo] + +EDGES +----- +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] + to: [Step: name=s2] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] + to: [Variable: name=I] +] +[Edge + from: [CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1] + to: [Variable: name=J] +] +[Edge + from: [Step: name=s0] + to: [Variable: name=foo] +] +[Edge + from: [Step: name=s1] + to: [Variable: name=bar] +] +[Edge + from: [Variable: name=I] + to: [Step: name=s1] +] +[Edge + from: [Variable: name=J] + to: [Step: name=s1] +] +[Edge + from: [Variable: name=L] + to: [CompositeTaskForScope: collection=[Variable: name=L], var=[Variable: name=I], # nodes=1] +] +[Edge + from: [Variable: name=M] + to: [CompositeTaskForScope: collection=[Variable: name=M], var=[Variable: name=J], # nodes=1] +] +[Edge + from: [Variable: name=bar] + to: [Step: name=s2] +] +[Edge + from: [Variable: name=foo] + to: [Step: name=s1] +] diff --git a/test-files/parsing/8/parsetree b/test-files/parsing/8/parsetree new file mode 100644 index 0000000..ad42ec3 --- /dev/null +++ b/test-files/parsing/8/parsetree @@ -0,0 +1,250 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (for_loop: + for, + lparen, + identifier, + in, + identifier, + rparen, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: + comma, + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ) + ) + ), + semi + ) + ), + (_gen3: + (step_attr: + (step_output_list: + output, + colon, + (_gen8: + (step_output: + (step_output_mode: + file + ), + lparen, + string, + rparen, + (step_output_location: + as, + (variable: + identifier, + (_gen10: ) + ) + ) + ), + (_gen9: ) + ), + semi + ) + ), + (_gen3: ) + ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: + (step_attr: + (step_input_list: + input, + colon, + (_gen6: + (step_input: + identifier, + assign, + (variable: + identifier, + (_gen10: ) + ) + ), + (_gen7: ) + ), + semi + ) + ), + (_gen3: ) + ), + rbrace + ) + ), + (_gen1: ) + ) + ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/8/source.wdl b/test-files/parsing/8/source.wdl new file mode 100644 index 0000000..9cfe189 --- /dev/null +++ b/test-files/parsing/8/source.wdl @@ -0,0 +1,18 @@ +composite_task test { + step s0[version=0] { + output: File("abc") as foo; + } + + for (I in L) { + for (J in M) { + step s1[version=0] { + input: p0=I, p1=J, p2=foo; + output: File("def") as bar; + } + } + } + + step s2[version=0] { + input: p0=bar; + } +} diff --git a/test-files/parsing/8/tokens b/test-files/parsing/8/tokens new file mode 100644 index 0000000..2608312 --- /dev/null +++ b/test-files/parsing/8/tokens @@ -0,0 +1,87 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/8/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/8/source.wdl", "source_string": "dGVzdA=="}, + {"terminal": "lbrace", "line": 1, "col": 21, "resource": "test-files/parsing/8/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 2, "col": 3, "resource": "test-files/parsing/8/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 2, "col": 8, "resource": "test-files/parsing/8/source.wdl", "source_string": "czA="}, + {"terminal": "lsquare", "line": 2, "col": 10, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 2, "col": 11, "resource": "test-files/parsing/8/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 2, "col": 18, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 2, "col": 19, "resource": "test-files/parsing/8/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 2, "col": 20, "resource": "test-files/parsing/8/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 2, "col": 22, "resource": "test-files/parsing/8/source.wdl", "source_string": "ew=="}, + {"terminal": "output", "line": 3, "col": 5, "resource": "test-files/parsing/8/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 3, "col": 11, "resource": "test-files/parsing/8/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 3, "col": 13, "resource": "test-files/parsing/8/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 3, "col": 17, "resource": "test-files/parsing/8/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 3, "col": 18, "resource": "test-files/parsing/8/source.wdl", "source_string": "ImFiYyI="}, + {"terminal": "rparen", "line": 3, "col": 23, "resource": "test-files/parsing/8/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 3, "col": 25, "resource": "test-files/parsing/8/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 3, "col": 28, "resource": "test-files/parsing/8/source.wdl", "source_string": "Zm9v"}, + {"terminal": "semi", "line": 3, "col": 31, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 4, "col": 3, "resource": "test-files/parsing/8/source.wdl", "source_string": "fQ=="}, + {"terminal": "for", "line": 6, "col": 3, "resource": "test-files/parsing/8/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 6, "col": 7, "resource": "test-files/parsing/8/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 6, "col": 8, "resource": "test-files/parsing/8/source.wdl", "source_string": "SQ=="}, + {"terminal": "in", "line": 6, "col": 10, "resource": "test-files/parsing/8/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 6, "col": 13, "resource": "test-files/parsing/8/source.wdl", "source_string": "TA=="}, + {"terminal": "rparen", "line": 6, "col": 14, "resource": "test-files/parsing/8/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 6, "col": 16, "resource": "test-files/parsing/8/source.wdl", "source_string": "ew=="}, + {"terminal": "for", "line": 7, "col": 5, "resource": "test-files/parsing/8/source.wdl", "source_string": "Zm9y"}, + {"terminal": "lparen", "line": 7, "col": 9, "resource": "test-files/parsing/8/source.wdl", "source_string": "KA=="}, + {"terminal": "identifier", "line": 7, "col": 10, "resource": "test-files/parsing/8/source.wdl", "source_string": "Sg=="}, + {"terminal": "in", "line": 7, "col": 12, "resource": "test-files/parsing/8/source.wdl", "source_string": "aW4="}, + {"terminal": "identifier", "line": 7, "col": 15, "resource": "test-files/parsing/8/source.wdl", "source_string": "TQ=="}, + {"terminal": "rparen", "line": 7, "col": 16, "resource": "test-files/parsing/8/source.wdl", "source_string": "KQ=="}, + {"terminal": "lbrace", "line": 7, "col": 18, "resource": "test-files/parsing/8/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 8, "col": 7, "resource": "test-files/parsing/8/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 8, "col": 12, "resource": "test-files/parsing/8/source.wdl", "source_string": "czE="}, + {"terminal": "lsquare", "line": 8, "col": 14, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 8, "col": 15, "resource": "test-files/parsing/8/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 8, "col": 22, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 8, "col": 23, "resource": "test-files/parsing/8/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 8, "col": 24, "resource": "test-files/parsing/8/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 8, "col": 26, "resource": "test-files/parsing/8/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 9, "col": 9, "resource": "test-files/parsing/8/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 9, "col": 14, "resource": "test-files/parsing/8/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 9, "col": 16, "resource": "test-files/parsing/8/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 9, "col": 18, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 19, "resource": "test-files/parsing/8/source.wdl", "source_string": "SQ=="}, + {"terminal": "comma", "line": 9, "col": 20, "resource": "test-files/parsing/8/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 9, "col": 22, "resource": "test-files/parsing/8/source.wdl", "source_string": "cDE="}, + {"terminal": "assign", "line": 9, "col": 24, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 25, "resource": "test-files/parsing/8/source.wdl", "source_string": "Sg=="}, + {"terminal": "comma", "line": 9, "col": 26, "resource": "test-files/parsing/8/source.wdl", "source_string": "LA=="}, + {"terminal": "identifier", "line": 9, "col": 28, "resource": "test-files/parsing/8/source.wdl", "source_string": "cDI="}, + {"terminal": "assign", "line": 9, "col": 30, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 9, "col": 31, "resource": "test-files/parsing/8/source.wdl", "source_string": "Zm9v"}, + {"terminal": "semi", "line": 9, "col": 34, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ow=="}, + {"terminal": "output", "line": 10, "col": 9, "resource": "test-files/parsing/8/source.wdl", "source_string": "b3V0cHV0"}, + {"terminal": "colon", "line": 10, "col": 15, "resource": "test-files/parsing/8/source.wdl", "source_string": "Og=="}, + {"terminal": "file", "line": 10, "col": 17, "resource": "test-files/parsing/8/source.wdl", "source_string": "RmlsZQ=="}, + {"terminal": "lparen", "line": 10, "col": 21, "resource": "test-files/parsing/8/source.wdl", "source_string": "KA=="}, + {"terminal": "string", "line": 10, "col": 22, "resource": "test-files/parsing/8/source.wdl", "source_string": "ImRlZiI="}, + {"terminal": "rparen", "line": 10, "col": 27, "resource": "test-files/parsing/8/source.wdl", "source_string": "KQ=="}, + {"terminal": "as", "line": 10, "col": 29, "resource": "test-files/parsing/8/source.wdl", "source_string": "YXM="}, + {"terminal": "identifier", "line": 10, "col": 32, "resource": "test-files/parsing/8/source.wdl", "source_string": "YmFy"}, + {"terminal": "semi", "line": 10, "col": 35, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 11, "col": 7, "resource": "test-files/parsing/8/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 12, "col": 5, "resource": "test-files/parsing/8/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 13, "col": 3, "resource": "test-files/parsing/8/source.wdl", "source_string": "fQ=="}, + {"terminal": "step", "line": 15, "col": 3, "resource": "test-files/parsing/8/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 15, "col": 8, "resource": "test-files/parsing/8/source.wdl", "source_string": "czI="}, + {"terminal": "lsquare", "line": 15, "col": 10, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 15, "col": 11, "resource": "test-files/parsing/8/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 15, "col": 18, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 15, "col": 19, "resource": "test-files/parsing/8/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 15, "col": 20, "resource": "test-files/parsing/8/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 15, "col": 22, "resource": "test-files/parsing/8/source.wdl", "source_string": "ew=="}, + {"terminal": "input", "line": 16, "col": 5, "resource": "test-files/parsing/8/source.wdl", "source_string": "aW5wdXQ="}, + {"terminal": "colon", "line": 16, "col": 10, "resource": "test-files/parsing/8/source.wdl", "source_string": "Og=="}, + {"terminal": "identifier", "line": 16, "col": 12, "resource": "test-files/parsing/8/source.wdl", "source_string": "cDA="}, + {"terminal": "assign", "line": 16, "col": 14, "resource": "test-files/parsing/8/source.wdl", "source_string": "PQ=="}, + {"terminal": "identifier", "line": 16, "col": 15, "resource": "test-files/parsing/8/source.wdl", "source_string": "YmFy"}, + {"terminal": "semi", "line": 16, "col": 18, "resource": "test-files/parsing/8/source.wdl", "source_string": "Ow=="}, + {"terminal": "rbrace", "line": 17, "col": 3, "resource": "test-files/parsing/8/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 18, "col": 1, "resource": "test-files/parsing/8/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/parsing/9/ast b/test-files/parsing/9/ast new file mode 100644 index 0000000..564d566 --- /dev/null +++ b/test-files/parsing/9/ast @@ -0,0 +1,18 @@ +(CompositeTask: + name=identifier, + body=[ + (Step: + task=(Task: + name=identifier, + attributes=[ + (TaskAttribute: + key=identifier, + value=number + ) + ] + ), + name=None, + body=[] + ) + ] +) \ No newline at end of file diff --git a/test-files/parsing/9/formatted b/test-files/parsing/9/formatted new file mode 100644 index 0000000..5f0138b --- /dev/null +++ b/test-files/parsing/9/formatted @@ -0,0 +1,4 @@ +composite_task x { + step y[version=0] { + } +} diff --git a/test-files/parsing/9/graph b/test-files/parsing/9/graph new file mode 100644 index 0000000..c4e467e --- /dev/null +++ b/test-files/parsing/9/graph @@ -0,0 +1,6 @@ +VERTICIES +--------- +[Step: name=y] + +EDGES +----- diff --git a/test-files/parsing/9/parsetree b/test-files/parsing/9/parsetree new file mode 100644 index 0000000..e6366b8 --- /dev/null +++ b/test-files/parsing/9/parsetree @@ -0,0 +1,44 @@ +(wdl: + (_gen0: + (wdl_entity: + (composite_task: + composite_task, + identifier, + lbrace, + (_gen1: + (composite_task_entity: + (step: + step, + (task_identifier: + identifier, + (_gen4: + (task_attrs: + lsquare, + (_gen5: + (task_attr: + identifier, + assign, + (task_attr_value: + number + ) + ), + (_gen5: ) + ), + rsquare + ) + ) + ), + (_gen2: ), + lbrace, + (_gen3: ), + rbrace + ) + ), + (_gen1: ) + ), + rbrace + ) + ), + (_gen0: ) + ) +) \ No newline at end of file diff --git a/test-files/parsing/9/source.wdl b/test-files/parsing/9/source.wdl new file mode 100644 index 0000000..195e03f --- /dev/null +++ b/test-files/parsing/9/source.wdl @@ -0,0 +1 @@ +composite_task x {step y[version=0] {}} diff --git a/test-files/parsing/9/tokens b/test-files/parsing/9/tokens new file mode 100644 index 0000000..2a0b8d5 --- /dev/null +++ b/test-files/parsing/9/tokens @@ -0,0 +1,15 @@ +[ + {"terminal": "composite_task", "line": 1, "col": 1, "resource": "test-files/parsing/9/source.wdl", "source_string": "Y29tcG9zaXRlX3Rhc2s="}, + {"terminal": "identifier", "line": 1, "col": 16, "resource": "test-files/parsing/9/source.wdl", "source_string": "eA=="}, + {"terminal": "lbrace", "line": 1, "col": 18, "resource": "test-files/parsing/9/source.wdl", "source_string": "ew=="}, + {"terminal": "step", "line": 1, "col": 19, "resource": "test-files/parsing/9/source.wdl", "source_string": "c3RlcA=="}, + {"terminal": "identifier", "line": 1, "col": 24, "resource": "test-files/parsing/9/source.wdl", "source_string": "eQ=="}, + {"terminal": "lsquare", "line": 1, "col": 25, "resource": "test-files/parsing/9/source.wdl", "source_string": "Ww=="}, + {"terminal": "identifier", "line": 1, "col": 26, "resource": "test-files/parsing/9/source.wdl", "source_string": "dmVyc2lvbg=="}, + {"terminal": "assign", "line": 1, "col": 33, "resource": "test-files/parsing/9/source.wdl", "source_string": "PQ=="}, + {"terminal": "number", "line": 1, "col": 34, "resource": "test-files/parsing/9/source.wdl", "source_string": "MA=="}, + {"terminal": "rsquare", "line": 1, "col": 35, "resource": "test-files/parsing/9/source.wdl", "source_string": "XQ=="}, + {"terminal": "lbrace", "line": 1, "col": 37, "resource": "test-files/parsing/9/source.wdl", "source_string": "ew=="}, + {"terminal": "rbrace", "line": 1, "col": 38, "resource": "test-files/parsing/9/source.wdl", "source_string": "fQ=="}, + {"terminal": "rbrace", "line": 1, "col": 39, "resource": "test-files/parsing/9/source.wdl", "source_string": "fQ=="} +] diff --git a/test-files/syntax-error/0/errors b/test-files/syntax-error/0/errors new file mode 100644 index 0000000..9578141 --- /dev/null +++ b/test-files/syntax-error/0/errors @@ -0,0 +1,9 @@ +org.broadinstitute.parser.SyntaxError: Step 'btask' inside for loop doesn't use loop iterator: item +Location: test-files/syntax-error/0/source.wdl @ line 8, column 10: + + step btask[version=0] { + ^ +Loop iterator is declared @ line 7, column 9: + + for ( item in foo ) { + ^ diff --git a/test-files/syntax-error/0/source.wdl b/test-files/syntax-error/0/source.wdl new file mode 100644 index 0000000..6ac7df5 --- /dev/null +++ b/test-files/syntax-error/0/source.wdl @@ -0,0 +1,24 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as x; + } + + for ( item in foo ) { + step btask[version=0] { + input: p0=x, p1=GLOBAL; + output: File("bar.txt") as y; + } + + step ctask[version=0] { + input: p0=x, p1=y; + output: File("quux.txt") as z; + } + } + + step dtask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as r; + } + +} diff --git a/test-files/syntax-error/1/errors b/test-files/syntax-error/1/errors new file mode 100644 index 0000000..cf6a838 --- /dev/null +++ b/test-files/syntax-error/1/errors @@ -0,0 +1,9 @@ +org.broadinstitute.parser.SyntaxError: Two steps output to the same variable: x +Location: test-files/syntax-error/1/source.wdl @ line 9, column 35: + + output: File("report.txt") as x; + ^ +Previous output for variable was @ line 4, column 32: + + output: File("foo.txt") as x; + ^ diff --git a/test-files/syntax-error/1/source.wdl b/test-files/syntax-error/1/source.wdl new file mode 100644 index 0000000..e270d49 --- /dev/null +++ b/test-files/syntax-error/1/source.wdl @@ -0,0 +1,12 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as x; + } + + step btask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("report.txt") as x; + } + +} diff --git a/test-files/syntax-error/2/errors b/test-files/syntax-error/2/errors new file mode 100644 index 0000000..7bece5f --- /dev/null +++ b/test-files/syntax-error/2/errors @@ -0,0 +1,9 @@ +org.broadinstitute.parser.SyntaxError: Two steps output to the same variable: xyz +Location: test-files/syntax-error/2/source.wdl @ line 9, column 32: + + output: File("foo.txt") as xyz; + ^ +Previous output for variable was @ line 4, column 32: + + output: File("foo.txt") as xyz; + ^ diff --git a/test-files/syntax-error/2/source.wdl b/test-files/syntax-error/2/source.wdl new file mode 100644 index 0000000..6c7b688 --- /dev/null +++ b/test-files/syntax-error/2/source.wdl @@ -0,0 +1,12 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as xyz; + } + + step btask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("foo.txt") as xyz; + } + +} diff --git a/test-files/syntax-error/3/errors b/test-files/syntax-error/3/errors new file mode 100644 index 0000000..3f5bae9 --- /dev/null +++ b/test-files/syntax-error/3/errors @@ -0,0 +1,9 @@ +org.broadinstitute.parser.SyntaxError: Two steps have the same name: atask +Location: test-files/syntax-error/3/source.wdl @ line 7, column 8: + + step atask[version=0] { + ^ +Previous step was defined @ line 3, column 8: + + step atask[version=0] { + ^ diff --git a/test-files/syntax-error/3/source.wdl b/test-files/syntax-error/3/source.wdl new file mode 100644 index 0000000..5674ce3 --- /dev/null +++ b/test-files/syntax-error/3/source.wdl @@ -0,0 +1,12 @@ +composite_task foo { + + step atask[version=0] { + output: File("foo.txt") as abc; + } + + step atask[version=0] { + input: p0=x, p1=y, p2=z; + output: File("bar.txt") as xyz; + } + +} diff --git a/test-files/syntax-error/4/errors b/test-files/syntax-error/4/errors new file mode 100644 index 0000000..49f0bfc --- /dev/null +++ b/test-files/syntax-error/4/errors @@ -0,0 +1,5 @@ +org.broadinstitute.parser.SyntaxError: Version information missing for task x +Location: test-files/syntax-error/4/source.wdl @ line 3, column 8: + + step x {} + ^ diff --git a/test-files/syntax-error/4/source.wdl b/test-files/syntax-error/4/source.wdl new file mode 100644 index 0000000..b67f205 --- /dev/null +++ b/test-files/syntax-error/4/source.wdl @@ -0,0 +1,4 @@ +composite_task foo { + for (a in b) {for (c in d) {for ( e in f) {}}} + step x {} +} diff --git a/test-files/syntax-error/5/errors b/test-files/syntax-error/5/errors new file mode 100644 index 0000000..24f1d24 --- /dev/null +++ b/test-files/syntax-error/5/errors @@ -0,0 +1,6 @@ +org.broadinstitute.parser.SyntaxError: Unexpected symbol identifier. Expecting composite_task. +Rule: wdl := _gen0 +Location: test-files/syntax-error/5/source.wdl @ line 1, column 1: + +composite task foo {} +^ diff --git a/test-files/syntax-error/5/source.wdl b/test-files/syntax-error/5/source.wdl new file mode 100644 index 0000000..87fe13a --- /dev/null +++ b/test-files/syntax-error/5/source.wdl @@ -0,0 +1 @@ +composite task foo {}