Changing what method to call to start parsing
This commit is contained in:
parent
6b42f8b8de
commit
d7baf065fb
@ -445,7 +445,7 @@ mod eval_tests {
|
||||
|
||||
fn parse(tokens: Vec<Token>) -> ParseResult<AST> {
|
||||
let mut parser = ::parsing::Parser::new(tokens);
|
||||
parser.program()
|
||||
parser.parse()
|
||||
}
|
||||
|
||||
macro_rules! all_output {
|
||||
|
@ -102,7 +102,7 @@ fn parsing(handle: &mut Schala, input: Vec<tokenizing::Token>, comp: Option<&mut
|
||||
Some(parser) => parser
|
||||
};
|
||||
|
||||
let ast = parser.program();
|
||||
let ast = parser.parse();
|
||||
let trace = parser.format_parse_trace();
|
||||
|
||||
comp.map(|comp| {
|
||||
|
@ -46,9 +46,9 @@ struct ParserRestrictions {
|
||||
}
|
||||
|
||||
impl Parser {
|
||||
pub fn new(input: Vec<Token>) -> Parser {
|
||||
pub fn new(initial_input: Vec<Token>) -> Parser {
|
||||
Parser {
|
||||
tokens: input.into_iter().peekable(),
|
||||
tokens: initial_input.into_iter().peekable(),
|
||||
parse_record: vec![],
|
||||
parse_level: 0,
|
||||
restrictions: ParserRestrictions { no_struct_literal: false }
|
||||
@ -65,6 +65,16 @@ impl Parser {
|
||||
self.tokens.next().map(|ref t| { t.token_type.clone() }).unwrap_or(TokenType::EOF)
|
||||
}
|
||||
|
||||
pub fn parse(&mut self) -> ParseResult<AST> {
|
||||
self.program()
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn parse_with_new_tokens(&mut self, new_tokens: Vec<Token>) -> ParseResult<AST> {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn format_parse_trace(self) -> Vec<String> {
|
||||
self.parse_record.into_iter().map(|r| {
|
||||
let mut indent = String::new();
|
||||
@ -252,7 +262,7 @@ enumerator := identifier '<-' expression | identifier '=' expression //TODO add
|
||||
impl Parser {
|
||||
//TODO make this a proper public interface
|
||||
#[recursive_descent_method]
|
||||
pub fn program(&mut self) -> ParseResult<AST> {
|
||||
fn program(&mut self) -> ParseResult<AST> {
|
||||
let mut statements = Vec::new();
|
||||
loop {
|
||||
match self.peek() {
|
||||
@ -1063,7 +1073,7 @@ mod parse_tests {
|
||||
|
||||
fn parse(tokens: Vec<::tokenizing::Token>) -> ParseResult<AST> {
|
||||
let mut parser = super::Parser::new(tokens);
|
||||
parser.program()
|
||||
parser.parse()
|
||||
}
|
||||
|
||||
macro_rules! rc {
|
||||
|
Loading…
Reference in New Issue
Block a user