Turn strs into chars where possible
This commit is contained in:
parent
73e32252c4
commit
5466f7afbf
6 changed files with 24 additions and 24 deletions
|
|
@ -14,11 +14,11 @@ use super::var::var;
|
||||||
fn atom_paren(
|
fn atom_paren(
|
||||||
expr: impl Parser<char, Expr, Error = Error> + Clone,
|
expr: impl Parser<char, Expr, Error = Error> + Clone,
|
||||||
) -> impl Parser<char, Expr, Error = Error> {
|
) -> impl Parser<char, Expr, Error = Error> {
|
||||||
just("(")
|
just('(')
|
||||||
.ignore_then(space())
|
.ignore_then(space())
|
||||||
.then(expr)
|
.then(expr)
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just(")"))
|
.then_ignore(just(')'))
|
||||||
.map_with_span(|((s0, inner), s1), span| Expr::Paren {
|
.map_with_span(|((s0, inner), s1), span| Expr::Paren {
|
||||||
s0,
|
s0,
|
||||||
inner: Box::new(inner),
|
inner: Box::new(inner),
|
||||||
|
|
|
||||||
|
|
@ -114,13 +114,13 @@ pub fn table_lit(
|
||||||
.then(space())
|
.then(space())
|
||||||
.map(|((s0, elem), s1)| (s0, elem, s1));
|
.map(|((s0, elem), s1)| (s0, elem, s1));
|
||||||
|
|
||||||
let trailing_comma = just(",").ignore_then(space()).or_not();
|
let trailing_comma = just(',').ignore_then(space()).or_not();
|
||||||
|
|
||||||
let elems = elem.separated_by(just(",")).then(trailing_comma);
|
let elems = elem.separated_by(just(',')).then(trailing_comma);
|
||||||
|
|
||||||
just("'{")
|
just("'{")
|
||||||
.ignore_then(elems)
|
.ignore_then(elems)
|
||||||
.then_ignore(just("}"))
|
.then_ignore(just('}'))
|
||||||
.map_with_span(|(elems, trailing_comma), span| TableLit {
|
.map_with_span(|(elems, trailing_comma), span| TableLit {
|
||||||
elems,
|
elems,
|
||||||
trailing_comma,
|
trailing_comma,
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,11 @@ fn suffix_field_access(
|
||||||
expr: impl Parser<char, Expr, Error = Error> + Clone,
|
expr: impl Parser<char, Expr, Error = Error> + Clone,
|
||||||
) -> impl Parser<char, Suffix, Error = Error> {
|
) -> impl Parser<char, Suffix, Error = Error> {
|
||||||
space()
|
space()
|
||||||
.then_ignore(just("["))
|
.then_ignore(just('['))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then(expr)
|
.then(expr)
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just("]"))
|
.then_ignore(just(']'))
|
||||||
.map(|(((s0, s1), index), s2)| Suffix::FieldAccess {
|
.map(|(((s0, s1), index), s2)| Suffix::FieldAccess {
|
||||||
s0,
|
s0,
|
||||||
s1,
|
s1,
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ pub fn table_constr_elem(
|
||||||
) -> impl Parser<char, TableConstrElem, Error = Error> {
|
) -> impl Parser<char, TableConstrElem, Error = Error> {
|
||||||
let lit = table_lit_elem(expr.clone()).map(TableConstrElem::Lit);
|
let lit = table_lit_elem(expr.clone()).map(TableConstrElem::Lit);
|
||||||
|
|
||||||
let indexed = just("[")
|
let indexed = just('[')
|
||||||
.ignore_then(space())
|
.ignore_then(space())
|
||||||
.then(expr.clone())
|
.then(expr.clone())
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just("]"))
|
.then_ignore(just(']'))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just(":"))
|
.then_ignore(just(':'))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then(expr)
|
.then(expr)
|
||||||
.map_with_span(
|
.map_with_span(
|
||||||
|
|
@ -44,13 +44,13 @@ pub fn table_constr(
|
||||||
.then(space())
|
.then(space())
|
||||||
.map(|((s0, elem), s1)| (s0, elem, s1));
|
.map(|((s0, elem), s1)| (s0, elem, s1));
|
||||||
|
|
||||||
let trailing_comma = just(",").ignore_then(space()).or_not();
|
let trailing_comma = just(',').ignore_then(space()).or_not();
|
||||||
|
|
||||||
let elems = elem.separated_by(just(",")).then(trailing_comma);
|
let elems = elem.separated_by(just(',')).then(trailing_comma);
|
||||||
|
|
||||||
just("{")
|
just('{')
|
||||||
.ignore_then(elems)
|
.ignore_then(elems)
|
||||||
.then_ignore(just("}"))
|
.then_ignore(just('}'))
|
||||||
.map_with_span(|(elems, trailing_comma), span| TableConstr {
|
.map_with_span(|(elems, trailing_comma), span| TableConstr {
|
||||||
elems,
|
elems,
|
||||||
trailing_comma,
|
trailing_comma,
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,13 @@ pub fn table_pattern() -> impl Parser<char, TablePattern, Error = Error> {
|
||||||
.then(space())
|
.then(space())
|
||||||
.map(|((s0, elem), s1)| (s0, elem, s1));
|
.map(|((s0, elem), s1)| (s0, elem, s1));
|
||||||
|
|
||||||
let trailing_comma = just(",").ignore_then(space()).or_not();
|
let trailing_comma = just(',').ignore_then(space()).or_not();
|
||||||
|
|
||||||
let elems = elem.separated_by(just(",")).then(trailing_comma);
|
let elems = elem.separated_by(just(',')).then(trailing_comma);
|
||||||
|
|
||||||
just("{")
|
just('{')
|
||||||
.ignore_then(elems)
|
.ignore_then(elems)
|
||||||
.then_ignore(just("}"))
|
.then_ignore(just('}'))
|
||||||
.map_with_span(|(elems, trailing_comma), span| TablePattern {
|
.map_with_span(|(elems, trailing_comma), span| TablePattern {
|
||||||
elems,
|
elems,
|
||||||
trailing_comma,
|
trailing_comma,
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ use super::basic::{ident, space, Error};
|
||||||
fn var_access(
|
fn var_access(
|
||||||
expr: impl Parser<char, Expr, Error = Error> + Clone,
|
expr: impl Parser<char, Expr, Error = Error> + Clone,
|
||||||
) -> impl Parser<char, Var, Error = Error> {
|
) -> impl Parser<char, Var, Error = Error> {
|
||||||
just("[")
|
just('[')
|
||||||
.ignore_then(space())
|
.ignore_then(space())
|
||||||
.then(expr)
|
.then(expr)
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just("]"))
|
.then_ignore(just(']'))
|
||||||
.map_with_span(|((s0, index), s1), span| Var::Access {
|
.map_with_span(|((s0, index), s1), span| Var::Access {
|
||||||
s0,
|
s0,
|
||||||
index: Box::new(index),
|
index: Box::new(index),
|
||||||
|
|
@ -28,13 +28,13 @@ fn var_assign(
|
||||||
let local = text::keyword("local").ignore_then(space()).or_not();
|
let local = text::keyword("local").ignore_then(space()).or_not();
|
||||||
|
|
||||||
local
|
local
|
||||||
.then_ignore(just("["))
|
.then_ignore(just('['))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then(expr.clone())
|
.then(expr.clone())
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just("]"))
|
.then_ignore(just(']'))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just("="))
|
.then_ignore(just('='))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then(expr)
|
.then(expr)
|
||||||
.map_with_span(
|
.map_with_span(
|
||||||
|
|
@ -59,7 +59,7 @@ fn var_assign_ident(
|
||||||
local
|
local
|
||||||
.then(ident())
|
.then(ident())
|
||||||
.then(space())
|
.then(space())
|
||||||
.then_ignore(just("="))
|
.then_ignore(just('='))
|
||||||
.then(space())
|
.then(space())
|
||||||
.then(expr)
|
.then(expr)
|
||||||
.map_with_span(
|
.map_with_span(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue