Skip to content

Commit

Permalink
Improve parsing algorithm to handle spaces and comments #63
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Oct 15, 2021
1 parent 21644f1 commit 9edc745
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
7 changes: 4 additions & 3 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,10 @@ function parseCli(line, res, pos,c,last,is_doll,c1) {
}
function reparseCli( res,i,err) {
err = parseCli($0, res)
if (err)
die("syntax error at line " NR ": " err)
else
if (err) {
addError("Syntax error: " err)
die(Error)
} else
for (i=NF=0; i in res; i++)
$(++NF)=res[i]
}
Expand Down
10 changes: 10 additions & 0 deletions tests/21_parsing.tush
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,13 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh
| goal 'goal;b' [empty].
| goal 'goal&c' [empty].
| goal 'default' [empty].

$ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_err1.sh
@ Syntax error: unterminated argument:
@ tests/21_parsing_err1.sh:3: @goal 'goal name
? 1

$ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_err2.sh
@ Syntax error: joined arguments:
@ tests/21_parsing_err2.sh:4: @doc doc'text
? 1
4 changes: 4 additions & 0 deletions tests/21_parsing_err1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


@goal 'goal name
echo 123
5 changes: 5 additions & 0 deletions tests/21_parsing_err2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


@goal 'goal name'
@doc doc'text
echo 123

0 comments on commit 9edc745

Please sign in to comment.