Last active
September 19, 2024 14:47
-
-
Save Chubek/886580036f37bda5d6023595821afa51 to your computer and use it in GitHub Desktop.
Revisions
-
Chubek revised this gist
Jan 10, 2024 . 1 changed file with 37 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,38 @@ " ebnf.vim - Syntax highlighting for EBNF if exists("b:current_syntax") finish endif syntax clear " Comments syntax region ebnfComment start= "===" end= "===" contained syntax region ebnfComment start= "#" end= "#" contained " Identifiers syntax match ebnfIdentifier /[a-z]\+\%(-[a-z]\+\)\?/ " Literals syntax match ebnfCharacterLiteral /'\([^']\|\\.\)+'/ syntax match ebnfStringLiteral /"\([^"]\|\\.\)+"/ " Operators and special characters syntax match ebnfOp "::=" syntax match ebnfOp "|" syntax match ebnfOp "?" syntax match ebnfOp "\[" syntax match ebnfOp "]" syntax match ebnfOp "(" syntax match ebnfOp ")" syntax match ebnfOp "{" syntax match ebnfOp "}" " Link groups to colors hi link ebnfComment Comment hi link ebnfIdentifier Identifier hi link ebnfCharacterLiteral Constant hi link ebnfStringLiteral Constant hi link ebnfOp Operator let b:current_syntax = "ebnf" -
Chubek created this gist
Jan 8, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ The following grammar is based on this EBNF specifications for EBNF meta-grammar: ```ebnf ebnf ::= [ global-desc ] { local-desc | rule | comment } local-desc ::= '{' ? { any-character } ? '}' global-desc :: "{{" ? { any-character } ? "}}" rule ::= identifier '::=' expression [ '.' ] expression ::= term { '|' term } term ::= factor { factor } factor ::= identifier | string-literal | character-literal | '(' expression ')' | '[' expression ']' | '{' expression '}' | '?' expression '?' | option | repetition | group option ::= expression '?' repetition ::= expression '*' | expression '+' group ::= '(' expression ')' character-literal ::= "'" ? any-character ? "'" string-literal ::= '"' ? { any-character } ? '"' identifier ::= letter { letter | '-' } letter ::= 'A' | 'B' | ... | 'z' ``` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ " Vim syntax file for EBNF " Define syntax groups syntax region ebnfLocalDesc start=/{/ end=/}/ contains=@ebnf syntax region ebnfGlobalDesc start= '{{' end= '}}' contains=@ebnf syntax keyword ebnfKeyword ::= "|" "." "?" "*" "+" syntax match ebnfSpecial /[\?\*\+\|\.]/ contained syntax keyword ebnfBoolean true false syntax match ebnfIdentifier /\v[A-Za-z][\w-]*/ syntax match ebnfCharacterLiteral /'.'/ syntax match ebnfStringLiteral /".*"/ syntax region ebnfGroup start="(" end=")" contains=@ebnf " Highlighting highlight link ebnfKeyword Keyword highlight link ebnfSpecial Special highlight link ebnfBoolean Boolean highlight link ebnfIdentifier Identifier highlight link ebnfCharacterLiteral Character highlight link ebnfStringLiteral String highlight link ebnfGroup Statement " Enable syntax highlighting let b:current_syntax = "ebnf"