Skip to content

feat: mut variable syntax support for TaggedExpr and RuleParam #372

@A4-Tacks

Description

@A4-Tacks
use std::{collections::HashMap, cell::RefCell};

peg::parser!(grammar parser() for str {
    pub rule keyvals() -> HashMap<&'input str, &'input str>
        = map:({ RefCell::new(HashMap::new()) })
        (k:$(['a'..='z']+) ":" v:$(['a'..='z']+) {
            map.borrow_mut().insert(k, v)
        })**","
        { map.into_inner() }
});

// Expect
//peg::parser!(grammar parser() for str {
//    pub rule keyvals() -> HashMap<&'input str, &'input str>
//        = mut map:({ HashMap::new() })
//        (k:$(['a'..='z']+) ":" v:$(['a'..='z']+) {
//            map.insert(k, v)
//        })**","
//        { map }
//});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions