[−][src]Crate combine_language
Example
let env = LanguageEnv::new(LanguageDef { ident: Identifier { start: letter(), rest: alpha_num(), reserved: ["if", "then", "else", "let", "in", "type"].iter() .map(|x| (*x).into()) .collect(), }, op: Identifier { start: satisfy(|c| "+-*/".chars().any(|x| x == c)), rest: satisfy(|c| "+-*/".chars().any(|x| x == c)), reserved: ["+", "-", "*", "/"].iter().map(|x| (*x).into()).collect() }, comment_start: string("/*").map(|_| ()), comment_end: string("*/").map(|_| ()), comment_line: string("//").map(|_| ()), }); let id = env.identifier();//An identifier parser let integer = env.integer();//An integer parser let result = (id, integer).easy_parse("this /* Skips comments */ 42"); assert_eq!(result, Ok(((String::from("this"), 42), "")));
Structs
| Assoc | Struct for encompassing the associativity of an operator |
| BetweenChar | Parses |
| Expression | Expression parser which handles binary operators |
| Identifier | Defines how to define an identifier (or operator) |
| LanguageDef | A struct type which contains the necessary definitions to construct a language parser |
| LanguageEnv | A type containing parsers for a specific language.
For some parsers there are two version where the parser which ends with a |
| Lex | A lexing parser for a language |
| Reserved | Parses a reserved word |
| WhiteSpace | A whitespace parser for a language |
Enums
| Fixity | Enumeration on fixities for the expression parser |
Functions
| expression_parser | Constructs an expression parser out of a term parser, an operator parser and a function which combines a binary expression to new expressions. |
| float |
Type Definitions
| LanguageParser | |
| LexLanguageParser |