]> gitweb.factorcode.org Git - factor.git/commitdiff
Move modules and peg-lexer to unmaintained
authorSlava Pestov <slava@shill.local>
Mon, 19 Oct 2009 10:56:35 +0000 (05:56 -0500)
committerSlava Pestov <slava@shill.local>
Mon, 19 Oct 2009 10:56:35 +0000 (05:56 -0500)
38 files changed:
extra/modules/rpc-server/authors.txt [deleted file]
extra/modules/rpc-server/rpc-server-docs.factor [deleted file]
extra/modules/rpc-server/rpc-server.factor [deleted file]
extra/modules/rpc-server/summary.txt [deleted file]
extra/modules/rpc/authors.txt [deleted file]
extra/modules/rpc/rpc-docs.factor [deleted file]
extra/modules/rpc/rpc.factor [deleted file]
extra/modules/rpc/summary.txt [deleted file]
extra/modules/using/authors.txt [deleted file]
extra/modules/using/summary.txt [deleted file]
extra/modules/using/using-docs.factor [deleted file]
extra/modules/using/using.factor [deleted file]
extra/peg-lexer/authors.txt [deleted file]
extra/peg-lexer/peg-lexer-docs.factor [deleted file]
extra/peg-lexer/peg-lexer-tests.factor [deleted file]
extra/peg-lexer/peg-lexer.factor [deleted file]
extra/peg-lexer/summary.txt [deleted file]
extra/peg-lexer/tags.txt [deleted file]
extra/peg-lexer/test-parsers/test-parsers.factor [deleted file]
unmaintained/modules/rpc-server/authors.txt [new file with mode: 0644]
unmaintained/modules/rpc-server/rpc-server-docs.factor [new file with mode: 0644]
unmaintained/modules/rpc-server/rpc-server.factor [new file with mode: 0644]
unmaintained/modules/rpc-server/summary.txt [new file with mode: 0644]
unmaintained/modules/rpc/authors.txt [new file with mode: 0644]
unmaintained/modules/rpc/rpc-docs.factor [new file with mode: 0644]
unmaintained/modules/rpc/rpc.factor [new file with mode: 0644]
unmaintained/modules/rpc/summary.txt [new file with mode: 0644]
unmaintained/modules/using/authors.txt [new file with mode: 0644]
unmaintained/modules/using/summary.txt [new file with mode: 0644]
unmaintained/modules/using/using-docs.factor [new file with mode: 0644]
unmaintained/modules/using/using.factor [new file with mode: 0644]
unmaintained/peg-lexer/authors.txt [new file with mode: 0644]
unmaintained/peg-lexer/peg-lexer-docs.factor [new file with mode: 0644]
unmaintained/peg-lexer/peg-lexer-tests.factor [new file with mode: 0644]
unmaintained/peg-lexer/peg-lexer.factor [new file with mode: 0644]
unmaintained/peg-lexer/summary.txt [new file with mode: 0755]
unmaintained/peg-lexer/tags.txt [new file with mode: 0644]
unmaintained/peg-lexer/test-parsers/test-parsers.factor [new file with mode: 0644]

diff --git a/extra/modules/rpc-server/authors.txt b/extra/modules/rpc-server/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/modules/rpc-server/rpc-server-docs.factor b/extra/modules/rpc-server/rpc-server-docs.factor
deleted file mode 100644 (file)
index fc2c234..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: help.syntax help.markup modules.rpc-server modules.using ;
-IN: modules.rpc-server
-HELP: service
-{ $syntax "IN: my-vocab service" }
-{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } } ;
\ No newline at end of file
diff --git a/extra/modules/rpc-server/rpc-server.factor b/extra/modules/rpc-server/rpc-server.factor
deleted file mode 100644 (file)
index d82f13f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-! Copyright (C) 2009 Sam Anklesaria.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators continuations effects
-io.encodings.binary io.servers.connection kernel namespaces
-sequences serialize sets threads vocabs vocabs.parser init io ;
-IN: modules.rpc-server
-
-<PRIVATE
-TUPLE: rpc-request args vocabspec wordname ;
-SYMBOL: serving-vocabs serving-vocabs [ V{ } clone ] initialize
-
-: getter ( -- ) deserialize dup serving-vocabs get-global index
-        [ vocab-words [ stack-effect ] { } assoc-map-as ]
-        [ \ no-vocab boa ] if serialize flush ;
-
-: doer ( -- ) deserialize dup vocabspec>> serving-vocabs get-global index
-        [ [ args>> ] [ wordname>> ] [ vocabspec>> vocab-words ] tri at [ execute ] curry with-datastack ]
-        [ vocabspec>> \ no-vocab boa ] if serialize flush ;
-
-PRIVATE>
-SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
-
-: start-rpc-server ( -- )
-    binary <threaded-server>
-    "rpcs" >>name 9012 >>insecure
-    [ deserialize {
-      { "getter" [ getter ] }
-      {  "doer" [ doer ] }
-      { "loader" [ deserialize vocab serialize flush ] } 
-    } case ] >>handler
-    start-server ;
diff --git a/extra/modules/rpc-server/summary.txt b/extra/modules/rpc-server/summary.txt
deleted file mode 100644 (file)
index 3688644..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Serve factor words as rpcs
\ No newline at end of file
diff --git a/extra/modules/rpc/authors.txt b/extra/modules/rpc/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/modules/rpc/rpc-docs.factor b/extra/modules/rpc/rpc-docs.factor
deleted file mode 100644 (file)
index af99d21..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-USING: help.syntax help.markup ;
-IN: modules.rpc
-ARTICLE: { "modules" "protocol" } "RPC Protocol"
-{ $list
-   "Send vocab as string"
-   "Send arglist"
-   "Send word as string"
-   "Receive result list"
-} ;
\ No newline at end of file
diff --git a/extra/modules/rpc/rpc.factor b/extra/modules/rpc/rpc.factor
deleted file mode 100644 (file)
index b394090..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-! Copyright (C) 2009 Sam Anklesaria.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs fry generalizations io.encodings.binary
-io.sockets kernel locals namespaces parser sequences serialize
-vocabs vocabs.parser words io ;
-IN: modules.rpc
-
-TUPLE: rpc-request args vocabspec wordname ;
-
-: send-with-check ( message -- reply/* )
-    serialize flush deserialize dup no-vocab? [ throw ] when ;
-
-:: define-remote ( str effect addrspec vocabspec -- )
-    str create-in effect [ in>> length ] [ out>> length ] bi
-    '[ _ narray vocabspec str rpc-request boa addrspec 9012 <inet> binary
-    [ "doer" serialize send-with-check ] with-client _ firstn ]
-    effect define-declared ;
-
-:: remote-vocab ( addrspec vocabspec -- vocab )
-   vocabspec "-remote" append dup vocab [ dup set-current-vocab
-     vocabspec addrspec 9012 <inet> binary [ "getter" serialize send-with-check ] with-client
-     [ first2 addrspec vocabspec define-remote ] each
-   ] unless ;
-
-: remote-load ( addr vocabspec -- voabspec ) [ swap
-    9012 <inet> binary [ "loader" serialize serialize flush deserialize ] with-client ] keep
-    [ dictionary get-global set-at ] keep ;
\ No newline at end of file
diff --git a/extra/modules/rpc/summary.txt b/extra/modules/rpc/summary.txt
deleted file mode 100644 (file)
index cc1501f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-remote procedure call client
\ No newline at end of file
diff --git a/extra/modules/using/authors.txt b/extra/modules/using/authors.txt
deleted file mode 100644 (file)
index 2300f69..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
diff --git a/extra/modules/using/summary.txt b/extra/modules/using/summary.txt
deleted file mode 100644 (file)
index 62fdb05..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Improved module import syntax with network transparency
\ No newline at end of file
diff --git a/extra/modules/using/using-docs.factor b/extra/modules/using/using-docs.factor
deleted file mode 100644 (file)
index 0f67f2b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-USING: help.syntax help.markup strings modules.using ;
-IN: modules.using
-ARTICLE: { "modules.using" "use" } "Using the modules.using vocab"
-"This vocabulary defines " { $link POSTPONE: USING*: } " as an alternative to " { $link POSTPONE: USING: } " which makes qualified imports easier. "
-"Secondly, it allows loading vocabularies from remote servers, as long as the remote vocabulary can be accessed at compile time. "
-"Finally, the word can treat words in remote vocabularies as remote procedure calls. Any inputs are passed to the imported words as normal, and the result will appear on the stack- the only difference is that the word isn't called locally." ;
-ABOUT: { "modules.using" "use" }
-
-HELP: USING*:
-{ $syntax "USING: rpc-server::module fetch-sever:module { module qualified-name } { module => word ... } { qualified-module } { module EXCEPT word ... } { module word => importname } ;" }
-{ $description "Adds vocabularies to the search path. Vocabularies can be loaded off a server or called as an rpc if preceded by a valid hostname. Bracketed pairs facilitate all types of qualified imports on both remote and local modules." } ;
\ No newline at end of file
diff --git a/extra/modules/using/using.factor b/extra/modules/using/using.factor
deleted file mode 100644 (file)
index 5691caa..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-! Copyright (C) 2009 Sam Anklesaria.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel modules.rpc peg peg-lexer peg.ebnf sequences
-strings vocabs.parser ;
-IN: modules.using
-
-EBNF: modulize
-tokenpart = (!(':').)+ => [[ >string ]]
-s = ':' => [[ drop ignore ]]
-rpc = tokenpart s s tokenpart => [[ first2 remote-vocab ]]
-remote = tokenpart s tokenpart => [[ first2 remote-load ]]
-module = rpc | remote | tokenpart
-;EBNF
-
-ON-BNF: USING*:
-tokenizer = <foreign factor>
-sym = !(";"|"}"|"=>"|"EXCEPT").
-modspec = sym => [[ modulize ]]
-qualified-with = modspec sym => [[ first2 add-qualified ignore ]]
-qualified = modspec => [[ dup add-qualified ignore ]]
-from = modspec "=>" sym+ => [[ first3 nip add-words-from ignore ]]
-exclude = modspec "EXCEPT" sym+ => [[ first3 nip add-words-excluding ignore ]]
-rename = modspec sym "=>" sym => [[ first4 nip swapd add-renamed-word ignore ]]
-long = "{" ( from | exclude | rename | qualified-with | qualified ) "}" => [[ drop ignore ]]
-short = modspec => [[ use-vocab ignore ]]
-wordSpec = long | short
-using = wordSpec+ ";" => [[ drop ignore ]]
-;ON-BNF
\ No newline at end of file
diff --git a/extra/peg-lexer/authors.txt b/extra/peg-lexer/authors.txt
deleted file mode 100644 (file)
index ce0899f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Sam Anklesaria
\ No newline at end of file
diff --git a/extra/peg-lexer/peg-lexer-docs.factor b/extra/peg-lexer/peg-lexer-docs.factor
deleted file mode 100644 (file)
index 18a458e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-USING: peg.ebnf help.syntax help.markup strings ;
-IN: peg-lexer
-
-HELP: ON-BNF:
-{ $syntax "ON-BNF: word ... ;ON-BNF" }
-{ $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack.  Parser syntax is as in " { $link POSTPONE: EBNF: } } ;
-
-HELP: create-bnf
-{ $values { "name" string } { "parser" parser } }
-{ $description "Runtime equivalent of " { $link POSTPONE: ON-BNF: } " also useful with manually constructed parsers." } ;
-
-HELP: factor
-{ $values { "input" string } { "ast" "a sequence of tokens" } }
-{ $description "Tokenizer that acts like standard factor lexer, separating tokens by whitespace." } ;
\ No newline at end of file
diff --git a/extra/peg-lexer/peg-lexer-tests.factor b/extra/peg-lexer/peg-lexer-tests.factor
deleted file mode 100644 (file)
index 99a1397..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-USING: tools.test peg-lexer.test-parsers ;
-IN: peg-lexer.tests
-
-{ V{ "1234" "-end" } } [
-   test1 1234-end
-] unit-test
-
-{ V{ 1234 53 } } [
-   test2 12345
-] unit-test
-
-{ V{ "heavy" "duty" "testing" } } [
-   test3 heavy duty testing
-] unit-test
\ No newline at end of file
diff --git a/extra/peg-lexer/peg-lexer.factor b/extra/peg-lexer/peg-lexer.factor
deleted file mode 100644 (file)
index dcde55c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-USING: hashtables assocs sequences locals math accessors multiline delegate strings
-delegate.protocols kernel peg peg.ebnf peg.private lexer namespaces combinators parser
-words ;
-IN: peg-lexer
-
-TUPLE: lex-hash hash ;
-CONSULT: assoc-protocol lex-hash hash>> ;
-: <lex-hash> ( a -- lex-hash ) lex-hash boa ;
-
-: pos-or-0 ( neg? -- pos/0 ) dup 0 < [ drop 0 ] when ;
-
-:: prepare-pos ( v i -- c l )
-    [let | n [ i v head-slice ] |
-           v CHAR: \n n last-index -1 or 1 + -
-           n [ CHAR: \n = ] count 1 +
-    ] ;
-      
-: store-pos ( v a -- )
-    input swap at prepare-pos
-    lexer get [ (>>line) ] keep (>>column) ;
-
-M: lex-hash set-at
-    swap {
-        { pos [ store-pos ] }
-        [ swap hash>> set-at ]
-    } case ;
-
-:: at-pos ( t l c -- p ) t l head-slice [ length ] map sum l 1 - + c + ;
-
-M: lex-hash at*
-    swap {
-      { input [ drop lexer get text>> "\n" join t ] }
-      { pos [ drop lexer get [ text>> ] [ line>> 1 - ] [ column>> 1 + ] tri at-pos t ] }
-      [ swap hash>> at* ]
-    } case ;
-
-: with-global-lexer ( quot -- result )
-   [
-       f lrstack set
-       V{ } clone error-stack set H{ } clone \ heads set
-       H{ } clone \ packrat set
-   ] f make-assoc <lex-hash>
-   swap bind ; inline
-
-: parse* ( parser -- ast )
-    compile
-    [ execute [ error-stack get first throw ] unless* ] with-global-lexer
-    ast>> ; inline
-
-: create-bnf ( name parser -- )
-    reset-tokenizer [ lexer get skip-blank parse* dup ignore? [ drop ] [ parsed ] if ] curry
-    define-syntax word make-inline ;
-    
-SYNTAX: ON-BNF:
-    CREATE-WORD reset-tokenizer ";ON-BNF" parse-multiline-string parse-ebnf
-    main swap at create-bnf ;
-
-! Tokenizer like standard factor lexer
-EBNF: factor
-space = " " | "\n" | "\t"
-spaces = space* => [[ drop ignore ]]
-chunk = (!(space) .)+ => [[ >string ]]
-expr = spaces chunk
-;EBNF
diff --git a/extra/peg-lexer/summary.txt b/extra/peg-lexer/summary.txt
deleted file mode 100755 (executable)
index 2de36ba..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Use peg to write parsing words
diff --git a/extra/peg-lexer/tags.txt b/extra/peg-lexer/tags.txt
deleted file mode 100644 (file)
index 44385cf..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-extensions
-reflection
diff --git a/extra/peg-lexer/test-parsers/test-parsers.factor b/extra/peg-lexer/test-parsers/test-parsers.factor
deleted file mode 100644 (file)
index 83c9f85..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-USING: peg-lexer math.parser strings ;
-IN: peg-lexer.test-parsers
-
-ON-BNF: test1
-      num = [1-4]* => [[ >string ]]
-      expr = num ( "-end" | "-done" )
-;ON-BNF
-
-ON-BNF: test2
-      num = [1-4]* => [[ >string string>number ]]
-      expr= num [5-9]
-;ON-BNF
-
-ON-BNF: test3
-      tokenizer = <foreign factor>
-      expr= "heavy" "duty" "testing"
-;ON-BNF
\ No newline at end of file
diff --git a/unmaintained/modules/rpc-server/authors.txt b/unmaintained/modules/rpc-server/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/modules/rpc-server/rpc-server-docs.factor b/unmaintained/modules/rpc-server/rpc-server-docs.factor
new file mode 100644 (file)
index 0000000..fc2c234
--- /dev/null
@@ -0,0 +1,5 @@
+USING: help.syntax help.markup modules.rpc-server modules.using ;
+IN: modules.rpc-server
+HELP: service
+{ $syntax "IN: my-vocab service" }
+{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } } ;
\ No newline at end of file
diff --git a/unmaintained/modules/rpc-server/rpc-server.factor b/unmaintained/modules/rpc-server/rpc-server.factor
new file mode 100644 (file)
index 0000000..d82f13f
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs combinators continuations effects
+io.encodings.binary io.servers.connection kernel namespaces
+sequences serialize sets threads vocabs vocabs.parser init io ;
+IN: modules.rpc-server
+
+<PRIVATE
+TUPLE: rpc-request args vocabspec wordname ;
+SYMBOL: serving-vocabs serving-vocabs [ V{ } clone ] initialize
+
+: getter ( -- ) deserialize dup serving-vocabs get-global index
+        [ vocab-words [ stack-effect ] { } assoc-map-as ]
+        [ \ no-vocab boa ] if serialize flush ;
+
+: doer ( -- ) deserialize dup vocabspec>> serving-vocabs get-global index
+        [ [ args>> ] [ wordname>> ] [ vocabspec>> vocab-words ] tri at [ execute ] curry with-datastack ]
+        [ vocabspec>> \ no-vocab boa ] if serialize flush ;
+
+PRIVATE>
+SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
+
+: start-rpc-server ( -- )
+    binary <threaded-server>
+    "rpcs" >>name 9012 >>insecure
+    [ deserialize {
+      { "getter" [ getter ] }
+      {  "doer" [ doer ] }
+      { "loader" [ deserialize vocab serialize flush ] } 
+    } case ] >>handler
+    start-server ;
diff --git a/unmaintained/modules/rpc-server/summary.txt b/unmaintained/modules/rpc-server/summary.txt
new file mode 100644 (file)
index 0000000..3688644
--- /dev/null
@@ -0,0 +1 @@
+Serve factor words as rpcs
\ No newline at end of file
diff --git a/unmaintained/modules/rpc/authors.txt b/unmaintained/modules/rpc/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/modules/rpc/rpc-docs.factor b/unmaintained/modules/rpc/rpc-docs.factor
new file mode 100644 (file)
index 0000000..af99d21
--- /dev/null
@@ -0,0 +1,9 @@
+USING: help.syntax help.markup ;
+IN: modules.rpc
+ARTICLE: { "modules" "protocol" } "RPC Protocol"
+{ $list
+   "Send vocab as string"
+   "Send arglist"
+   "Send word as string"
+   "Receive result list"
+} ;
\ No newline at end of file
diff --git a/unmaintained/modules/rpc/rpc.factor b/unmaintained/modules/rpc/rpc.factor
new file mode 100644 (file)
index 0000000..b394090
--- /dev/null
@@ -0,0 +1,27 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs fry generalizations io.encodings.binary
+io.sockets kernel locals namespaces parser sequences serialize
+vocabs vocabs.parser words io ;
+IN: modules.rpc
+
+TUPLE: rpc-request args vocabspec wordname ;
+
+: send-with-check ( message -- reply/* )
+    serialize flush deserialize dup no-vocab? [ throw ] when ;
+
+:: define-remote ( str effect addrspec vocabspec -- )
+    str create-in effect [ in>> length ] [ out>> length ] bi
+    '[ _ narray vocabspec str rpc-request boa addrspec 9012 <inet> binary
+    [ "doer" serialize send-with-check ] with-client _ firstn ]
+    effect define-declared ;
+
+:: remote-vocab ( addrspec vocabspec -- vocab )
+   vocabspec "-remote" append dup vocab [ dup set-current-vocab
+     vocabspec addrspec 9012 <inet> binary [ "getter" serialize send-with-check ] with-client
+     [ first2 addrspec vocabspec define-remote ] each
+   ] unless ;
+
+: remote-load ( addr vocabspec -- voabspec ) [ swap
+    9012 <inet> binary [ "loader" serialize serialize flush deserialize ] with-client ] keep
+    [ dictionary get-global set-at ] keep ;
\ No newline at end of file
diff --git a/unmaintained/modules/rpc/summary.txt b/unmaintained/modules/rpc/summary.txt
new file mode 100644 (file)
index 0000000..cc1501f
--- /dev/null
@@ -0,0 +1 @@
+remote procedure call client
\ No newline at end of file
diff --git a/unmaintained/modules/using/authors.txt b/unmaintained/modules/using/authors.txt
new file mode 100644 (file)
index 0000000..2300f69
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
diff --git a/unmaintained/modules/using/summary.txt b/unmaintained/modules/using/summary.txt
new file mode 100644 (file)
index 0000000..62fdb05
--- /dev/null
@@ -0,0 +1 @@
+Improved module import syntax with network transparency
\ No newline at end of file
diff --git a/unmaintained/modules/using/using-docs.factor b/unmaintained/modules/using/using-docs.factor
new file mode 100644 (file)
index 0000000..0f67f2b
--- /dev/null
@@ -0,0 +1,11 @@
+USING: help.syntax help.markup strings modules.using ;
+IN: modules.using
+ARTICLE: { "modules.using" "use" } "Using the modules.using vocab"
+"This vocabulary defines " { $link POSTPONE: USING*: } " as an alternative to " { $link POSTPONE: USING: } " which makes qualified imports easier. "
+"Secondly, it allows loading vocabularies from remote servers, as long as the remote vocabulary can be accessed at compile time. "
+"Finally, the word can treat words in remote vocabularies as remote procedure calls. Any inputs are passed to the imported words as normal, and the result will appear on the stack- the only difference is that the word isn't called locally." ;
+ABOUT: { "modules.using" "use" }
+
+HELP: USING*:
+{ $syntax "USING: rpc-server::module fetch-sever:module { module qualified-name } { module => word ... } { qualified-module } { module EXCEPT word ... } { module word => importname } ;" }
+{ $description "Adds vocabularies to the search path. Vocabularies can be loaded off a server or called as an rpc if preceded by a valid hostname. Bracketed pairs facilitate all types of qualified imports on both remote and local modules." } ;
\ No newline at end of file
diff --git a/unmaintained/modules/using/using.factor b/unmaintained/modules/using/using.factor
new file mode 100644 (file)
index 0000000..5691caa
--- /dev/null
@@ -0,0 +1,28 @@
+! Copyright (C) 2009 Sam Anklesaria.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel modules.rpc peg peg-lexer peg.ebnf sequences
+strings vocabs.parser ;
+IN: modules.using
+
+EBNF: modulize
+tokenpart = (!(':').)+ => [[ >string ]]
+s = ':' => [[ drop ignore ]]
+rpc = tokenpart s s tokenpart => [[ first2 remote-vocab ]]
+remote = tokenpart s tokenpart => [[ first2 remote-load ]]
+module = rpc | remote | tokenpart
+;EBNF
+
+ON-BNF: USING*:
+tokenizer = <foreign factor>
+sym = !(";"|"}"|"=>"|"EXCEPT").
+modspec = sym => [[ modulize ]]
+qualified-with = modspec sym => [[ first2 add-qualified ignore ]]
+qualified = modspec => [[ dup add-qualified ignore ]]
+from = modspec "=>" sym+ => [[ first3 nip add-words-from ignore ]]
+exclude = modspec "EXCEPT" sym+ => [[ first3 nip add-words-excluding ignore ]]
+rename = modspec sym "=>" sym => [[ first4 nip swapd add-renamed-word ignore ]]
+long = "{" ( from | exclude | rename | qualified-with | qualified ) "}" => [[ drop ignore ]]
+short = modspec => [[ use-vocab ignore ]]
+wordSpec = long | short
+using = wordSpec+ ";" => [[ drop ignore ]]
+;ON-BNF
\ No newline at end of file
diff --git a/unmaintained/peg-lexer/authors.txt b/unmaintained/peg-lexer/authors.txt
new file mode 100644 (file)
index 0000000..ce0899f
--- /dev/null
@@ -0,0 +1 @@
+Sam Anklesaria
\ No newline at end of file
diff --git a/unmaintained/peg-lexer/peg-lexer-docs.factor b/unmaintained/peg-lexer/peg-lexer-docs.factor
new file mode 100644 (file)
index 0000000..18a458e
--- /dev/null
@@ -0,0 +1,14 @@
+USING: peg.ebnf help.syntax help.markup strings ;
+IN: peg-lexer
+
+HELP: ON-BNF:
+{ $syntax "ON-BNF: word ... ;ON-BNF" }
+{ $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack.  Parser syntax is as in " { $link POSTPONE: EBNF: } } ;
+
+HELP: create-bnf
+{ $values { "name" string } { "parser" parser } }
+{ $description "Runtime equivalent of " { $link POSTPONE: ON-BNF: } " also useful with manually constructed parsers." } ;
+
+HELP: factor
+{ $values { "input" string } { "ast" "a sequence of tokens" } }
+{ $description "Tokenizer that acts like standard factor lexer, separating tokens by whitespace." } ;
\ No newline at end of file
diff --git a/unmaintained/peg-lexer/peg-lexer-tests.factor b/unmaintained/peg-lexer/peg-lexer-tests.factor
new file mode 100644 (file)
index 0000000..99a1397
--- /dev/null
@@ -0,0 +1,14 @@
+USING: tools.test peg-lexer.test-parsers ;
+IN: peg-lexer.tests
+
+{ V{ "1234" "-end" } } [
+   test1 1234-end
+] unit-test
+
+{ V{ 1234 53 } } [
+   test2 12345
+] unit-test
+
+{ V{ "heavy" "duty" "testing" } } [
+   test3 heavy duty testing
+] unit-test
\ No newline at end of file
diff --git a/unmaintained/peg-lexer/peg-lexer.factor b/unmaintained/peg-lexer/peg-lexer.factor
new file mode 100644 (file)
index 0000000..dcde55c
--- /dev/null
@@ -0,0 +1,64 @@
+USING: hashtables assocs sequences locals math accessors multiline delegate strings
+delegate.protocols kernel peg peg.ebnf peg.private lexer namespaces combinators parser
+words ;
+IN: peg-lexer
+
+TUPLE: lex-hash hash ;
+CONSULT: assoc-protocol lex-hash hash>> ;
+: <lex-hash> ( a -- lex-hash ) lex-hash boa ;
+
+: pos-or-0 ( neg? -- pos/0 ) dup 0 < [ drop 0 ] when ;
+
+:: prepare-pos ( v i -- c l )
+    [let | n [ i v head-slice ] |
+           v CHAR: \n n last-index -1 or 1 + -
+           n [ CHAR: \n = ] count 1 +
+    ] ;
+      
+: store-pos ( v a -- )
+    input swap at prepare-pos
+    lexer get [ (>>line) ] keep (>>column) ;
+
+M: lex-hash set-at
+    swap {
+        { pos [ store-pos ] }
+        [ swap hash>> set-at ]
+    } case ;
+
+:: at-pos ( t l c -- p ) t l head-slice [ length ] map sum l 1 - + c + ;
+
+M: lex-hash at*
+    swap {
+      { input [ drop lexer get text>> "\n" join t ] }
+      { pos [ drop lexer get [ text>> ] [ line>> 1 - ] [ column>> 1 + ] tri at-pos t ] }
+      [ swap hash>> at* ]
+    } case ;
+
+: with-global-lexer ( quot -- result )
+   [
+       f lrstack set
+       V{ } clone error-stack set H{ } clone \ heads set
+       H{ } clone \ packrat set
+   ] f make-assoc <lex-hash>
+   swap bind ; inline
+
+: parse* ( parser -- ast )
+    compile
+    [ execute [ error-stack get first throw ] unless* ] with-global-lexer
+    ast>> ; inline
+
+: create-bnf ( name parser -- )
+    reset-tokenizer [ lexer get skip-blank parse* dup ignore? [ drop ] [ parsed ] if ] curry
+    define-syntax word make-inline ;
+    
+SYNTAX: ON-BNF:
+    CREATE-WORD reset-tokenizer ";ON-BNF" parse-multiline-string parse-ebnf
+    main swap at create-bnf ;
+
+! Tokenizer like standard factor lexer
+EBNF: factor
+space = " " | "\n" | "\t"
+spaces = space* => [[ drop ignore ]]
+chunk = (!(space) .)+ => [[ >string ]]
+expr = spaces chunk
+;EBNF
diff --git a/unmaintained/peg-lexer/summary.txt b/unmaintained/peg-lexer/summary.txt
new file mode 100755 (executable)
index 0000000..2de36ba
--- /dev/null
@@ -0,0 +1 @@
+Use peg to write parsing words
diff --git a/unmaintained/peg-lexer/tags.txt b/unmaintained/peg-lexer/tags.txt
new file mode 100644 (file)
index 0000000..44385cf
--- /dev/null
@@ -0,0 +1,2 @@
+extensions
+reflection
diff --git a/unmaintained/peg-lexer/test-parsers/test-parsers.factor b/unmaintained/peg-lexer/test-parsers/test-parsers.factor
new file mode 100644 (file)
index 0000000..83c9f85
--- /dev/null
@@ -0,0 +1,17 @@
+USING: peg-lexer math.parser strings ;
+IN: peg-lexer.test-parsers
+
+ON-BNF: test1
+      num = [1-4]* => [[ >string ]]
+      expr = num ( "-end" | "-done" )
+;ON-BNF
+
+ON-BNF: test2
+      num = [1-4]* => [[ >string string>number ]]
+      expr= num [5-9]
+;ON-BNF
+
+ON-BNF: test3
+      tokenizer = <foreign factor>
+      expr= "heavy" "duty" "testing"
+;ON-BNF
\ No newline at end of file