Enum sqparse::ContextType
source · pub enum ContextType {
Show 46 variants
Span,
Expression,
TableLiteral,
ArrayLiteral,
VectorLiteral,
FunctionLiteral,
ClassLiteral,
CallArgumentList,
BlockStatement,
IfStatement,
IfStatementCondition,
WhileStatement,
WhileStatementCondition,
DoWhileStatement,
DoWhileStatementCondition,
SwitchStatement,
SwitchStatementCondition,
ForStatement,
ForStatementCondition,
ForeachStatement,
ForeachStatementCondition,
TryCatchStatement,
TryCatchStatementCatchName,
ReturnStatement,
YieldStatement,
ThrowStatement,
ThreadStatement,
DelayThreadStatement,
WaitThreadStatement,
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
^^^^^^^^^^^^^ expression
TableLiteral
Literal defining a table.
Example
local ages = SumAges({ Charlie = 28, Maeve = 23 })
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ table literal
ArrayLiteral
Literal defining an array.
Example
local cities = ["Adelaide", "Sydney"].join(", ")
^^^^^^^^^^^^^^^^^^^^^^ array literal
VectorLiteral
Literal defining a 3D vector.
Example
player.LookAt(< -5.2, 0.0, 10.0 >)
^^^^^^^^^^^^^^^^^^^ vector literal
FunctionLiteral
Literal defining an anonymous function.
Example
local writeVal = function() { }
^^^^^^^^^^^^^^ function literal
ClassLiteral
Literal defining an anonymous class.
Example
local ageManager = class { Ages = ages }
^^^^^^^^^^^^^^^^^^^^^ class literal
CallArgumentList
List of arguments in a function call.
Example
player.SayTo(friend, "Hello there!")
^^^^^^^^^^^^^^^^^^^^^^ call arguments
BlockStatement
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 condition
WhileStatement
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 condition
DoWhileStatement
All of a do while statement.
Example
do {
_^^^^
| Shoot();
| } while ( IsButtonDown() )
|_^^^^^^^^^^^^^^^^^^^^^^^^^^ do while statement
DoWhileStatementCondition
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 statement
SwitchStatementCondition
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 statement
ForStatementCondition
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 statement
TryCatchStatementCatchName
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 statement
WaitThreadStatement
A waitthread statement.
Example
waitthread readAllFiles()
^^^^^^^^^^^^^^^^^^^^^^^^^ wait thread statement
WaitStatement
GlobalStatement
ClassDefinition
Class definition.
Example
class Person {
_^^^^^^^^^^^^^^
| alive = true
| constructor(name) {
| this.name <- name
| }
| }
|_^ class definition
EnumDefinition
Enum definition.
Example
enum GameMode {
_^^^^^^^^^^^^^^^
| SURVIVAL,
| CREATIVE,
| ADVENTURE,
| }
|_^ enum definition
FunctionDefinition
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 = MaxHealth
VarDefinition
Variable definition.
Example
local cities = ["Adelaide", "Sydney"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable definition
StructDefinition
Struct definition.
Example
struct Waypoint {
_^^^^^^^^^^^^^^^^^
| float x,
| float y,
| string name
| }
|_^ struct definition
TypeDefinition
Property
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 method
FunctionParamList
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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type
GenericArgumentList
List of arguments in a generic type.
Example
table<string, country>
^^^^^^^^^^^^^^^^^ generic argument list
Trait 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 moresource§impl Debug for ContextType
impl Debug for ContextType
source§impl Display for ContextType
impl Display for ContextType
source§impl PartialEq<ContextType> for ContextType
impl PartialEq<ContextType> for ContextType
source§fn eq(&self, other: &ContextType) -> bool
fn eq(&self, other: &ContextType) -> bool
self and other values to be equal, and is used
by ==.