summary refs log tree commit diff stats
path: root/compiler/lexer.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/lexer.nim')
-rw-r--r--compiler/lexer.nim122
1 files changed, 61 insertions, 61 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index 7410f7ec5..17c971912 100644
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -136,7 +136,7 @@ proc printTok*(tok: TToken)
 proc tokToStr*(tok: TToken): string
 
 proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream) =
-  OpenLexer(lex, filename.fileInfoIdx, inputStream)
+  openLexer(lex, filename.fileInfoIdx, inputstream)
 
 proc lexMessage*(L: TLexer, msg: TMsgKind, arg = "")
 
@@ -160,16 +160,16 @@ proc tokToStr*(tok: TToken): string =
   of tkFloatLit..tkFloat64Lit: result = $tok.fNumber
   of tkInvalid, tkStrLit..tkCharLit, tkComment: result = tok.literal
   of tkParLe..tkColon, tkEof, tkAccent: 
-    result = tokTypeToStr[tok.tokType]
+    result = TokTypeToStr[tok.tokType]
   else:
     if tok.ident != nil:
       result = tok.ident.s
     else: 
-      InternalError("tokToStr")
+      internalError("tokToStr")
       result = ""
   
 proc prettyTok*(tok: TToken): string =
-  if IsKeyword(tok.tokType): result = "keyword " & tok.ident.s
+  if isKeyword(tok.tokType): result = "keyword " & tok.ident.s
   else: result = tokToStr(tok)
   
 proc printTok*(tok: TToken) = 
@@ -199,7 +199,7 @@ proc fillToken(L: var TToken) =
   
 proc openLexer(lex: var TLexer, fileIdx: int32, inputstream: PLLStream) = 
   openBaseLexer(lex, inputstream)
-  lex.fileIdx = fileIdx
+  lex.fileIdx = fileidx
   lex.indentAhead = - 1
   inc(lex.Linenumber, inputstream.lineOffset) 
 
@@ -226,7 +226,7 @@ proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: TCharSet) =
   while true: 
     if buf[pos] in chars: 
       add(tok.literal, buf[pos])
-      Inc(pos)
+      inc(pos)
     else: 
       break 
     if buf[pos] == '_': 
@@ -234,11 +234,11 @@ proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: TCharSet) =
         lexMessage(L, errInvalidToken, "_")
         break
       add(tok.literal, '_')
-      Inc(pos)
+      inc(pos)
   L.bufPos = pos
 
-proc matchTwoChars(L: TLexer, first: Char, second: TCharSet): bool = 
-  result = (L.buf[L.bufpos] == first) and (L.buf[L.bufpos + 1] in Second)
+proc matchTwoChars(L: TLexer, first: char, second: TCharSet): bool = 
+  result = (L.buf[L.bufpos] == first) and (L.buf[L.bufpos + 1] in second)
 
 proc isFloatLiteral(s: string): bool =
   for i in countup(0, len(s) - 1):
@@ -249,7 +249,7 @@ proc isFloatLiteral(s: string): bool =
 proc getNumber(L: var TLexer): TToken = 
   var 
     pos, endpos: int
-    xi: biggestInt
+    xi: BiggestInt
   # get the base:
   result.tokType = tkIntLit   # int literal until we know better
   result.literal = ""
@@ -390,22 +390,22 @@ proc getNumber(L: var TLexer): TToken =
             xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('A') + 10)
             inc(pos)
           else: break 
-      else: InternalError(getLineInfo(L), "getNumber")
+      else: internalError(getLineInfo(L), "getNumber")
       case result.tokType
       of tkIntLit, tkInt64Lit: result.iNumber = xi
-      of tkInt8Lit: result.iNumber = biggestInt(int8(toU8(int(xi))))
-      of tkInt16Lit: result.iNumber = biggestInt(toU16(int(xi)))
-      of tkInt32Lit: result.iNumber = biggestInt(toU32(xi))
+      of tkInt8Lit: result.iNumber = BiggestInt(int8(toU8(int(xi))))
+      of tkInt16Lit: result.iNumber = BiggestInt(toU16(int(xi)))
+      of tkInt32Lit: result.iNumber = BiggestInt(toU32(xi))
       of tkUIntLit, tkUInt64Lit: result.iNumber = xi
-      of tkUInt8Lit: result.iNumber = biggestInt(int8(toU8(int(xi))))
-      of tkUInt16Lit: result.iNumber = biggestInt(toU16(int(xi)))
-      of tkUInt32Lit: result.iNumber = biggestInt(toU32(xi))
+      of tkUInt8Lit: result.iNumber = BiggestInt(int8(toU8(int(xi))))
+      of tkUInt16Lit: result.iNumber = BiggestInt(toU16(int(xi)))
+      of tkUInt32Lit: result.iNumber = BiggestInt(toU32(xi))
       of tkFloat32Lit: 
         result.fNumber = (cast[PFloat32](addr(xi)))[] 
         # note: this code is endian neutral!
         # XXX: Test this on big endian machine!
       of tkFloat64Lit: result.fNumber = (cast[PFloat64](addr(xi)))[] 
-      else: InternalError(getLineInfo(L), "getNumber")
+      else: internalError(getLineInfo(L), "getNumber")
     elif isFloatLiteral(result.literal) or (result.tokType == tkFloat32Lit) or
         (result.tokType == tkFloat64Lit): 
       result.fnumber = parseFloat(result.literal)
@@ -447,49 +447,49 @@ proc getEscapedChar(L: var TLexer, tok: var TToken) =
   of 'n', 'N': 
     if tok.toktype == tkCharLit: lexMessage(L, errNnotAllowedInCharacter)
     add(tok.literal, tnl)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'r', 'R', 'c', 'C': 
     add(tok.literal, CR)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'l', 'L': 
     add(tok.literal, LF)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'f', 'F': 
     add(tok.literal, FF)
     inc(L.bufpos)
   of 'e', 'E': 
     add(tok.literal, ESC)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'a', 'A': 
     add(tok.literal, BEL)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'b', 'B': 
     add(tok.literal, BACKSPACE)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'v', 'V': 
     add(tok.literal, VT)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 't', 'T': 
     add(tok.literal, Tabulator)
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of '\'', '\"': 
     add(tok.literal, L.buf[L.bufpos])
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of '\\': 
     add(tok.literal, '\\')
-    Inc(L.bufpos)
+    inc(L.bufpos)
   of 'x', 'X': 
     inc(L.bufpos)
     var xi = 0
     handleHexChar(L, xi)
     handleHexChar(L, xi)
-    add(tok.literal, Chr(xi))
+    add(tok.literal, chr(xi))
   of '0'..'9': 
     if matchTwoChars(L, '0', {'0'..'9'}): 
       lexMessage(L, warnOctalEscape)
     var xi = 0
     handleDecChars(L, xi)
-    if (xi <= 255): add(tok.literal, Chr(xi))
+    if (xi <= 255): add(tok.literal, chr(xi))
     else: lexMessage(L, errInvalidCharacterConstant)
   else: lexMessage(L, errInvalidCharacterConstant)
 
@@ -528,7 +528,7 @@ proc getString(L: var TLexer, tok: var TToken, rawMode: bool) =
     tok.tokType = tkTripleStrLit # long string literal:
     inc(pos, 2)               # skip ""
     # skip leading newline:
-    pos = HandleCRLF(L, pos)
+    pos = handleCRLF(L, pos)
     buf = L.buf
     while true: 
       case buf[pos]
@@ -538,9 +538,9 @@ proc getString(L: var TLexer, tok: var TToken, rawMode: bool) =
           L.bufpos = pos + 3 # skip the three """
           break 
         add(tok.literal, '\"')
-        Inc(pos)
+        inc(pos)
       of CR, LF: 
-        pos = HandleCRLF(L, pos)
+        pos = handleCRLF(L, pos)
         buf = L.buf
         add(tok.literal, tnl)
       of nimlexbase.EndOfFile: 
@@ -551,7 +551,7 @@ proc getString(L: var TLexer, tok: var TToken, rawMode: bool) =
         break 
       else: 
         add(tok.literal, buf[pos])
-        Inc(pos)
+        inc(pos)
   else: 
     # ordinary string literal
     if rawMode: tok.tokType = tkRStrLit
@@ -574,18 +574,18 @@ proc getString(L: var TLexer, tok: var TToken, rawMode: bool) =
         pos = L.bufPos
       else: 
         add(tok.literal, c)
-        Inc(pos)
+        inc(pos)
     L.bufpos = pos
 
 proc getCharacter(L: var TLexer, tok: var TToken) = 
-  Inc(L.bufpos)               # skip '
+  inc(L.bufpos)               # skip '
   var c = L.buf[L.bufpos]
   case c
   of '\0'..Pred(' '), '\'': lexMessage(L, errInvalidCharacterConstant)
   of '\\': getEscapedChar(L, tok)
   else: 
     tok.literal = $c
-    Inc(L.bufpos)
+    inc(L.bufpos)
   if L.buf[L.bufpos] != '\'': lexMessage(L, errMissingFinalQuote)
   inc(L.bufpos)               # skip '
   
@@ -606,7 +606,7 @@ proc getSymbol(L: var TLexer, tok: var TToken) =
         lexMessage(L, errInvalidToken, "_")
         break
     else: break 
-    Inc(pos)
+    inc(pos)
   h = !$h
   tok.ident = getIdent(addr(L.buf[L.bufpos]), pos - L.bufpos, h)
   L.bufpos = pos
@@ -631,8 +631,8 @@ proc getOperator(L: var TLexer, tok: var TToken) =
   while true: 
     var c = buf[pos]
     if c notin OpChars: break
-    h = h !& Ord(c)
-    Inc(pos)
+    h = h !& ord(c)
+    inc(pos)
   endOperator(L, tok, pos, h)
 
 proc scanComment(L: var TLexer, tok: var TToken) = 
@@ -680,17 +680,17 @@ proc skip(L: var TLexer, tok: var TToken) =
   while true:
     case buf[pos]
     of ' ':
-      Inc(pos)
+      inc(pos)
     of Tabulator:
       lexMessagePos(L, errTabulatorsAreNotAllowed, pos)
       inc(pos)
     of CR, LF:
-      pos = HandleCRLF(L, pos)
+      pos = handleCRLF(L, pos)
       buf = L.buf
       var indent = 0
       while buf[pos] == ' ':
-        Inc(pos)
-        Inc(indent)
+        inc(pos)
+        inc(indent)
       if buf[pos] > ' ':
         tok.indent = indent
         break
@@ -725,7 +725,7 @@ proc rawGetTok(L: var TLexer, tok: var TToken) =
         getOperator(L, tok)
     of ',':
       tok.toktype = tkComma
-      Inc(L.bufpos)
+      inc(L.bufpos)
     of 'l': 
       # if we parsed exactly one character and its a small L (l), this
       # is treated as a warning because it may be confused with the number 1
@@ -734,58 +734,58 @@ proc rawGetTok(L: var TLexer, tok: var TToken) =
       getSymbol(L, tok)
     of 'r', 'R':
       if L.buf[L.bufPos + 1] == '\"': 
-        Inc(L.bufPos)
+        inc(L.bufPos)
         getString(L, tok, true)
       else: 
         getSymbol(L, tok)
     of '(': 
-      Inc(L.bufpos)
+      inc(L.bufpos)
       if L.buf[L.bufPos] == '.' and L.buf[L.bufPos+1] != '.': 
         tok.toktype = tkParDotLe
-        Inc(L.bufpos)
+        inc(L.bufpos)
       else: 
         tok.toktype = tkParLe
     of ')': 
       tok.toktype = tkParRi
-      Inc(L.bufpos)
+      inc(L.bufpos)
     of '[': 
-      Inc(L.bufpos)
+      inc(L.bufpos)
       if L.buf[L.bufPos] == '.' and L.buf[L.bufPos+1] != '.':
         tok.toktype = tkBracketDotLe
-        Inc(L.bufpos)
+        inc(L.bufpos)
       else:
         tok.toktype = tkBracketLe
     of ']':
       tok.toktype = tkBracketRi
-      Inc(L.bufpos)
+      inc(L.bufpos)
     of '.':
       if L.buf[L.bufPos+1] == ']': 
         tok.tokType = tkBracketDotRi
-        Inc(L.bufpos, 2)
+        inc(L.bufpos, 2)
       elif L.buf[L.bufPos+1] == '}': 
         tok.tokType = tkCurlyDotRi
-        Inc(L.bufpos, 2)
+        inc(L.bufpos, 2)
       elif L.buf[L.bufPos+1] == ')': 
         tok.tokType = tkParDotRi
-        Inc(L.bufpos, 2)
+        inc(L.bufpos, 2)
       else: 
         getOperator(L, tok)
     of '{': 
-      Inc(L.bufpos)
+      inc(L.bufpos)
       if L.buf[L.bufPos] == '.' and L.buf[L.bufPos+1] != '.':
         tok.toktype = tkCurlyDotLe
-        Inc(L.bufpos)
+        inc(L.bufpos)
       else: 
         tok.toktype = tkCurlyLe
     of '}': 
       tok.toktype = tkCurlyRi
-      Inc(L.bufpos)
+      inc(L.bufpos)
     of ';': 
       tok.toktype = tkSemiColon
-      Inc(L.bufpos)
+      inc(L.bufpos)
     of '`': 
       tok.tokType = tkAccent
-      Inc(L.bufpos)
+      inc(L.bufpos)
     of '\"': 
       # check for extended raw string literal:
       var rawMode = L.bufpos > 0 and L.buf[L.bufpos-1] in SymChars
@@ -810,6 +810,6 @@ proc rawGetTok(L: var TLexer, tok: var TToken) =
         tok.literal = $c
         tok.tokType = tkInvalid
         lexMessage(L, errInvalidToken, c & " (\\" & $(ord(c)) & ')')
-        Inc(L.bufpos)
+        inc(L.bufpos)
   
 dummyIdent = getIdent("")