about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-12-05 19:55:13 +0100
committerbptato <nincsnevem662@gmail.com>2021-12-05 19:55:13 +0100
commit31117cad22df103f84cfbe97dff08debcde72a66 (patch)
tree5f9e4b0515e63e953758fe10da9fc52d45171e0f /src/css
parent0f9c94abf5ff9e4f2ce4d8d49424c9458bbf6229 (diff)
downloadchawan-31117cad22df103f84cfbe97dff08debcde72a66.tar.gz
Change configuration format to toml
Diffstat (limited to 'src/css')
-rw-r--r--src/css/parser.nim48
1 files changed, 1 insertions, 47 deletions
diff --git a/src/css/parser.nim b/src/css/parser.nim
index ec2b6591..0c1f91cc 100644
--- a/src/css/parser.nim
+++ b/src/css/parser.nim
@@ -1,6 +1,3 @@
-# CSS tokenizer and parser. It kinda works, though certain less specific
-# details of the specification might have been implemented incorrectly.
-
 import unicode
 import streams
 import math
@@ -73,49 +70,6 @@ type
 func `==`*(a: CSSParsedItem, b: CSSTokenType): bool =
   return a of CSSToken and CSSToken(a).tokenType == b
 
-func toNumber(s: seq[Rune]): float64 =
-  var sign = 1
-  var t = 1
-  var d = 0
-  var integer: float64 = 0
-  var f: float64 = 0
-  var e: float64 = 0
-
-  var i = 0
-  if i < s.len and s[i] == Rune('-'):
-    sign = -1
-    inc i
-  elif i < s.len and s[i] == Rune('+'):
-    inc i
-
-  while i < s.len and isDigitAscii(s[i]):
-    integer *= 10
-    integer += float64(decValue(s[i]))
-    inc i
-
-  if i < s.len and s[i] == Rune('.'):
-    inc i
-    while i < s.len and isDigitAscii(s[i]):
-      f *= 10
-      f += float64(decValue(s[i]))
-      inc i
-      inc d
-
-  if i < s.len and (s[i] == Rune('e') or s[i] == Rune('E')):
-    inc i
-    if i < s.len and s[i] == Rune('-'):
-      t = -1
-      inc i
-    elif i < s.len and s[i] == Rune('+'):
-      inc i
-
-    while i < s.len and isDigitAscii(s[i]):
-      e *= 10
-      e += float64(decValue(s[i]))
-      inc i
-
-  return float64(sign) * (integer + f * pow(10, float64(-d))) * pow(10, (float64(t) * e))
-
 func isNameStartCodePoint*(r: Rune): bool =
   return not isAscii(r) or r == Rune('_') or isAlphaAscii(r)
 
@@ -273,7 +227,7 @@ proc consumeNumber(state: var CSSTokenizerState): tuple[t: tflagb, val: float64]
         while state.has() and isDigitAscii(state.curr()):
           repr &= state.consume()
 
-  let val = toNumber(repr)
+  let val = parseFloat64($repr)
   return (t, val)
 
 proc consumeNumericToken(state: var CSSTokenizerState): CSSToken =