-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarter.spiral
More file actions
37 lines (29 loc) · 1.11 KB
/
starter.spiral
File metadata and controls
37 lines (29 loc) · 1.11 KB
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
;; TODO:
;; - export selector (both to other concepts, and to specify that it should be indexed)
;; - DISREGARDING the idea of selectors for now
;; - wildcard in a literal set
;; - same literal syntax in requireKeys?
;; - something like a _rootList (ie, NodeList, RuleList), or _rootListClass?
;; NOTES:
;; '~' means 'specializes'
;; '..' allows you to set attributes on fields - want to change this
;; '<>' is a literal set
concept HTML {-
@root_list_type = Node;
AttrKey = "href|src|id|class|data-*|*";
AttrVal = string;
Attr = (key:AttrKey, val:AttrVal)
-> "%s=%s" % (self.key, self.val);
Attrs = list<Attr>
-> " ".join(self);
Tag = "a|script|div|span|img";
Node = (tag:Tag, attrs:Attrs, innerNodes:NodeList, text:string)
-> "<%s %s>%s %s</%s>" % (self.tag, self.attrs, self.innerNodes, self.text, self.tag);
;; Specializations
;; Node~Link = (tag:<a>, attrs..requireKeys(['href']));
;; Node~Picture = (tag:<img>, attrs..requireKeys(['src'], innerNodes:list())
-}
concept CSS {-
;;RuleList = list(Rule);
;;Rule = (selector:Selector, style:Style);
-}