-
public final class Protelis2KotlinKt
-
-
Field Summary
Fields Modifier and Type Field Description private Contextcontextprivate final StringprotelisFileExt
-
Method Summary
Modifier and Type Method Description ContextgetContext()ContextsetContext(Context context)final StringgetProtelisFileExt()final UnitregisterProtelisType(String pt)Utility function to extend contextual info with a Protelis type final Pair<String, String>parseTypeAndRest(String line)Parses a type and returns both the parsed type and the remaining text final ProtelisFunDocparseDoc(String doc)Parses the documentation of a Protelis function final ProtelisFunparseProtelisFunction(String fline)Parses a Protelis function definition final List<ProtelisItem>parseFile(String content)Parses Protelis source code into a list of ProtelisItems final StringgenerateKotlinDoc(ProtelisFunDoc docs)Generates (Dokka ) Kotlin documentation from a ProtelisFunDoc final StringgenerateKotlinType(String protelisType)Generates a Kotlin type from a Protelis type final StringsanitizeNameForKotlin(String name)Symbols used frely in Protelis but that are not valid in Kotlin (e.g. final StringgenerateKotlinFun(ProtelisFun fn)Generates a Kotlin function from a Protelis function descriptor final StringgenerateKotlinItem(ProtelisItem pitem)Generates a Kotlin item (doc + fun signature) from a Protelis item (doc + fun) final StringgenerateKotlin(List<ProtelisItem> protelisItems)Generates a string from a list of Protelis items (function and docs pairs) final StringpackageToClassName(String pkg)Turns a Protelis package to a class name using camelcase convention final Unitmain(Array<String> args)Main function: reads all Protelis files under a base directory, parses them, and generates corresponding Kotlin files in a destination directory. -
-
Method Detail
-
getContext
Context getContext()
-
setContext
Context setContext(Context context)
-
getProtelisFileExt
final String getProtelisFileExt()
-
registerProtelisType
final Unit registerProtelisType(String pt)
Utility function to extend contextual info with a Protelis type
-
parseTypeAndRest
final Pair<String, String> parseTypeAndRest(String line)
Parses a type and returns both the parsed type and the remaining text
- Parameters:
line- The text line to be parsed
-
parseDoc
final ProtelisFunDoc parseDoc(String doc)
Parses the documentation of a Protelis function
- Parameters:
doc- The documentation string to be parsed
-
parseProtelisFunction
final ProtelisFun parseProtelisFunction(String fline)
Parses a Protelis function definition
- Parameters:
fline- The string of a Protelis function definition to be parsed
-
parseFile
final List<ProtelisItem> parseFile(String content)
Parses Protelis source code into a list of ProtelisItems
- Parameters:
content- The string of Protelis source code to be parsed
-
generateKotlinDoc
final String generateKotlinDoc(ProtelisFunDoc docs)
Generates (Dokka ) Kotlin documentation from a ProtelisFunDoc
- Parameters:
docs- The ProtelisFunDoc object encapsulating the docs for a Protelis function
-
generateKotlinType
final String generateKotlinType(String protelisType)
Generates a Kotlin type from a Protelis type
-
sanitizeNameForKotlin
final String sanitizeNameForKotlin(String name)
Symbols used frely in Protelis but that are not valid in Kotlin (e.g., as they are reserved words) are sanitized
-
generateKotlinFun
final String generateKotlinFun(ProtelisFun fn)
Generates a Kotlin function from a Protelis function descriptor
-
generateKotlinItem
final String generateKotlinItem(ProtelisItem pitem)
Generates a Kotlin item (doc + fun signature) from a Protelis item (doc + fun)
-
generateKotlin
final String generateKotlin(List<ProtelisItem> protelisItems)
Generates a string from a list of Protelis items (function and docs pairs)
-
packageToClassName
final String packageToClassName(String pkg)
Turns a Protelis package to a class name using camelcase convention
-
main
final Unit main(Array<String> args)
Main function: reads all Protelis files under a base directory, parses them, and generates corresponding Kotlin files in a destination directory.
This is to be called with two arguments:
The base directory from which recursively looking for Protelis files
The destination directory that will contain the output Kotlin files
-
-
-
-