reorganize typedef
This commit is contained in:
parent
465c63706b
commit
6a4dd3ce54
|
@ -6,7 +6,7 @@ use nom::{
|
||||||
sequence::{preceded, terminated},
|
sequence::{preceded, terminated},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::IResult;
|
use crate::parser::IResult;
|
||||||
|
|
||||||
pub fn decimal(input: &str) -> IResult<&str, u64> {
|
pub fn decimal(input: &str) -> IResult<&str, u64> {
|
||||||
map_res(
|
map_res(
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod literals;
|
||||||
mod parser;
|
mod parser;
|
||||||
mod rtlil;
|
mod rtlil;
|
||||||
|
|
||||||
use nom::error::{convert_error, VerboseError};
|
use nom::error::convert_error;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
@ -16,9 +16,6 @@ struct Opt {
|
||||||
input: PathBuf,
|
input: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom IResult type for verboseerror
|
|
||||||
pub type IResult<I, O, E = VerboseError<I>> = nom::IResult<I, O, E>;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let opt = Opt::from_args();
|
let opt = Opt::from_args();
|
||||||
let mut infile = File::open(opt.input).expect("could not open file");
|
let mut infile = File::open(opt.input).expect("could not open file");
|
||||||
|
|
|
@ -3,16 +3,20 @@ use nom::{
|
||||||
bytes::complete::tag,
|
bytes::complete::tag,
|
||||||
character::complete::{alpha1, alphanumeric1, char, multispace0, multispace1},
|
character::complete::{alpha1, alphanumeric1, char, multispace0, multispace1},
|
||||||
combinator::{map, opt, recognize},
|
combinator::{map, opt, recognize},
|
||||||
error::{context, ParseError},
|
error::{context, ParseError, VerboseError},
|
||||||
multi::{many0, many1, separated_list0},
|
multi::{many0, many1, separated_list0},
|
||||||
sequence::{delimited, pair, preceded, separated_pair, terminated, tuple},
|
sequence::{delimited, pair, preceded, separated_pair, terminated, tuple},
|
||||||
};
|
};
|
||||||
|
|
||||||
use nom_locate::{position, LocatedSpan};
|
use nom_locate::{position, LocatedSpan};
|
||||||
|
|
||||||
|
// custom span type for nom_locate
|
||||||
type Span<'a> = LocatedSpan<&'a str>;
|
type Span<'a> = LocatedSpan<&'a str>;
|
||||||
|
|
||||||
|
// custom IResult type for VerboseError
|
||||||
|
pub type IResult<I, O, E = VerboseError<I>> = nom::IResult<I, O, E>;
|
||||||
|
|
||||||
use crate::literals::{decimal, hexadecimal};
|
use crate::literals::{decimal, hexadecimal};
|
||||||
use crate::IResult;
|
|
||||||
|
|
||||||
fn ws0<'a, F: 'a, O, E: ParseError<&'a str>>(
|
fn ws0<'a, F: 'a, O, E: ParseError<&'a str>>(
|
||||||
inner: F,
|
inner: F,
|
||||||
|
@ -207,7 +211,7 @@ pub fn module(input: &str) -> IResult<&str, Module> {
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(input: &str) -> IResult<&str, Module> {
|
pub fn parse(input: &str) -> IResult<&str, Module> {
|
||||||
module(input)
|
module(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue