mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +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:
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 } ] ;
|
||||
|
||||
Reference in New Issue
Block a user