petitparser / dart-petitparser Goto Github PK
View Code? Open in Web Editor NEWDynamic parser combinators in Dart.
Home Page: https://pub.dartlang.org/packages/petitparser
License: MIT License
Dynamic parser combinators in Dart.
Home Page: https://pub.dartlang.org/packages/petitparser
License: MIT License
Hi, I'm trying to debug a grammar that has several ref
s everywhere. This is pretty much just how the examples do it, so I figured I'd take the same approach.
Unfortunately, with something like
Parser foo() => letter()
Parser bar() => ref(foo)
I can't just do e.g. trace(bar)
, as that will tell me that References cannot be copied.
Unsupported operation: References cannot be copied.
package:petitparser/src/definition/reference.dart 50:23 Reference.copy
package:petitparser/src/reflection/transform.dart 18:34 transformParser
package:petitparser/src/debug/progress.dart 29:10 progress
I guess copying a function reference doesn't make much sense (in Dart.) Is there another way to debug parsers that contain ref
s? Which I imagine is most of the non-trivial ones. Or am I overlooking something? Thanks!
It's not clear how pattern() works.
I am guessing that the the ^ symbol stands in for any valid character? Does that include unicode special characters? Umlauts, etc.
Hi @renggli ,
I need some quick help and direction. I am trying to implement JMES PATH Specification, currently expression in the grammar is used recursively. How do i create a parse so it does not run into cyclic problems?
below is an example, not sure what i can do to address the situation:
Parser STAR() => ref(token, '*');
Parser DOT() => ref(token, '.');
Parser expressionSegment() => ref(sub_expressionSegment);
Parser sub_expressionSegment() =>
ref(expressionSegment) & ref(DOT) & ref(STAR);
The parser create stack overflow with below stack:
package:petitparser/src/parser/repeater/possesive.dart 56:3 PossessiveRepeatingParser.parseOn
package:petitparser/src/parser/combinator/sequence.dart 41:34 SequenceParser.parseOn
package:petitparser/src/parser/combinator/choice.dart 45:28 ChoiceParser.parseOn
package:petitparser/src/parser/repeater/possesive.dart 61:31 PossessiveRepeatingParser.parseOn
package:petitparser/src/parser/combinator/sequence.dart 41:34 SequenceParser.parseOn
package:petitparser/src/parser/combinator/choice.dart 45:28 ChoiceParser.parseOn
package:petitparser/src/parser/repeater/possesive.dart 61:31 PossessiveRepeatingParser.parseOn
package:petitparser/src/parser/combinator/sequence.dart 41:34 SequenceParser.parseOn
package:petitparser/src/parser/combinator/choice.dart 45:28 ChoiceParser.parseOn
package:petitparser/src/parser/repeater/possesive.dart 61:31 PossessiveRepeatingParser.parseOn
package:petitparser/src/parser/combinator/sequence.dart 41:34 SequenceParser.parseOn
package:petitparser/src/parser/combinator/choice.dart 45:28 ChoiceParser.parseOn
package:petitparser/src/parser/repeater/possesive.dart 61:31 PossessiveRepeatingParser.parseOn
package:petitparser/src/parser/combinator/sequence.dart 41:34 SequenceParser.parseOn
package:petitparser/src/parser/combinator/choice.dart 45:28 ChoiceParser.parseOn
package:petitparser/src/parser/repeater/possesive.dart 61:31 PossessiveRepeatingParser.parseOn
package:petitparser/src/parser/combinator/sequence.dart 41:34 SequenceParser.parseOn
package:petitparser/src/parser/combinator/choice.dart 45:28 ChoiceParser.parseOn
package:petitparser/src/parser/repeater/possesive.dart 61:31 PossessiveRepeatingParser.parseOn
Any help is appreciated or direction.
Regards,
Pratik Parikh
The homepage refers to a GitHub URL that redirects to this repo: https://github.com/petitparser/dart-petitparser/blob/master/pubspec.yaml#L5
Could you please help me with this question when you have time, thank you !
http://stackoverflow.com/questions/17428108/how-to-match-b-in-regex-in-petitparserdart
E.g. I may want to add a until()
and trimLeft(..)
and trimRight(...)
, that I can write as:
string("/*").trimLeft().until(string("*/"))
But I don't find a way to do it.
Could you please make it possible? (e.g. use noSuchMethod in Parser to delegate missing method invocation to another global object, which can be set by me, or some better solutions)
Hi @renggli ,
The version of Dart bundled with the latest version of flutter (1.2.1) is Dart 2.1.2.
I'm not able to use the latest version of petitparser because it needs >= Dart 2.2.0.
Can you please change the minimum required Dart version to 2.1.0?
Thanks
No clue if this is feasible, but...
It'd be great to set a flag to request an exception throw at the point of returning a FailureResult
This would allow inspection of the call stack to see where the failure occurred, in which part of the grammar/parser etc.
Possible?
I can't seem to parse Atom feeds using the XML parser, I thin but I'm not yet sure that its failing on constructs like this
content
It seems to fail on seeing the /"> of the tag.
Presumably it needs rules for Atom feed formats.
For a project I am working on uncompressed data files can be very large (easily 500k). I'd rather not load and hold the entire file in memory to parse it. Instead, I want to stream in characters as needed.
I see the "dart/grammar.dart" example uses a different style from other examples. It's clear and not use ref(...)
:
simpleFormalParameter =
declaredIdentifier
| metadata & identifier
;
normalFormalParameter =
functionSignature
| fieldFormalParameter
| simpleFormalParameter
;
I prefer this style, but how to set actions for them?
Just wanted to say thanks for developing this library, very awesome that the API matches the version written for Smalltalk!
Also I knew there was something familiar about @renggli 's username...I wrote an article about using Magritte back in 2009 when I was taking a CS continuing education course: https://neverfriday.com/2009/04/13/how-i-used-magritte-seaside-smalltalk-for-cs-class-project/
Now I wonder; can Dart match some of the power of Smalltalk?
Thanks again for writing this library (and for Magritte!)
http://www.dartlang.org/articles/style-guide/#names
The style guide suggests naming_files_like_this.dart to be more friendly to case-insensitive file systems.
The optimizer for character parsers uses HashSet and HashMap causing the order of the alternative character matchers to be non-deterministic.
Following doesn't work, since flatten
will ignore the pre trim
word().plus().trim().flatten()
So I have to write:
word().plus().trim().map((chars) => chars.join());
Is there a simpler solution?
See my question please:
http://stackoverflow.com/questions/17240119/how-to-use-petitparser-to-write-a-json-formatter
Thank you!
dart --checked test/dart_test.dart
Curious if you're seeing this.
I'm on the latest integration build 0.5.1.0 r22072
I noticed the following functions and classes do not have test-coverage and/or do not seem to be in use anywhere:
removeDuplicates()
profile()
progress()
debug()
ContinuationParser
_repeat()
Thoughts?
I'd expect this to pass (copy-paste into core_test.dart
).
Thoughts?
test('foo', () {
var letterLine = letter().plus().flatten().seq(Token.newlineParser())
.pick(0);
var parser = digit().plus().seq(letterLine).flatten();
expectSuccess(parser, '123abc\n', '123abc');
});
I'm thinking to use PetitParserDart instead of RegRex in my dart program, since I find it easier to write the code in PetitParserDart for complex rules than regex. But I don't know if the performance is good enough.
So I just write a small test:
import "package:petitparser/petitparser.dart";
const s = "dfsdf 2323 efwe 3345 fewf 9897 dfsdf 2323 efwe 3345 fewf 9897 dfsdf 2323 efwe 3345 fewf 9897 dfsdf 2323 efwe 3345 fewf 9897";
main() {
test(petitTest);
test(regexTest);
}
test(x()) {
var start = new DateTime.now();
for (int i = 0;i < 100000;i++) {
x();
}
var end = new DateTime.now();
print("cost: ${end.millisecondsSinceEpoch - start.millisecondsSinceEpoch} ms");
}
var regexParser = new RegExp(r"\d+");
regexTest() {
for (var m in regexParser.allMatches(s)) {
m.group(0);
}
}
var petitParser = (digit().plus().flatten() | any()).plus();
petitTest() {
petitParser.parse(s).value;
}
The result is:
cost: 924 ms
cost: 959 ms
Seems they have very similar performance. I'm not sure if my test is correct, and I want to get more information about PetitParserDart from you.
Thank you ~
Calling "removeDuplicates" on the DartGrammar is extremely slow (1+ minutes). Calling it on smaller grammars is not that slow, but still far from ideal.
Hello, I just saw that 3.0.0 is out, congratulations!
I tried updating my pubspec.yaml
to the new version and I see two breaking changes.
Error: The method 'anyIn' isn't defined for the class 'PSGrammarDefinition'.
Error: The method 'pick' isn't defined for the class 'Parser<dynamic>'.
PSGrammarDefinition
is derived from the lisp grammar.dart
in the examples, so I was able to change anyIn
to anyOf
per 287d88e#diff-4f3d5b971b9e0c8449d1a97a58a92e05
It'd be nice to note that change in the ChangeLog.
I see that pick
is now an extension method on Parser
, but why is it that it says it's not defined?
I'm running Dart 2.7.1 and I kept the same import line as before:
import 'package:petitparser/petitparser.dart';
See my question here:
and thank you!
Figure out why #import('dart:unittest') does not work.
This is more or less a bug on our (the Dart team's) part. The unittest library is in the Dart SDK but is not yet in the semi-arbitrary blessed set of libraries that can be imported using "dart:". For now, what you're doing is correct. In the future, you'll be able to do one of two things:
#import('package:unittest/unittest.dart')
.#import('dart:unittest')
will work.Sorry for the confusion.
And, since this isn't really an issue on your part, feel free to close this issue. :)
What is the easiest way to globally ignore all white-space while parsing (without pre-processing the input to remove the white-space before parsing)?
When write my own parser, I found it better to extend _DelegateParser
or _ListParser
as you do. But these two parsers are private, could you please make them public?
I want to define a verbatim
syntax, it can be specified an end word
, which is used to determine the end.
verbatim(ending)
... any text ...
ending
or
verbatim(otherword)
... any text ...
otherword
Is it possible to use petitparserdart to define such grammar?
Currently code is scattered with type-checks on the parsed input being a String
or a List
. Having a buffer could avoid this problem and enable further extensibility on the data being parsed.
/// An immutable parse buffer.
abstract class Buffer<E, S> {
///
factory Buffer.from(Object input) {
if (input is String) {
return new _StringBuffer(input, input.length);
} else if (input is List) {
return new _ListBuffer(input, input.length);
}
}
/// Return the underlying data structure.
S data;
/// Return the size of the buffer.
int get size;
/// Return the element at position [value].
E operator [](int index);
/// Return the sequence from [start] to [stop].
S sequence(int start, int stop);
}
class _StringBuffer implements Buffer<int, String> {
@override
final String data;
@override
final int length;
_StringBuffer(this.data, this.length);
@override
int operator [](int index) => data.codeUnitAt(index);
@override
String sequence(int startIndex, int stopIndex) => data.substring(startIndex, stopIndex);
}
class _ListBuffer<T> implements Buffer<T, List<T>> {
@override
final List<T> data;
@override
final int length;
_ListBuffer(this.data, this.length);
@override
T operator [](int index) => data[index];
@override
List<T> sequence(int startIndex, int stopIndex) => data.sublist(startIndex, stopIndex);
}
I have a large grammar, and I need to be able to track source code locations, however, it is very cumbersome, with the Token class. Do you have any suggestions or ideas for things to add the petitparser to make this easier?
This is my grammar: https://github.com/badger-lang/badger/blob/master/lib/src/parser/grammar.dart
Hi, I was curious if there is a good way to implement a range with padding. Currently trying to implement the iso8601 spec and a lot of numbers have a fixed length. See the official grammar below.
date-fullyear = 4DIGIT
date-month = 2DIGIT ; 01-12
date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
; month/year
time-hour = 2DIGIT ; 00-23
time-minute = 2DIGIT ; 00-59
time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second
; rules
time-secfrac = "." 1*DIGIT
time-numoffset = ("+" / "-") time-hour ":" time-minute
time-offset = "Z" / time-numoffset
partial-time = time-hour ":" time-minute ":" time-second
[time-secfrac]
full-date = date-fullyear "-" date-month "-" date-mday
full-time = partial-time time-offset
date-time = full-date "T" full-time
I would like a helper as follows
Parser<String> num2Digit(int n) => ?
Any idea on the best way to implement this? Thanks!
I need to build a math expression parser, so I started playing around a bit with the example. I found some strange behavior though.
When I run this code:
import 'package:petitparser/petitparser.dart';
void main() {
var number = (char('-').optional() &
digit().star() &
char('.').seq(digit().plus()).optional())
.flatten()
.trim()
.map(num.parse);
var term = undefined();
var prod = undefined();
var prim = undefined();
term.set(prod.seq(char('+').trim()).seq(term).map((values) {
print(values);
return values[0] + values[2];
}).or(prod));
prod.set(prim.seq(char('*').trim()).seq(prod).map((values) {
return values[0] * values[2];
}).or(prim));
prim.set(char('(').trim().seq(term).seq(char(')'.trim())).map((values) {
return values[1];
}).or(number));
var start = term.end();
print(start.parse('(1 + 2) + 2 * 3').value);
}
I get this as output:
[1, +, 2]
[1, +, 2]
[3, +, 6]
9
I think that means 1 + 2
went through twice, while it only has to be computed once. Perhaps there is a bug somewhere?
Some more descriptive toString's would help when debugging.
I found a way to use methods to define grammars, but it ended up with "stackoverflow" exception:
class MyParser {
abc() => string('abc');
ddd() => abc() & eee();
eee() => ddd();
}
main() {
var parser = new MyParser();
parser.eee().parse("abc");
}
It will throw stackoverflow exception since eee()
invokes ddd()
which invokes eee()
, again and again.
So I want to define a RefParser
:
typedef Parser ToParser();
class RefParser extends Parser {
ToParser _toParser;
RefParser(this._toParser);
Result _parse(Context context) => _toParser()._parse(context);
Parser copy() => new RefParser(_toParser);
}
And a method:
RefParser ref(ToParser p) => new RefParser(p);
Now I can rewrite the code to:
class MyParser {
abc() => string('abc');
ddd() => abc() & ref(eee);
eee() => ref(ddd);
}
Which won't throw exception and running well.
Since RefParser
overrides a private method _parse
, I can't define it outside library PetitParseDart
, or there will be an exception to invoke the _parse
method.
So I ask if you can add it to the library, so we can provide a typesafe
style of using this library.
PS: we can also create another &
and |
to accept ToParser
type, that we don't need to write ref(...)
anymore.
I have a need to parse ATOM feeds into JSON. I can parse the feed OK using the XML class and I'm wondering if a toJSON method would be a good addition here.
As far as I know there is no XML/JSON parser in Dart yet, I could of course get one from js and convert it but its probably a need more than I will have and its better if its part of an XML package such as this(IMHO).
I only need to generate from the document level but I guess it should be added to each element type, as toString() is.
I don't mind looking at this if you think it would be a good addition.
Hello,
I'm experimenting with the smalltalk parser, and I experienced issues with some configurations involving blocks as follows (dummy example):
var source = '''exampleWithNumber: x
|y z x|
y := true & false not & (nil isNil) ifFalse: [self halt].
self size + super size.
#( #a "a" 1 1.0)
do: [:each | Transcript show: (each class name);
show: ' '.].
x := y ifTrue:[x := 7] ifFalse:[8 essai].
^ x < y'''
the parser doesn't seems to paser th bold line.
But if I write this, its works :
var source = '''exampleWithNumber: x
|y z x|
y := true & false not & (nil isNil) ifFalse: [self halt].
self size + super size.
#( #a "a" 1 1.0)
do: [:each | Transcript show: (each class name);
show: ' '.].
(x := 5 ifTrue:[x := 7] ifFalse:[8 essai]).
^ x < y'''
any clues?
Hi there,
I noticed that trace
parsers are unable to trace the "children" of Reference
parsers, which would be handy.
I got around this without too much trouble (little code change, and introduced the trace in the referenced function), but it would be really nice to see a cohesive trace through the entirety of the input, with proper indentation and all that.
Anyway, thanks! This library has proven useful for a tiny DSL I'm writing.
Compile warning:
[Warning from Dart2JS on SlideSample|web/slide.dart]: web/packages/petitparser/src/core/characters/optimize.dart: Duplicated library name 'petitparser.core.characters.any_of'. [Warning from Dart2JS on SlideSample|web/slide.dart]: web/packages/petitparser/src/core/characters/any_of.dart: Duplicated library name 'petitparser.core.characters.any_of'.
In example/lispshell/lispshell.dart, line 74, "readAsTextSync" should be changed into "readAsStringSync".
With this construct :-
'<content type="text">Google is sponsoring at' '<a href="http://www.pubcon.com/">WebmasterWorld PubCon 2006\</a>. Come and' 'visit us at the booth or join us for an evening demo reception where we' 'will be talking "5 ways to enhance your website with Google Code".' 'After all, it is Vegas, baby! See you soon. </content>'
The XML parser is splitting out the 'a' tag, presumably because it sees the '<', however this is text and shouldn't be parsed should it?
Code:
var p0 = char('@') & word().plus().star().trim();
var p1 = p0.flatten();
var p2 = p0.pick(1);
var p3 = p0.pick(1).flatten();
var s = "@ abc ";
print("[${p1.parse(s).value}]");
print("[${p2.parse(s).value}]");
print("[${p3.parse(s).value}]");
Output:
[@ abc ]
[[[a, b, c]]]
[@ abc ] // ??? it's not pick(1) anymore
It seems if there is a flatten
after pick
, the pick
will be ignored. Is it expected behavior?
The library lib/test.dart
has import import 'package:matcher/matcher.dart';
.
This means that the package matcher
must be a public dependency, not
dev_dependencies:
browser: '>=0.10.0 <0.11.0'
test: '>=0.12.1 <0.13.0'
This prevents Analysis Server from building linked summaries for the package petitparser
and the transitive list of packages that use it.
Just importing petitparser
and referencing it in code will crash Flutter web apps on Safari.
You can find the steps to reproduce the error in this comment:
The error that is thrown in the JavaScript console in Safari is the following:
[Error] SyntaxError: Duplicate parameter 'char' not allowed in function with default parameter values.
(anonymous function) (optional.dart.lib.js:376)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__parser__combinator__delegate')
load__packages__petitparser__src__parser__action__cast_dart (cast.dart.lib.js:6:84)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__core__parser')
load__packages__petitparser__src__parser__action__pick_dart (pick.dart.lib.js:6:82)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__parser__combinator__delegate')
load__packages__petitparser__src__parser__action__flatten_dart (flatten.dart.lib.js:6:84)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__core__parser')
load__packages__xml__src__xml__utils__character_data_parser_dart (character_data_parser.dart.lib.js:6:82)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__parser__repeater__possesive')
load__packages__petitparser__src__parser__repeater__separated_by_dart (separated_by.dart.lib.js:7:85)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__core__parser')
load__packages__petitparser__src__parser__misc__epsilon_dart (epsilon.dart.lib.js:6:82)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__core__parser')
load__packages__petitparser__src__definition__reference_dart (reference.dart.lib.js:6:82)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__core__parser')
load__packages__petitparser__src__parser__predicate__predicate_dart (predicate.dart.lib.js:6:82)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__core__parser')
load__packages__petitparser__src__parser__repeater__limited_dart (limited.dart.lib.js:7:82)
execCb (require.js:1696)
check (require.js:883)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__parser__character__parser')
load__packages__petitparser__src__parser__character__whitespace_dart (whitespace.dart.lib.js:7:82)
execCb (require.js:1696)
check (require.js:883)
(anonymous function) (require.js:1139)
(anonymous function) (require.js:134)
(anonymous function) (require.js:1189)
each (require.js:59)
emit (require.js:1188)
check (require.js:938)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
[Error] TypeError: undefined is not an object (evaluating 'packages__petitparser__src__parser__combinator__optional$46dart.src__parser__character__parser')
load__packages__petitparser__src__parser__character__range_dart (range.dart.lib.js:7:82)
execCb (require.js:1696)
check (require.js:883)
(anonymous function) (require.js:1139)
(anonymous function) (require.js:134)
(anonymous function) (require.js:1189)
each (require.js:59)
emit (require.js:1188)
check (require.js:938)
enable (require.js:1176)
init (require.js:788)
callGetModule (require.js:1203)
completeLoad (require.js:1590)
onScriptLoad (require.js:1717)
This is the case as of version 3.1.0
.
Hi Lukas,
I'm curious as to your feelings about the potential for porting Petit Parser to the Characters package?
I'm wondering if the CharacterRange iterator is sufficient for Petit Parser's backtracking requirements. The upside of migrating to the Character package is that Petit Parser would be parsing in terms of Unicode Grapheme clusters instead of characters.
brett
Hi,
Firstly, awesome package! Bit scary at first, but examples are great. Greatly appreciate your work.
Minor issue I found:
print(char('x').trim().flatten().parse('x ').value.length); // 5
If I understand correctly, this should just match the 'x'
and discard trailing whitespace
. I had a look at the source code... but got scared again.
In SDK version 21823, I get an error message that says the class declaration for abstract class XmlNode illegal:
" Error: line 29 pos 45: type 'XmlNode' illegally refers to itself".
The problem is in nodes.dart in the 'xml' folder.
Can be also used as a more powerful action / map parser, to be able to transform a successful parse result into a failure or vice-versa.
See the question from stackoverflow: http://stackoverflow.com/questions/21951118/how-to-use-debug-with-undefined-parser
We can use def
to define grammars:
def("params", char('(') & ... & char(')'));
And ref it in other grammar:
def("fun", ... & ref("params") & ...);
I found the return value of def(...)
is void
, is it possible to let it return the value of ref(...)
, that I can write:
var params = def("params", char('(') & ... & char(')'));
var fun = def("fun", .. & params & ...);
Which is type-safer than former one.
I'm officially burned out now, why the heck is this not working?
var mtext = """use std\nuse blo""";
Parser bla =
// use
(whitespace().star().optional() & string("use") & whitespace().plus()
// [package name]
& word().plus().flatten()
// check for end of line
& whitespace().star().optional() & char("\n").plus()).times(2);
var res2 = bla.parse(mtext);
print(res2);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.