Remove multi-line comments

pull/2/head
Jean-Marc MEESSEN 5 years ago
parent 39c6a76dc0
commit 1adf11e8a0

@ -74,9 +74,19 @@ func loadFile() {
regexpLineComment, _ := regexp.Compile("^#")
regexpOnlySpaces, _ := regexp.Compile("^\\s+$")
regexpSingleMultiLineComment, _ := regexp.Compile("^{.+}$")
regexpStartMultiLineComment, _ := regexp.Compile("^{")
regexpEndMultiLineComment, _ := regexp.Compile("}$")
var isInMultiLine = false
//Loop through all the stored lined
for _, eachline := range txtlines {
// ****
// ** Lets do some house keeping first by droping the unecessary lines
// ****
//Skip the line if it starts with "#"
if(regexpLineComment.MatchString(eachline)) {
continue
@ -86,6 +96,26 @@ func loadFile() {
continue
}
// Process multi-line comments
if(regexpStartMultiLineComment.MatchString(eachline)) {
//Single-line "multi-line" coment
if(regexpSingleMultiLineComment.MatchString(eachline)) {
continue
}
isInMultiLine = true
continue
}
if(isInMultiLine) {
if(regexpEndMultiLineComment.MatchString(eachline)) {
isInMultiLine = false
}
continue
}
// ****
// ** Process the data line
// ****
fmt.Println(eachline)
}
}

@ -1,3 +1,4 @@
# Commands for testing
* `./FLEcli -i test/data/fle-1.txt load`
* `./FLEcli -i test/data/fle-1.txt load`
* `./FLEcli -i test/sample_contest_ru.txt load`
Loading…
Cancel
Save