diff --git a/ava.ebnf b/ava.ebnf new file mode 100644 index 0000000..c8d28ef --- /dev/null +++ b/ava.ebnf @@ -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; diff --git a/standard-types.md b/standard-types.md index 8ba3fd4..f6daaf9 100644 --- a/standard-types.md +++ b/standard-types.md @@ -15,6 +15,7 @@ `BigInt` `Decimal` `String` +`Char` `(a, b, ...)` (Tuples) `List[A]` (List of some type) `Array[A]` (Array of some type) diff --git a/strings.md b/strings.md index ed218ce..36085dc 100644 --- a/strings.md +++ b/strings.md @@ -1 +1,4 @@ # Strings + +- UTF-8 by default +- ASCII-only support? diff --git a/table-of-contents.md b/table-of-contents.md index 298bcd1..2444ea2 100644 --- a/table-of-contents.md +++ b/table-of-contents.md @@ -1,5 +1,11 @@ # Table of Contents +## Grammar + +The entire Grammar is defined in [ava.ebnf](./ava.ebnf). + +## Discussion + - [Keywords](keywords.md) - [Operators & Symbols](operators-symbols.md) - [Names](names.md) diff --git a/type-classes.md b/type-classes.md index b15218f..ceab292 100644 --- a/type-classes.md +++ b/type-classes.md @@ -1 +1,16 @@ # 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 +```