-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback_sender.go
More file actions
40 lines (34 loc) · 1.1 KB
/
callback_sender.go
File metadata and controls
40 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package adapter
import (
"github.com/code-game-project/cge-parser/parser"
)
type callbackSender struct {
CBMetadata func(cgeVersion string)
CBDiagnostic func(diagnosticType parser.DiagnosticType, message string, startLine, startColumn, endLine, endColumn int)
CBToken func(tokenType parser.TokenType, lexeme string, line, column int)
CBObject func(object parser.Object)
}
func (c *callbackSender) SendMetadata(cgeVersion string) error {
if c.CBMetadata != nil {
c.CBMetadata(cgeVersion)
}
return nil
}
func (c *callbackSender) SendDiagnostic(diagnosticType parser.DiagnosticType, message string, startLine, startColumn, endLine, endColumn int) error {
if c.CBDiagnostic != nil {
c.CBDiagnostic(diagnosticType, message, startLine, startColumn, endLine, endColumn)
}
return nil
}
func (c *callbackSender) SendToken(tokenType parser.TokenType, lexeme string, line, column int) error {
if c.CBToken != nil {
c.CBToken(tokenType, lexeme, line, column)
}
return nil
}
func (c *callbackSender) SendObject(object parser.Object) error {
if c.CBObject != nil {
c.CBObject(object)
}
return nil
}