From 3919e92dcb92f0ffc001792c3e95a69b8985a99f Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Thu, 19 Mar 2020 20:01:13 -0400 Subject: [PATCH] Allow function declarations inside rulesets --- src/function.rs | 2 +- src/token.rs | 2 +- tests/functions.rs | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/function.rs b/src/function.rs index e2d13bd..ee52a5c 100644 --- a/src/function.rs +++ b/src/function.rs @@ -64,7 +64,7 @@ impl Function { return Err("unexpected EOF (TODO: better error message)".into()); } } - + devour_whitespace(toks); Ok((name, Function::new(scope, args, body))) } diff --git a/src/token.rs b/src/token.rs index d819e99..b4841a5 100644 --- a/src/token.rs +++ b/src/token.rs @@ -109,4 +109,4 @@ impl fmt::Display for TokenKind { } } } -} \ No newline at end of file +} diff --git a/tests/functions.rs b/tests/functions.rs index 7f9739d..7b494b3 100644 --- a/tests/functions.rs +++ b/tests/functions.rs @@ -53,3 +53,13 @@ test!( "$x: 0;\na {\n color: if($x != 0, a, b);\n}\n", "a {\n color: b;\n}\n" ); +test!( + function_decl_in_ruleset, + "a {\n @function foo() {\n @return 3;\n }\n color: foo();\n}\n", + "a {\n color: 3;\n}\n" +); +test!( + function_decl_in_foreign_ruleset, + "a {\n @function foo() {\n @return 3;\n }\n}\nb {\n color: foo();\n}\n", + "b {\n color: foo();\n}\n" +);