Commit 26c9e03d authored by Adrian Cochrane's avatar Adrian Cochrane

Describe language syntax.

parent 8752def6
## Language
This language should have it's own MIMEtype, and trigger an interpretor entirely seperate from the normal web browser. It is expected that developers will
### Shebang
If a file starts with `#!`, the last whitespace-seperated "word" of that line should specify the URL of another script written in the same language specified here.
This file should contain a function of the signature `parse : Func Bytes Program` or `parse : Func List Char Program`, using the standard library types.
### Importing files
A file may start with a comma-seperated list surrounded by square brackets of names which should be accessible to any script importing it.
Following this maybe lines specifying a URL after the keyword `import`. After this may be a comma-seperated list of names to import from that file surrounded by square brackets, the keyword `as` followed by an identifier, and/or the keyword `via` followed by another URL. `as` prefixes any names imported from that file with the seperated by a dot (`.`), and `via` specifies the script which should be used to parse it as if that file specified a shebang line.
There may also by lines specifying a MIMEtype and a URL (in that order) following the keyword `parser`. This allows that script to be triggered upon importing a file specifying that MIMEtype as it's `Content-Type`.
### Type declarations
Following the keyword `type` may be one identifier starting with an uppercase letter followed by others starting with a lowercase letter. The former identifiers is it's name,and the latter defines new "generic" types. Next should occur an `=` followed by a `|`-seperated list of "variants" containing at least one.
These variants should start with an identifier starting with an uppercase letter, optionally followed by whitespace-seperated type signatures which may include the generic types listed before the `=`.
### Function declarations
A function is defined in the form "name parameters... `=` expression" where name and each parameter is an identifier starting with a lowercase letter.
"expression" may consist of:
* A square-bracketed and comma seperated list of "name parameters... `=` expression" may precede an expression, defining functions for use exclusively in the following expression or between each other.
* A sequence of identifiers indicates that the first identifier indicates a function to call and the rest should be passed as arguments. Or it may call a variant defined by a type declaration.
* A curly-bracketed and comma seperated list of "name arguments... `=` expression" may follow an expression, for the left hand side to match the variant it ultimately calls and the right hand side indicating what should take it's place.
### Type signatures
At any point between type and function declarations a type signature may be specified. This starts with the name of a function defined in this file followed by a `:`. After this is a prefix-encoded expression of referring to any in-scope type signatures, whether imported or inline. If the function does not have this type compilation should fail.
That is it starts with a type's name followed by any type parameters it requires, the values of which takes on the same structure.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment