moo/lib/syntax.txt

89 lines
3.2 KiB
Plaintext
Raw Permalink Normal View History

literal := number-literal | string-literal | character-literal | symbol-literal
string-literal := single-quote string-character* single-quote
string-character := normal-character | (single-quote single-quote)
single-quote := "'"
normal-character := character-except-single-quote
character-literal := "$" character
character := normal-character | "'"
symbol-literal := "#" symbol-body
symbol-body := identifier | keyword+ | binary-selector | string
unary-selector := identifier
binary-selector := binary-selector-character+
binary-selector-character := "+" | "/" | "\" | ...
selector-argument := identifier
identifier := alpha-char (alpha-char | digit-char)*
keyword := identifier ":"
class-definition := #class class-modifier? "{" class-body "}"
class-modifier := "(" (#byte | #character | #word | #pointer)? ")"
class-body := variable-definition* method-definition*
variable-definition := (#dcl | #declare) variable-modifier? variable-list "."
variable-modifier := "(" (#class | #classinst)? ")"
variable-list := identifier*
method-definition := #method method-modifier? method-actual-definition
method-modifier := "(" (#class | #instance) ")"
method-actual-definition := method-name "{" method-tempraries? method-primitive? method-statements* "}"
method-name := unary-method-name | binary-method-name | keyword-method-name
unary-method-name := unary-selector
binary-method-name := binary-selector selector-argument
keyword-method-name := (keyword selector-argument)+
method-temporaries := "|" variable-list "|"
method-primitive := "<" "primitive:" integer ">"
method-statements := method-statement ("." | ("." method-statements))*
method-statement := method-return-statement | method-expression
method-return-statement := "^" method-expression
2015-06-03 04:22:19 +00:00
method-expression := method-assignment-expression | basic-expression
method-assignment-expression := identifier ":=" method-expression
basic-expression := expression-primary (message-expression cascaded-message-expression)?
2015-06-03 04:22:19 +00:00
expression-primary := identifier | literal | block-constructor | ( "(" method-expression ")" )
----------------------------------------------------------
message-expression := (unary-message-expression+ binary-message-expresson* keyword-message-expression?) |
(binary-message-expression+ keyword-message-expression?) |
keyword-message-expression
cascaded-message-expression := (";" message-expression)*
keyword-message-expression := (keyword keyword-argument)+
keyword-argument := expression-primary unary-selector* binary-message-expression*
binary-message-expression := binary-selector binary-argument
binary-argument := expression-primary unary-selector*
------------------------------------------------------------
#include '....'.
#class Test(Object)
{
}
#main
================================================
#library Dynlib from 'dyn-lib.so' <--- this is a generic shared library
{
## no instance variables allowed
## class-level(static) functions only.
int abc (int, float, void*) <--- call this as Dynlib.abc (...). anc proper type conversion back and forth must occur.
int abc (int, float, void*) as abc: aaa x: x y: y <--- remap the original name to a moo-style name.
}
#class abc from 'x11.so' <--- this is a moo-only shared library
{
}