This commit is contained in:
Aleksey Kladov 2018-07-31 22:29:38 +03:00
parent 8105c14454
commit 904a832b7c
5 changed files with 18 additions and 17 deletions

View File

@ -5,9 +5,9 @@ extern crate libsyntax2;
extern crate tools; extern crate tools;
use clap::{App, Arg, SubCommand}; use clap::{App, Arg, SubCommand};
use std::time::Instant;
use std::{fs, io::Read, path::Path}; use std::{fs, io::Read, path::Path};
use tools::collect_tests; use tools::collect_tests;
use std::time::Instant;
type Result<T> = ::std::result::Result<T, failure::Error>; type Result<T> = ::std::result::Result<T, failure::Error>;

View File

@ -34,12 +34,11 @@ pub(super) fn expr(p: &mut Parser) {
loop { loop {
lhs = match p.current() { lhs = match p.current() {
L_PAREN => call_expr(p, lhs), L_PAREN => call_expr(p, lhs),
DOT if p.nth(1) == IDENT => DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN {
if p.nth(2) == L_PAREN { method_call_expr(p, lhs)
method_call_expr(p, lhs) } else {
} else { field_expr(p, lhs)
field_expr(p, lhs) },
}
_ => break, _ => break,
} }
} }
@ -193,11 +192,11 @@ fn struct_lit(p: &mut Parser) {
expr(p); expr(p);
} }
m.complete(p, STRUCT_LIT_FIELD); m.complete(p, STRUCT_LIT_FIELD);
}, }
DOTDOT => { DOTDOT => {
p.bump(); p.bump();
expr(p); expr(p);
}, }
_ => p.err_and_bump("expected identifier"), _ => p.err_and_bump("expected identifier"),
} }
if !p.at(R_CURLY) { if !p.at(R_CURLY) {

View File

@ -142,7 +142,9 @@ fn fn_value_parameters(p: &mut Parser) {
_ => return, _ => return,
}; };
let m = p.start(); let m = p.start();
for _ in 0..n_toks { p.bump(); } for _ in 0..n_toks {
p.bump();
}
m.complete(p, SELF_PARAM); m.complete(p, SELF_PARAM);
if !p.at(R_PAREN) { if !p.at(R_PAREN) {
p.expect(COMMA); p.expect(COMMA);

View File

@ -33,16 +33,16 @@ fn type_arg(p: &mut Parser) {
LIFETIME => { LIFETIME => {
p.bump(); p.bump();
m.complete(p, LIFETIME_ARG); m.complete(p, LIFETIME_ARG);
}, }
IDENT if p.nth(1) == EQ => { IDENT if p.nth(1) == EQ => {
name_ref(p); name_ref(p);
p.bump(); p.bump();
types::type_(p); types::type_(p);
m.complete(p, ASSOC_TYPE_ARG); m.complete(p, ASSOC_TYPE_ARG);
}, }
_ => { _ => {
types::type_(p); types::type_(p);
m.complete(p, TYPE_ARG); m.complete(p, TYPE_ARG);
}, }
} }
} }

View File

@ -1,7 +1,7 @@
use std::{fmt::Write}; use std::fmt::Write;
use { use {
algo::walk::{walk, WalkEvent},
SyntaxNode, SyntaxNode,
algo::walk::{WalkEvent, walk},
}; };
/// Parse a file and create a string representation of the resulting parse tree. /// Parse a file and create a string representation of the resulting parse tree.
@ -34,13 +34,13 @@ pub fn dump_tree(syntax: &SyntaxNode) -> String {
} }
} }
level += 1; level += 1;
}, }
WalkEvent::Exit(_) => level -= 1, WalkEvent::Exit(_) => level -= 1,
} }
} }
assert_eq!(level, 0); assert_eq!(level, 0);
for err in errors[err_pos..].iter() { for err in errors[err_pos..].iter() {
writeln!(buf, "err: `{}`", err.message).unwrap(); writeln!(buf, "err: `{}`", err.message).unwrap();
} }