]>
Witch of Git - ivy/blob - src/main.rs
1 use ess
::{self, parser
::ParseError
, Sexp
};
2 use std
::io
::{self, Read
};
7 fn parse(input
: &str) -> Result
<Sexp
, ParseError
> {
8 let (sexp
, rest
) = ess
::parse_one(input
)?
;
9 if !rest
.trim().is
_empty
() {
10 return Err(ParseError
::Unexpected('
\0'
, sexp
.get_loc().1));
15 fn main() -> io
::Result
<()> {
16 let stdin
= std
::io
::stdin();
17 let mut text
= String
::new();
18 stdin
.lock().read_to_string(&mut text
)?
;
19 let sexp
= match parse(&text
) {
22 println
!("{:?}", err
);
23 std
::process
::exit(1);
26 let ast
= match Ast
::parse(&sexp
) {
30 std
::process
::exit(1);
33 println
!("{:#?}", ast
);