From 1f4ea71cf91de70af102f1e04802b755675c94ca Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 20 Feb 2020 02:50:18 -0800 Subject: [PATCH] More combine --- schala-lang/language/src/parser.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/schala-lang/language/src/parser.rs b/schala-lang/language/src/parser.rs index bf0e961..50a65c7 100644 --- a/schala-lang/language/src/parser.rs +++ b/schala-lang/language/src/parser.rs @@ -217,14 +217,16 @@ fn expression_kind(text: &str) -> ParseResult { mod thing { use crate::ast::*; use crate::builtin::Builtin; - use combine::{many1, Parser, sep_by}; - use combine::parser::char::{letter, space}; - pub fn perform_parsing(input: &str) -> () { - let word = many1(letter()); - let mut parser = sep_by(word, space()); - let result = parser.parse(input); - result + use combine::parser::range::{range, take_while1}; + use combine::parser::repeat::sep_by; + use combine::*; + + pub fn perform_parsing(input: &str) -> String { + let identifier = take_while1(|c: char| c.is_alphabetic()); + let mut parser = sep_by(identifier, range(", ")); + let result: Result<(Vec<&str>, &str), _> = parser.easy_parse(input); + format!("{:?}", result) } } @@ -232,5 +234,5 @@ mod thing { pub fn perform_parsing(input: &str) -> Result { // let output = expression_kind(input) let output = thing::perform_parsing(input); - Ok(format!("{:?}", output)) + Ok(output) }