We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
之前已经添加了seqJoin这个解析器的尾处理器,与以下两个解析器尾处理器的连续调用是等价的:
var p1 = jcon.string('1'); var p2 = jcon.string('2'); var p12 = jcon.seq(p1, p2); p12.parse('12'); // 结果是['1','2'] 使用数组保存每个被结合的解析器的解析结果 var joined_p12 = p12.joinValue(); joined_p12.parse('12'); //结果是"12",将解析器的value数组进行join的“尾处理”。 jcon.seqJoin(p1, p2).parse('12'); //结果是"12",seqJoin等价于seq().joinValue(),是两个内dsl的结合
现在出现了新的需求,需要设计新的内部dsl来表现需求:
var p1 = jcon.string('1'); var p2 = jcon.string('2'); var p3 = jcon.string('3'); jcon.seq(p1, p2).seq(p3).parse('123'); // [['1','2'], '3'] 没有平坦化的数据 jcon.seq(p1, p2).seq(p3).flat().parse('123'); // ['1', '2', '3'] 需要对当前层次的value进行平坦化
另外,有一个需求是需要直接设置value的:
var whitespace = jcon.regex(/ \r\n\t\f+/); whitespace.parse(' '); //parse到了3个空白字符 whitespace.value(' ').parse(' ');// 无论parse到多少个空白字符,都返回{success:true, value:' '}
The text was updated successfully, but these errors were encountered:
acodercc
No branches or pull requests
之前已经添加了seqJoin这个解析器的尾处理器,与以下两个解析器尾处理器的连续调用是等价的:
现在出现了新的需求,需要设计新的内部dsl来表现需求:
另外,有一个需求是需要直接设置value的:
The text was updated successfully, but these errors were encountered: