1 ! Copyright (C) 2008 Chris Double.
2 ! See https://factorcode.org/license.txt for BSD license.
4 USING: accessors kernel math peg peg.ebnf peg.ebnf.private
5 peg.javascript peg.javascript.private sequences tools.test ;
11 T{ ast-string f "hello" }
20 "123; 'hello'; foo(x);" tokenize-javascript
23 { V{ T{ ast-regexp f "<(w+)[^>]*?)/>" "g" } } } [
24 "/<(\\w+)[^>]*?)\\/>/g" tokenize-javascript
28 V{ T{ ast-string { value "abc\"def\"" } } }
29 } [ "\"abc\\\"def\\\"\"" tokenize-javascript ] unit-test
32 V{ T{ ast-string { value "\b\f\n\r\t\v'\"\\" } } }
33 } [ "\"\\b\\f\\n\\r\\t\\v\\'\\\"\\\\\"" tokenize-javascript ] unit-test
36 V{ T{ ast-string { value "abc" } } }
37 } [ "\"\\x61\\u0062\\u{63}\"" tokenize-javascript ] unit-test
45 T{ ast-string f "hello" }
50 V{ T{ ast-get f "x" } }
55 "123; 'hello'; foo(x);" parse-javascript
62 " main \ parse-javascript rule (parse) remaining>> length zero?
68 function foldl(f, initial, seq) {
69 for(var i=0; i< seq.length; ++i)
70 initial = f(initial, seq[i]);
72 }" main \ parse-javascript rule (parse) remaining>> length zero?
77 ParseState.prototype.from = function(index) {
78 var r = new ParseState(this.input, this.index + index);
80 r.length = this.length - index;
82 }" main \ parse-javascript rule (parse) remaining>> length zero?
86 { T{ ast-begin f V{ T{ ast-number f 123 } } } } [
87 "123;" parse-javascript