Add support for EBNF

Extended Backus–Naur form ([EBNF][]) is a metalanguage used to specify
language grammars.

[EBNF]: https://en.wikipedia.org/wiki/Extended_Backus–Naur_form
This commit is contained in:
René Schwaiger
2016-10-31 14:51:51 +01:00
parent 417239004a
commit 33899b9d6b
9 changed files with 184 additions and 0 deletions

3
.gitmodules vendored
View File

@@ -800,3 +800,6 @@
[submodule "vendor/grammars/ABNF.tmbundle"]
path = vendor/grammars/ABNF.tmbundle
url = https://github.com/sanssecours/ABNF.tmbundle
[submodule "vendor/grammars/EBNF.tmbundle"]
path = vendor/grammars/EBNF.tmbundle
url = https://github.com/sanssecours/EBNF.tmbundle

View File

@@ -22,6 +22,8 @@ vendor/grammars/ColdFusion:
- text.html.cfm
vendor/grammars/Docker.tmbundle:
- source.dockerfile
vendor/grammars/EBNF.tmbundle:
- source.ebnf
vendor/grammars/Elm/Syntaxes:
- source.elm
- text.html.mediawiki.elm-build-output

View File

@@ -1029,6 +1029,15 @@ E:
tm_scope: none
ace_mode: text
language_id: 92
EBNF:
type: data
extensions:
- ".ebnf"
tm_scope: source.ebnf
ace_mode: text
codemirror_mode: ebnf
codemirror_mime_type: text/x-ebnf
language_id: 430
ECL:
type: programming
color: "#8a1267"

24
samples/EBNF/grammar.ebnf Normal file
View File

@@ -0,0 +1,24 @@
(*
Source: https://github.com/sunjay/lion
License: MIT
*)
Statement = ( NamedFunction | AnonymousFunction | Assignment | Expr ) , "\n" ;
Expr = AnonymousFunction | Term | "(" , Expr , ")" ,
{ AnonymousFunction | Term | "(" , Expr , ")" } ;
Assignment = Symbol , "=" , Expr ;
AnonymousFunction = "\" , FunctionRHS ;
NamedFunction = Symbol , FunctionRHS ;
FunctionRHS = FunctionParams , "=" , FunctionBody ;
FunctionParams = FunctionParam , { FunctionParam } ;
FunctionParam = Term ;
FunctionBody = Expr ;
Term = Symbol | Number | SingleWordString ;
SingleWordString = '"' , Symbol , '"' ;
(* Symbol is a collection of valid symbol characters, not defined here *)
(* Number is a valid numeric literal *)

View File

@@ -0,0 +1,40 @@
(*
Source: https://github.com/io7m/jsom0
License: ISC
*)
name =
"name" , string , ";" ;
diffuse =
"diffuse" , real , real , real , ";" ;
ambient =
"ambient" , real , real , real , ";" ;
specular =
"specular" , real , real , real , real , ";" ;
shininess =
"shininess" , real , ";" ;
alpha =
"alpha" , real , ";" ;
mapping =
"map_chrome" | "map_uv" ;
texture =
"texture" , string , real , mapping , ";" ;
material =
"material" , ";" ,
name ,
diffuse ,
ambient ,
specular ,
shininess ,
alpha ,
[ texture ] ,
"end" , ";" ;

61
samples/EBNF/object.ebnf Normal file
View File

@@ -0,0 +1,61 @@
(*
Source: https://github.com/io7m/jsom0
License: ISC
*)
vertex_p3n3_name =
"vertex_p3n3" ;
vertex_p3n3t2_name =
"vertex_p3n3t2" ;
vertex_type =
vertex_p3n3_name | vertex_p3n3t2_name ;
vertex_position =
"position" , real , real , real , ";" ;
vertex_normal =
"normal" , real , real , real , ";" ;
vertex_uv =
"uv" , real , real , ";" ;
vertex_p3n3 =
vertex_p3n3_name , vertex_position , vertex_normal , "end" , ";" ;
vertex_p3n3t2 =
vertex_p3n3t2_name , vertex_position , vertex_normal , vertex_uv , "end" , ";" ;
vertex =
vertex_p3n3 | vertex_p3n3t2 ;
vertex_array =
"array" , positive , vertex_type , { vertex } , "end" , ";" ;
vertices =
"vertices" , ";" , vertex_array , "end" , ";" ;
triangle =
"triangle" , natural , natural , natural , ";" ;
triangle_array =
"array" , positive, "triangle" , { triangle } , "end" , ";" ;
triangles =
"triangles" , ";" , triangle_array , "end" , ";" ;
name =
"name" , string , ";" ;
material_name =
"material_name" , string , ";" ;
object =
"object" , ";" ,
name ,
material_name ,
vertices ,
triangles ,
"end" , ";" ;

20
samples/EBNF/types.ebnf Normal file
View File

@@ -0,0 +1,20 @@
(*
Source: https://github.com/io7m/jsom0
License: ISC
*)
digit_without_zero =
"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
digit =
"0" | digit_without_zero ;
positive =
digit_without_zero , { digit } ;
natural =
"0" | positive ;
real =
[ "-" ] , digit , [ "." , { digit } ] ;

View File

@@ -0,0 +1,24 @@
---
type: grammar
name: EBNF.tmbundle
license: mit
---
Copyright (C) 2012 by Arne Schroppe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.