LALRPOP mapping not defined

This is my full LALRPOP 0.20 program so far:

use std::str::FromStr;
use std::rc::Rc;
use lalrpop_util::ErrorRecovery;
use crate::parser::css_parser::parse_string_content;
use crate::compilation_unit::CompilationUnit;
use crate::compilation_unit::Location;
use crate::tree;

grammar<'err, 'cu>(errors: &'err mut Vec<ErrorRecovery<usize, Token<'input>, &'static str>>, compilation_unit: &'cu Rc<CompilationUnit>);

match {
    r"[ \t\r\n]*" => {},
    r"/\*[^*]*\*+(?:[^/*][^*]*\*+)*/" => {},
}

pub Number: (f64, Location) = <i: @L> <s:r"[+\-]?([0-9]+(\.[0-9]+)?)|(\.[0-9]+)"> <j: @R> => {
    (f64::from_str(s).unwrap_or(f64::NAN), Location::with_offsets(compilation_unit, i, j))
};

NumberWithPercent: (f64, Location) = <i: @L> <v: Number> r"\%" <j: @R> => {
    (v.0 / 100.0, Location::with_offsets(compilation_unit, i, j))
};

NumberWithUnit: tree::CssNumberPropertyValue = <i: @L> <v: Number> <unit:r"(?xi) ((_((_)?_)?)?) [a-z] [a-z0-9\-_]*"> <j: @R> =>
    tree::CssNumberPropertyValue {
        location: Location::with_offsets(compilation_unit, i, j),
        value: v.0,
        unit: Some(unit.to_owned()),
    };

String: (String, Location) = {
    <i: @L> <s:r#"(?xi) "([^"\\]|\\[a-f0-9]{1,6})*""#> <r: @R> => {
        let loc = Location::with_offsets(compilation_unit, i, j);
        (parse_string_content(s, loc), loc)
    },
    <i: @L> <s:r"(?xi) '([^'\\]|\\[a-f0-9]{1,6})*'"> <r: @R> => {
        let loc = Location::with_offsets(compilation_unit, i, j);
        (parse_string_content(s, loc), loc)
    },
};

Id: (String, Location) = <i: @L> <s:r"(?xi) ((_((_)?_)?)?) [a-z] [a-z0-9\-_]*"> <j: @R> => {
    (s.to_owned(), Location::with_offsets(compilation_unit, i, j))
};

I'm getting:

.\parser\css.lalrpop:16:42: 16:80 error: terminal r#"[+\\-]?([0-9]+(\\.[0-9]+)?)|(\\.[0-9]+)"# does not have a match mapping defined for it

I've tried bracing all mappings as you can see.

I thought this had something to do with the match {} above, but it's also not?

So...

LALRPOP had a match {} example for ignoring whitespace and comments, but I think they forgot a else { _ } clause.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.