Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DiaGrammar rule file and generated diagram for grammarkdown spec. #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added spec/grammarkdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions spec/grammarkdown.rule
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
DiaGrammar [Options: [
grammar-only?: false
ruleset: true
hovering: true
string-input: true
case-parsing: false
live-edit?: true
iterate-times: 1
max-iterate: 5
font-size: 11
selected-rule: "grammar"
latest-inputs: [
]
]]
grammar: [some [rule | directive | comment some newline]]
rule: [defines choice]
defines: [nonterminal definer]
choice: [sequence any [alt sequence] newline [newline | end]]
sequence: [opt argblock some elements opt link | prose]
elements: [_ [element opt optional | assertion]]
element: [terminal | identifier opt condition]
terminal: [character | string | unicode]
identifier: [nonterminal not definer]

directive: [#"@" thru some newline]
nonterminal: [[opt "uri" some name-part | "uri"] opt argblock]
definer: [opt #" " 1 3 #":" opt one-of newline some [ws | tab]]
one-of: [" one of"]
prose: [#">" to [newline | end]]
assertion: [#"[" _ assert-kind _ #"]"]
assert-kind: [
"empty" | lookahead | no-symbol | lexical-goal | prose-assert
]
lookahead: ["lookahead " looking-for]
looking-for: [look-simple | look-compound]
look-simple: [["==" | "!="] _ terminal any [_ terminal]]
look-compound: [["<-" | "<!"] _ [nonterminal | terminal-list]]
no-symbol: ["no" _ [element | #"|" identifier #"|"] _ "here"]
lexical-goal: ["lexical goal" _ element]
prose-assert: [#">" some [terminal | not #"]" skip]]
terminal-list: [#"{" list-element some [#"," _ list-element] #"}"]
list-element: [some [_ element | _ assertion]]
optional: #"?"
condition: [" but not " opt "one of " cond-list]
cond-list: [element any [" or " element]]
link: [_ #"#" to newline]

character: "```"
string: [#"`" any [not #"`" skip] #"`"]
unicode: [#"<" [some upper | #"U" #"+" some hexa] #">"]
name-part: [upper any [lower | digit]]
alt: [newline tab]
upper: charset [#"A" - #"Z"]
lower: charset [#"a" - #"z"]
argblock: [#"[" _ args _ #"]"]
args: [arg any [#"," _ arg]]
arg: [opt modifier name-part]
modifier: [#"~" | #"+" | #"?"]
ws: charset " ^-"
ws+: [some ws]
ws*: [any ws]
_: ws* ;comment any [newline comment] | ws*]
digit: charset "0123456789"
hexa: union digit charset [#"A" - #"F" #"a" - #"f"]
comment: [line-comment | long-comment]
line-comment: ["//" any [not newline skip]]
long-comment: [_ "/*" thru "*/"]
newline: [_ opt comment #"^/"]