forked from amber-lang/amber
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG] Update grammar.ebnf amber-lang#608 (amber-lang#609)
- Loading branch information
Showing
2 changed files
with
146 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#! /usr/bin/env amber | ||
|
||
import { | ||
replace, | ||
starts_with, | ||
words, | ||
} from "std/text" | ||
|
||
main (args) { | ||
let keywords = [Text] | ||
let should_append = false | ||
for line in lines("grammar.ebnf") { | ||
if not should_append and not starts_with(line, "KEYWORD"): continue | ||
should_append = true | ||
for token in words(line) { | ||
if { | ||
starts_with(token, "'"): keywords += [replace(token, "'", "")] | ||
token == ";": should_append = false | ||
} | ||
} | ||
} | ||
let result = $ echo "\$\{{nameof keywords}[@]}" | sort $ failed { | ||
echo "Something went wrong while sorting the keywords" | ||
} | ||
for item in words(result) { | ||
echo item | ||
} | ||
} |