pub enum ContextType {
Show 48 variants
Span,
Expression,
TableLiteral,
ArrayLiteral,
VectorLiteral,
FunctionLiteral,
ClassLiteral,
CallArgumentList,
Statement,
BlockStatement,
IfStatement,
IfStatementCondition,
WhileStatement,
WhileStatementCondition,
DoWhileStatement,
DoWhileStatementCondition,
SwitchStatement,
SwitchStatementCondition,
ForStatement,
ForStatementCondition,
ForeachStatement,
ForeachStatementCondition,
TryCatchStatement,
TryCatchStatementCatchName,
ReturnStatement,
YieldStatement,
ThrowStatement,
ThreadStatement,
DelayThreadStatement,
WaitThreadStatement,
WaitThreadSoloStatement,
WaitStatement,
GlobalStatement,
ClassDefinition,
EnumDefinition,
FunctionDefinition,
ConstDefinition,
VarDefinition,
StructDefinition,
TypeDefinition,
Property,
Constructor,
Method,
FunctionParamList,
FunctionEnvironment,
FunctionCaptureList,
Type,
GenericArgumentList,
}Expand description
Context information that can be attached to a ParseError.
Essentially, if an error has a context, it means that the parser knows that the error is inside some specific syntactical construct.
This is intended to hint at the state of the parser to make syntax errors and parser debugging a bit easier.
Implements std::fmt::Display to write a useful description of the context.
Variants§
Span
A span of something. This should generally be replaced with a more specific context.
Expression
An expression with a value and an operator.
§Example
(1 + 5) * 3--
^^^^^^^ ^^^ expression
^^^^^^^^^^^^^ expressionTableLiteral
Literal defining a table.
§Example
local ages = SumAges({ Charlie = 28, Maeve = 23 })
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ table literalArrayLiteral
Literal defining an array.
§Example
local cities = ["Adelaide", "Sydney"].join(", ")
^^^^^^^^^^^^^^^^^^^^^^ array literalVectorLiteral
Literal defining a 3D vector.
§Example
player.LookAt(< -5.2, 0.0, 10.0 >)
^^^^^^^^^^^^^^^^^^^ vector literalFunctionLiteral
Literal defining an anonymous function.
§Example
local writeVal = function() { }
^^^^^^^^^^^^^^ function literalClassLiteral
Literal defining an anonymous class.
§Example
local ageManager = class { Ages = ages }
^^^^^^^^^^^^^^^^^^^^^ class literalCallArgumentList
List of arguments in a function call.
§Example
player.SayTo(friend, "Hello there!")
^^^^^^^^^^^^^^^^^^^^^^ call argumentsStatement
A statement in a program or block.
§Example
local name = "squirrel"
^^^^^^^^^^^^^^^^^^^^^^^ statementBlockStatement
A block statement, containing multiple sub-statements.
§Example
local count = 6;
{
_^
| log("hello");
| }
|_^ block statement
log("world");IfStatement
All of an if statement.
§Example
local isTimedOut = player.IsTimedOut()
if (isTimedOut && player.IsAlive()) {
_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| player.Kill()
| }
|_^ if statement
```textIfStatementCondition
The condition in an if statement.
§Example
if ( IsLoggedIn() ) LogOut()
^^^^^^^^^^^^^^^^ if statement conditionWhileStatement
All of a while statement.
§Example
while (!IsDay()) {
_^^^^^^^^^^^^^^^^^^
| Sleep();
| }
|_^ while statement
WakeUp();WhileStatementCondition
The condition of a while statement.
§Example
while (!isDone) Continue()
^^^^^^^^^ while statement conditionDoWhileStatement
All of a do while statement.
§Example
do {
_^^^^
| Shoot();
| } while ( IsButtonDown() )
|_^^^^^^^^^^^^^^^^^^^^^^^^^^ do while statementDoWhileStatementCondition
The condition of a do while statement.
§Example
do {
train()
} while (fitness < 10)
^^^^^^^^^^^^^^ do while statement condition
SwitchStatement
All of a switch statement.
§Example
switch (state) {
_^^^^^^^^^^^^^^^^
| case "playing": play(); break;
| cause "paused": pause(); break;
| }
|_^ switch statementSwitchStatementCondition
The condition of a switch statement.
§Example
switch ( GameMode() ) {
^^^^^^^^^^^^^^ switch statement condition
case "slayer":
return;
case "creative":
SetHealth(100);
break;
}ForStatement
All of a for statement.
§Example
for (local i = 0; i < 10; i++) {
_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| println(i)
| }
|_^ for statementForStatementCondition
The condition of a for statement.
§Example
for (local i = 0; i < players.len; i++) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ for statement condition
players[i].say("hello")
}ForeachStatement
All of a foreach statement.
§Example
foreach (i, video in videos) {
_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| println("playing " + i)
| play(video)
| }
|_^ForeachStatementCondition
The condition of a foreach statement.
§Example
foreach (Map map in maps) {
^^^^^^^^^^^^^^^^^ foreach statement condition
map.load()
println("loaded map: " + map.name)
}TryCatchStatement
All of a try catch statement.
§Example
try {
_^^^^^
| FetchData()
| } catch (error) {
| println("could not fetch data: " + error)
| }
|_^ try catch statementTryCatchStatementCatchName
The catch binding in a try catch statement.
§Example
try {
money += withdraw(500)
} catch (error) {
^^^^^^^ try catch statement catch name
println(error)
}ReturnStatement
YieldStatement
A yield statement in a generator function.
§Example
foreach (player in players) {
yield player.health
^^^^^^^^^^^^^^^^^^^ yield statement
}ThrowStatement
A throw statement.
§Example
if ( !request.success ) {
throw "Request Failed"
^^^^^^^^^^^^^^^^^^^^^^ throw statement
}ThreadStatement
DelayThreadStatement
A delaythread statement.
§Example
delaythread(10) alert("times up!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ delay thread statementWaitThreadStatement
A waitthread statement.
§Example
waitthread readAllFiles()
^^^^^^^^^^^^^^^^^^^^^^^^^ wait thread statementWaitThreadSoloStatement
A waitthreadsolo statement.
§Example
waitthreadsolo WaitForPlayerExitButtonPressed( player )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ wait thread solo statementWaitStatement
GlobalStatement
ClassDefinition
Class definition.
§Example
class Person {
_^^^^^^^^^^^^^^
| alive = true
| constructor(name) {
| this.name <- name
| }
| }
|_^ class definitionEnumDefinition
Enum definition.
§Example
enum GameMode {
_^^^^^^^^^^^^^^^
| SURVIVAL,
| CREATIVE,
| ADVENTURE,
| }
|_^ enum definitionFunctionDefinition
Function definition.
§Example
void function Damage( entity player ) {
_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| player.health -= 5
| }
|_^ function definition
Damage( me )ConstDefinition
Constant value definition.
§Example
const MaxHealth = 10;
^^^^^^^^^^^^^^^^^^^^^ const definition
player.health = MaxHealthVarDefinition
Variable definition.
§Example
local cities = ["Adelaide", "Sydney"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable definitionStructDefinition
Struct definition.
§Example
struct Waypoint {
_^^^^^^^^^^^^^^^^^
| float x,
| float y,
| string name
| }
|_^ struct definitionTypeDefinition
Type definition.
§Example
typedef PlayerMap table<string, player>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type definitionProperty
Property in a class, table, or struct.
§Example
class Player {
isPlaying = true
^^^^^^^^^^^^^^^^ class property
}Constructor
Constructor in a class or table.
§Example
class FunMachine() {
constructor() {
_____^^^^^^^^^^^^^^^
| this.funLevel <- 11
| }
|_____^ class constructor
}Method
Method in a class or table.
§Example
class FooCalculator {
int function calculateFoo() {
_____^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| return 4
| }
| }
|_^ class methodFunctionParamList
Function definition’s parameter list.
§Example
function foobar(int a, string b = "no", ...) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function param list
}FunctionEnvironment
Function environment definition.
§Example
local person = { age = 32 }
function printPersonDetails[person]() {
^^^^^^^^ function environment
println(this.age)
}FunctionCaptureList
Function free variable/capture list.
§Example
filterFunc = function(val) : (max) {
^^^^^ function capture list
return val <= max
}Type
A type with an optional number of type modifiers.
§Example
table<string, person&> ornull
^^^^^ ^^^^^^ ^^^^^^ type
^^^^^^^ type
^^^^^^^^^^^^^^^^^^^^^^ type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ typeGenericArgumentList
List of arguments in a generic type.
§Example
table<string, country>
^^^^^^^^^^^^^^^^^ generic argument listTrait Implementations§
Source§impl Clone for ContextType
impl Clone for ContextType
Source§fn clone(&self) -> ContextType
fn clone(&self) -> ContextType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more