Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
package parser |
|
2 |
|
|
3 |
import ( |
|
4 |
"fmt"
|
|
5 |
|
|
6 |
"github.com/noirbizarre/gonja/nodes"
|
|
7 |
"github.com/noirbizarre/gonja/tokens"
|
|
8 |
log "github.com/sirupsen/logrus" |
|
9 |
)
|
|
10 |
|
|
11 | 4 |
func (p *Parser) ParseComment() (*nodes.Comment, error) { |
12 | 4 |
log.WithFields(log.Fields{ |
13 | 4 |
"current": p.Current(), |
14 | 4 |
}).Trace("ParseComment") |
15 | 1 |
|
16 | 4 |
tok := p.Match(tokens.CommentBegin) |
17 |
if tok == nil { |
|
18 |
msg := fmt.Sprintf(`Expected '%s' , got %s`, p.Config.CommentStartString, p.Current()) |
|
19 |
return nil, p.Error(msg, p.Current()) |
|
20 |
}
|
|
21 |
|
|
22 | 4 |
comment := &nodes.Comment{ |
23 | 4 |
Start: tok, |
24 | 4 |
Trim: &nodes.Trim{}, |
25 | 1 |
}
|
26 | 1 |
|
27 | 4 |
tok = p.Match(tokens.Data) |
28 |
if tok == nil { |
|
29 |
comment.Text = "" |
|
30 |
} else { |
|
31 | 4 |
comment.Text = tok.Val |
32 | 1 |
}
|
33 |
|
|
34 | 4 |
tok = p.Match(tokens.CommentEnd) |
35 |
if tok == nil { |
|
36 |
msg := fmt.Sprintf(`Expected '%s' , got %s`, p.Config.CommentEndString, p.Current()) |
|
37 |
return nil, p.Error(msg, p.Current()) |
|
38 |
}
|
|
39 | 4 |
comment.End = tok |
40 | 1 |
|
41 | 4 |
log.WithFields(log.Fields{ |
42 | 4 |
"node": comment, |
43 | 4 |
}).Trace("ParseComment return") |
44 | 4 |
return comment, nil |
45 |
}
|
Read our documentation on viewing source code .