1
0
Fork 0
mirror of https://github.com/on4kjm/FLEcli.git synced 2025-01-18 13:01:09 +01:00

Remove multi-line comments

This commit is contained in:
Jean-Marc MEESSEN 2020-05-30 22:12:45 +02:00
parent 39c6a76dc0
commit 1adf11e8a0
2 changed files with 32 additions and 1 deletions

View file

@ -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)
}
}

View file

@ -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`