Skip to content

Commit

Permalink
fixed out of bounds for zero length tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Henderson <tadh@google.com>
  • Loading branch information
timtadh committed Feb 20, 2018
1 parent 02854b9 commit 978d0bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion machines/dfa_machine.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package machines

import "fmt"

// DFATrans represents a Deterministic Finite Automatons state transition table
type DFATrans [][256]int

Expand Down Expand Up @@ -76,7 +78,8 @@ func DFALexerEngine(startState, errorState int, trans DFATrans, accepting DFAAcc
return tc, match, nil, scan
}
}
if match, has := accepting[state]; has {
if match, has := accepting[state]; has && startTC < len(text) {
fmt.Println(state, match, tc, startTC, len(text))
matchID = match
matchTC = tc
startLC := lineCols[startTC]
Expand Down

0 comments on commit 978d0bb

Please sign in to comment.