HomeForumSourceResearchGuide
Sign in to contribute to source. how it works
Type definition file util.compiler.SyntaxParser by barry
expand copy to clipboardexpand
uses data.String
uses data.KeyValue

data TokSubTypes {
	//subtypes for literals
	const int L_INT = 1
	const int L_DEC = 2
	const int L_STRING = 3

	//operations
	const int DECLARE = 4
	const int DECLARE_ARRAY = 5
	const int ASSIGN = 6
	const int IF = 7
	const int ELSE = 8
	const int ELSEIF = 9
	const int FOR = 10
	const int WHILE = 11
	const int MUTEX = 12
	const int RETURN = 13
	const int NEW_INSTANCE = 14
	const int FRAME_INIT_OBJECT = 15
	const int OBJECT_CALL = 16
	const int EQUAL = 17
	const int NOT_EQUAL = 18
	const int BOOL_NOT = 19
	const int INCREMENT = 21
	const int DECREMENT = 22
	const int FRAME_INIT_LOCAL = 23
	const int LOCAL_CALL = 24
	const int NEW_ARRAY = 25
	const int NEW_ARRAY_CONSTRUCT = 26
	const int NEW_ARRAY_INIT = 27
	const int NEW_ARRAY_APPEND = 28
	const int ASSIGN_DATA_PARAM = 29
	const int MEMBER = 30
	const int ARRAY_INDEX = 31
	const int DX_GET_SELF_ID = 32
	const int DX_EQ_OBJECT_REF = 33
	const int GREATER_THAN = 34
	const int LESS_THAN = 35
	const int GREATER_THAN_EQ = 36
	const int LESS_THAN_EQ = 37
	const int NUM_ADD = 38
	const int NUM_SUB = 39
	const int NUM_MUL = 40
	const int NUM_DIV = 41
	const int NUM_MOD = 42
	const int BIT_NOT = 43
	const int BIT_AND = 44
	const int BIT_OR = 45
	const int BIT_LSHIFT = 46
	const int BIT_RSHIFT = 47
	const int BIT_XOR = 48
	const int ARRAY_LENGTH = 49
	const int THROW = 50
	const int BREAK = 51
	const int IFX_AND = 52
	const int IFX_OR = 53
	const int TYPE_CONST = 54
	const int NEW_ARRAY_CONSTRUCT_SE = 55 //"string expression" version
	const int NEW_ARRAY_INIT_SE = 56
	const int NEW_ARRAY_APPEND_SE = 57
	const int LOCAL_CALL_ASYNCH = 58
	const int IS_SET = 59
	const int CLONE = 60
	const int EQUAL_REF = 61
	const int NOT_EQUAL_REF = 62
	const int GET_TYPE_FIELD = 63
	const int GET_VAR_FIELD = 64
	const int TYPEOF = 65
	const int NEW_INSTANCE_FROM = 66
	const int NEW_ARRAY_FROM = 67
	const int NEW_ARRAY_CONSTRUCT_FROM = 68
	const int NEW_ARRAY_INIT_FROM = 69
	const int SINK_EVENT = 70
	const int STOP_EVENT = 71
	const int EMIT_EVENT = 72
	const int ARRAY_COPY = 73
	const int NEW_ARRAY_MD_INIT = 74
	const int SUB_ARRAY = 75
	const int SERIAL = 76
	const int GET_RUNTIME_IDC = 77
	const int PAUSE_OBJECT = 78
	const int RESUME_OBJECT = 79
	const int REWIRE_OBJECT = 80
	const int WAIT_FOR_OBJECT = 81
	const int WAIT_FOR_OBJECT_THREADS = 82
	const int HALT = 83
	const int HTOD = 84
	const int DTOH = 85
	const int GET_DIMENSIONS = 86
	const int SET_DIMENSIONS = 87
	const int NEGATIVE = 88
	const int HAS_TYPE = 89
	const int THIS_THREAD = 90
	const int RCLONE = 91
	const int IMPLEMENTS = 92
	const int DELINK = 93
	const int DYNAMIC_CALL = 94
	const int EMIT_EVENT_DYN = 95
}

data DanaToken nocycle {
	const int TOKEN = 1
	const int KEYWORD = 2
	const int VARIABLE = 3
	const int LITERAL = 4
	const int TYPE = 5
	const int EXPRESSION = 6
	const int SQ_EXPRESSION = 7
	const int SCOPE = 8
	const int PARAM = 9
	const int USES = 10
	
	const int COMPONENT = 11
	const int PROVIDES = 12
	const int REQUIRES = 13
	const int TYPE_HEADER = 14
	const int IMPLEMENTATION = 15
	const int FUNCTION_HEADER = 16
	const int EVENT_HEADER = 17
	const int FUNCTION_CALL = 18

	const int OUTER_SCOPE = 19
	
	const int OPERATION = 20
	
	int type
	int subType
	char token[]
	
	int lineNumber
	int offset
	int length
	
	const int EX_CONSTANT_STR = 1
	const int EX_CONSTANT_INT = 2
	const int EX_CONSTANT_DEC = 3
	int exInt1
	int exInt2
	
	char exStr1[]
	char exStr2[]
	
	DanaToken next
	
	DanaToken subTokens
	DanaToken subTokensEnd
	int subTokensSkip

	char commentBlock[]
	}

data DanaTypeField {
	char name[]
	char type[]
	char qualifier[]
	DanaToken value
	byte valueType
	const byte INHERITED = 128
	byte flags
	bool deprecated
	char deprecatedBy[]
	}

data DanaType nocycle {
	const byte NULL = 0
	const byte INTEGER = 1
	const byte DECIMAL = 2
	const byte DATA = 3
	const byte INTERFACE = 4
	const byte ARRAY = 5
	const byte FUNCTION = 6
	const byte EVENT = 7
	const byte VAR = 8
	byte class
	char name[]
	char simpleName[]
	char fromFile[]
	DanaTypeField fields[]
	int storageSize
	char extendsType[]
	DanaToken defaultFunction
	const byte F_NO_CYCLE = 1
	byte flags
	bool deprecated
	char deprecatedBy[]
	}

data ParseError {
	int line
	char file[]
	char message[]
}

data ParseResult {
	bool success
	DanaToken tree
	ParseError errors[]
}

interface SyntaxParser {

	SyntaxParser(store String searchPaths[], opt int addressWidth)
	
	// general parsing & cloning
	
	ParseResult parse(char source[], opt char filePath[], KeyValue memFiles[])
	
	DanaType[] getTypes()
	
	}
Revision history
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n util.compiler.SyntaxParser -m "reason for update" -u yourUsername
Version 3 by barry
Version 2 by barry
Version 1 (this version) by barry
Notes for this version: New compiler components