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

data TypeDef {
	const int INTEGER	= 1
	const int DECIMAL	= 2
	const int DATA		= 3
	const int INTERFACE	= 4
	const int COMPONENT	= 5
	
	int class
	
	char name[]
	char fullName[]
	
	char doc_description[]
	}

data DataDef extends TypeDef {
	FieldDef fields[]
	FieldDef constants[]
	
	TypeDef extendsType
	}

data FieldDef {
	char name[]
	char displayName[]
	char type[]
	bool array
	bool scope_store
	bool opt_param
	
	char doc_description[]
	}

data EventSourceDef {
	char name[]
	char displayName[]
	char type[]
	bool array
	
	char doc_description[]
	
	FieldDef params[]
	}

data FunctionDef {
	char name[]
	char returnType[]
	
	char doc_description[]
	
	FieldDef params[]

	char defaultFunction[]
	}

data InterfaceDef extends TypeDef {
	FunctionDef functions[]
	EventSourceDef eventSources[]
	FieldDef transferFields[]
	FieldDef constants[]
	
	InterfaceDef extendsType
	}

data ProIntfDef {
	char typeName[]
	char variantName[]
	String subInterfaces[]
}

data ReqIntfDef {
	char typeName[]
	char variantName[]
	bool isNative
}

data ComponentDef extends TypeDef {
	ProIntfDef provIntfs[]
	ReqIntfDef reqIntfs[]
	}

//a single parsed source file with all of the types that it contains, and references to all of the support files that it used
data SourceFile {
	char path[]
	char package[]
	
	TypeDef types[]
	
	SourceFile supportFiles[]
	}

//this structure contains ALL parsed files, and a cache of ALL files used by those parsed files
data ParsedFiles {
	SourceFile primaryFiles[]
	SourceFile supportFiles[]
	}

data ParseIssue {
	const int I_UNRESOLVED_TYPE = 1
	const int I_PARSE_FAILURE = 2
	const int I_SYNTAX_ERROR = 3
	int type
	char element[]
	char inFile[]
	char description[]
	int atLine
}

data ParseStatus {
	bool success
	ParseIssue issues[]
}

/*
 {"description" : "Generate a documentation structure which can then be written to HTML or another format."}
*/

interface TypeParser {
	/*
	 {"@description" : "Initialise a new Dana source code type parser."}
	*/
	TypeParser()

	/*
	 {"@description" : "Parse a file, building a documentation structure for it.",
	 	"fileContent" : "the contents (in memory) of the file to parse",
		"filePath" : "the name of the file being parsed",
		"searchPaths" : "an optional list of additional search paths to use when resolving used types"}
	*/
	ParseStatus parseFile(char fileContent[], opt char filePath[], opt String searchPaths[], opt KeyValue resFiles[])
	
	/*
	 {"@description" : "Get a documentation structure for all files parsed so far."}
	*/
	ParsedFiles getParsedFiles()
	}
Revision history
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n parsing.TypeParser -m "reason for update" -u yourUsername
Version 2 (this version) by barry
Notes for this version: Adds a field to hold a default function implementation.
Version 1 by barry