Skip to content

Commit

Permalink
Add Treetop Support - https://cjheath.github.io/treetop/ (#571)
Browse files Browse the repository at this point in the history
A DSL that integrates with Ruby for expressing a PEG (parsing expression
grammer). The tool uses itself to define the language so if you really want
the full details on the language it is at:

https://github.com/cjheath/treetop/blob/master/lib/treetop/compiler/metagrammar.treetop

But the cliff notes are:

* Very Ruby-like
* Only supports single-line comments
* Embeds proper Ruby code so I just copy/pasted the complexitychecks from the
  Ruby language specs.

To make this commit I just:

1. Added it to the `languages.json` file (per README)
2. Ran `go generate` (per README)
3. Ran `./test-all.sh`. This confirmed all green and updated `LANGAUGES.md` and
   `SCC-OUTPUT-REPORT.html` (maybe this step should be added to README?)

I also ran `go build` to create the binary and tested it against my project
which has many Treetop files and confirmed it worked.
  • Loading branch information
eric1234 authored Jan 14, 2025
1 parent 11fd9fb commit 6d92d43
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
1 change: 1 addition & 0 deletions LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ Textile (textile)
Thrift (thrift)
TL (tl)
TOML (toml)
Treetop (treetop,tt)
TTCN-3 (ttcn,ttcn3,ttcnpp)
Twig Template (twig)
TypeScript (ts,tsx)
Expand Down
26 changes: 13 additions & 13 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<th>447</th>
<th>7678</th>
<th>1413</th>
<th>256040</th>
<th>256080</th>
<th>4138</th>
</tr><tr>
<td>processor/workers_test.go</td>
Expand Down Expand Up @@ -240,16 +240,6 @@
<td>0</td>
<td>2209</td>
<td>35</td>
</tr><tr>
<td>processor/bloom.go</td>
<td></td>
<td>37</td>
<td>7</td>
<td>12</td>
<td>18</td>
<td>2</td>
<td>1062</td>
<td>29</td>
</tr><tr>
<td>processor/cocomo_test.go</td>
<td></td>
Expand All @@ -260,6 +250,16 @@
<td>6</td>
<td>686</td>
<td>23</td>
</tr><tr>
<td>processor/bloom.go</td>
<td></td>
<td>37</td>
<td>7</td>
<td>12</td>
<td>18</td>
<td>2</td>
<td>1062</td>
<td>29</td>
</tr><tr>
<td>processor/helpers_test.go</td>
<td></td>
Expand Down Expand Up @@ -288,7 +288,7 @@
<td>1</td>
<td>4</td>
<td>0</td>
<td>23199</td>
<td>23239</td>
<td>6</td>
</tr></tbody>
<tfoot><tr>
Expand All @@ -299,7 +299,7 @@
<th>447</th>
<th>7678</th>
<th>1413</th>
<th>256040</th>
<th>256080</th>
<th>4138</th>
</tr>
<tr>
Expand Down
27 changes: 27 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6520,6 +6520,33 @@
}
]
},
"Treetop": {
"complexitychecks": [
"for ",
"for(",
"if ",
"if(",
"switch ",
"while ",
"else ",
"|| ",
"&& ",
"!= ",
"== "
],
"extensions": ["treetop", "tt"],
"line_comment": ["#"],
"quotes": [
{
"end": "\"",
"start": "\""
},
{
"end": "'",
"start": "'"
}
]
},
"Twig Template": {
"complexitychecks": ["{% for ", "{% if ", "{% else ", "{% elseif "],
"extensions": ["twig"],
Expand Down
Loading

0 comments on commit 6d92d43

Please sign in to comment.