Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/nf-lang/src/main/antlr/ScriptLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ options {
superClass = AbstractLexer;
}

channels {
COMMENT // The COMMENT channel will contain all comments, and are separatly introduced into the AST during creation
}

@header {
package nextflow.script.parser;

Expand Down Expand Up @@ -830,18 +834,18 @@ NL : LineTerminator /* { this.ignoreTokenInsideParens(); } */

// Multiple-line comments (including groovydoc comments)
ML_COMMENT
: '/*' .*? '*/' /* { this.ignoreMultiLineCommentConditionally(); } */ -> type(NL)
: '/*' .*? '*/' /* { this.ignoreMultiLineCommentConditionally(); } */ -> channel(COMMENT)
;

// Single-line comments
SL_COMMENT
: '//' ~[\r\n\uFFFF]* /* { this.ignoreTokenInsideParens(); } */ -> type(NL)
: '//' ~[\r\n\uFFFF]* /* { this.ignoreTokenInsideParens(); } */ -> channel(COMMENT)
;

// Script-header comments.
// The very first characters of the file may be "#!". If so, ignore the first line.
SH_COMMENT
: '#!' { require(errorIgnored || 0 == this.tokenIndex, "Shebang comment should appear at the first line", -2, true); } ShCommand (LineTerminator '#!' ShCommand)* -> type(NL)
: '#!' { require(errorIgnored || 0 == this.tokenIndex, "Shebang comment should appear at the first line", -2, true); } ShCommand (LineTerminator '#!' ShCommand)* -> channel(COMMENT)
;

// Unexpected characters will be handled by groovy parser later.
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-lang/src/main/antlr/ScriptParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ processWhen
;

processExec
: (SCRIPT | SHELL | EXEC) COLON nls blockStatements
: execType=(SCRIPT | SHELL | EXEC) COLON nls blockStatements
;

processStub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,22 @@ public class WorkflowNode extends MethodNode {
public final Statement publishers;

public WorkflowNode(String name, Statement takes, Statement main, Statement emits, Statement publishers) {
super(name, 0, dummyReturnType(emits), dummyParams(takes), ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
super(
name != null ? name : "", // getText causes an exception if name is null, ugly hack for now
0,
dummyReturnType(emits),
dummyParams(takes),
ClassNode.EMPTY_ARRAY,
EmptyStatement.INSTANCE
);
this.takes = takes;
this.main = main;
this.emits = emits;
this.publishers = publishers;
}

public boolean isEntry() {
return getName() == null;
return getName() == "";
}

public boolean isCodeSnippet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public void compile(SourceUnit source) {
source.buildAST();
}
catch( RecognitionException e ) {
System.err.println("RecognitionException: " + e.getMessage());
}
catch( CompilationFailedException e ) {
System.err.println("CompilationFailedException: " + e.getMessage());
}
}

Expand Down
Loading