several modules changed

This commit is contained in:
Araq 2014-08-28 02:21:49 +02:00
commit bf9764e563
7 changed files with 80 additions and 81 deletions

View file

@ -89,5 +89,5 @@ proc generatedTime*(oid: Oid): Time =
result = Time(tmp) result = Time(tmp)
when isMainModule: when isMainModule:
let xo = genOID() let xo = genOid()
echo xo.generatedTime echo xo.generatedTime

View file

@ -38,7 +38,7 @@ type
cfgError ## an error ocurred during parsing cfgError ## an error ocurred during parsing
CfgEvent* = object of RootObj ## describes a parsing event 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 cfgEof: nil
of cfgSectionStart: of cfgSectionStart:
section*: string ## `section` contains the name of the section*: string ## `section` contains the name of the
@ -70,12 +70,11 @@ type
# implementation # implementation
const 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 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".} = lineOffset = 0) {.rtl, extern: "npc$1".} =
## initializes the parser with an input stream. `Filename` is only used ## initializes the parser with an input stream. `Filename` is only used
## for nice error messages. `lineOffset` can be used to influence the line ## 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')) xi = (xi * 10) + (ord(c.buf[c.bufpos]) - ord('0'))
inc(c.bufpos) inc(c.bufpos)
proc getEscapedChar(c: var CfgParser, tok: var TToken) = proc getEscapedChar(c: var CfgParser, tok: var Token) =
inc(c.bufpos) # skip '\' inc(c.bufpos) # skip '\'
case c.buf[c.bufpos] case c.buf[c.bufpos]
of 'n', 'N': of 'n', 'N':

View file

@ -155,7 +155,7 @@ proc readRow*(my: var CsvParser, columns = 0): bool =
else: error(my, my.bufpos, my.sep & " expected") else: error(my, my.bufpos, my.sep & " expected")
break break
setlen(my.row, col) setLen(my.row, col)
result = col > 0 result = col > 0
if result and col != columns and columns > 0: if result and col != columns and columns > 0:
error(my, oldpos+1, $columns & " columns expected, but found " & error(my, oldpos+1, $columns & " columns expected, but found " &

View file

@ -59,7 +59,7 @@ when declared(os.paramCount):
result.val = TaintedString"" result.val = TaintedString""
proc parseWord(s: string, i: int, w: var string, proc parseWord(s: string, i: int, w: var string,
delim: CharSet = {'\x09', ' ', '\0'}): int = delim: set[char] = {'\x09', ' ', '\0'}): int =
result = i result = i
if s[result] == '\"': if s[result] == '\"':
inc(result) inc(result)

View file

@ -31,7 +31,7 @@ type
cmdLongOption, ## a long option ``--option`` detected cmdLongOption, ## a long option ``--option`` detected
cmdShortOption ## a short option ``-c`` detected cmdShortOption ## a short option ``-c`` detected
OptParser* = OptParser* =
object of TObject ## this object implements the command line parser object of RootObj ## this object implements the command line parser
cmd: seq[string] cmd: seq[string]
pos: int pos: int
remainingShortOptions: string remainingShortOptions: string
@ -102,10 +102,10 @@ proc next(p: var OptParser) =
let token = p.cmd[p.pos] let token = p.cmd[p.pos]
p.pos += 1 p.pos += 1
if token.startswith("--"): if token.startsWith("--"):
p.kind = cmdLongOption p.kind = cmdLongOption
nextOption(p, token[2..token.len-1], allowEmpty=true) nextOption(p, token[2..token.len-1], allowEmpty=true)
elif token.startswith("-"): elif token.startsWith("-"):
p.kind = cmdShortOption p.kind = cmdShortOption
nextOption(p, token[1..token.len-1], allowEmpty=true) nextOption(p, token[1..token.len-1], allowEmpty=true)
else: else:

View file

@ -64,12 +64,12 @@ proc close(L: var SqlLexer) =
proc getColumn(L: SqlLexer): int = proc getColumn(L: SqlLexer): int =
## get the current column the parser has arrived at. ## get the current column the parser has arrived at.
result = getColNumber(L, L.bufPos) result = getColNumber(L, L.bufpos)
proc getLine(L: SqlLexer): int = 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] case c.buf[c.bufpos]
of '0'..'9': of '0'..'9':
xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('0')) 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: else:
discard 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'}: if c.buf[c.bufpos] in {'0'..'7'}:
xi = (xi shl 3) or (ord(c.buf[c.bufpos]) - ord('0')) xi = (xi shl 3) or (ord(c.buf[c.bufpos]) - ord('0'))
inc(c.bufpos) inc(c.bufpos)
proc getEscapedChar(c: var TSqlLexer, tok: var TToken) = proc getEscapedChar(c: var SqlLexer, tok: var Token) =
inc(c.bufpos) inc(c.bufpos)
case c.buf[c.bufpos] case c.buf[c.bufpos]
of 'n', 'N': of 'n', 'N':
add(tok.literal, '\L') add(tok.literal, '\L')
Inc(c.bufpos) inc(c.bufpos)
of 'r', 'R', 'c', 'C': of 'r', 'R', 'c', 'C':
add(tok.literal, '\c') add(tok.literal, '\c')
Inc(c.bufpos) inc(c.bufpos)
of 'l', 'L': of 'l', 'L':
add(tok.literal, '\L') add(tok.literal, '\L')
Inc(c.bufpos) inc(c.bufpos)
of 'f', 'F': of 'f', 'F':
add(tok.literal, '\f') add(tok.literal, '\f')
inc(c.bufpos) inc(c.bufpos)
of 'e', 'E': of 'e', 'E':
add(tok.literal, '\e') add(tok.literal, '\e')
Inc(c.bufpos) inc(c.bufpos)
of 'a', 'A': of 'a', 'A':
add(tok.literal, '\a') add(tok.literal, '\a')
Inc(c.bufpos) inc(c.bufpos)
of 'b', 'B': of 'b', 'B':
add(tok.literal, '\b') add(tok.literal, '\b')
Inc(c.bufpos) inc(c.bufpos)
of 'v', 'V': of 'v', 'V':
add(tok.literal, '\v') add(tok.literal, '\v')
Inc(c.bufpos) inc(c.bufpos)
of 't', 'T': of 't', 'T':
add(tok.literal, '\t') add(tok.literal, '\t')
Inc(c.bufpos) inc(c.bufpos)
of '\'', '\"': of '\'', '\"':
add(tok.literal, c.buf[c.bufpos]) add(tok.literal, c.buf[c.bufpos])
Inc(c.bufpos) inc(c.bufpos)
of '\\': of '\\':
add(tok.literal, '\\') add(tok.literal, '\\')
Inc(c.bufpos) inc(c.bufpos)
of 'x', 'X': of 'x', 'X':
inc(c.bufpos) inc(c.bufpos)
var xi = 0 var xi = 0
handleHexChar(c, xi) handleHexChar(c, xi)
handleHexChar(c, xi) handleHexChar(c, xi)
add(tok.literal, Chr(xi)) add(tok.literal, chr(xi))
of '0'..'7': of '0'..'7':
var xi = 0 var xi = 0
handleOctChar(c, xi) handleOctChar(c, xi)
handleOctChar(c, xi) 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
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] case c.buf[pos]
of '\c': result = lexbase.handleCR(c, pos) of '\c': result = lexbase.handleCR(c, pos)
of '\L': result = lexbase.handleLF(c, pos) of '\L': result = lexbase.handleLF(c, pos)
else: result = pos else: result = pos
proc skip(c: var TSqlLexer) = proc skip(c: var SqlLexer) =
var pos = c.bufpos var pos = c.bufpos
var buf = c.buf var buf = c.buf
var nested = 0 var nested = 0
while true: while true:
case buf[pos] case buf[pos]
of ' ', '\t': of ' ', '\t':
Inc(pos) inc(pos)
of '-': of '-':
if buf[pos+1] == '-': if buf[pos+1] == '-':
while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos) 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 break # EndOfFile also leaves the loop
c.bufpos = pos c.bufpos = pos
proc getString(c: var TSqlLexer, tok: var TToken, kind: TokKind) = proc getString(c: var SqlLexer, tok: var Token, kind: TokKind) =
var pos = c.bufPos + 1 var pos = c.bufpos + 1
var buf = c.buf var buf = c.buf
tok.kind = kind tok.kind = kind
block parseLoop: block parseLoop:
@ -208,16 +208,16 @@ proc getString(c: var TSqlLexer, tok: var TToken, kind: TokKind) =
tok.kind = tkInvalid tok.kind = tkInvalid
break parseLoop break parseLoop
elif (ch == '\\') and kind == tkEscapeConstant: elif (ch == '\\') and kind == tkEscapeConstant:
c.bufPos = pos c.bufpos = pos
getEscapedChar(c, tok) getEscapedChar(c, tok)
pos = c.bufPos pos = c.bufpos
else: else:
add(tok.literal, ch) add(tok.literal, ch)
Inc(pos) inc(pos)
c.bufpos = pos c.bufpos = pos
var line = c.linenumber var line = c.lineNumber
skip(c) skip(c)
if c.linenumber > line: if c.lineNumber > line:
# a new line whitespace has been parsed, so we check if the string # a new line whitespace has been parsed, so we check if the string
# continues after the whitespace: # continues after the whitespace:
buf = c.buf # may have been reallocated buf = c.buf # may have been reallocated
@ -227,8 +227,8 @@ proc getString(c: var TSqlLexer, tok: var TToken, kind: TokKind) =
else: break parseLoop else: break parseLoop
c.bufpos = pos c.bufpos = pos
proc getDollarString(c: var TSqlLexer, tok: var TToken) = proc getDollarString(c: var SqlLexer, tok: var Token) =
var pos = c.bufPos + 1 var pos = c.bufpos + 1
var buf = c.buf var buf = c.buf
tok.kind = tkDollarQuotedConstant tok.kind = tkDollarQuotedConstant
var tag = "$" var tag = "$"
@ -242,7 +242,7 @@ proc getDollarString(c: var TSqlLexer, tok: var TToken) =
while true: while true:
case buf[pos] case buf[pos]
of '\c', '\L': of '\c', '\L':
pos = HandleCRLF(c, pos) pos = handleCRLF(c, pos)
buf = c.buf buf = c.buf
add(tok.literal, "\L") add(tok.literal, "\L")
of '\0': of '\0':
@ -263,19 +263,19 @@ proc getDollarString(c: var TSqlLexer, tok: var TToken) =
inc(pos) inc(pos)
c.bufpos = 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 pos = c.bufpos
var buf = c.buf var buf = c.buf
while true: while true:
add(tok.literal, buf[pos]) add(tok.literal, buf[pos])
Inc(pos) inc(pos)
if buf[pos] notin {'a'..'z','A'..'Z','0'..'9','_','$', '\128'..'\255'}: if buf[pos] notin {'a'..'z','A'..'Z','0'..'9','_','$', '\128'..'\255'}:
break break
c.bufpos = pos c.bufpos = pos
tok.kind = tkIdentifier tok.kind = tkIdentifier
proc getQuotedIdentifier(c: var TSqlLexer, tok: var TToken) = proc getQuotedIdentifier(c: var SqlLexer, tok: var Token) =
var pos = c.bufPos + 1 var pos = c.bufpos + 1
var buf = c.buf var buf = c.buf
tok.kind = tkQuotedIdentifier tok.kind = tkQuotedIdentifier
while true: while true:
@ -292,11 +292,11 @@ proc getQuotedIdentifier(c: var TSqlLexer, tok: var TToken) =
break break
else: else:
add(tok.literal, ch) add(tok.literal, ch)
Inc(pos) inc(pos)
c.bufpos = pos c.bufpos = pos
proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) = proc getBitHexString(c: var SqlLexer, tok: var Token, validChars: set[char]) =
var pos = c.bufPos + 1 var pos = c.bufpos + 1
var buf = c.buf var buf = c.buf
block parseLoop: block parseLoop:
while true: while true:
@ -304,7 +304,7 @@ proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
var ch = buf[pos] var ch = buf[pos]
if ch in validChars: if ch in validChars:
add(tok.literal, ch) add(tok.literal, ch)
Inc(pos) inc(pos)
elif ch == '\'': elif ch == '\'':
inc(pos) inc(pos)
break break
@ -312,9 +312,9 @@ proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
tok.kind = tkInvalid tok.kind = tkInvalid
break parseLoop break parseLoop
c.bufpos = pos c.bufpos = pos
var line = c.linenumber var line = c.lineNumber
skip(c) skip(c)
if c.linenumber > line: if c.lineNumber > line:
# a new line whitespace has been parsed, so we check if the string # a new line whitespace has been parsed, so we check if the string
# continues after the whitespace: # continues after the whitespace:
buf = c.buf # may have been reallocated buf = c.buf # may have been reallocated
@ -324,9 +324,9 @@ proc getBitHexString(c: var TSqlLexer, tok: var TToken, validChars: TCharSet) =
else: break parseLoop else: break parseLoop
c.bufpos = pos c.bufpos = pos
proc getNumeric(c: var TSqlLexer, tok: var TToken) = proc getNumeric(c: var SqlLexer, tok: var Token) =
tok.kind = tkInteger tok.kind = tkInteger
var pos = c.bufPos var pos = c.bufpos
var buf = c.buf var buf = c.buf
while buf[pos] in Digits: while buf[pos] in Digits:
add(tok.literal, buf[pos]) add(tok.literal, buf[pos])
@ -355,11 +355,11 @@ proc getNumeric(c: var TSqlLexer, tok: var TToken) =
tok.kind = tkInvalid tok.kind = tkInvalid
c.bufpos = pos c.bufpos = pos
proc getOperator(c: var TSqlLexer, tok: var TToken) = proc getOperator(c: var SqlLexer, tok: var Token) =
const operators = {'+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%', const operators = {'+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%',
'^', '&', '|', '`', '?'} '^', '&', '|', '`', '?'}
tok.kind = tkOperator tok.kind = tkOperator
var pos = c.bufPos var pos = c.bufpos
var buf = c.buf var buf = c.buf
var trailingPlusMinus = false var trailingPlusMinus = false
while true: while true:
@ -381,14 +381,14 @@ proc getOperator(c: var TSqlLexer, tok: var TToken) =
inc(pos) inc(pos)
c.bufpos = pos c.bufpos = pos
proc getTok(c: var TSqlLexer, tok: var TToken) = proc getTok(c: var SqlLexer, tok: var Token) =
tok.kind = tkInvalid tok.kind = tkInvalid
setlen(tok.literal, 0) setLen(tok.literal, 0)
skip(c) skip(c)
case c.buf[c.bufpos] case c.buf[c.bufpos]
of ';': of ';':
tok.kind = tkSemiColon tok.kind = tkSemicolon
inc(c.bufPos) inc(c.bufpos)
add(tok.literal, ';') add(tok.literal, ';')
of ',': of ',':
tok.kind = tkComma tok.kind = tkComma
@ -399,19 +399,19 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
inc(c.bufpos) inc(c.bufpos)
add(tok.literal, ':') add(tok.literal, ':')
of 'e', 'E': of 'e', 'E':
if c.buf[c.bufPos + 1] == '\'': if c.buf[c.bufpos + 1] == '\'':
Inc(c.bufPos) inc(c.bufpos)
getString(c, tok, tkEscapeConstant) getString(c, tok, tkEscapeConstant)
else: else:
getSymbol(c, tok) getSymbol(c, tok)
of 'b', 'B': of 'b', 'B':
if c.buf[c.bufPos + 1] == '\'': if c.buf[c.bufpos + 1] == '\'':
tok.kind = tkBitStringConstant tok.kind = tkBitStringConstant
getBitHexString(c, tok, {'0'..'1'}) getBitHexString(c, tok, {'0'..'1'})
else: else:
getSymbol(c, tok) getSymbol(c, tok)
of 'x', 'X': of 'x', 'X':
if c.buf[c.bufPos + 1] == '\'': if c.buf[c.bufpos + 1] == '\'':
tok.kind = tkHexStringConstant tok.kind = tkHexStringConstant
getBitHexString(c, tok, {'a'..'f','A'..'F','0'..'9'}) getBitHexString(c, tok, {'a'..'f','A'..'F','0'..'9'})
else: else:
@ -423,18 +423,18 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
add(tok.literal, '[') add(tok.literal, '[')
of ']': of ']':
tok.kind = tkBracketRi tok.kind = tkBracketRi
Inc(c.bufpos) inc(c.bufpos)
add(tok.literal, ']') add(tok.literal, ']')
of '(': of '(':
tok.kind = tkParLe tok.kind = tkParLe
Inc(c.bufpos) inc(c.bufpos)
add(tok.literal, '(') add(tok.literal, '(')
of ')': of ')':
tok.kind = tkParRi tok.kind = tkParRi
Inc(c.bufpos) inc(c.bufpos)
add(tok.literal, ')') add(tok.literal, ')')
of '.': of '.':
if c.buf[c.bufPos + 1] in Digits: if c.buf[c.bufpos + 1] in Digits:
getNumeric(c, tok) getNumeric(c, tok)
else: else:
tok.kind = tkDot tok.kind = tkDot
@ -456,7 +456,7 @@ proc getTok(c: var TSqlLexer, tok: var TToken) =
add(tok.literal, c.buf[c.bufpos]) add(tok.literal, c.buf[c.bufpos])
inc(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] 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)) result.add(parseDataType(p))
parseColumnConstraints(p, result) parseColumnConstraints(p, result)
proc parseIfNotExists(p: var SqlParser, k: TSqlNodeKind): SqlNode = proc parseIfNotExists(p: var SqlParser, k: SqlNodeKind): SqlNode =
getTok(p) getTok(p)
if isKeyw(p, "if"): if isKeyw(p, "if"):
getTok(p) getTok(p)
@ -1076,10 +1076,10 @@ proc parseStmt(p: var SqlParser): SqlNode =
else: else:
sqlError(p, "CREATE expected") 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. ## opens the parser `p` and assigns the input stream `input` to it.
## `filename` is only used for error messages. ## `filename` is only used for error messages.
open(TSqlLexer(p), input, filename) open(SqlLexer(p), input, filename)
p.tok.kind = tkInvalid p.tok.kind = tkInvalid
p.tok.literal = "" p.tok.literal = ""
getTok(p) getTok(p)
@ -1090,16 +1090,16 @@ proc parse(p: var SqlParser): SqlNode =
result = newNode(nkStmtList) result = newNode(nkStmtList)
while p.tok.kind != tkEof: while p.tok.kind != tkEof:
var s = parseStmt(p) var s = parseStmt(p)
eat(p, tkSemiColon) eat(p, tkSemicolon)
result.add(s) result.add(s)
if result.len == 1: if result.len == 1:
result = result.sons[0] result = result.sons[0]
proc close(p: var SqlParser) = proc close(p: var SqlParser) =
## closes the parser `p`. The associated input stream is closed too. ## 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. ## parses the SQL from `input` into an AST and returns the AST.
## `filename` is only used for error messages. ## `filename` is only used for error messages.
## Syntax errors raise an `EInvalidSql` exception. ## Syntax errors raise an `EInvalidSql` exception.

View file

@ -31,12 +31,12 @@ proc parseUrl*(url: string): Url {.deprecated.} =
var temp = "" var temp = ""
if url[i] != '/': # url isn't a relative path if url[i] != '/': # url isn't a relative path
while True: while true:
# Scheme # Scheme
if url[i] == ':': if url[i] == ':':
if url[i+1] == '/' and url[i+2] == '/': if url[i+1] == '/' and url[i+2] == '/':
scheme = temp scheme = temp
temp.setlen(0) temp.setLen(0)
inc(i, 3) # Skip the // inc(i, 3) # Skip the //
# Authority(username, password) # Authority(username, password)
if url[i] == '@': if url[i] == '@':
@ -45,7 +45,7 @@ proc parseUrl*(url: string): Url {.deprecated.} =
if colon >= 0: if colon >= 0:
password = username.substr(colon+1) password = username.substr(colon+1)
username = username.substr(0, colon-1) username = username.substr(0, colon-1)
temp.setlen(0) temp.setLen(0)
inc(i) #Skip the @ inc(i) #Skip the @
# hostname(subdomain, domain, port) # hostname(subdomain, domain, port)
if url[i] == '/' or url[i] == '\0': if url[i] == '/' or url[i] == '\0':
@ -55,7 +55,7 @@ proc parseUrl*(url: string): Url {.deprecated.} =
port = hostname.substr(colon+1) port = hostname.substr(colon+1)
hostname = hostname.substr(0, colon-1) hostname = hostname.substr(0, colon-1)
temp.setlen(0) temp.setLen(0)
break break
temp.add(url[i]) temp.add(url[i])
@ -63,16 +63,16 @@ proc parseUrl*(url: string): Url {.deprecated.} =
if url[i] == '/': inc(i) # Skip the '/' if url[i] == '/': inc(i) # Skip the '/'
# Path # Path
while True: while true:
if url[i] == '?': if url[i] == '?':
path = temp path = temp
temp.setlen(0) temp.setLen(0)
if url[i] == '#': if url[i] == '#':
if temp[0] == '?': if temp[0] == '?':
query = temp query = temp
else: else:
path = temp path = temp
temp.setlen(0) temp.setLen(0)
if url[i] == '\0': if url[i] == '\0':
if temp[0] == '?': if temp[0] == '?':