XetoIO
@Js
const mixin XetoIO
XetoIO is used to read/write various Xeto formats via Namespace.io.
Convenience for writeAst to an in-memory string
Parse the Xeto source representation into its dict AST representation
Write instance data to Xeto source code
Parse the Axon source representation into its dict AST representation
Convenience for readXeto but always returns data as list of dicts
Write xeto instance data as JSON The stream is left open and returned
Print the Axon source representation from its dict AST representation
Read xeto instance data from Xeto source code
Print the Xeto source representation from its dict AST representation
Convenience for writeAxon to an in-memory string
Convenience for writeXeto to an in-memory string
Read xeto instance data from JSON
Convenience for writeJson to an in-memory string
abstract Dict readAst(Str in, Dict? opts)
Parse the Xeto source representation into its dict AST representation.
Options:
- libName: for internal qnames (default to proj)
- rtInclude: marker to make it a Haxall rt rec
abstract Dict readAxon(Str in, Dict? opts)
Parse the Axon source representation into its dict AST representation. Return dict with following tags that are extracted from axon source:
- doc: str for leading comment
- slots: grid for parameters and return type
- axon: source code for everything after "=>"
Options:
- libName: for internal qnames (default to proj)
abstract Obj? readJson(InStream in, Spec? spec, Dict? opts)
Read xeto instance data from JSON. The given spec is used to infer the JSON object if no spec tag is defined. The stream guaranteed to be closed upon return.
abstract Obj? readXeto(Str in, Dict? opts)
Read xeto instance data from Xeto source code. Raise exception if there are any syntax or semantic errors. If the input contains a scalar value or one dict, then it is returned as the value. Or if the input contains two or more dicts then return a Dict[] of the instances.
Options
- externRefs: marker to allow unresolved refs to compile
abstract Dict[] readXetoDicts(Str in, Dict? opts)
Convenience for readXeto but always returns data as list of dicts. If the data is not a Dict nor list of Dicts, then raise an exception.
abstract OutStream writeAst(OutStream out, Dict ast, Dict? opts)
Print the Xeto source representation from its dict AST representation. The stream is left open and returned.
Options
- qnameForce: for all types to be qualified
abstract Str writeAstToStr(Dict ast, Dict? opts)
Convenience for writeAst to an in-memory string
abstract OutStream writeAxon(OutStream out, Dict ast, Dict? opts)
Print the Axon source representation from its dict AST representation. The stream is left open and returned.
Options
- qnameForce: for all types to be qualified
abstract Str writeAxonToStr(Dict ast, Dict? opts)
Convenience for writeAxon to an in-memory string
abstract OutStream writeJson(OutStream out, Obj? val, Dict? opts)
Write xeto instance data as JSON The stream is left open and returned.
Options:
- pretty: add indentation to pretty print
- escUnicode: use escape sequences for values greater than 0x7f
abstract Str writeJsonToStr(Obj? val, Dict? opts)
Convenience for writeJson to an in-memory string
abstract OutStream writeXeto(OutStream out, Obj? val, Dict? opts)
Write instance data to Xeto source code. If the val is a Dict[], then it is flattened in the output. The stream is left open and returned.
abstract Str writeXetoToStr(Obj? val, Dict? opts)
Convenience for writeXeto to an in-memory string