Skip to content
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

Add ability to ignore script lines #34

Merged
merged 1 commit into from
Mar 15, 2020
Merged
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
28 changes: 28 additions & 0 deletions internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,34 @@ func lexCmdScriptLine(_ *LexContext, l *lexer.Lexer) LexFn {
return lexCmdScriptLine
}
m := l.Marker()
// # at beginning of script line = ignore line
//
if peekRuneEquals(l, runeHash) {
// Consume comment block
//
for peekRuneEquals(l, runeHash) {
l.Next()
// Consume rest of line, including newline
//
for !matchNewlineOrEOF(l) {
l.Next()
}
}
// If the line following the comment block is not part of the script,
// then assume the comment is also not part of the script
// NOTE: We have to include RBrace here on the chance that the user
// is using braces to wrap the script.
//
m2 := l.Marker()
if matchNewlineOrEOF(l) || matchOneOrMore(l, isSpaceOrTab) || matchRune(l, runeRBrace) {
m2.Apply()
l.Clear() // Discard the comment block
return lexCmdScriptLine
}
m.Apply() // End script before comment block
l.EmitType(TokenScriptEnd)
return nil
}
// !whitespace at beginning of non-blank line terminates script
//
if !matchOneOrMore(l, isSpaceOrTab) {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// Version stores the version tag - Should include leading 'v' - Update before tagging new versions.
//
var Version = "v0.7.1+assert"
var Version = "v0.7.1+assert.script-comments"

// BuildDate is optional and can be set using '-ldflags "-X 'main.BuildDate=..."'.
//
Expand Down