Skip to content
This repository has been archived by the owner on Jan 21, 2019. It is now read-only.

Commit

Permalink
Fix #11 - checking blanks and added \r as blank as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Xumeiquer committed Sep 18, 2017
1 parent b68198f commit 3ab7156
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lexic/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func isPercent(r rune) bool {

// isBlank reports whether r is a black character
func isBlank(r rune) bool {
return r == ' ' || r == '\t' || r == '\n'
return r == ' ' || r == '\t' || r == '\n' || r == '\r'
}

// isSpace reports whether r is a space character.
Expand Down
5 changes: 3 additions & 2 deletions lexic/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ func scanCommentOrRegex(l *Lexer) stateFn {

mod := ""
r = l.next()
if !isValidRegexpMod(r) {
l.errorf("Line %d: illegal regex modifier", l.Line)
fmt.Printf("%s -- '%s'", l.Name, string(r))
if !isBlank(r) && !isValidRegexpMod(r) {
l.errorf("Line %d: illegal regex modifier (%s)", l.Line, string(r))
}
for isValidRegexpMod(r) {
mod += string(r)
Expand Down
17 changes: 9 additions & 8 deletions yago/yago.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import (
)

const (
MULTILINE = `\s*/\*([^*]|\*+[^*/])*\*+/\s*`
INLINE = `(?m)\s*//.*[\n\r][\n\r]?`
BLANKS = `(?m)\s+$`
QUOTES = `"`
MAXBUFF = 1024 * 1024 // If needed Go will take it form RAM.
MULTILINE = `\s*/\*([^*]|\*+[^*/])*\*+/\s*`
INLINE = `(?m)\s*//.*[\n\r][\n\r]?`
BLANKS = `(?m)\s+$`
QUOTES = `"`
MAXBUFF = 1024 * 1024 // If needed Go will take it form RAM.
DEBUG_LEVEL = "INFO"
)

func NewParser(name string) *grammar.Parser {
Expand All @@ -31,7 +32,7 @@ func ProcessFile(fileName string) []*grammar.Parser {
checkErr(err)

p := NewParser(path.Base(fileName))
p.SetLogLevel("INFO")
p.SetLogLevel(DEBUG_LEVEL)
p.Parse(string(file))

var res []*grammar.Parser
Expand All @@ -54,7 +55,7 @@ func ProcessDir(dirName string) []*grammar.Parser {
checkErr(err)

p := NewParser(path.Base(filePath))
p.SetLogLevel("INFO")
p.SetLogLevel(DEBUG_LEVEL)
p.Parse(string(file))
res = append(res, p)
}
Expand Down Expand Up @@ -90,7 +91,7 @@ func ProcessIndex(indexFile, cwd string) []*grammar.Parser {
checkErr(err)

p := NewParser(path.Base(rulePath))
p.SetLogLevel("INFO")
p.SetLogLevel(DEBUG_LEVEL)
p.Parse(string(file))
res = append(res, p)
} else {
Expand Down

0 comments on commit 3ab7156

Please sign in to comment.