1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// use cssparser::{Parser, ParserInput};
// use less_allocator::{Allocator, Vec};
// use parser::TopLevelRuleParser;
// use rules::CssRuleList;
// use traits::ToCss;
//
// mod error;
// mod parser;
// mod printer;
// mod properties;
// mod rules;
// mod selector;
// mod traits;
// mod values;
//
// /// In less specifications, syntax are defined as follows.
// ///
// /// The `primary` rule is the *entry* and *exit* point of the parser.
// /// The rules here can appear at any level of the parse tree.
// ///
// /// The recursive nature of the grammar is an interplay between the `block`
// /// rule, which represents `{ .. }`, the `ruleset` rule, and this `primary` rule,
// /// as represented by this simplified grammar:
// ///
// /// primary → (ruleset | declaration)+
// /// ruleset → selector+ block
// /// block → '{' primary '}'
// ///
// /// Only at one point is the primary rule not called from the
// /// block rule: at the root level.
//
// pub fn parse(code: &str) {
// let allocator = Allocator::default();
// let mut input = ParserInput::new(code);
// let mut parser = Parser::new(&mut input);
//
// let rules = allocator.alloc(CssRuleList(Vec::new_in(&allocator)));
// let mut at_rule_parser = TopLevelRuleParser::new(&allocator, rules);
// let rule_set_parser = cssparser::StyleSheetParser::new(&mut parser, &mut at_rule_parser);
//
// for rule in rule_set_parser {
// dbg!(rule);
// }
//
// dbg!(&rules);
// dbg!(allocator.allocated_bytes());
//
// dbg!(rules.to_css_string(&allocator).unwrap());
// }
//
// #[cfg(test)]
// mod test {
//
// use super::*;
//
// // fn foo() {
// // let alloc = Allocator::default();
// //
// // let mut v = Vec::new_in(&alloc);
// // v.push(1);
// // v.push(2)
// // }
//
// #[test]
// fn test() {
// // foo();
// //
// // println!("called");
// let code = r#"
// @foo: 16px;
// .class {
// @bar: 15px + @foo;
// @r: 255
// font-size: @bar + 17px;
// background-color:rgb(0,0,1);
// }
// "#;
// let code = r#"
// @code: 255;
// .class {
// font-size: 16px + 12px;
// background-color: rgb(0, 0, @code);
// color: rgb(@code, 0, 1);
// }
// "#;
// parse(code)
// }
// }