summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/oids.nim2
-rw-r--r--lib/pure/parsecfg.nim9
-rw-r--r--lib/pure/parsecsv.nim2
-rw-r--r--lib/pure/parseopt.nim2
-rw-r--r--lib/pure/parseopt2.nim6
-rw-r--r--lib/pure/parsesql.nim126
-rw-r--r--lib/pure/parseurl.nim14
7 files changed, 80 insertions, 81 deletions
diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim
index c0bfb7c08..7c58a2dda 100644
--- a/lib/pure/oids.nim
+++ b/lib/pure/oids.nim
@@ -89,5 +89,5 @@ proc generatedTime*(oid: Oid): Time =
   result = Time(tmp)
 
 when isMainModule:
-  let xo = genOID()
+  let xo = genOid()
   echo xo.generatedTime
diff --git a/lib/pure/parsecfg.nim b/lib/pure/parsecfg.nim
index c340bf98b..a45976d86 100644
--- a/lib/pure/parsecfg.nim
+++ b/lib/pure/parsecfg.nim
@@ -38,7 +38,7 @@ type
     cfgError            ## an error ocurred during parsing
     
   CfgEvent* = object of RootObj ## describes a parsing event
-    case kind*: TCfgEventKind    ## the kind of the event
+    case kind*: CfgEventKind    ## the kind of the event
     of cfgEof: nil
     of cfgSectionStart: 
       section*: string           ## `section` contains the name of the 
@@ -70,12 +70,11 @@ type
 # implementation
 
 const 
-  SymChars: CharSet = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF', '.',
-                       '/', '\\'} 
+  SymChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF', '.', '/', '\\'} 
   
 proc rawGetTok(c: var CfgParser, tok: var Token) {.gcsafe.}
 
-proc open*(c: var CfgParser, input: PStream, filename: string, 
+proc open*(c: var CfgParser, input: Stream, filename: string, 
            lineOffset = 0) {.rtl, extern: "npc$1".} =
   ## initializes the parser with an input stream. `Filename` is only used
   ## for nice error messages. `lineOffset` can be used to influence the line
@@ -122,7 +121,7 @@ proc handleDecChars(c: var CfgParser, xi: var int) =
     xi = (xi * 10) + (ord(c.buf[c.bufpos]) - ord('0'))
     inc(c.bufpos)
 
-proc getEscapedChar(c: var CfgParser, tok: var TToken) = 
+proc getEscapedChar(c: var CfgParser, tok: var Token) = 
   inc(c.bufpos)               # skip '\'
   case c.buf[c.bufpos]
   of 'n', 'N': 
diff --git a/lib/pure/parsecsv.nim b/lib/pure/parsecsv.nim
index d267906a3..c8abdca4f 100644
--- a/lib/pure/parsecsv.nim
+++ b/lib/pure/parsecsv.nim
@@ -155,7 +155,7 @@ proc readRow*(my: var CsvParser, columns = 0): bool =
       else: error(my, my.bufpos, my.sep & " expected")
       break
   
-  setlen(my.row, col)
+  setLen(my.row, col)
   result = col > 0
   if result and col != columns and columns > 0: 
     error(my, oldpos+1, $columns & " columns expected, but found " & 
diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim
index b325bd1f5..de00bc76d 100644
--- a/lib/pure/parseopt.nim
+++ b/lib/pure/parseopt.nim
@@ -59,7 +59,7 @@ when declared(os.paramCount):
     result.val = TaintedString""
 
 proc parseWord(s: string, i: int, w: var string, 
-               delim: CharSet = {'\x09', ' ', '\0'}): int = 
+               delim: set[char] = {'\x09', ' ', '\0'}): int = 
   result = i
   if s[result] == '\"': 
     inc(result)
diff --git a/lib/pure/parseopt2.nim b/lib/pure/parseopt2.nim
index c283a5edf..5b1f50958 100644
--- a/lib/pure/parseopt2.nim
+++ b/lib/pure/parseopt2.nim
@@ -31,7 +31,7 @@ type
     cmdLongOption,            ## a long option ``--option`` detected
     cmdShortOption            ## a short option ``-c`` detected
   OptParser* =
-      object of TObject ## this object implements the command line parser
+      object of RootObj ## this object implements the command line parser
     cmd: seq[string]
     pos: int
     remainingShortOptions: string
@@ -102,10 +102,10 @@ proc next(p: var OptParser) =
   let token = p.cmd[p.pos]
   p.pos += 1
 
-  if token.startswith("--"):
+  if token.startsWith("--"):
     p.kind = cmdLongOption
     nextOption(p, token[2..token.len-1], allowEmpty=true)
-  elif token.startswith("-"):
+  elif token.startsWith("-"):
     p.kind = cmdShortOption
     nextOption(p, token[1..token.len-1], allowEmpty=true)
   else:
diff --git a/lib/pure/parsesql.nim b/lib/pure/parsesql.nim
index fcca0aa44..bb4ede779 100644
--- a/lib/pure/parsesql.nim
+++ b/lib/pure/parsesql.nim
@@ -64,12 +64,12 @@ proc close(L: var SqlLexer) =
 
 proc getColumn(L: SqlLexer): int = 
   ## get the current column the parser has arrived at.
-  result = getColNumber(L, L.bufPos)
+  result = getColNumber(L, L.bufpos)
 
 proc getLine(L: SqlLexer): int = 
-  result = L.linenumber
+  result = L.lineNumber
 
-proc handleHexChar(c: var TSqlLexer, xi: var int) = 
+proc handleHexChar(c: var SqlLexer, xi: var int) = 
   case c.buf[c.bufpos]
   of '0'..'9': 
     xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0'))
@@ -83,76 +83,76 @@ proc handleHexChar(c: var TSqlLexer, xi: var int) =
   else: 
     discard
 
-proc handleOctChar(c: var TSqlLexer, xi: var int) = 
+proc handleOctChar(c: var SqlLexer, xi: var int) = 
   if c.buf[c.bufpos] in {'0'..'7'}:
     xi = (xi shl 3) or (ord(c.buf[c.bufpos]) - ord('0'))
     inc(c.bufpos)
 
-proc getEscapedChar(c: var TSqlLexer, tok: var TToken) = 
+proc getEscapedChar(c: var SqlLexer, tok: var Token) = 
   inc(c.bufpos)
   case c.buf[c.bufpos]
   of 'n', 'N': 
     add(tok.literal, '\L')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'r', 'R', 'c', 'C': 
     add(tok.literal, '\c')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'l', 'L': 
     add(tok.literal, '\L')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'f', 'F': 
     add(tok.literal, '\f')
     inc(c.bufpos)
   of 'e', 'E': 
     add(tok.literal, '\e')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'a', 'A': 
     add(tok.literal, '\a')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'b', 'B': 
     add(tok.literal, '\b')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'v', 'V': 
     add(tok.literal, '\v')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 't', 'T': 
     add(tok.literal, '\t')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of '\'', '\"': 
     add(tok.literal, c.buf[c.bufpos])
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of '\\': 
     add(tok.literal, '\\')
-    Inc(c.bufpos)
+    inc(c.bufpos)
   of 'x', 'X': 
     inc(c.bufpos)
     var xi = 0
     handleHexChar(c, xi)
     handleHexChar(c, xi)
-    add(tok.literal, Chr(xi))
+    add(tok.literal, chr(xi))
   of '0'..'7': 
     var xi = 0
     handleOctChar(c, xi)
     handleOctChar(c, xi)
     handleOctChar(c, xi)
-    if (xi <= 255): add(tok.literal, Chr(xi))
+    if (xi <= 255): add(tok.literal, chr(xi))
     else: tok.kind = tkInvalid
   else: tok.kind = tkInvalid
   
-proc handleCRLF(c: var TSqlLexer, pos: int): int = 
+proc handleCRLF(c: var SqlLexer, pos: int): int = 
   case c.buf[pos]
   of '\c': result = lexbase.handleCR(c, pos)
   of '\L': result = lexbase.handleLF(c, pos)
   else: result = pos
 
-proc skip(c: var TSqlLexer) = 
+proc skip(c: var SqlLexer) = 
   var pos = c.bufpos
   var buf = c.buf
   var nested = 0
   while true: 
     case buf[pos]
     of ' ', '\t': 
-      Inc(pos)
+      inc(pos)
     of '-':
       if buf[pos+1] == '-':
         while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos)
@@ -189,8 +189,8 @@ proc skip(c: var TSqlLexer) =
       break                   # EndOfFile also leaves the loop
   c.bufpos = pos
   
-proc getString(c: var TSqlLexer, tok: var TToken, kind: TokKind) = 
-  var pos = c.bufPos + 1
+proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) = 
+  var pos = c.bufpos + 1
   var buf = c.buf
   tok.kind = kind
   block parseLoop:
@@ -208,16 +208,16 @@ proc getString(c: var TSqlLexer, tok: var TToken, kind: TokKind) =
           tok.kind = tkInvalid
           break parseLoop
         elif (ch == '\\') and kind == tkEscapeConstant: 
-          c.bufPos = pos
+          c.bufpos = pos
           getEscapedChar(c, tok)
-          pos = c.bufPos
+          pos = c.bufpos
         else: 
           add(tok.literal, ch)
-          Inc(pos)
+          inc(pos)
       c.bufpos = pos
-      var line = c.linenumber
+      var line = c.lineNumber
       skip(c)
-      if c.linenumber > line:
+      if c.lineNumber > line:
         # a new line whitespace has been parsed, so we check if the string
         # continues after the whitespace:
         buf = c.buf # may have been reallocated
@@ -227,8 +227,8 @@ proc getString(c: var TSqlLexer, tok: var TToken, kind: TokKind) =
       else: break parseLoop
   c.bufpos = pos
 
-proc getDollarString(c: var TSqlLexer, tok: var TToken) = 
-  var pos = c.bufPos + 1
+proc getDollarString(c: var SqlLexer, tok: var Token) = 
+  var pos = c.bufpos + 1
   var buf = c.buf
   tok.kind = tkDollarQuotedConstant
   var tag = "$"
@@ -242,7 +242,7 @@ proc getDollarString(c: var TSqlLexer, tok: var TToken) =
   while true:
     case buf[pos]
     of '\c', '\L': 
-      pos = HandleCRLF(c, pos)
+      pos = handleCRLF(c, pos)
       buf = c.buf
       add(tok.literal, "\L")
     of '\0':
@@ -263,19 +263,19 @@ proc getDollarString(c: var TSqlLexer, tok: var TToken) =
       inc(pos)
   c.bufpos = pos
 
-proc getSymbol(c: var TSqlLexer, tok: var TToken) = 
+proc getSymbol(c: var SqlLexer, tok: var Token) = 
   var pos = c.bufpos
   var buf = c.buf
   while true: 
     add(tok.literal, buf[pos])
-    Inc(pos)
+    inc(pos)
     if buf[pos] notin {'a'..'z','A'..'Z','0'..'9','_','$', '\128'..'\255'}:
       break
   c.bufpos = pos
   tok.kind = tkIdentifier
 
-proc getQuotedIdentifier(c: var TSqlLexer, tok: var TToken) = 
-  var pos = c.bufPos + 1
+proc getQuotedIdentifier(c: var SqlLexer, tok: var Token) = 
+  var pos = c.bufpos + 1
   var buf = c.buf
   tok.kind = tkQuotedIdentifier
   while true:
@@ -292,11 +292,11 @@ proc getQuotedIdentifier(c: var TSqlLexer, tok: var TToken) =
       break
     else:
       add(tok.literal, ch)
-      Inc(pos)
+      inc(pos)
   c.bufpos = pos
 
-proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
-  var pos = c.bufPos + 1
+proc getBitHexString(c: var SqlLexer, tok: var Token, validChars: set[char]) =
+  var pos = c.bufpos + 1
   var buf = c.buf
   block parseLoop:
     while true:
@@ -304,7 +304,7 @@ proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
         var ch = buf[pos]
         if ch in validChars:
           add(tok.literal, ch)
-          Inc(pos)          
+          inc(pos)          
         elif ch == '\'':
           inc(pos)
           break
@@ -312,9 +312,9 @@ proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
           tok.kind = tkInvalid
           break parseLoop
       c.bufpos = pos
-      var line = c.linenumber
+      var line = c.lineNumber
       skip(c)
-      if c.linenumber > line:
+      if c.lineNumber > line:
         # a new line whitespace has been parsed, so we check if the string
         # continues after the whitespace:
         buf = c.buf # may have been reallocated
@@ -324,9 +324,9 @@ proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
       else: break parseLoop
   c.bufpos = pos
 
-proc getNumeric(c: var TSqlLexer, tok: var TToken) =
+proc getNumeric(c: var SqlLexer, tok: var Token) =
   tok.kind = tkInteger
-  var pos = c.bufPos
+  var pos = c.bufpos
   var buf = c.buf
   while buf[pos] in Digits:
     add(tok.literal, buf[pos])
@@ -355,11 +355,11 @@ proc getNumeric(c: var TSqlLexer, tok: var TToken) =
       tok.kind = tkInvalid
   c.bufpos = pos  
 
-proc getOperator(c: var TSqlLexer, tok: var TToken) =
+proc getOperator(c: var SqlLexer, tok: var Token) =
   const operators = {'+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%',
                      '^', '&', '|', '`', '?'}
   tok.kind = tkOperator
-  var pos = c.bufPos
+  var pos = c.bufpos
   var buf = c.buf
   var trailingPlusMinus = false
   while true:
@@ -381,14 +381,14 @@ proc getOperator(c: var TSqlLexer, tok: var TToken) =
     inc(pos)
   c.bufpos = pos
 
-proc getTok(c: var TSqlLexer, tok: var TToken) = 
+proc getTok(c: var SqlLexer, tok: var Token) = 
   tok.kind = tkInvalid
-  setlen(tok.literal, 0)
+  setLen(tok.literal, 0)
   skip(c)
   case c.buf[c.bufpos]
   of ';': 
-    tok.kind = tkSemiColon
-    inc(c.bufPos)
+    tok.kind = tkSemicolon
+    inc(c.bufpos)
     add(tok.literal, ';')
   of ',':
     tok.kind = tkComma
@@ -399,19 +399,19 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
     inc(c.bufpos)
     add(tok.literal, ':')
   of 'e', 'E': 
-    if c.buf[c.bufPos + 1] == '\'': 
-      Inc(c.bufPos)
+    if c.buf[c.bufpos + 1] == '\'': 
+      inc(c.bufpos)
       getString(c, tok, tkEscapeConstant)
     else: 
       getSymbol(c, tok)
   of 'b', 'B':
-    if c.buf[c.bufPos + 1] == '\'':
+    if c.buf[c.bufpos + 1] == '\'':
       tok.kind = tkBitStringConstant
       getBitHexString(c, tok, {'0'..'1'})
     else:
       getSymbol(c, tok)
   of 'x', 'X':
-    if c.buf[c.bufPos + 1] == '\'':
+    if c.buf[c.bufpos + 1] == '\'':
       tok.kind = tkHexStringConstant
       getBitHexString(c, tok, {'a'..'f','A'..'F','0'..'9'})
     else:
@@ -423,18 +423,18 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
     add(tok.literal, '[')
   of ']': 
     tok.kind = tkBracketRi
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, ']')
   of '(':
     tok.kind = tkParLe
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, '(')
   of ')':
     tok.kind = tkParRi
-    Inc(c.bufpos)
+    inc(c.bufpos)
     add(tok.literal, ')')
   of '.': 
-    if c.buf[c.bufPos + 1] in Digits:
+    if c.buf[c.bufpos + 1] in Digits:
       getNumeric(c, tok)
     else:
       tok.kind = tkDot
@@ -456,7 +456,7 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
     add(tok.literal, c.buf[c.bufpos])
     inc(c.bufpos)
   
-proc errorStr(L: TSqlLexer, msg: string): string = 
+proc errorStr(L: SqlLexer, msg: string): string = 
   result = "$1($2, $3) Error: $4" % [L.filename, $getLine(L), $getColumn(L), msg]
 
 
@@ -819,7 +819,7 @@ proc parseColumnDef(p: var SqlParser): SqlNode =
   result.add(parseDataType(p))
   parseColumnConstraints(p, result)  
 
-proc parseIfNotExists(p: var SqlParser, k: TSqlNodeKind): SqlNode = 
+proc parseIfNotExists(p: var SqlParser, k: SqlNodeKind): SqlNode = 
   getTok(p)
   if isKeyw(p, "if"):
     getTok(p)
@@ -1076,10 +1076,10 @@ proc parseStmt(p: var SqlParser): SqlNode =
   else:
     sqlError(p, "CREATE expected")
 
-proc open(p: var SqlParser, input: PStream, filename: string) =
+proc open(p: var SqlParser, input: Stream, filename: string) =
   ## opens the parser `p` and assigns the input stream `input` to it.
   ## `filename` is only used for error messages.
-  open(TSqlLexer(p), input, filename)
+  open(SqlLexer(p), input, filename)
   p.tok.kind = tkInvalid
   p.tok.literal = ""
   getTok(p)
@@ -1090,16 +1090,16 @@ proc parse(p: var SqlParser): SqlNode =
   result = newNode(nkStmtList)
   while p.tok.kind != tkEof:
     var s = parseStmt(p)
-    eat(p, tkSemiColon)
+    eat(p, tkSemicolon)
     result.add(s)
   if result.len == 1:
     result = result.sons[0]
   
 proc close(p: var SqlParser) =
   ## closes the parser `p`. The associated input stream is closed too.
-  close(TSqlLexer(p))
+  close(SqlLexer(p))
 
-proc parseSQL*(input: PStream, filename: string): SqlNode =
+proc parseSQL*(input: Stream, filename: string): SqlNode =
   ## parses the SQL from `input` into an AST and returns the AST. 
   ## `filename` is only used for error messages.
   ## Syntax errors raise an `EInvalidSql` exception.
diff --git a/lib/pure/parseurl.nim b/lib/pure/parseurl.nim
index 2637a879d..32e69b89a 100644
--- a/lib/pure/parseurl.nim
+++ b/lib/pure/parseurl.nim
@@ -31,12 +31,12 @@ proc parseUrl*(url: string): Url {.deprecated.} =
   var temp = ""
   
   if url[i] != '/': # url isn't a relative path
-    while True:
+    while true:
       # Scheme
       if url[i] == ':':
         if url[i+1] == '/' and url[i+2] == '/':
           scheme = temp
-          temp.setlen(0)
+          temp.setLen(0)
           inc(i, 3) # Skip the //
       # Authority(username, password)
       if url[i] == '@':
@@ -45,7 +45,7 @@ proc parseUrl*(url: string): Url {.deprecated.} =
         if colon >= 0:
           password = username.substr(colon+1)
           username = username.substr(0, colon-1)
-        temp.setlen(0)
+        temp.setLen(0)
         inc(i) #Skip the @ 
       # hostname(subdomain, domain, port)
       if url[i] == '/' or url[i] == '\0':
@@ -55,7 +55,7 @@ proc parseUrl*(url: string): Url {.deprecated.} =
           port = hostname.substr(colon+1)
           hostname = hostname.substr(0, colon-1)
         
-        temp.setlen(0)
+        temp.setLen(0)
         break
       
       temp.add(url[i])
@@ -63,16 +63,16 @@ proc parseUrl*(url: string): Url {.deprecated.} =
 
   if url[i] == '/': inc(i) # Skip the '/'
   # Path
-  while True:
+  while true:
     if url[i] == '?':
       path = temp
-      temp.setlen(0)
+      temp.setLen(0)
     if url[i] == '#':
       if temp[0] == '?':
         query = temp
       else:
         path = temp
-      temp.setlen(0)
+      temp.setLen(0)
       
     if url[i] == '\0':
       if temp[0] == '?':