ContextType

Enum ContextType 

Source
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
^^^^^^^^^^^^^ 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
§

Statement

A statement in a program or block.

§Example

local name = "squirrel"
^^^^^^^^^^^^^^^^^^^^^^^ statement
§

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
```text
§

IfStatementCondition

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

A return statement in a function.

§Example

return rnd(0, 10)
^^^^^^^^^^^^^^^^^ return statement
§

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

A thread statement.

§Example

thread PostmatchScreen()
^^^^^^^^^^^^^^^^^^^^^^^^ thread statement
§

DelayThreadStatement

A delaythread statement.

§Example

delaythread(10) alert("times up!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ delay thread statement
§

WaitThreadStatement

A waitthread statement.

§Example

waitthread readAllFiles()
^^^^^^^^^^^^^^^^^^^^^^^^^ wait thread statement
§

WaitThreadSoloStatement

A waitthreadsolo statement.

§Example

waitthreadsolo WaitForPlayerExitButtonPressed( player )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ wait thread solo statement
§

WaitStatement

A wait statement.

§Example

println("3")
wait 1
^^^^^^ wait statement
println("2")
§

GlobalStatement

A global statement.

§Example

global MaxThreads = 10
^^^^^^^^^^^^^^^^^^^^^^ global statement
§

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

Type definition.

§Example

typedef PlayerMap table<string, player>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type definition
§

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

Source§

fn clone(&self) -> ContextType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContextType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ContextType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ContextType

Source§

fn eq(&self, other: &ContextType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ContextType

Source§

impl Eq for ContextType

Source§

impl StructuralPartialEq for ContextType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.