summary refs log tree commit diff stats
path: root/compiler/c2nim
diff options
context:
space:
mode:
authorVincent Burns <discoloda@gmail.com>2014-01-13 02:01:10 -0500
committerVincent Burns <discoloda@gmail.com>2014-01-13 02:01:10 -0500
commitd9a61c13dd4a355a3898b4b852d078a2e1b5f0fd (patch)
treeeb468766284a5cba4cae100ef4d0ab6fbb3523a8 /compiler/c2nim
parent5f905865bed2080c49b29dd48decdd24c4702cc9 (diff)
downloadNim-d9a61c13dd4a355a3898b4b852d078a2e1b5f0fd.tar.gz
Fix for expression parsing, 'new' is a valid C symbol
Diffstat (limited to 'compiler/c2nim')
-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")