mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-16 17:00:53 +00:00
Merge pull request #223 from minijackson/user_uses_intern_token
Add user uses in generated mod intern_token
This commit is contained in:
commit
ed82f669fb
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,7 @@ doc/pascal/lalrpop/src/pascal.rs
|
||||
doc/whitespace/src/parser.rs
|
||||
|
||||
lalrpop-test/src/error.rs
|
||||
lalrpop-test/src/error_issue_113.rs
|
||||
lalrpop-test/src/error_recovery.rs
|
||||
lalrpop-test/src/error_recovery_pull_182.rs
|
||||
lalrpop-test/src/expr.rs
|
||||
|
@ -34,7 +34,8 @@ pub fn compile<W: Write>(
|
||||
let prefix = &grammar.prefix;
|
||||
|
||||
rust!(out, "mod {}intern_token {{", prefix);
|
||||
try!(out.write_standard_uses(prefix));
|
||||
rust!(out, "#![allow(unused_imports)]");
|
||||
try!(out.write_uses("", &grammar));
|
||||
rust!(out, "pub struct {}Matcher<'input> {{", prefix);
|
||||
rust!(out, "text: &'input str,"); // remaining input
|
||||
rust!(out, "consumed: usize,"); // number of chars consumed thus far
|
||||
|
14
lalrpop-test/src/error_issue_113.lalrpop
Normal file
14
lalrpop-test/src/error_issue_113.lalrpop
Normal file
@ -0,0 +1,14 @@
|
||||
use lalrpop_util::ParseError;
|
||||
use super::MyCustomError;
|
||||
|
||||
grammar;
|
||||
|
||||
extern {
|
||||
type Error = MyCustomError;
|
||||
}
|
||||
|
||||
pub Items: Vec<(usize, usize)> = {
|
||||
=> vec![],
|
||||
Items "+" =>? Err(ParseError::User { error: MyCustomError('+') }),
|
||||
<v:Items> "-" =>? Ok(v),
|
||||
};
|
@ -59,8 +59,13 @@ mod loc_issue_90_lib;
|
||||
/// test that uses `super` in paths in various places
|
||||
mod use_super;
|
||||
|
||||
/// test that exercises locations and spans
|
||||
/// Custom error type (issue #113)
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct MyCustomError(char);
|
||||
|
||||
/// test that exercises locations, spans, and custom errors
|
||||
mod error;
|
||||
mod error_issue_113;
|
||||
|
||||
/// Test error recovery
|
||||
mod error_recovery;
|
||||
|
@ -44,7 +44,8 @@ pub fn compile<W: Write>(
|
||||
let prefix = &grammar.prefix;
|
||||
|
||||
rust!(out, "mod {}intern_token {{", prefix);
|
||||
try!(out.write_standard_uses(prefix));
|
||||
rust!(out, "#![allow(unused_imports)]");
|
||||
try!(out.write_uses("", &grammar));
|
||||
rust!(out, "extern crate regex as {}regex;", prefix);
|
||||
rust!(out, "pub struct {}Matcher<'input> {{", prefix);
|
||||
rust!(out, "text: &'input str,"); // remaining input
|
||||
|
Loading…
x
Reference in New Issue
Block a user