uses SyntaxParser
uses data.String
data FunctionRef {
char name[]
char intfName[]
}
data OpRef {
//index into the op array of this reference
int index
}
data OpToken nocycle {
int type
int subType
int subTypeB
int subTypeC
int flagA
int flagB
int flagC
int lineNumber
//which token this op was parsed from (if any)
DanaToken fromToken
//what type this op returns (if known)
DanaType returnType
//temporary note of a variable/field name, before its index is resolved
char variableName[]
//index into a variable list (e.g. for locals)
int variableIndex
//temporary note of a function name, before its index is resolved
char functionName[]
//function call index, for object calls
int functionIndex
//bindport index, for object instantiations
int bindportIndex
//event ranges, for sinkevent
int eventRangeLow
int eventRangeHigh
//scope override value (e.g. for ex2 of getRef)
int scopeOverride
//reference to another function (e.g. for local-function-call instructions)
FunctionRef functionRef
//reference to another op (e.g. for jump instructions)
OpRef opRef
//ops which reference this one
OpRef refBy[]
//a value referred to by this instruction (like a literal)
byte refValue[]
//a type referred to by the instruction (like typeof)
DanaType refType
//params
OpToken parameters[]
//the (potentially nested) first parameter which represents the reference point of any jump instructions
OpToken entryPoint
//add an abort-check instruction after this one
bool addAbortCheck
}
data Parameter nocycle {
char name[]
const byte Q_OPT = 1
const byte Q_STORE = 2
byte qualifier
bool autoStore
DanaType type
}
data ScopeVariable {
//the name of the variable
char name[]
//the variable's index into the flat list of variables
int index
int scopeLevel
int levelInstance
}
data Variable {
const byte SC_NEUTRAL = 0
const byte SC_LOCAL = 1
const byte SC_LOCAL_AUTO = 2
const byte SC_STORE = 3
byte storeClass
}
data OpFunction nocycle {
char name[]
DanaType returnType
const int CONSTRUCTOR = 1
const int FUNCTION = 2
const int EVENTSINK = 3
byte ftype
char fromFile[]
char fromType[]
//note: the first field entries in "variables" are a copy of "parameters"
Parameter parameters[]
Variable variableInfo[]
DanaType variables
ScopeVariable variableScopes[] //co-vector to variables.fields, describing scoping attributes of each local variable
OpToken instructions[]
bool inherited
}
data InterfaceFunctions nocycle {
char type[]
OpFunction functions[]
}
data OpParseError {
char file[]
int line
char message[]
}
data ProvidedObject nocycle {
char mainInterface[]
char semantic[]
String subInterfaces[]
DanaType instanceGlobals
DanaType transferState
InterfaceFunctions interfaces[]
OpFunction localFunctions[]
OpFunction initFunction
int eventSinkCount
}
data RequiredInterface nocycle {
char name[]
char semantic[]
bool isNative
char autoInstance[]
}
//NOTE: we don't need a "constants" field because they'll be parsed directly to "literal" instructions as part of the internal process
data OpParseResult nocycle {
bool success
ProvidedObject providedObjects[]
RequiredInterface requiredInterfaces[]
DanaType staticGlobals
OpFunction classInitFunction
OpParseError errors[]
OpParseError warnings[]
}
//this pass derives typing, literals, and control-flow, plus scoping and variables, "store" status, and giving an execution-order instruction list
interface OpParser {
OpParser(opt int addressWidth, opt bool perfProfile)
OpParseResult parse(char file[], store DanaToken tree, store DanaType types[])
}
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n util.compiler.OpParser -m "reason for update" -u yourUsername
Version 3 (this version) by barry
Notes for this version: Synch to other compiler interface changes.