add in Go case insensitive stream from bramp
This commit is contained in:
parent
21de2317fa
commit
d3a7fe37ff
|
@ -68,4 +68,9 @@ Then, when creating the character stream to parse from, we need a custom class t
|
|||
CharStream s = CharStreams.fromPath(Paths.get('test.sql'));
|
||||
CaseChangingCharStream upper = new CaseChangingCharStream(s, true);
|
||||
Lexer lexer = new SomeSQLLexer(upper);
|
||||
```
|
||||
```
|
||||
|
||||
Here are implementations of `CaseChangingCharStream` in various target languages:
|
||||
|
||||
* [Java](https://github.com/parrt/antlr4/blob/case-insensitivity-doc/doc/resources/CaseChangingCharStream.java)
|
||||
*
|
|
@ -1,32 +0,0 @@
|
|||
package antlr
|
||||
|
||||
import (
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCaseChangingStream(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
upper bool
|
||||
want []int
|
||||
}{
|
||||
{"abcd", true, []int{'A', 'B', 'C', 'D', TokenEOF}},
|
||||
{"ABCD", true, []int{'A', 'B', 'C', 'D', TokenEOF}},
|
||||
{"abcd", false, []int{'a', 'b', 'c', 'd', TokenEOF}},
|
||||
{"ABCD", false, []int{'a', 'b', 'c', 'd', TokenEOF}},
|
||||
{"", false, []int{TokenEOF}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
var got []int
|
||||
is := NewCaseChangingStream(NewInputStream(test.input), test.upper)
|
||||
for i := 1; i <= is.Size()+1; i++ {
|
||||
got = append(got, is.LA(i))
|
||||
}
|
||||
|
||||
if diff := pretty.Compare(test.want, got); diff != "" {
|
||||
t.Errorf("NewCaseChangingStream(%q, %v) diff: (-got +want)\n%s", test.input, test.upper, diff)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue