Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: Capture all comments in parser #6332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
ErikDanielsson wants to merge 6 commits into nextflow-io:master
base: master
Choose a base branch
Loading
from ErikDanielsson:fix-parser-comment-handling
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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

AltStyle によって変換されたページ (->オリジナル) /