Skip to content

Commit 3b317a5

Browse files
committed
Lesson 23 has been added
1 parent ae8b02c commit 3b317a5

File tree

8 files changed

+685
-0
lines changed

8 files changed

+685
-0
lines changed

otus-23/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/target
2+
/classes
3+
/checkouts
4+
profiles.clj
5+
pom.xml
6+
pom.xml.asc
7+
*.jar
8+
*.class
9+
/.lein-*
10+
/.nrepl-port
11+
/.prepl-port
12+
.hgignore
13+
.hg/

otus-23/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# outs-23
2+
3+
Комбинаторные парсеры
4+
5+
## Полезные ссылки
6+
- комбинаторный парсер на Clojure https://github.com/strojure/parsesso
7+
- комбинаторный парсер на Clojure https://github.com/rm-hull/jasentaa
8+
- instaparse https://github.com/Engelberg/instaparse
9+
- пример JSON на instaparse https://nextjournal.com/learn-ast-with-clojure/20210524
10+
- интересный пример на instaparse https://www.toomuchcode.org/blog/2015/11/14/insta-declarative-dsls/

otus-23/project.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(defproject otus-23 "0.1.0-SNAPSHOT"
2+
:description "OTUS #23"
3+
:dependencies [[org.clojure/clojure "1.11.1"]
4+
[instaparse "1.4.12"]]
5+
:repl-options {:init-ns otus-23.core})

otus-23/resources/html.bnf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
document = (tag | spase)*
2+
3+
<tag> = html-comment | html-tag
4+
5+
html-comment = <comment-start> comment-content <comment-end>
6+
<comment-content> = #'.+?(?=-->)'
7+
<comment-start> = <'<!--'>
8+
<comment-end> = <'-->'>
9+
10+
html-tag = tag-start (tag-self-close | (close-tag [spase] tag-content tag-close))
11+
12+
<tag-start> = open-tag tag-name [spase attrs] [spase]
13+
tag-content = ([spase] (tag | text) [spase])*
14+
<tag-self-close> = <'/>' [spase]>
15+
<tag-close> = open-tag slash <tag-name> close-tag [spase]
16+
17+
<open-tag> = <'<'>
18+
<close-tag> = <'>'>
19+
<tag-name> = #'[a-zA-Z0-9_-]+' | '!DOCTYPE' | '!doctype'
20+
21+
attrs = (attr [spase])*
22+
<attr> = attr-w-value | attr-wo-value
23+
<attr-w-value> = attr-name <'='> attr-value
24+
<attr-wo-value> = attr-name
25+
<attr-name> = #'[a-zA-Z0-9_\-\:]+'
26+
<attr-value> = quot string quot
27+
28+
text = #'[^<\n]+(?=<[\w\/])' | #'[^<]+(?=\n)'
29+
<spase> = <#'[ \t\n]+'>
30+
<word-with-digit> = #'[\w\d]+'
31+
<string> = #'[^"]*'
32+
<quot> = <'"'>
33+
<slash> = <'/'>

otus-23/resources/sample.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8"/>
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
5+
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
6+
<title>My Website</title>
7+
<link rel="stylesheet" href="./style.css"/>
8+
<link rel="icon" href="./favicon.ico" type="image/x-icon"/>
9+
</head>
10+
<body>
11+
<main>
12+
<h1>Welcome to My Website</h1>
13+
</main>
14+
<script src="index.js"></script>
15+
</body>
16+
</html>

otus-23/resources/sample.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"id": "0001",
3+
"type": "donut",
4+
"name": "Cake",
5+
"ppu": 0.55,
6+
"batters": {
7+
"batter": [
8+
{
9+
"id": "1001",
10+
"type": "Regular"
11+
},
12+
{
13+
"id": "1002",
14+
"type": "Chocolate"
15+
},
16+
{
17+
"id": "1003",
18+
"type": "Blueberry"
19+
},
20+
{
21+
"id": "1004",
22+
"type": "Devil's Food"
23+
}
24+
]
25+
},
26+
"topping": [
27+
{
28+
"id": "5001",
29+
"type": "None"
30+
},
31+
{
32+
"id": "5002",
33+
"type": "Glazed"
34+
},
35+
{
36+
"id": "5005",
37+
"type": "Sugar"
38+
},
39+
{
40+
"id": "5007",
41+
"type": "Powdered Sugar"
42+
},
43+
{
44+
"id": "5006",
45+
"type": "Chocolate with Sprinkles"
46+
},
47+
{
48+
"id": "5003",
49+
"type": "Chocolate"
50+
},
51+
{
52+
"id": "5004",
53+
"type": "Maple"
54+
}
55+
]
56+
}

0 commit comments

Comments
 (0)