Starting EBNF
This commit is contained in:
		
							parent
							
								
									e9c6b3a39b
								
							
						
					
					
						commit
						592ddb7baa
					
				
					 5 changed files with 104 additions and 0 deletions
				
			
		
							
								
								
									
										79
									
								
								ava.ebnf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								ava.ebnf
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,79 @@ | ||||||
|  | (* Core Character Sequences *) | ||||||
|  | 
 | ||||||
|  | white_space         ::= '\u0020' | '\u0009' | '\u000D' | '\u000A' | ||||||
|  | paren               ::= '(' | ')'; | ||||||
|  | bracket             ::= '[' | ']'; | ||||||
|  | brace               ::= '{' | '}'; | ||||||
|  | digit               ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'; | ||||||
|  | hex                 ::= '0' | ... | '9' | 'A' | ... | 'F' | 'a' | ... | 'f' ; | ||||||
|  | upper               ::= 'A' | ... | 'Z' | Lu | Lt | Nl | ||||||
|  |                       | Lo upper only | ||||||
|  |                       | Lm upper only; | ||||||
|  | lower               ::= 'a' | ... | 'z' | Ll | ||||||
|  |                       | Lo lower only | ||||||
|  |                       | Lm lower only; | ||||||
|  | letter              ::= upper | lower; | ||||||
|  | escape_unicode      ::= '\', 'u', hex, hex, hex, hex; | ||||||
|  | escape_char         ::= '\', ('b' | 'f' | 'n' | 'r' | 't' | '\' | '"'); | ||||||
|  | escape_seq          ::= escape_unicode | escape_char; | ||||||
|  | number_integer      ::= '0' | digit, [{digit}]; | ||||||
|  | number_float        ::= number_integer, '.', number_integer; | ||||||
|  | newline             ::= '\n'; | ||||||
|  | printable_char      ::= printable utf8; | ||||||
|  | char_char           ::= printable_char without newline or single quote | ||||||
|  |                       | escape_seq; | ||||||
|  | string_char         ::= printable_char without newline or double quote | ||||||
|  |                       | escape_seq; | ||||||
|  | 
 | ||||||
|  | (* Comments *) | ||||||
|  | 
 | ||||||
|  | comment             ::= '-', '-', {utf8}; | ||||||
|  | docstring           ::= '-', '-', '-', {utf8}; | ||||||
|  | 
 | ||||||
|  | (* Literal Values *) | ||||||
|  | 
 | ||||||
|  | literal_bool        ::= 'true' | 'false'; | ||||||
|  | literal_integer     ::= ['-'], number_integer; | ||||||
|  | literal_float       ::= ['-'], number_float; | ||||||
|  | literal_char        ::= "'", char_char, "'"; | ||||||
|  | literal_string      ::= '"', {string_char}, "'"; | ||||||
|  | empty_tuple         ::= '(', ')'; | ||||||
|  | literal             ::= literal_bool | ||||||
|  |                       | literal_integer | ||||||
|  |                       | literal_float | ||||||
|  |                       | literal_char | ||||||
|  |                       | literal_string | ||||||
|  |                       | empty_tuple; | ||||||
|  | 
 | ||||||
|  | (* Keywords *) | ||||||
|  | 
 | ||||||
|  | k_type              ::= 't', 'y', 'p', 'e'; | ||||||
|  | k_class             ::= 'c', 'l', 'a', 's', 's'; | ||||||
|  | k_alias             ::= 'a', 'l', 'i', 'a', 's'; | ||||||
|  | k_const             ::= 'c', 'o', 'n', 's', 't'; | ||||||
|  | k_enum              ::= 'e', 'n', 'u', 'm'; | ||||||
|  | k_record            ::= 'r', 'e', 'c', 'o', 'r', 'd'; | ||||||
|  | k_object            ::= 'o', 'b', 'j', 'e', 'c', 't'; | ||||||
|  | k_let               ::= 'l', 'e', 't'; | ||||||
|  | k_mut               ::= 'm', 'u', 't'; | ||||||
|  | k_export            ::= 'e', 'x', 'p', 'o', 'r', 't'; | ||||||
|  | k_import            ::= 'i', 'm', 'p', 'o', 'r', 't'; | ||||||
|  | k_namespace         ::= 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e'; | ||||||
|  | k_infix             ::= 'i', 'n', 'f', 'i', 'x'; | ||||||
|  | k_fn                ::= 'f', 'n'; | ||||||
|  | k_end               ::= 'e', 'n', 'd'; | ||||||
|  | k_match             ::= 'm', 'a', 't', 'c', 'h'; | ||||||
|  | k_case              ::= 'c', 'a', 's', 'e'; | ||||||
|  | k_if                ::= 'i', 'f'; | ||||||
|  | k_then              ::= 't', 'h', 'e', 'n'; | ||||||
|  | k_else              ::= 'e', 'l', 's', 'e'; | ||||||
|  | k_do                ::= 'd', 'o'; | ||||||
|  | k_return            ::= 'r', 'e', 't', 'u', 'r', 'n'; | ||||||
|  | k_given             ::= 'g', 'i', 'v', 'e', 'n'; | ||||||
|  | k_true              ::= 't', 'r', 'u', 'e'; | ||||||
|  | k_false             ::= 'f', 'a', 'l', 's', 'e'; | ||||||
|  | keyword             ::= k_type | k_class | k_alias | k_const | k_enum | k_record | ||||||
|  |                       | k_object | k_let | k_mut | k_export | k_import | ||||||
|  |                       | k_namespace | k_infix | k_fn | k_end | k_match | k_case | ||||||
|  |                       | k_if | k_then | k_else | k_do | k_return | k_given | ||||||
|  |                       | k_true | k_false; | ||||||
|  | @ -15,6 +15,7 @@ | ||||||
| `BigInt` | `BigInt` | ||||||
| `Decimal` | `Decimal` | ||||||
| `String` | `String` | ||||||
|  | `Char` | ||||||
| `(a, b, ...)` (Tuples) | `(a, b, ...)` (Tuples) | ||||||
| `List[A]` (List of some type) | `List[A]` (List of some type) | ||||||
| `Array[A]` (Array of some type) | `Array[A]` (Array of some type) | ||||||
|  |  | ||||||
|  | @ -1 +1,4 @@ | ||||||
| # Strings | # Strings | ||||||
|  | 
 | ||||||
|  | - UTF-8 by default | ||||||
|  | - ASCII-only support? | ||||||
|  |  | ||||||
|  | @ -1,5 +1,11 @@ | ||||||
| # Table of Contents | # Table of Contents | ||||||
| 
 | 
 | ||||||
|  | ## Grammar | ||||||
|  | 
 | ||||||
|  | The entire Grammar is defined in [ava.ebnf](./ava.ebnf). | ||||||
|  | 
 | ||||||
|  | ## Discussion | ||||||
|  | 
 | ||||||
| - [Keywords](keywords.md) | - [Keywords](keywords.md) | ||||||
| - [Operators & Symbols](operators-symbols.md) | - [Operators & Symbols](operators-symbols.md) | ||||||
| - [Names](names.md) | - [Names](names.md) | ||||||
|  |  | ||||||
|  | @ -1 +1,16 @@ | ||||||
| # Type Classes | # Type Classes | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | given A | ||||||
|  | class Foo | ||||||
|  |     fn foo: (data: A) => String | ||||||
|  | end class | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | instance Foo[String] | ||||||
|  |     fn foo: (data: String) => String | ||||||
|  |         data | ||||||
|  |     end fn | ||||||
|  | end instance | ||||||
|  | ``` | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue