summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflaviut <tamasflaviu@gmail.com>2014-06-08 19:41:36 -0400
committerflaviut <tamasflaviu@gmail.com>2014-06-08 19:41:36 -0400
commitce29b9f78c74285a31908135a73ee62051bd7525 (patch)
treefe05c3e0502b7734144ff6b94b8270ae982c3f24
parent145cb3ae8ccf58495a3e38f6646041661de2affb (diff)
downloadNim-ce29b9f78c74285a31908135a73ee62051bd7525.tar.gz
fix tokenizing bug
-rw-r--r--compiler/parser.nim21
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index 0f52750c9..18de1570a 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -287,7 +287,7 @@ proc colcom(p: var TParser, n: PNode) =
   skipComment(p, n)
 
 proc parseSymbol(p: var TParser, allowNil = false): PNode =
-  #| symbol = '`' (KEYW|IDENT|operator|'('|')'|'['|']'|'{'|'}'|'='|literal)+ '`'
+  #| symbol = '`' (KEYW|IDENT|literal|(operator|'('|')'|'['|']'|'{'|'}'|'=')+)+ '`'
   #|        | IDENT
   case p.tok.tokType
   of tkSymbol: 
@@ -296,19 +296,24 @@ proc parseSymbol(p: var TParser, allowNil = false): PNode =
   of tkAccent: 
     result = newNodeP(nkAccQuoted, p)
     getTok(p)
-    var accm = ""
     while true:
       case p.tok.tokType
       of tkAccent:
-        if accm == "": 
+        if result.len == 0: 
           parMessage(p, errIdentifierExpected, p.tok)
         break
-      of tkEof, tkInvalid, tkComment:
-          parMessage(p, errIdentifierExpected, p.tok)
-      else:
-        accm.add(tokToStr(p.tok))
+      of tkOpr, tkDot, tkDotDot, tkEquals, tkParLe..tkParDotRi:
+        var accm = ""
+        while p.tok.tokType in {tkOpr, tkDot, tkDotDot, tkEquals,
+                                tkParLe..tkParDotRi}:
+          accm.add(tokToStr(p.tok))
+          getTok(p)
+        result.add(newIdentNodeP(getIdent(accm), p))
+      of tokKeywordLow..tokKeywordHigh, tkSymbol, tkIntLit..tkCharLit:
+        result.add(newIdentNodeP(getIdent(tokToStr(p.tok)), p))
         getTok(p)
-    result.add(newIdentNodeP(getIdent(accm), p))
+      else:
+        parMessage(p, errIdentifierExpected, p.tok)
     eat(p, tkAccent)
   else:
     if allowNil and p.tok.tokType == tkNil: