Commit Graph

307 Commits (031ea6c39cc26217c68448bc205dcd8d9eaf8731)

Author SHA1 Message Date
Slava Pestov 83099e01d4 Fixing PEG: 2008-06-18 00:58:29 -05:00
Slava Pestov dc3929f3db Improve PEG: word 2008-06-18 00:35:19 -05:00
Slava Pestov 685d53e264 Add gather word; faster 'implementors' using inverted index 2008-06-12 05:49:46 -05:00
Eduardo Cavazos c5cc533182 peg.ebnf: minor update 2008-06-10 20:31:32 -05:00
Doug Coleman f706b50ac7 remove dipd, it's 2dip 2008-05-23 22:48:58 -05:00
Slava Pestov c60baf1232 sift and harvest words added 2008-05-13 23:36:55 -05:00
Slava Pestov 26aa656123 with-locals no longer necessary 2008-05-07 08:48:51 -05:00
Chris Double e1f82caf83 Use accessors in places for peg 2008-04-29 14:19:14 +12:00
Chris Double c671ccce99 { ... } whitespace grouping 2008-04-29 14:15:05 +12:00
Chris Double 7319dd5165 Add ~ grouping operator to ignore whitespace between elements in group 2008-04-29 12:37:26 +12:00
Doug Coleman 4d0ba8c3c1 reverse args for assoc-diff, diff
fix lots of usings
fix help lint
2008-04-26 02:01:43 -05:00
Doug Coleman b7c1f9dbe8 extra changes:
index* -> index-from
last-index* -> last-index-from
1 tail -> rest
1 tail-slice -> rest-slice
subset -> filter
prepose
find* -> find-from
find-last* -> find-last-from
before, after generic, < for integers
make between? work for timestamps
2008-04-25 23:17:08 -05:00
Slava Pestov b7037bf46a Merge commit 'doublec/master' 2008-04-14 05:44:28 -05:00
Chris Double 9f0f2d0bbc peg delay parsers now infer 2008-04-14 22:42:45 +12:00
Doug Coleman 72080fda4a construct-boa -> boa
construct-empty -> new
2008-04-13 15:06:27 -05:00
Chris Double 688cbfaafa Delocalise grow-lr 2008-04-11 14:46:11 +12:00
Chris Double 0dd8e462c6 Minor peg refactorings 2008-04-09 14:09:30 +12:00
Chris Double c39ece54a1 Merge commit 'origin/master' 2008-04-09 10:49:26 +12:00
Slava Pestov 9d8062aa46 Remove *.lib from using 2008-04-07 22:16:51 -05:00
Chris Double a641c6d332 Add \r to ebnf escape rules 2008-04-07 14:39:18 +12:00
Chris Double 719376e412 Remove w-c-u from ebnf transform 2008-04-07 13:17:09 +12:00
Chris Double 463a1991ca Fix peg help 2008-04-07 13:02:56 +12:00
Chris Double a093943627 Remove match from peg.parsers USING: list 2008-04-07 12:50:07 +12:00
Chris Double 00d09d20e2 Remove MATCH-VARS not used in pegs 2008-04-07 12:07:44 +12:00
Chris Double e00a392736 Refactor delay parser 2008-04-05 18:41:28 +13:00
Chris Double 2744313ac1 Refactor sp peg parser 2008-04-05 18:36:17 +13:00
Chris Double d93c7958fd Refactor action peg parser 2008-04-05 18:33:50 +13:00
Chris Double 247bf2137b Refactor ensure and ensure-not parsers 2008-04-05 18:30:11 +13:00
Chris Double 796981e192 Refactor semantic peg parser 2008-04-05 18:19:11 +13:00
Chris Double 3123654a84 Refactor optional peg parser 2008-04-05 18:05:09 +13:00
Chris Double d4897fa007 Refactor repeat0 and repeat1 peg parsers 2008-04-05 18:01:18 +13:00
Chris Double 226d211342 Refactor choice peg parser 2008-04-05 17:54:18 +13:00
Chris Double 102178f787 Refactor seq peg parser 2008-04-05 17:51:42 +13:00
Chris Double 7b73d2734f Refactor range peg parser 2008-04-05 17:33:39 +13:00
Chris Double 80d11405a9 Refactor token peg parser 2008-04-05 17:25:04 +13:00
Chris Double 8b16816bf8 Refactor satisfy peg parser 2008-04-05 17:17:52 +13:00
Chris Double a6b160c447 apply-memo-rule doesn't need to be inline 2008-04-05 02:26:41 +13:00
Chris Double 72dbac6a29 delocalise apply-memo-rule 2008-04-05 02:07:17 +13:00
Chris Double a4700e072e delocalise apply-rule 2008-04-05 01:56:37 +13:00
Chris Double 970f0055c2 Fix failing ebnf unit test 2008-04-03 17:33:37 +13:00
Chris Double cc7d945a80 Change ebnf variables to not use namespaces 2008-04-03 17:28:09 +13:00
Chris Double 27f2992dc5 Add failing ebnf test 2008-04-03 16:09:03 +13:00
Chris Double eac450bdcf Add ebnf rule word 2008-04-02 15:55:18 +13:00
Chris Double 34a1505d95 PL0 whitespace handling improvement 2008-04-02 15:47:30 +13:00
Chris Double bbcc84862f Tweak ast from sequences in ebnf 2008-04-02 15:47:21 +13:00
Chris Double 1b58ba404e Fix peg.pl0 test failures 2008-04-02 13:50:29 +13:00
Chris Double 9d0485cd8a Merge commit 'origin/master' 2008-04-02 13:02:47 +13:00
Chris Double 6b454eed36 Various peg/ebnf fixes
- Box parsers were broken when involved in left recursion detection
- ebnf no longer implicitly ignores white space between terminates/non-terminals
- ebnf now handles \t and \n in grammars so productions to detect white space work
- reset-delegates is now reset-pegs
2008-04-02 12:59:12 +13:00
Chris Double 122fd50d4a Throw error when ebnf uses a non-existant non-terminal 2008-04-01 14:49:20 +13:00
Eduardo Cavazos 4f07aefc97 Merge branch 'master' of git://factorcode.org/git/factor
Conflicts:

	core/classes/tuple/tuple.factor
2008-03-31 19:42:21 -06:00
Eduardo Cavazos aa40350aa7 replace add* and add with prefix and suffix 2008-03-31 18:18:05 -06:00
Chris Double 72bfd57f30 Make ebnf forgiving of whitespace at end of expression 2008-04-01 11:28:14 +13:00
Chris Double a41f8ef733 Mention how to fail from action in pegs 2008-03-31 17:26:42 +13:00
Chris Double f66774e875 Add tests for semantic and add syntax for it to ebnf
Syntax is ?[ ...]?
For example:
[EBNF num=. ?[ number? ]? list=list:x num:y => [[ drop x y + ]] | num EBNF] { 1 2 3 4 5 6 } swap call .
2008-03-31 16:50:05 +13:00
Chris Double c45eba6898 Add semantic parser 2008-03-31 16:34:59 +13:00
Chris Double 8a800361df Merge commit 'origin/master' 2008-03-31 15:01:22 +13:00
Chris Double 729ac1d6dc Some ebnf tweaks and tests to do with variables 2008-03-31 14:59:22 +13:00
Chris Double ee2194d1dc Allow variable names on elements 2008-03-31 14:03:16 +13:00
Chris Double 55a69392fa First cut at variables in ebnf 2008-03-31 13:52:42 +13:00
Chris Double 5989680a7b Ensure box parsers are never cached 2008-03-31 00:53:33 +13:00
Chris Double bb8198d3d0 Declare stack effects for compiled parsers 2008-03-30 23:24:02 +13:00
Chris Double 78633e03a0 Allow var names in ebnf but ignore them for now 2008-03-30 19:01:47 +13:00
Slava Pestov f9779f5c38 Fix conflict 2008-03-29 23:48:01 -05:00
Chris Double a23e0ce15c Fix hashcode* on parsers 2008-03-30 17:35:47 +13:00
Chris Double d002e02948 Use left recursive grammar in peg.expr 2008-03-30 17:23:11 +13:00
Chris Double af9e27823a Add => action rule for an entire sequence 2008-03-30 17:17:31 +13:00
Slava Pestov c22af5c7a6 Rename 2apply to bi@ 2008-03-29 20:36:58 -05:00
Chris Double 691d26068d Refactor peg compiler cache
Instead of a cache stored in a global variable, the compiled parser is stored in a slot in the parser delegate.
2008-03-30 14:00:45 +13:00
Slava Pestov 2aafe074b2 Merge branch 'master' of git://double.co.nz/git/factor 2008-03-29 00:38:31 -05:00
Chris Double ca4f775756 Fix PEG: 2008-03-29 18:33:37 +13:00
Chris Double 8105e66aec Add box parser to docs 2008-03-29 17:45:21 +13:00
Chris Double 86653e7a46 Don't use 'delay' parser in ebnf 2008-03-29 17:42:21 +13:00
Slava Pestov 2c3c66c6af Update peg for words being moved 2008-03-28 23:37:52 -05:00
Chris Double 0db0d9cd44 Move towards having ebnf infer 2008-03-29 16:24:13 +13:00
Chris Double 5f37b4fc72 compiled pegs infer 2008-03-29 16:11:08 +13:00
Chris Double 7bf27a5eb2 EBNF test using Java Primary production 2008-03-29 03:41:40 +13:00
Chris Double 25eea7ea1b Fix ebnf tests for left recursion 2008-03-29 02:51:49 +13:00
Chris Double 261539a86a Unit test for left recursive grammar 2008-03-29 02:47:03 +13:00
Chris Double dd979c8b3b Indirect Left recursive grammars working 2008-03-29 02:45:21 +13:00
Chris Double 68cbdf76aa Handle direct left recusion 2008-03-29 01:17:54 +13:00
Chris Double 010ce80076 Handle left recursion by failing again 2008-03-29 00:49:39 +13:00
Chris Double cca4700e49 Fix ebnf for peg changes 2008-03-29 00:41:41 +13:00
Chris Double 4b353c7529 Rewrite peg internals 2008-03-29 00:37:40 +13:00
Chris Double 1d87e513f5 lr2 wip 2008-03-28 21:17:08 +13:00
Chris Double d2190fd1ec Direct left recurson working 2008-03-28 14:30:10 +13:00
Chris Double 749f10ba9f Implement direct left recursion
As per VPRI Technical Report TR-2007-002 section 3.2
2008-03-28 14:30:10 +13:00
Chris Double f596aa2d71 Handle compilation of circular parsers 2008-03-28 14:26:05 +13:00
Chris Double f96a251f8a Refactor pegs to remove MEMO: and use unique id's 2008-03-28 12:35:47 +13:00
Chris Double 89c7698738 Fix MEMO problem with seq* and choice* 2008-03-28 11:30:46 +13:00
Chris Double fa8b311b27 Add packrat-parse, etc 2008-03-28 00:04:08 +13:00
Chris Double f6b7f8197e Add tests for left recusion in pegs 2008-03-27 23:54:34 +13:00
Chris Double 4e29081e93 Make left recursion in pegs a failed parse
Eventually left recursion will work fine, but this is prevents an infinite loop for now.
2008-03-27 18:15:22 +13:00
Chris Double 4c50daed22 Testcase for packrat behaviour 2008-03-27 17:58:08 +13:00
Chris Double bc5f82255f peg refactorings 2008-03-27 17:24:05 +13:00
Chris Double 708726d208 Add with-packrat word and more memoization 2008-03-27 15:50:27 +13:00
Chris Double 7c0535884e Fix up peg memoization of compiled parsers 2008-03-27 15:34:49 +13:00
Chris Double e6da3bc43a Use cache in compiled-parser in peg 2008-03-27 14:55:14 +13:00
Chris Double c0f4e37427 Fix usage of cache in pegs 2008-03-27 12:58:53 +13:00
Chris Double 2614792254 Implement packrat algorithm 2008-03-27 12:31:13 +13:00
Chris Double c793a381fe Add hook for packrat implementation 2008-03-27 11:24:06 +13:00
Chris Double 85a3ee3e5b Remove memoization in 'compile' word in pegs
This creates issues when recompiling a an existing EBNF parser for reasons I've not yet tracked down. Disabling it slows things down but makes things work correctly till I investigate the issue.
2008-03-27 11:24:06 +13:00
Chris Double de3e4e049f Use cleave instead of get-slots in peg 2008-03-26 16:21:33 +13:00
Chris Double 1ec945ba4c Use new slots in peg.ebnf 2008-03-26 16:16:23 +13:00
Chris Double 8569d18068 Use new slots in peg 2008-03-26 16:08:14 +13:00
Chris Double b1561de0f6 Reduce amount of generated code for peg token parser 2008-03-26 15:40:17 +13:00
Chris Double 9b7246555a Fix just parser in pegs 2008-03-26 15:26:54 +13:00
Chris Double 943b02ab2f Fix performance regression in pegs
delay parser is improved to use a memoized quotation so the
construction and compilation of the parser at runtime only
occurs once.
Changed compile so it would use equality rather than identity
for memoization purposes.
2008-03-22 01:59:16 +13:00
Chris Double d1e0aa6e80 Get peg subvocabs working again 2008-03-22 00:58:53 +13:00
Chris Double a14854520d Compile pegs down to words 2008-03-21 03:05:21 +13:00
Chris Double 1c6882b32c Rip out packrat stuff
It was broken since the transition to generating compiled quotations. As far as I know, no one was using packrat-parse anyway.
Rework in progress...
2008-03-21 01:26:20 +13:00
Chris Double d1e7ede35d Add support for & syntax in ebnf 2008-03-20 17:25:27 +13:00
Chris Double dbd0583044 Tidy up expr groups 2008-03-20 17:19:41 +13:00
Chris Double 8ade4f9b5b Fix vocab name in expr tests 2008-03-20 17:16:50 +13:00
Chris Double 44954753bd Change <EBNF .. EBNF> to [EBNF .. EBNF] 2008-03-20 17:13:27 +13:00
Chris Double e7980ebc61 More refactoring of EBNF
<EBNF .. EBNF> now produces a quotation that when called does the parsing
EBNF: foo ... ;EBNF creates a 'foo' word with stack effect (string -- result)
when called it parses the string and returns the result.
2008-03-20 17:11:09 +13:00
Chris Double 7dc772db26 Refactor ebnf parser generation 2008-03-20 16:05:10 +13:00
Chris Double c1f69f01be Change ordering of [[ ... ]] 2008-03-20 14:57:12 +13:00
Chris Double 39c228db6d Update peg.pl0 to use range pattern syntax
This allows removing the words for ident and number, replacing them
with EBNF expressions.
2008-03-20 14:22:14 +13:00
Chris Double 68388fbed9 Updated peg.expr to use range-pattern for digits 2008-03-20 14:15:06 +13:00
Chris Double ec4f964e4f Fix pl0 for EBNF syntax changes 2008-03-20 14:06:21 +13:00
Chris Double 795ef0ae3b Add ranges to EBNF syntax
This works:
  <EBNF letter = [a-zA-Z] EBNF>
and
  <EBNF not-digit = [^0-9] EBNF>
2008-03-20 13:55:19 +13:00
Chris Double 264284d0c4 Add range-pattern parser 2008-03-20 13:40:22 +13:00
Chris Double 97b58580a7 Add expression evaluator example for EBNF 2008-03-20 03:30:53 +13:00
Chris Double 92d8140d87 Change ebnf-action to properly nest with attached parser
This allows removal of last-parser hack. Syntax of EBNF changes though.
Now an action must attach to a group:

  <EBNF foo = (a b c) [[ ...act on group... ]] EBNF>
2008-03-20 03:05:40 +13:00
Chris Double 65fabeec11 remove => action and replace it with [[ code ]] in EBNF
Previously the action had to be a factor word and could only appear at the end of a rule:

  : aword ( ast -- ast ) drop V{ 1 2 } ;
  <EBNF foo = "a" "b" => aword EBNF>

Now actions can appear anywhere after an element, and can be any factor code between [[ ... ]] delimiters:

  <EBNF foo = "a" "b" [[ drop V{ 1 2 } ]] EBNF>
  <EBNF foo = "a" [[ drop 1 ]] "b" [[ drop 2 ]] EBNF>

Unfortunately since this means the ebnf>quot code uses the equivalent of eval, it no longer compiles nicely since it can't be inferred. The generated parsers however do compile.
2008-03-20 02:16:30 +13:00
Chris Double c0b7bdf823 Add *, + and ? to list of non-allowed ebnf identifier characteres 2008-03-20 01:25:57 +13:00
Chris Double 82d54d3776 EBNF syntax change
[ ... ] is now ( ... )?
{ ... } is now ( ... )*
Added ( ... )+
2008-03-20 01:18:09 +13:00
Chris Double 64135b73e1 Add support for ensure-not and parsing any single character to EBNF
This allows, for example:
  foo = {!("_" | "-") .}

This will match zero or more of any character, except for _ or -
2008-03-19 19:15:52 +13:00
Chris Double 208c88c449 Update pl0 for ebnf changes, and add more tests 2008-03-19 18:35:45 +13:00
Chris Double eef6ae7827 Remove need for '.' to terminate rule lines in EBNF 2008-03-19 18:07:31 +13:00
Chris Double 9403d97e22 Add syntax-pack and grouped to ebnf refactoring 2008-03-19 17:52:22 +13:00
Chris Double 708d55fb8e Add syntax word for ebnf 2008-03-19 17:37:08 +13:00
Chris Double 7578538122 Minor tidyup of ebnf 2008-03-19 17:34:47 +13:00
Chris Double cc9a17b551 Use choice* and seq* in ebnf 2008-03-19 17:00:53 +13:00
Chris Double 4b37c9098e Use multiline for parsing EBNF string 2008-03-19 16:54:42 +13:00
Doug Coleman ef437c96da add 1token and docs 2008-03-12 10:43:18 -05:00
Slava Pestov 5af2be3798 More documentation fixes 2008-03-11 21:01:39 -05:00
Slava Pestov 32526206f1 Help fixes 2008-03-11 19:51:58 -05:00
dharmatech a336cb7570 Unit test fixes 2008-03-06 13:46:15 -06:00
Doug Coleman f84761ae0c fix docs for delay 2008-03-05 18:15:28 -06:00
Slava Pestov 47a96775d8 Add PEG: word 2008-03-03 16:57:30 -06:00
Slava Pestov 05a02ade7a Unix <process-stream> now compiles 2008-03-03 16:45:18 -06:00
Doug Coleman 6378d38d63 add missing usings 2008-03-03 14:32:37 -06:00
Doug Coleman 2f48327b47 move non-core peg parsers to peg.parsers
document and unit test peg.parsers
add just parser
2008-03-03 13:28:53 -06:00
Slava Pestov e98cd1fd59 New convention for unit tests 2008-03-01 17:00:45 -05:00
Doug Coleman 635b02ca27 implement list-of, list-of* in terms of (list-of)
add 2choice 3choice
2008-02-26 17:13:15 -06:00
Doug Coleman 11147c7bc0 add 2seq, 3seq 2008-02-26 15:17:17 -06:00
Slava Pestov d165f29b36 Merge git://double.co.nz/git/factor 2008-02-25 16:32:36 -06:00
Daniel Ehrenberg f6845d43d3 Massive name change in files, string streams 2008-02-15 22:20:31 -06:00
Chris Double 8542dc5812 Add seq* and choice* to peg 2008-02-14 10:39:37 +13:00