More combine

This commit is contained in:
greg 2020-02-20 02:50:18 -08:00
parent cd49c2c78f
commit 1f4ea71cf9

View File

@ -217,14 +217,16 @@ fn expression_kind(text: &str) -> ParseResult<ExpressionKind> {
mod thing { mod thing {
use crate::ast::*; use crate::ast::*;
use crate::builtin::Builtin; use crate::builtin::Builtin;
use combine::{many1, Parser, sep_by};
use combine::parser::char::{letter, space};
pub fn perform_parsing(input: &str) -> () { use combine::parser::range::{range, take_while1};
let word = many1(letter()); use combine::parser::repeat::sep_by;
let mut parser = sep_by(word, space()); use combine::*;
let result = parser.parse(input);
result 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<String, String> { pub fn perform_parsing(input: &str) -> Result<String, String> {
// let output = expression_kind(input) // let output = expression_kind(input)
let output = thing::perform_parsing(input); let output = thing::perform_parsing(input);
Ok(format!("{:?}", output)) Ok(output)
} }