aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--language/functions.rst20
-rw-r--r--language/index.rst1
-rw-r--r--language/scanning.rst2
-rw-r--r--syntax.md10
4 files changed, 22 insertions, 11 deletions
diff --git a/language/functions.rst b/language/functions.rst
new file mode 100644
index 0000000..86d1144
--- /dev/null
+++ b/language/functions.rst
@@ -0,0 +1,20 @@
+Functions
+---------
+
+.. crowbar:element:: FunctionDeclaration <- FunctionSignature ';'
+
+ A function declaration defines the return type, name, and arguments of a function without specifying its behavior.
+ It is generally used as part of an API boundary.
+
+.. crowbar:element:: FunctionDefinition <- FunctionSignature Block
+
+ A function definition provides the actual behavior of a function, which may have been declared previously or may not.
+
+ .. todo::
+
+ define function linkage/exportedness
+
+.. crowbar:element:: FunctionSignature <- Type identifier '(' SignatureArguments? ')'
+ SignatureArguments <- Type identifier (',' Type identifier)* ','?
+
+ A function signature specifies the return type, name, and arguments of a function.
diff --git a/language/index.rst b/language/index.rst
index eb2d92c..66492a9 100644
--- a/language/index.rst
+++ b/language/index.rst
@@ -18,3 +18,4 @@ Syntax elements in this document are given in the form of `parsing expression gr
source-file
include
type-definition
+ functions
diff --git a/language/scanning.rst b/language/scanning.rst
index c45e6b8..3ed9bfe 100644
--- a/language/scanning.rst
+++ b/language/scanning.rst
@@ -14,7 +14,7 @@ Scanning
One of the literal words ``bool``, ``break``, ``case``,
``char``, ``const``, ``continue``, ``default``, ``do``, ``double``,
``else``, ``enum``, ``extern``, ``float``, ``for``, ``fragile``,
- ``function``, ``if``, :crowbar:ref:`include <IncludeStatement>`, ``int``, ``long``, ``return``,
+ ``function``, ``if``, :crowbar:ref:`include <IncludeStatement>`, ``int``, ``long``, ``opaque``, ``return``,
``short``, ``signed``, ``sizeof``, ``struct``, ``switch``, ``union``,
``unsigned``, ``void``, or ``while``.
diff --git a/syntax.md b/syntax.md
index 96f0b88..e6ec9f1 100644
--- a/syntax.md
+++ b/syntax.md
@@ -1,15 +1,5 @@
# Syntax (old)
-### Top-level elements
-
-```PEG
-FunctionDeclaration ← FunctionSignature ';'
-FunctionDefinition ← FunctionSignature Block
-FunctionSignature ← Type identifier '(' SignatureArguments? ')'
-SignatureArguments ← Type identifier ',' SignatureArguments /
- Type identifier ','?
-```
-
### Statements
```PEG