[librsvg] parse_transform.lalrpop: Don't use "comma?" everywhere; use a helper production
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] parse_transform.lalrpop: Don't use "comma?" everywhere; use a helper production
- Date: Thu, 23 Mar 2017 21:32:28 +0000 (UTC)
commit e91e03239e05a6d7d9f3ee81a7c9937c5186ac33
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Mar 23 14:05:26 2017 -0600
parse_transform.lalrpop: Don't use "comma?" everywhere; use a helper production
This shrinks the generated parse_transform.rs from 800652 bytes to
417847 bytes.
rust/src/parse_transform.lalrpop | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/rust/src/parse_transform.lalrpop b/rust/src/parse_transform.lalrpop
index a99df98..a9c84b2 100644
--- a/rust/src/parse_transform.lalrpop
+++ b/rust/src/parse_transform.lalrpop
@@ -36,17 +36,17 @@ Transform: cairo::Matrix = {
SkewY
};
-pub Matrix: cairo::Matrix = "matrix" "(" <Num> comma? <Num> comma? <Num> comma? <Num> comma? <Num> comma?
<Num> ")" =>
+pub Matrix: cairo::Matrix = "matrix" "(" <Num> <Num2> <Num2> <Num2> <Num2> <Num2> ")" =>
cairo::Matrix::new (<>);
pub Translate: cairo::Matrix = {
"translate" "(" <Num> ")" => cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, <>, 0.0),
- "translate" "(" <Num> comma? <Num> ")" => cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, <>)
+ "translate" "(" <Num> <Num2> ")" => cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, <>)
};
pub Scale: cairo::Matrix = {
"scale" "(" <Num> ")" => cairo::Matrix::new (<>, 0.0, 0.0, <>, 0.0, 0.0),
- "scale" "(" <sx: Num> comma? <sy: Num> ")" => cairo::Matrix::new (sx, 0.0, 0.0, sy, 0.0, 0.0),
+ "scale" "(" <sx: Num> <sy: Num2> ")" => cairo::Matrix::new (sx, 0.0, 0.0, sy, 0.0, 0.0),
};
pub Rotate: cairo::Matrix = {
@@ -56,7 +56,7 @@ pub Rotate: cairo::Matrix = {
cairo::Matrix::new (c, s, -s, c, 0.0, 0.0)
},
- "rotate" "(" <angle: Num> comma? <tx: Num> comma? <ty: Num> ")" => {
+ "rotate" "(" <angle: Num> <tx: Num2> <ty: Num2> ")" => {
let a = angle * PI / 180.0;
let (s, c) = a.sin_cos ();
let mut m = cairo::Matrix::new (1.0, 0.0, 0.0, 1.0, tx, ty);
@@ -85,6 +85,10 @@ pub SkewY: cairo::Matrix = {
}
};
+pub Num2: f64 = {
+ comma? <Num>
+};
+
pub Num: f64 = <s:r"[+-]?([0-9]*\.[0-9]+|[0-9]+(\.[0-9]*)?)([Ee][+-]?[0-9]+)?"> =>
f64::from_str (s).unwrap ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]