
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
github.com/Marwes/combine-language
This a crate providing an easy way of constructing parsers which can easily parse various programming languages. It has much of the same API as Text.Parsec.Token but are otherwise a bit different to fit in to the ownership model of rust. The crate is an extension of the combine crate.
extern crate combine;
extern crate combine_language;
use combine::{satisfy, EasyParser, Parser};
use combine::parser::char::{alpha_num, letter, string};
use combine_language::{Identifier, LanguageEnv, LanguageDef};
fn main() {
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), "")));
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.