($ok) {
my $ast = clean_ast($match);
say estr_to_json($ast);
my $opt_ast = OptSppAst($ast);
say estr_to_json($opt_ast);
}
else {
say $match;
}
}
if (not($ok)) {
error($match);
}
my $clean_ast = clean_ast($match);
return estr_to_json($clean_ast)
}
sub get_my_table {
my $grammar = GetMyGrammar();
my $ast = GrammarToAst($
shift;
my $grammar = read_file($file);
my $ast = GrammarToAst($grammar);
return estr_to_json($ast)
}
sub LintSppAst {
my $ast = shift;
my $table = {};
my $values = [];
for my
lse {
croak("not implement action: |$call|");
}
}
my $action_str = estr_to_json($action);
croak("Expr not action: $action-str");
return '';
}
sub opt_spp_array {
@ISA = qw(Exporter);
our @EXPORT = qw(GetSppAst);
use Mylisp::Estr;
sub GetSppAst {
my $json = <<'EOF'
[["door",["Rules",[["Rept",["+",["Branch",[["Rept",["+",["Cclass","s"]]],["Rtoken","_c
",["*",["Ctoken","eatom"]]],["Blank","b"],["Char","]"]]]],["eatom",["Branch",[["Ntoken","Array"],["Ntoken","Sub"],["Ntoken","Sym"],["Ntoken","Kstr"]]]]]
EOF
;
return json_to_estr($json);
}
1;
tr is_estr is_atom is_atoms is_blank estr estr_atom estr_strs estr_ints estr_int json_to_estr estr_to_json char_to_json atoms flat match _name name value off elen erest epush eappend eunshift is_atom_
_to_str($int));
}
sub json_to_estr {
my $json = shift;
if (is_estr($json)) {
return $json;
}
my $chars = [];
my $mode = 0;
for my $ch (@{to_chars($json)}) {
if ($mode ==
apush($chars,$ch);
}
}
}
}
return to_str($chars);
}
sub estr_to_json {
my $estr = shift;
if (is_str($estr)) {
return $estr;
}
my $chars = [];
my $