From 1adf11e8a0d06fb59b589906c8a72c5a9197fc7a Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Sat, 30 May 2020 22:12:45 +0200 Subject: [PATCH] Remove multi-line comments --- cmd/load.go | 30 ++++++++++++++++++++++++++++++ test/commands.md | 3 ++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cmd/load.go b/cmd/load.go index 9353cac..50687f7 100644 --- a/cmd/load.go +++ b/cmd/load.go @@ -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) } } \ No newline at end of file diff --git a/test/commands.md b/test/commands.md index cb0163d..9c17505 100644 --- a/test/commands.md +++ b/test/commands.md @@ -1,3 +1,4 @@ # Commands for testing -* `./FLEcli -i test/data/fle-1.txt load` \ No newline at end of file +* `./FLEcli -i test/data/fle-1.txt load` +* `./FLEcli -i test/sample_contest_ru.txt load` \ No newline at end of file