summary refs log tree commit diff stats
path: root/compiler/c2nim/cparse.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/c2nim/cparse.nim')
-rw-r--r--compiler/c2nim/cparse.nim15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim
index 30cee180a..df263ee4e 100644
--- a/compiler/c2nim/cparse.nim
+++ b/compiler/c2nim/cparse.nim
@@ -1152,7 +1152,7 @@ proc startExpression(p : var TParser, tok : TToken) : PNode =
         eat(p, pxParLe)
         addSon(result, typeDesc(p))
         eat(p, pxParRi)
-    elif tok.s == "new" or tok.s == "delete" and pfCpp in p.options.flags:
+    elif (tok.s == "new" or tok.s == "delete") and pfCpp in p.options.flags:
       var opr = tok.s
       result = newNodeP(nkCall, p)
       if p.tok.xkind == pxBracketLe:
@@ -2096,9 +2096,12 @@ proc statement(p: var TParser): PNode =
   assert result != nil
 
 proc parseUnit(p: var TParser): PNode =
-  result = newNodeP(nkStmtList, p)
-  getTok(p) # read first token
-  while p.tok.xkind != pxEof:
-    var s = statement(p)
-    if s.kind != nkEmpty: embedStmts(result, s)
+  try:
+    result = newNodeP(nkStmtList, p)
+    getTok(p) # read first token
+    while p.tok.xkind != pxEof:
+      var s = statement(p)
+      if s.kind != nkEmpty: embedStmts(result, s)
+  except:
+    parMessage(p, errGenerated, "Uncaught exception raised during parsing")