Support for underscores

This commit is contained in:
greg 2018-07-10 03:43:14 -07:00
parent 0ec29f6dd0
commit 00692aa89e
4 changed files with 5 additions and 23 deletions

View File

@ -132,6 +132,7 @@ pub struct Guard {
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub enum Pattern { pub enum Pattern {
Ignored,
TuplePattern(Vec<Pattern>), TuplePattern(Vec<Pattern>),
Literal(PatternLiteral), Literal(PatternLiteral),
TupleStruct(Rc<String>, Vec<Pattern>), TupleStruct(Rc<String>, Vec<Pattern>),

View File

@ -79,7 +79,6 @@ fn parsing(_handle: &mut Schala, input: Vec<tokenizing::Token>, comp: Option<&mu
let (ast, trace) = parsing::parse(input); let (ast, trace) = parsing::parse(input);
comp.map(|comp| { comp.map(|comp| {
println!("DEBUG OPTS: {:?}", comp.cur_debug_options);
//TODO need to control which of these debug stages get added //TODO need to control which of these debug stages get added
let opt = comp.cur_debug_options.get(0).map(|s| s.clone()); let opt = comp.cur_debug_options.get(0).map(|s| s.clone());
match opt { match opt {

View File

@ -694,21 +694,6 @@ impl Parser {
}); });
parse_method!(simple_pattern(&mut self) -> ParseResult<Pattern> { parse_method!(simple_pattern(&mut self) -> ParseResult<Pattern> {
/*
let name = self.identifier()?;
match self.peek() {
LParen => {
let tuple_members = delimited!(self, LParen, type_name, Comma, RParen);
Ok(TupleStruct(name, tuple_members))
},
LCurlyBrace => {
let typed_identifier_list = delimited!(self, LCurlyBrace, typed_identifier, Comma, RCurlyBrace);
Ok(Record(name, typed_identifier_list))
},
_ => Ok(UnitStruct(name))
}
*/
Ok(match self.peek() { Ok(match self.peek() {
Identifier(_) => { Identifier(_) => {
let id = self.identifier()?; let id = self.identifier()?;
@ -729,6 +714,10 @@ impl Parser {
let Expression(expr_type, _) = self.number_literal()?; let Expression(expr_type, _) = self.number_literal()?;
Pattern::Literal(PatternLiteral::NumPattern(expr_type)) Pattern::Literal(PatternLiteral::NumPattern(expr_type))
}, },
Underscore => {
self.next();
Pattern::Ignored
},
other => return ParseError::new(&format!("{:?} is not a valid Pattern", other)) other => return ParseError::new(&format!("{:?} is not a valid Pattern", other))
}) })
}); });

View File

@ -413,13 +413,6 @@ impl Repl {
} }
writeln!(buf, "").unwrap(); writeln!(buf, "").unwrap();
/*
writeln!(buf, "exit | quit - exit the REPL").unwrap();
writeln!(buf, "debug [show|hide] <pass_name> - show or hide debug info for a given pass").unwrap();
writeln!(buf, "debug passes - display the names of all passes").unwrap();
writeln!(buf, "lang [prev|next|go <name> |show] - toggle to previous or next language, go to a specific language by name, or show all languages").unwrap();
*/
writeln!(buf, "Language-specific help for {}", lang.get_language_name()).unwrap(); writeln!(buf, "Language-specific help for {}", lang.get_language_name()).unwrap();
writeln!(buf, "-----------------------").unwrap(); writeln!(buf, "-----------------------").unwrap();
writeln!(buf, "{}", lang.custom_interpreter_directives_help()).unwrap(); writeln!(buf, "{}", lang.custom_interpreter_directives_help()).unwrap();