@@ -25,6 +25,10 @@ The lexer takes an input string and returns a stream of tokens.
2525| ------------ | ----------------------------- | --------------------------------------------------------------------- |
2626| ` LParan ` | ` ( ` | Opening parantheses for a call expression |
2727| ` RParan ` | ` ) ` | Closing parantheses for a call expression |
28+ | ` Comma ` | ` , ` | Separator between arguments in ` Fn ` types |
29+ | ` LAngle ` | ` < ` | Generic type delimitor |
30+ | ` RAngle ` | ` > ` | Generic type delimitor |
31+ | ` Arrow ` | ` -> ` | Separator between ` Fn ` arg parans and return type |
2832| ` Identifier ` | ` [!?:]?[a-zA-Z][a-zA-Z0-9_]* ` | Identifer referencing a builtin function, variable, prompt, or secret |
2933| ` String ` | `` `[^`]*` `` | A literal string of text delimited by backticks |
3034| ` True ` | ` true ` | A literal boolean value of ` true ` |
@@ -103,9 +107,10 @@ pub struct ExprCall {
103107
104108#### ExprIdentifier
105109
106- An identifier referencing a builtin, variable, prompt, secret, or client value.
110+ An identifier referencing a builtin, type, variable, prompt, secret, or client value.
107111
108112- ` builtin_name `
113+ - ` TypeName ` , ` TypeName<Type> ` , ` Fn(Type, ...Type) -> Type `
109114- ` :var_name `
110115- ` ?prompt_name `
111116- ` !secret_name `
@@ -120,6 +125,7 @@ pub enum IdentifierKind {
120125 Prompt ,
121126 Secret ,
122127 Client ,
128+ Type ,
123129}
124130
125131let ident = ExprIdentifier :: new (" :foo" );
@@ -226,6 +232,7 @@ Valid bytecode will always begin with 4 bytes representing the current language
226232| ` SECRET ` | 3 | Secret (identifier prefixed with ` ! ` ) |
227233| ` USER_BUILTIN ` | 4 | User provided builtin function |
228234| ` CLIENT_CTX ` | 5 | Client provided value (identifier prefixed with ` @ ` ) |
235+ | ` TYPE ` | 6 | A type stored in ` ExprByteCode ` |
229236
230237### Compile Time Environment
231238
@@ -267,6 +274,35 @@ pub struct FnArg {
267274
268275See: [ builtins.rs] ( ./src/builtins.rs ) , [ types.rs] ( ./src/types.rs ) , [ value.rs] ( ./src/value.rs )
269276
277+ ### ExprByteCode
278+
279+ The result of an expression compilation is ` ExprByteCode ` .
280+
281+ ``` rust
282+ pub struct ExprByteCode {
283+ version : [u8 ; 4 ],
284+ codes : Vec <u8 >,
285+ strings : Vec <String >,
286+ types : Vec <Type >,
287+ }
288+ ```
289+
290+ #### Version
291+
292+ The version of the compiler encoded as bytes.
293+
294+ #### Codes
295+
296+ The actual bytecode values.
297+
298+ #### Strings
299+
300+ An indexed list of strings encountered during compilation. These string indexes are referenced by the ` opcode::CONSTANT ` opcode.
301+
302+ #### Type
303+
304+ An indexed list of types encountered during compilation. These type indexes are referenced by the ` opcode::GET ` opcode and ` lookup::TYPE ` lookup.
305+
270306### Usage
271307
272308``` rust
0 commit comments