aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddyconfig/caddyfile
diff options
context:
space:
mode:
Diffstat (limited to 'caddyconfig/caddyfile')
-rw-r--r--caddyconfig/caddyfile/lexer.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/caddyconfig/caddyfile/lexer.go b/caddyconfig/caddyfile/lexer.go
index 4db63749b..9b523f397 100644
--- a/caddyconfig/caddyfile/lexer.go
+++ b/caddyconfig/caddyfile/lexer.go
@@ -340,6 +340,8 @@ func (l *lexer) finalizeHeredoc(val []rune, marker string) ([]rune, error) {
return []rune(out), nil
}
+// Quoted returns true if the token was enclosed in quotes
+// (i.e. double quotes, backticks, or heredoc).
func (t Token) Quoted() bool {
return t.wasQuoted > 0
}
@@ -356,6 +358,19 @@ func (t Token) NumLineBreaks() int {
return lineBreaks
}
+// Clone returns a deep copy of the token.
+func (t Token) Clone() Token {
+ return Token{
+ File: t.File,
+ imports: append([]string{}, t.imports...),
+ Line: t.Line,
+ Text: t.Text,
+ wasQuoted: t.wasQuoted,
+ heredocMarker: t.heredocMarker,
+ snippetName: t.snippetName,
+ }
+}
+
var heredocMarkerRegexp = regexp.MustCompile("^[A-Za-z0-9_-]+$")
// isNextOnNewLine tests whether t2 is on a different line from t1