Skip to content

Commit 6b59989

Browse files
committed
Unexport scanner and lexer functions.
1 parent 1bb6937 commit 6b59989

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

asyncpi.y

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ values : /* empty */ { $$ = []Name{} }
6868

6969
// Parse is the entry point to the asyncpi calculus parser.
7070
func Parse(r io.Reader) (Process, error) {
71-
l := NewLexer(r)
71+
l := newLexer(r)
7272
asyncpiParse(l)
7373
select {
7474
case err := <-l.Errors:

lexer.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ package asyncpi
44

55
import "io"
66

7-
// Lexer for asyncpi.
8-
type Lexer struct {
9-
scanner *Scanner
7+
// lexer for asyncpi.
8+
type lexer struct {
9+
scanner *scanner
1010
Errors chan error
1111
}
1212

13-
// NewLexer returns a new yacc-compatible lexer.
14-
func NewLexer(r io.Reader) *Lexer {
15-
return &Lexer{scanner: NewScanner(r), Errors: make(chan error, 1)}
13+
// newLexer returns a new yacc-compatible lexer.
14+
func newLexer(r io.Reader) *lexer {
15+
return &lexer{scanner: newScanner(r), Errors: make(chan error, 1)}
1616
}
1717

1818
// Lex is provided for yacc-compatible parser.
19-
func (l *Lexer) Lex(yylval *asyncpiSymType) int {
19+
func (l *lexer) Lex(yylval *asyncpiSymType) int {
2020
var token tok
2121
token, yylval.strval, _, _ = l.scanner.Scan()
2222
return int(token)
2323
}
2424

2525
// Error handles error.
26-
func (l *Lexer) Error(err string) {
26+
func (l *lexer) Error(err string) {
2727
l.Errors <- &ParseError{Err: err, Pos: l.scanner.pos}
2828
}

parser.y.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const asyncpiInitialStackSize = 16
6363

6464
// Parse is the entry point to the asyncpi calculus parser.
6565
func Parse(r io.Reader) (Process, error) {
66-
l := NewLexer(r)
66+
l := newLexer(r)
6767
asyncpiParse(l)
6868
select {
6969
case err := <-l.Errors:

scanner.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import (
66
"io"
77
)
88

9-
// Scanner is a lexical scanner.
10-
type Scanner struct {
9+
// scanner is a lexical scanner.
10+
type scanner struct {
1111
r *bufio.Reader
1212
pos TokenPos
1313
}
1414

15-
// NewScanner returns a new instance of Scanner.
16-
func NewScanner(r io.Reader) *Scanner {
17-
return &Scanner{r: bufio.NewReader(r), pos: TokenPos{Char: 0, Lines: []int{}}}
15+
// newScanner returns a new instance of Scanner.
16+
func newScanner(r io.Reader) *scanner {
17+
return &scanner{r: bufio.NewReader(r), pos: TokenPos{Char: 0, Lines: []int{}}}
1818
}
1919

2020
// read reads the next rune from the buffered reader.
2121
// Returns the rune(0) if reached the end or error occurs.
22-
func (s *Scanner) read() rune {
22+
func (s *scanner) read() rune {
2323
ch, _, err := s.r.ReadRune()
2424
if err != nil {
2525
return eof
@@ -34,7 +34,7 @@ func (s *Scanner) read() rune {
3434
}
3535

3636
// unread places the previously read rune back on the reader.
37-
func (s *Scanner) unread() {
37+
func (s *scanner) unread() {
3838
_ = s.r.UnreadRune()
3939
if s.pos.Char == 0 {
4040
s.pos.Char = s.pos.Lines[len(s.pos.Lines)-1]
@@ -45,7 +45,7 @@ func (s *Scanner) unread() {
4545
}
4646

4747
// Scan returns the next token and parsed value.
48-
func (s *Scanner) Scan() (token tok, value string, startPos, endPos TokenPos) {
48+
func (s *scanner) Scan() (token tok, value string, startPos, endPos TokenPos) {
4949
ch := s.read()
5050

5151
if isWhitespace(ch) {
@@ -89,7 +89,7 @@ func (s *Scanner) Scan() (token tok, value string, startPos, endPos TokenPos) {
8989
return kILLEGAL, string(ch), startPos, endPos
9090
}
9191

92-
func (s *Scanner) scanName() (token tok, value string, startPos, endPos TokenPos) {
92+
func (s *scanner) scanName() (token tok, value string, startPos, endPos TokenPos) {
9393
var buf bytes.Buffer
9494
startPos = s.pos
9595
defer func() { endPos = s.pos }()
@@ -115,7 +115,7 @@ func (s *Scanner) scanName() (token tok, value string, startPos, endPos TokenPos
115115
return kNAME, buf.String(), startPos, endPos
116116
}
117117

118-
func (s *Scanner) skipWhitespace() {
118+
func (s *scanner) skipWhitespace() {
119119
for {
120120
if ch := s.read(); ch == eof {
121121
break

0 commit comments

Comments
 (0)