enterprise/syn-serde/examples/rust2json/rust2json_main.json

783 lines
22 KiB
JSON
Raw Permalink Normal View History

2020-02-17 12:09:45 +00:00
{
"attrs": [
{
"style": "inner",
"path": {
"segments": [
{
"ident": "warn"
}
]
},
"tokens": [
{
"group": {
"delimiter": "parenthesis",
"stream": [
{
"ident": "rust_2018_idioms"
}
]
}
}
]
}
],
"items": [
{
"use": {
"tree": {
"path": {
"ident": "std",
"tree": {
"group": [
{
"ident": "env"
},
{
"ident": "fs"
},
{
"path": {
"ident": "io",
"tree": {
"group": [
{
"ident": "self"
},
{
"ident": "BufWriter"
},
{
"ident": "Write"
}
]
}
}
},
{
"path": {
"ident": "path",
"tree": {
"ident": "PathBuf"
}
}
}
]
}
}
}
}
},
{
"use": {
"tree": {
"path": {
"ident": "syn_serde",
"tree": {
"ident": "json"
}
}
}
}
},
{
"type": {
"ident": "Result",
"generics": {
"params": [
{
"type": {
"ident": "T"
}
}
]
},
"ty": {
"path": {
"segments": [
{
"ident": "std"
},
{
"ident": "result"
},
{
"ident": "Result",
"arguments": {
"angle_bracketed": {
"args": [
{
"type": {
"path": {
"segments": [
{
"ident": "T"
}
]
}
}
},
{
"type": {
"path": {
"segments": [
{
"ident": "Box",
"arguments": {
"angle_bracketed": {
"args": [
{
"type": {
"trait_object": {
"dyn": true,
"bounds": [
{
"trait": {
"path": {
"segments": [
{
"ident": "std"
},
{
"ident": "error"
},
{
"ident": "Error"
}
]
}
}
}
]
}
}
}
]
}
}
}
]
}
}
}
]
}
}
}
]
}
}
}
},
{
"fn": {
"ident": "main",
"inputs": [],
"output": null,
"stmts": [
{
"expr": {
"if": {
"cond": {
"let": {
"pat": {
"tuple_struct": {
"path": {
"segments": [
{
"ident": "Err"
}
]
},
"pat": {
"elems": [
{
"ident": {
"ident": "e"
}
}
]
}
}
},
"expr": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "try_main"
}
]
}
},
"args": []
}
}
}
},
"then_branch": [
{
"semi": {
"macro": {
"path": {
"segments": [
{
"ident": "eprintln"
}
]
},
"delimiter": "paren",
"tokens": [
{
"lit": "\"{}\""
},
{
"punct": {
"op": ",",
"spacing": "alone"
}
},
{
"ident": "e"
}
]
}
}
},
{
"semi": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "std"
},
{
"ident": "process"
},
{
"ident": "exit"
}
]
}
},
"args": [
{
"lit": {
"int": "1"
}
}
]
}
}
}
]
}
}
}
]
}
},
{
"fn": {
"ident": "try_main",
"inputs": [],
"output": {
"path": {
"segments": [
{
"ident": "Result",
"arguments": {
"angle_bracketed": {
"args": [
{
"type": {
"tuple": {
"elems": []
}
}
}
]
}
}
}
]
}
},
"stmts": [
{
"let": {
"pat": {
"ident": {
"mut": true,
"ident": "args"
}
},
"init": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "env"
},
{
"ident": "args_os"
}
]
}
},
"args": []
}
}
}
},
{
"let": {
"pat": {
"_": {}
},
"init": {
"method_call": {
"receiver": {
"path": {
"segments": [
{
"ident": "args"
}
]
}
},
"method": "next",
"args": []
}
}
}
},
{
"let": {
"pat": {
"ident": {
"ident": "filepath"
}
},
"init": {
"match": {
"expr": {
"tuple": {
"elems": [
{
"method_call": {
"receiver": {
"path": {
"segments": [
{
"ident": "args"
}
]
}
},
"method": "next",
"args": []
}
},
{
"method_call": {
"receiver": {
"path": {
"segments": [
{
"ident": "args"
}
]
}
},
"method": "next",
"args": []
}
}
]
}
},
"arms": [
{
"pat": {
"tuple": {
"elems": [
{
"tuple_struct": {
"path": {
"segments": [
{
"ident": "Some"
}
]
},
"pat": {
"elems": [
{
"ident": {
"ident": "arg"
}
}
]
}
}
},
{
"ident": {
"ident": "None"
}
}
]
}
},
"body": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "PathBuf"
},
{
"ident": "from"
}
]
}
},
"args": [
{
"path": {
"segments": [
{
"ident": "arg"
}
]
}
}
]
}
}
},
{
"pat": {
"_": {}
},
"body": {
"block": {
"stmts": [
{
"semi": {
"macro": {
"path": {
"segments": [
{
"ident": "println"
}
]
},
"delimiter": "paren",
"tokens": [
{
"lit": "\"Usage: rust2json path/to/filename.rs\""
}
]
}
}
},
{
"semi": {
"return": {
"expr": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "Ok"
}
]
}
},
"args": [
{
"tuple": {
"elems": []
}
}
]
}
}
}
}
}
]
}
}
}
]
}
}
}
},
{
"let": {
"pat": {
"ident": {
"ident": "code"
}
},
"init": {
"try": {
"expr": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "fs"
},
{
"ident": "read_to_string"
}
]
}
},
"args": [
{
"reference": {
"expr": {
"path": {
"segments": [
{
"ident": "filepath"
}
]
}
}
}
}
]
}
}
}
}
}
},
{
"let": {
"pat": {
"ident": {
"ident": "syntax"
}
},
"init": {
"try": {
"expr": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "syn"
},
{
"ident": "parse_file"
}
]
}
},
"args": [
{
"reference": {
"expr": {
"path": {
"segments": [
{
"ident": "code"
}
]
}
}
}
}
]
}
}
}
}
}
},
{
"let": {
"pat": {
"ident": {
"ident": "writer"
}
},
"init": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "io"
},
{
"ident": "stdout"
}
]
}
},
"args": []
}
}
}
},
{
"let": {
"pat": {
"ident": {
"mut": true,
"ident": "writer"
}
},
"init": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "BufWriter"
},
{
"ident": "new"
}
]
}
},
"args": [
{
"method_call": {
"receiver": {
"path": {
"segments": [
{
"ident": "writer"
}
]
}
},
"method": "lock",
"args": []
}
}
]
}
}
}
},
{
"semi": {
"try": {
"expr": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "json"
},
{
"ident": "to_writer_pretty"
}
]
}
},
"args": [
{
"reference": {
"mut": true,
"expr": {
"path": {
"segments": [
{
"ident": "writer"
}
]
}
}
}
},
{
"reference": {
"expr": {
"path": {
"segments": [
{
"ident": "syntax"
}
]
}
}
}
}
]
}
}
}
}
},
{
"semi": {
"try": {
"expr": {
"method_call": {
"receiver": {
"path": {
"segments": [
{
"ident": "writer"
}
]
}
},
"method": "flush",
"args": []
}
}
}
}
},
{
"expr": {
"call": {
"func": {
"path": {
"segments": [
{
"ident": "Ok"
}
]
}
},
"args": [
{
"tuple": {
"elems": []
}
}
]
}
}
}
]
}
}
]
}