User:Nescius

From Valve Developer Community
Jump to: navigation, search

I just want to see my name in blue. You can leave now

personal notes

temp_reg = null
_stack = { ... }
_registry = { ... }
_table_default_delegate = { ... } //contains table methods
_array_default_delegate = { ... } //contains array methods
_string_default_delegate = { ... } //contains string methods
_number_default_delegate = { ... } //contains integer, float, bool methods
_handle_default_delegate = { ... } //contains chandle methods(only tointeger(), used with point_script_use_target)
_utlstringtoken_default_delegate = { ... } //?
_generator_default_delegate = { ... } //contains generator methods
_thread_default_delegate = { ... } //contains thread methods
_closure_default_delegate = { ... } //contains function methods
_class_default_delegate = { ... } //contains class methods
_instance_default_delegate = { ... } //contains instance methods
_weakref_default_delegate = { ... } //contains weak reference methods
_metamethodsmap = {
  _add: 0
  _sub: 1
  _mul: 2
  _div: 3
  _unm: 4
  _modulo: 5
  _set: 6
  _get: 7
  _typeof: 8
  _nexti: 9
  _cmp: 10
  _call: 11
  _cloned: 12
  _newslot: 13
  _delslot: 14
  _tostring: 15
  _newmember: 16
  _inherited: 17
}
_lasterror = null
_errorhandler = (native function) //can be set to something else with seterrorhandler()
_consts = { ... } //variables made with const and enum go here (getconsttable())
_roottable = { //script, script_execute and mapspawn.nut executed in this scope (getroottable())

    //global shortcuts {
    g_ModeScript = DirectorScript.MapScript.ChallengeScript
    g_MapScript = DirectorScript.MapScript

    SessionOptions = g_ModeScript.DirectorOptions
    SessionState = g_ModeScript.MutationState
    SessionSpawns = g_MapScript.MapSpawns
    // }

    g_RoundState = { ... } //used by hints and StartBox stuff in sm_utilities

    g_rr = { ... } //response_testbed.nut executed in this scope

    GameEventCallbacks = { ... } //OnGameEvent_
    ScriptEventCallbacks = { ... } //OnScriptEvent_

    DirectorScript = { //director_base.nut executed in this scope
        DirectorOptions = { ... } //4

        MapScript = { //mapscripts, trigger_finale scripts and scriptedmode.nut executed in this scope
            DirectorOptions = { ... } //3
            BaseScriptedDOTable = { ... } //added into ChallengeScript.DirectorOptions

            //these come from mapscripts {
            MapOptions = { ... } //added into ChallengeScript.DirectorOptions
            MapState = { ... } //added into ChallengeScript.MutationState
            MapSpawns = [] //entity groups to spawn

            SanitizeTable = { ... } //entities to remove
            // }

            ChallengeScript = { //modescripts executed in this scope
                MutationOptions = { ... } //added into DirectorOptions (below)
                MutationState = { ... }
                ModeSpawns = [] //added into MapSpawns

                DirectorOptions = { ... } //1
            }

            LocalScript = { //director's BeginScript input runs script in this scope
                DirectorOptions = { ... } //2
            }

            ScriptedDamageInfo = { ... } //used by AllowTakeDamage

            //entity group related
            EntityGroups = { ... }
            InstancedEntityGroup = { ... }
            ReplacementParms = { ... }
            UniqueTargetnames = { ... }

            //startbox related
            StartboxFloating_Info = { ... }
            StartboxCenter_Info = { ... }
            StartboxSpeedbump_Info = { ... }

            defaultClearout = { ... } //for clearout (used in holdout)
        }
    }

    g_ClearoutTable = { ... } //for clearout (used in holdout)

    //script_debug commands related
    ScriptDebugTraces = { ... }
    ScriptDebugTextFilters = { ... }

    //documentation
    _PublishedHelp = { ... }
    Documentation = {
        classes = { ... }
        instances = { ... }
        functions = { ... }
    }

    SPAWN_FLAGS = { ... } //entitygroup related, used in MapSpawns thingy

    //entity scopes are created in _roottable example:
    //<uniquestring><targetname or classname if no targetname> = {}
    _10dc_worldspawn = { ... }
    //name of this scope is saved in entity's m_iszScriptId netprop
    //entity's RunScriptCode,RunScriptFile inputs create this scope if it doesn't exist and executes script in it
    //also scripts specified in entity's 'vscripts' keyvalue executed in this scope
}


Squirrel grammar

id:= [a-zA-Z_]+[a-zA-Z_0-9]* //identifier

//literals
IntegerLiteral := [1-9][0-9]* | '0x' [0-9A-Fa-f]+ | ''' [.]+ ''' | 0[0-7]+
FloatLiteral := [0-9]+ '.' [0-9]+
FloatLiteral := [0-9]+ '.' 'e'|'E' '+'|'-' [0-9]+
StringLiteral:= '"'[.]* '"'
VerbatimStringLiteral:= '@''"'[.]* '"'

//operators
bassignops := '+=' | '/=' | '-=' | '*=' | '%=' | '<-' | '=' |
barithops := '+' | '-' |  '/' | '*' | '%'
bbitwops := '&' | '^' | '|' | '>>' | '<<' | '>>>'
blogicops := '||' | '&&'
bcompops := '!=' | '==' | '>=' | '<=' | '>' | '<=>'

ulogicops := '!'
urithops := '-'
ubitwops := '~'
uassignops := '++' | '--'

//other?
explist := exp [',' explist]
args := id [',' args]

//expressions
derefexp := id | exp '.' id
exp := '::' id | derefexp | functionexp
exp := derefexp '=' exp
exp := derefexp '<-' exp
exp := exp_cond '?' exp ':' exp
exp := exp binop exp
exp := keyexp 'in' tableexp
exp := instanceexp 'instanceof' classexp
exp := 'typeof' exp
exp := 'clone' exp
exp := exp ',' exp
exp := 'delete' derefexp

tslots := ( id ('='|':') exp | '[' exp ']' '=' exp | '"' [.]* '"' ':' exp) [',']
exp := '{' [tslots]* '}' //table constructor

exp := '[' [explist] ']' //array constructor

exp_cond := exp
initexp := exp
condexp := exp
incexp := exp
functionexp := 'function' '(' args ')' stat
exp := derefexp '(' explist ')'

//statements
stats := stat [';'|'\n'] stats 
stat := '{' stats '}'
stat := 'if' '(' exp ')' stat ['else' stat]
stat := 'break' | 'continue'
stat := 'for' '(' [initexp] ';' [condexp] ';' [incexp] ')' stat
stat := 'foreach' '(' [index_id','] value_id 'in' exp ')' stat
stat := 'while' '(' exp ')' stat
stat := 'do' stat 'while' '(' expression ')'
stat := 'switch' '(' exp ')' '{'
            'case' case_exp ':'
                stats
            ['default' ':'
                stats]
        '}'
stat := 'return' [exp] | 'yield' [exp]

initz := id [= exp][',' initz]
stat := 'local' initz

stat := 'const' id '=' IntegerLiteral | FloatLiteral | StringLiteral
enumerations := ( id '=' Integer | FloatLiteral | StringLiteral ) [',']
stat:= 'enum' id '{' enumerations '}'

//funcname := id ['::' id]
functionstat := 'function' id ['::' id]* '(' args ')' [':' '(' args ')'] stat
stat := functionstat

memberdecl := id '=' exp | '[' exp ']' '=' exp | functionstat | 'constructor' functionexp
stat := 'class' derefexp ['extends' derefexp] '{'
           [memberdecl]*
       '}'

stat := 'try' stat 'catch' '(' id ')' stat
stat := 'throw' [exp]

stat := exp