exprml_dart 0.0.2 exprml_dart: ^0.0.2 copied to clipboard
exprml_dart is a Dart library implementing an ExprML interpreter. The ExprML is a programming language that can evaluate expressions represented in JSON (and JSON-compatible YAML). The ExprML language [...]
import 'package:exprml_dart/exprml.dart';
import 'package:exprml_dart/exprml_pb.dart';
void main() {
// Decode JSON value from a source string in YAML.
final decodeResult = Decoder()
.decode(DecodeInput(text: 'cat: ["`Hello`", "`, `", "`ExprML`", "`!`"]'));
// Parse an AST from the decoded value.
final parseResult = Parser()
.parse(ParseInput(value: decodeResult.value));
// Evaluate the parsed AST as a JSON value.
final evaluateResult = Evaluator()
.evaluateExpr(EvaluateInput(expr: parseResult.expr));
// Encode the evaluated JSON value into a source string in YAML.
final encodeResult = Encoder()
.encode(EncodeInput(value: evaluateResult.value));
print(encodeResult.text);
// => "Hello, ExprML!"
}