-
Notifications
You must be signed in to change notification settings - Fork 0
/
steps-directive-annotation.go
54 lines (48 loc) · 1.29 KB
/
steps-directive-annotation.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package scanner
import (
"github.com/jsightapi/jsight-api-core/jerr"
)
func stateAnnotationSign2(s *Scanner, c byte) *jerr.JApiError {
switch c {
case AnnotationDelimiterPart:
s.step = stateAnnotationTextStart
case '*':
s.step = stateMultilineAnnotationTextStart
default:
s.curIndex -= 2
s.step = stateParameterStart
}
return nil
}
func stateAnnotationTextStart(s *Scanner, c byte) *jerr.JApiError {
s.found(AnnotationBegin)
s.step = stateAnnotation
return stateAnnotation(s, c)
}
func stateAnnotation(s *Scanner, c byte) *jerr.JApiError {
switch c {
case CommentSign:
s.foundAt(s.curIndex-1, AnnotationEnd)
s.step = stateSingleComment
return nil
case caseNewLine(c), EOF:
s.foundAt(s.curIndex-1, AnnotationEnd)
s.step = s.stepStack.Pop()
return s.step(s, c)
}
return nil
}
func stateMultilineAnnotationTextStart(s *Scanner, c byte) *jerr.JApiError {
s.foundAt(s.curIndex, AnnotationBegin)
s.step = stateMultilineAnnotation
return stateMultilineAnnotation(s, c)
}
func stateMultilineAnnotation(s *Scanner, c byte) *jerr.JApiError {
if c == AnnotationDelimiterPart && s.data.Byte(s.curIndex-1) == '*' {
s.foundAt(s.curIndex-2, AnnotationEnd)
s.step = s.stepStack.Pop()
} else if c == EOF {
return s.japiErrorUnexpectedChar("multiline annotation", "*/")
}
return nil
}