use Group; use Instruction; use Param; use ParamTy; use Ty; use std::str::FromStr; grammar["LALR(1)"]; pub Description : Vec = ; Group : Group = "group" ";" => { Group { name: name, instructions: is } }; Instruction : Instruction = ";" => { Instruction { opcode: op, name: name, params: params, group: None } }; Param : Param = { => { Param { ty: ParamTy::Single(Ty::from_str(&name).unwrap(), opt.is_some()), name: name, } }, ":" => { Param { name: name, ty:ty } } }; ParamTy : ParamTy = { "[" "]" => ParamTy::Repeat(ty), "[" "]" => ParamTy::RepeatMany(Some(ty).into_iter().chain(tys.into_iter()).collect()), => ParamTy::Single(ty, opt.is_some()), }; Ty: Ty = Id => Ty::from_str(&<>).unwrap(); #[inline] Name : String = { "group" => "group".to_owned(), Id }; Id : String = r"[A-Za-z_][A-Za-z0-9_-]*" => (<>).to_owned(); OpCode : u16 = r"[0-9]+" => u16::from_str(<>).unwrap();