[librsvg] parse_transform.rs: Start a lalrpop parser for the "transform" attribute
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] parse_transform.rs: Start a lalrpop parser for the "transform" attribute
- Date: Wed, 22 Mar 2017 17:59:34 +0000 (UTC)
commit 121cdb556b53b6b807aa58afca62b9eef7564b09
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Mar 21 20:40:42 2017 -0600
parse_transform.rs: Start a lalrpop parser for the "transform" attribute
rust/Cargo.lock | 321 ++++++++++++++++++++++++++++++++++++++
rust/Cargo.toml | 10 ++
rust/src/lib.rs | 1 +
rust/src/parse_transform.lalrpop | 7 +
rust/src/parsers.rs | 24 +++
5 files changed, 363 insertions(+), 0 deletions(-)
---
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index ef615c8..2b32a3a 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -7,11 +7,53 @@ dependencies = [
"cairo-sys-rs 0.3.2 (git+https://github.com/gtk-rs/cairo.git)",
"downcast-rs 1.0.0 (git+https://github.com/marcianx/downcast-rs)",
"glib 0.1.1 (git+https://github.com/gtk-rs/glib)",
+ "lalrpop 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-util 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"nom 2.1.0 (git+https://github.com/federicomenaquintero/nom.git)",
+ "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "aho-corasick"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "aho-corasick"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "atty"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "bit-set"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "bit-vec"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "bitflags"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -54,11 +96,32 @@ dependencies = [
]
[[package]]
+name = "diff"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "docopt"
+version = "0.6.86"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "lazy_static 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "downcast-rs"
version = "1.0.0"
source = "git+https://github.com/marcianx/downcast-rs#5ace99daf704b91f2eeab366b67b78b368d51884"
[[package]]
+name = "fixedbitset"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "glib"
version = "0.1.1"
source = "git+https://github.com/gtk-rs/glib#91f2ceb47cdc2d3b209ce3b6c96e3de928223842"
@@ -91,37 +154,295 @@ dependencies = [
]
[[package]]
+name = "itertools"
+version = "0.3.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "kernel32-sys"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "lalrpop"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bit-set 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-intern 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-snap 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-util 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "petgraph 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "lalrpop-intern"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "lalrpop-snap"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bit-set 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-intern 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-util 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "petgraph 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "lalrpop-util"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "lazy_static"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "libc"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "memchr"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "memchr"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "nom"
version = "2.1.0"
source = "git+https://github.com/federicomenaquintero/nom.git#c5733d4779f513a3eb7f39c09de1c2155da4d6e2"
[[package]]
+name = "petgraph"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "fixedbitset 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "pkg-config"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "regex"
+version = "0.1.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "regex"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "regex-syntax"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "regex-syntax"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rustc-serialize"
+version = "0.3.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "strsim"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "term"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "thread-id"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "thread-id"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "thread_local"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "thread_local"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unicode-xid"
+version = "0.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "unreachable"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "utf8-ranges"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "utf8-ranges"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "void"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "winapi-build"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[metadata]
+"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
+"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
+"checksum atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"d0fd4c0631f06448cc45a6bbb3b710ebb7ff8ccb96a0800c994afe23a70d5df2"
+"checksum bit-set 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"84527c7b0452f22545cc010e72d366a435561d2b28b978035550b3778c4d428d"
+"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
"checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum c_vec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"0059f5a658f62a4bd3937a7addc52ccfda144b75cce7a92b187e528629cdc507"
"checksum cairo-rs 0.1.1 (git+https://github.com/gtk-rs/cairo.git)" = "<none>"
"checksum cairo-sys-rs 0.3.2 (git+https://github.com/gtk-rs/cairo.git)" = "<none>"
+"checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" =
"0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472"
+"checksum docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" =
"4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9"
"checksum downcast-rs 1.0.0 (git+https://github.com/marcianx/downcast-rs)" = "<none>"
+"checksum fixedbitset 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"88c3c33fc4c00db33f5174eb98aea809c4c007db0b71351d810a7e094ea3b64d"
"checksum glib 0.1.1 (git+https://github.com/gtk-rs/glib)" = "<none>"
"checksum glib-sys 0.3.2 (git+https://github.com/gtk-rs/sys)" = "<none>"
"checksum gobject-sys 0.3.2 (git+https://github.com/gtk-rs/sys)" = "<none>"
+"checksum itertools 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" =
"16b73f1c685cfd8ff8d75698ed87e6188cd09944b30c0863d45c2c3699d1da0c"
+"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
+"checksum lalrpop 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"a50b5cdf6b58f1753c86ebcc4d0852ff30478133fb370a27dbf303cbd5621fdc"
+"checksum lalrpop-intern 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"39e21a3b0618b97e727f67d46bf1a21954384f6be6bf72558cc48f149881066e"
+"checksum lalrpop-snap 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"e82554f7abfe767e8a22286e7ca6d1ea7d873e91f0259981e15c7c6754d7340d"
+"checksum lalrpop-util 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"36497edf44be49f4663ebd9cfb154a81c84491986a62773c62624911efd3d84d"
+"checksum lazy_static 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" =
"7291b1dd97d331f752620b02dfdbc231df7fc01bf282a00769e1cdb963c460dc"
"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" =
"684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5"
+"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" =
"d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
+"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
"checksum nom 2.1.0 (git+https://github.com/federicomenaquintero/nom.git)" = "<none>"
+"checksum petgraph 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" =
"bfd1de18b0a5f1777162e5b61aaf498032467d5409ab4ca6dbd03049f5708de1"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" =
"3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
+"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" =
"4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
+"checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01"
+"checksum regex-syntax 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" =
"a21935ce5a4dfa48e3ded1aefbbe353fb9ab258b0d3fa0bd168bef00797b3dc7"
+"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" =
"f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
+"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457"
+"checksum rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" =
"684ce48436d6465300c9ea783b6b14c4361d6b8dcbb1375b486a69cc19e2dfb0"
+"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c"
+"checksum term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" =
"d168af3930b369cfe245132550579d47dfd873d69470755a19c2c6568dbbd989"
+"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
+"checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a"
+"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" =
"8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
+"checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7"
+"checksum unicode-xid 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"f69506a2561962651710609304bbb961fa3da598c812f877975a82e48ee144f9"
+"checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
+"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" =
"a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
+"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" =
"662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
+"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" =
"6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" =
"167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
+"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" =
"2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 25eb419..5e9d2ff 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -2,6 +2,7 @@
name = "rsvg_internals"
version = "0.0.1"
authors = ["Federico Mena Quintero <federico gnome org>"]
+build = "build.rs"
[dependencies]
libc = "0.2"
@@ -32,6 +33,15 @@ features = ["verbose-errors"]
git = "https://github.com/marcianx/downcast-rs"
version = "1.0.0"
+[dependencies.regex]
+version = "0.2.1"
+
+[dependencies.lalrpop-util]
+version = "0.12.5"
+
+[build-dependencies.lalrpop]
+version = "0.12.5"
+
[lib]
name = "rsvg_internals"
crate-type = ["staticlib"]
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 7ae50cb..1a04315 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -114,6 +114,7 @@ mod marker;
mod node;
mod paint_server;
mod parsers;
+mod parse_transform;
mod path_builder;
mod path_parser;
mod pattern;
diff --git a/rust/src/parse_transform.lalrpop b/rust/src/parse_transform.lalrpop
new file mode 100644
index 0000000..655ba68
--- /dev/null
+++ b/rust/src/parse_transform.lalrpop
@@ -0,0 +1,7 @@
+//-*- rust -*-
+
+use std::str::FromStr;
+
+grammar;
+
+pub Num: f64 = <s:r"[+-]?([0-9]*\.[0-9]+|[0-9]+(\.[0-9]*)?)([Ee][+-]?[0-9]+)?"> => f64::from_str (s).unwrap
();
diff --git a/rust/src/parsers.rs b/rust/src/parsers.rs
index c5cc979..7253d85 100644
--- a/rust/src/parsers.rs
+++ b/rust/src/parsers.rs
@@ -2,6 +2,8 @@ use nom::{IResult, double, is_alphabetic};
use std::str;
use std::f64::consts::*;
+use parse_transform::*;
+
// I don't know how to copy a nom::IError for long-term storage
// (i.e. when it can no longer reference the &[u8]). So, we explode a
// nom::IError into a simple error struct that can be passed around.
@@ -263,3 +265,25 @@ mod tests {
assert! (angle_degrees ("300foo").is_err ());
}
}
+
+#[cfg(test)]
+mod parse_transform_tests {
+ #[test]
+ fn parses_numbers () {
+ assert_eq! (parse_Num ("0"), Ok (0.0));
+ assert_eq! (parse_Num ("12345"), Ok (12345.0));
+ assert_eq! (parse_Num ("-123"), Ok (-123.0));
+ assert_eq! (parse_Num ("-123.25"), Ok (-123.25));
+ assert_eq! (parse_Num ("123.25"), Ok (123.25));
+ assert_eq! (parse_Num ("-.25"), Ok (-0.25));
+ assert_eq! (parse_Num (".25"), Ok (0.25));
+ assert_eq! (parse_Num ("-25."), Ok (-25.0));
+ assert_eq! (parse_Num ("25."), Ok (25.0));
+ assert_eq! (parse_Num ("22.5e1"), Ok (225.0));
+ assert_eq! (parse_Num ("-22.5e1"), Ok (-225.0));
+ assert_eq! (parse_Num ("-123.45e2"), Ok (-12345.0));
+ assert_eq! (parse_Num ("123.45E2"), Ok (12345.0));
+ assert_eq! (parse_Num ("-123.25e-2"), Ok (-1.2325));
+ assert_eq! (parse_Num ("123.25E-2"), Ok (1.2325));
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]