Skip to content

Commit

Permalink
organize grammar, improve content node, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wrapperup committed Mar 7, 2024
1 parent 0915d91 commit c1eb14b
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 231 deletions.
56 changes: 21 additions & 35 deletions corpus/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ Variables
(content)
(tag
(code))
(content)
(tag
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
(code))
(content)
(tag
(keyword))
(content))
Expand All @@ -41,6 +37,9 @@ Comments
{{# This is a comment #}}
{{# a comment #}}
{{# comment #}}

<h1>Hello world!</h1>

{{# life is pain comment #}}
{{ This is not a comment }}
{{# I'm a multi-line comment #}}
Expand All @@ -52,19 +51,15 @@ Comments
(content)
(tag
(comment))
(content)
(tag
(comment))
(content)
(tag
(comment))
(content)
(tag
(comment))
(content)
(tag
(code))
(content)
(tag
(comment))
(content))
Expand All @@ -85,40 +80,33 @@ Filters
---

(template
(content)
(tag
(keyword)
(code)
(filter
(code)))
(content)
(tag
(keyword)
(code)
(filter
(code)
(code)))
(content)
(tag
(keyword)
(code)
(filter
(code)))
(content)
(tag
(keyword)
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
(keyword)
(code)
(filter
(code)))
(content)
(tag
(keyword)
(code)
Expand All @@ -144,42 +132,34 @@ Expressions
---

(template
(content)
(tag
(keyword)
(code))
(content)
(tag
(code))
(content)
(tag
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
(keyword)
(code)
(filter
(code)))
(content)
(tag
(keyword)
(code)
(filter
(code)
(code)))
(content)
(tag
(keyword)
(code)
(filter
(code)
(code)
(code)))
(content)
(tag
(keyword))
(content))
Expand All @@ -200,27 +180,20 @@ Expressions 2
---

(template
(content)
(tag
(keyword)
(code))
(content)
(tag)
(content)
(tag)
(content)
(tag
(keyword)
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
(code))
(content))
Expand All @@ -233,31 +206,44 @@ Stress Keywords
{{ code }}
{{ keyword code }}
{{ keyword() code }}

<h1>Hello!</h1>
{{ Deno }}
{{ Deno thing }}

---

(template
(content)
(tag
(keyword)
(code))
(content)
(tag
(code))
(content)
(tag
(keyword)
(code))
(content)
(tag
(code))
(content)
(tag
(code))
(tag
(code))
(content))

====================
Test parens
====================

<h1 style="color: rgba(color)">Hello!</h1>
{{ hello }}
{{ code().doStuff!() }}

---

(template
(content)
(tag
(code))
(tag
(code))
(content))
43 changes: 22 additions & 21 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,6 @@
}
]
},
"keyword": {
"type": "PATTERN",
"value": "[a-z>][a-zA-Z]*? |if|for|include|set|import|export|layout|function"
},
"code_snippet": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[a-zA-Z>\\.\\(\\)\\!_\\?]"
},
{
"type": "SYMBOL",
"name": "_code"
}
]
},
"close_keyword": {
"type": "PATTERN",
"value": "\\/([a-zA-Z]+|if|for|include|set|import|export|layout|function)"
},
"filter": {
"type": "REPEAT1",
"content": {
Expand All @@ -179,6 +158,27 @@
]
}
},
"keyword": {
"type": "PATTERN",
"value": "[a-z>][a-zA-Z]*? |if|for|include|set|import|export|layout|function"
},
"code_snippet": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[a-zA-Z>\\.\\(\\)\\!_\\?]"
},
{
"type": "SYMBOL",
"name": "_code"
}
]
},
"close_keyword": {
"type": "PATTERN",
"value": "\\/([a-zA-Z]+|if|for|include|set|import|export|layout|function)"
},
"comment": {
"type": "PATTERN",
"value": "#[^#]+#"
Expand All @@ -201,3 +201,4 @@
"inline": [],
"supertypes": []
}

Loading

0 comments on commit c1eb14b

Please sign in to comment.