mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-28 17:20:22 +00:00
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:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
24
samples/EBNF/grammar.ebnf
Normal 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 *)
|
||||
|
||||
40
samples/EBNF/material.ebnf
Normal file
40
samples/EBNF/material.ebnf
Normal 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
61
samples/EBNF/object.ebnf
Normal 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
20
samples/EBNF/types.ebnf
Normal 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 } ] ;
|
||||
|
||||
1
vendor/grammars/EBNF.tmbundle
vendored
Submodule
1
vendor/grammars/EBNF.tmbundle
vendored
Submodule
Submodule vendor/grammars/EBNF.tmbundle added at 13efe9156b
24
vendor/licenses/grammar/EBNF.tmbundle.txt
vendored
Normal file
24
vendor/licenses/grammar/EBNF.tmbundle.txt
vendored
Normal 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.
|
||||
Reference in New Issue
Block a user