OSDN Git Service

fix contract exceptd check (#22)
authoroysheng <33340252+oysheng@users.noreply.github.com>
Thu, 25 Oct 2018 09:05:10 +0000 (17:05 +0800)
committerPaladz <yzhu101@uottawa.ca>
Thu, 25 Oct 2018 09:05:10 +0000 (17:05 +0800)
compiler/parse.go

index 4848aee..956825e 100644 (file)
@@ -48,6 +48,10 @@ func parse(buf []byte) (contracts []*Contract, err error) {
 
 func parseContracts(p *parser) []*Contract {
        var result []*Contract
+       if pos := scanKeyword(p.buf, p.pos, "contract"); pos < 0 {
+               p.errorf("expected contract")
+       }
+
        for peekKeyword(p) == "contract" {
                contract := parseContract(p)
                result = append(result, contract)