Skip to content

Instantly share code, notes, and snippets.

@matklad
Created February 7, 2020 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matklad/5725e97192363c973c985e3d765d7fbf to your computer and use it in GitHub Desktop.
Save matklad/5725e97192363c973c985e3d765d7fbf to your computer and use it in GitHub Desktop.
16:41:51|~/tmp
λ cat main.rs
use
fn main() {}
16:42:06|~/tmp
λ rustc +nightly -Z ast-json main.rs
error: expected identifier, found keyword `fn`
--> main.rs:3:1
|
3 | fn main() {}
| ^^ expected identifier, found keyword
error: expected one of `::`, `;`, or `as`, found `main`
--> main.rs:3:4
|
3 | fn main() {}
| ^^^^ expected one of `::`, `;`, or `as`
error: aborting due to 2 previous errors
16:42:08|~/tmp
λ ~/projects/rust-analyzer/target/release/ra_cli parse < main.rs
SOURCE_FILE@[0; 18)
USE_ITEM@[0; 3)
USE_KW@[0; 3) "use"
WHITESPACE@[3; 5) "\n\n"
FN_DEF@[5; 17)
FN_KW@[5; 7) "fn"
WHITESPACE@[7; 8) " "
NAME@[8; 12)
IDENT@[8; 12) "main"
PARAM_LIST@[12; 14)
L_PAREN@[12; 13) "("
R_PAREN@[13; 14) ")"
WHITESPACE@[14; 15) " "
BLOCK_EXPR@[15; 17)
BLOCK@[15; 17)
L_CURLY@[15; 16) "{"
R_CURLY@[16; 17) "}"
WHITESPACE@[17; 18) "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment