diff --git a/CLI/ocli.go b/CLI/ocli.go index 695877d0d..7c91e6c4f 100644 --- a/CLI/ocli.go +++ b/CLI/ocli.go @@ -56,16 +56,24 @@ func parseFile(path string) ([]parsedLine, error) { result := []parsedLine{} var fileErr *fileParseError scanner := bufio.NewScanner(file) + line := "" + startLineNumber := 1 for lineNumber := 1; scanner.Scan(); lineNumber++ { - line := scanner.Text() - if len(line) > 0 { + newLine := strings.TrimRight(scanner.Text(), " ") + if len(newLine) >= 1 && newLine[len(newLine)-1] == '\\' { + newLine = newLine[:len(newLine)-1] + line += newLine + "\n" + } else { + line += newLine root, err := Parse(line) if err != nil { - fileErr = addLineError(fileErr, err, filename, lineNumber, line) + fileErr = addLineError(fileErr, err, filename, startLineNumber, line) } if root != nil { - result = append(result, parsedLine{line, lineNumber, root}) + result = append(result, parsedLine{line, startLineNumber, root}) } + line = "" + startLineNumber = lineNumber + 1 } } if fileErr != nil { diff --git a/CLI/parser.go b/CLI/parser.go index 0c2b6e7ef..4ae7949d4 100644 --- a/CLI/parser.go +++ b/CLI/parser.go @@ -166,7 +166,7 @@ func (p *parser) error(message string) { func (p *parser) skipWhiteSpaces() { defer un(trace(p, "")) - for p.cursor < len(p.buf) && (p.peek() == ' ' || p.peek() == '\t') { + for p.cursor < len(p.buf) && (p.peek() == ' ' || p.peek() == '\t' || p.peek() == '\n') { p.forward(1) } } @@ -309,7 +309,7 @@ loop: } } if trim { - s = strings.Trim(s, " ") + s = strings.Trim(s, " \n") } if len(subExpr) == 0 { return &valueNode{s}