It seems that the problem here is that the stmtList
parser is implemented with the sepBy1
combinator. sepBy1 stmt sep
parses one or more occurrences of p
separated (but not ended) by sep
, i.e. in EBNF: p (sep p)*. When the parser sees the semicolon after importlib(""msxml6.dll""), it expects another statement after the whitespace.
If you want to make the semicolon at the end of a statement list optional, you could simply use sepEndBy1
instead of sepBy1
, or if you always want to require a semicolon, you could use
let stmtList = many1 stmt
do stmtRef:= choice [importlib; importalias] .>> str ";"