]> gitweb.factorcode.org Git - factor.git/commitdiff
parser, source-files: you need to bootstrap after this patch.
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 24 Jul 2015 05:00:48 +0000 (22:00 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 24 Jul 2015 05:03:43 +0000 (22:03 -0700)
cleans up some file vs path naming.

file -> current-source-file
file -> current-test-file somewhere else
source-file -> path>source-file
source-file-tuple -> source-file

19 files changed:
basis/command-line/command-line.factor
basis/help/definitions/definitions-tests.factor
basis/help/topics/topics-tests.factor
basis/source-files/errors/debugger/debugger.factor
basis/tools/crossref/crossref.factor
basis/tools/test/test.factor
basis/ui/tools/error-list/error-list.factor
basis/ui/tools/operations/operations.factor
core/compiler/units/units-docs.factor
core/parser/notes/notes-tests.factor
core/parser/notes/notes.factor
core/parser/parser-docs.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/source-files/errors/errors.factor
core/source-files/source-files-docs.factor
core/source-files/source-files.factor
core/syntax/syntax.factor
core/vocabs/loader/loader-tests.factor

index 7026abd19c175b1b3a621ae0167ae61473d826b0..349ca5e911db74ddbcb9a321fc4c3313e4e8f9bc 100644 (file)
@@ -60,7 +60,7 @@ SYMBOL: command-line
 : run-script ( file -- )
     t parser-quiet? [
         [ run-file ]
-        [ source-file main>> [ execute( -- ) ] when* ] bi
+        [ path>source-file main>> [ execute( -- ) ] when* ] bi
     ] with-variable ;
 
 : (parse-command-line) ( args -- )
index 9cbeff31d8d60607c5f4b77e302a24621e2d006c..a8d4f1052dacb03335d6aa250f76e028202cd66d 100644 (file)
@@ -10,7 +10,7 @@ IN: help.definitions.tests
         "IN: help.definitions.tests USING: help.syntax ; : hello ( -- ) ; HELP: hello \"test\" ; ARTICLE: \"hello\" \"world\" ; ARTICLE: \"hello2\" \"world\" ;" <string-reader> "foo"
         parse-stream drop
 
-        "foo" source-file definitions>> first cardinality
+        "foo" path>source-file definitions>> first cardinality
     ] unit-test
 
     [ t ] [ "hello" articles get key? ] unit-test
@@ -23,7 +23,7 @@ IN: help.definitions.tests
         "IN: help.definitions.tests USING: help.syntax ; : hello ( -- ) ; ARTICLE: \"hello\" \"world\" ;" <string-reader> "foo"
         parse-stream drop
 
-        "foo" source-file definitions>> first cardinality
+        "foo" path>source-file definitions>> first cardinality
     ] unit-test
 
     [ t ] [ "hello" articles get key? ] unit-test
index 0291243dd5a4ccb1bdb9781080b6d967ec3930da..a62b43fb6ed433f28c797f99469d6e7a532e8585 100644 (file)
@@ -23,7 +23,7 @@ SYMBOL: foo
         "\"def\" ;"
     } "\n" join
     [
-        "testfile" source-file file set
+        "testfile" path>source-file current-source-file set
         eval( -- )
     ] with-scope
 ] unit-test
index 5c28fb755895bbe3b17906693958510e2ca491f9..2e7cfbd50137db7a02031a9e865022be29e562ed 100644 (file)
@@ -7,7 +7,7 @@ CONSTANT: +listener-input+ "<Listener input>"
 
 : error-location ( error -- string )
     [
-        [ file>> [ % ] [ +listener-input+ % ] if* ]
+        [ path>> [ % ] [ +listener-input+ % ] if* ]
         [ line#>> [ ": " % # ] when* ] bi
     ] "" make ;
 
index 12cca05af907cd1b3a3c027a616877ec00500648..e8818127a14c8d39f0a8e030df395907f20357e0 100644 (file)
@@ -51,7 +51,7 @@ M: link uses
     [ { $vocab-link } article-links [ >vocab-link ] map ]
     bi append ;
 
-M: pathname uses string>> source-file top-level-form>> [ uses ] [ { } ] if* ;
+M: pathname uses string>> path>source-file top-level-form>> [ uses ] [ { } ] if* ;
 
 ! To make UI browser happy
 M: object uses drop f ;
index 24eb41f4f182701effc8da3d9545eb6559b03774..5ae7848d19a65ba1a9b679b6e3a6d06d023b8867 100644 (file)
@@ -36,7 +36,7 @@ t verbose-tests? set-global
 : <test-failure> ( error experiment file line# -- triple )
     test-failure new
         swap >>line#
-        swap >>file
+        swap >>path
         swap >>asset
         swap >>error
         error-continuation get >>continuation ;
@@ -46,10 +46,10 @@ t verbose-tests? set-global
     <test-failure> test-failures get push
     notify-error-observers ;
 
-SYMBOL: file
+SYMBOL: current-test-file
 
 : file-failure ( error -- )
-    [ f file get ] keep error-line failure ;
+    [ f current-test-file get ] keep error-line failure ;
 
 :: (unit-test) ( output input -- error ? )
     [ { } input with-datastack output assert-sequence= f f ] [ t ] recover ;
@@ -92,8 +92,8 @@ MACRO: <experiment> ( word -- quot )
     word <experiment> :> e
     e experiment.
     word execute [
-        file get [
-            e file get line# failure
+        current-test-file get [
+            e current-test-file get line# failure
         ] [ rethrow ] if
     ] [ drop ] if ; inline
 
@@ -114,7 +114,7 @@ SYNTAX: TEST:
 
 : fake-unit-test ( quot -- test-failures )
     [
-        "fake" file set
+        "fake" current-test-file set
         V{ } clone test-failures set
         call
         test-failures get
@@ -123,8 +123,8 @@ SYNTAX: TEST:
 PRIVATE>
 
 : run-test-file ( path -- )
-    dup file [
-        test-failures get file get +test-failure+ delete-file-errors
+    dup current-test-file [
+        test-failures get current-test-file get +test-failure+ delete-file-errors
         '[ _ run-file ] [ file-failure ] recover
     ] with-variable ;
 
index cbefaed0b1eea1a93b17e2eb34c9b23b7aeeb519..ccc8fb2b64721a1fcfe18866c59e2d017eea6144 100644 (file)
@@ -103,7 +103,7 @@ M: error-renderer column-alignment drop { 0 1 0 0 } ;
     sort-keys values ;
 
 : file-matches? ( error pathname/f -- ? )
-    [ file>> ] [ dup [ string>> ] when ] bi* = ;
+    [ path>> ] [ dup [ string>> ] when ] bi* = ;
 
 : <error-table-model> ( error-list -- model )
     [ model>> ] [ source-file>> ] bi
index dbf9b8ac0e7023069b6a3019095b1eae27d13e5a..fa5c2e04190a6960452ca4124e0741433098bf33 100644 (file)
@@ -87,7 +87,7 @@ IN: ui.tools.operations
 } define-operation
 
 : com-reload ( error -- )
-    file>> run-file ;
+    path>> run-file ;
 
 [ compiler-error? ] \ com-reload H{
     { +listener+ t }
index 18cdca553b108315234d5a50629be6e121513d03..f49f3b48c55e27d589231d394f34ead18a95f1bd 100644 (file)
@@ -50,10 +50,10 @@ HELP: remember-definition
 { $description "Saves the location of a definition and associates this definition with the current source file." } ;
 
 HELP: old-definitions
-{ $var-description "Stores a pair of sets where the members form the set of definitions which were defined by " { $link file } " the most recent time it was loaded." } ;
+{ $var-description "Stores a pair of sets where the members form the set of definitions which were defined by " { $link current-source-file } " the most recent time it was loaded." } ;
 
 HELP: new-definitions
-{ $var-description "Stores a pair of sets where the members form the set of definitions which were defined so far by the current parsing of " { $link file } "." } ;
+{ $var-description "Stores a pair of sets where the members form the set of definitions which were defined so far by the current parsing of " { $link current-source-file } "." } ;
 
 HELP: with-compilation-unit
 { $values { "quot" quotation } }
index d3b92055698f08a6a72fa59cc2f72d3d07ec9767..0ed0afd4d95ee7c75de21ab6d0bf4912e87bbf7a 100644 (file)
@@ -1,4 +1,4 @@
 USING: lexer namespaces parser.notes source-files tools.test ;
 IN: parser.notes.tests
 
-{ } [ f lexer set f file set "Hello world" note. ] unit-test
+{ } [ f lexer set f current-source-file set "Hello world" note. ] unit-test
index 64bbb7299aba008e152500abfdf145be748d7244..301dd5770225983e15a5f1fd2a46d847c2a5aca5 100644 (file)
@@ -10,7 +10,7 @@ t parser-quiet? set-global
 
 : note. ( str -- )
     parser-quiet? get [
-        file get [ path>> write ":" write ] when*
+        current-source-file get [ path>> write ":" write ] when*
         lexer get [ line>> number>string write ": " write ] when*
         "Note:" print dup print
     ] unless drop ;
index 1fed04bd7aabdf93cb3d611e15a6f32dad8df606..f605a82988d9e699ec0b16fea6a1091ed50eb07f 100644 (file)
@@ -245,14 +245,14 @@ HELP: parse-fresh
 
 HELP: filter-moved
 { $values { "set1" set } { "set2" set } { "seq" "an sequence of definitions" } }
-{ $description "Removes all definitions from " { $snippet "set2" } " which are in " { $snippet "set1" } " or are no longer present in the current " { $link file } "." } ;
+{ $description "Removes all definitions from " { $snippet "set2" } " which are in " { $snippet "set1" } " or are no longer present in the " { $link current-source-file } "." } ;
 
 HELP: forget-smudged
 { $description "Forgets removed definitions." } ;
 
 HELP: finish-parsing
 { $values { "lines" "the lines of text just parsed" } { "quot" "the quotation just parsed" } }
-{ $description "Records information to the current " { $link file } "." }
+{ $description "Records information to the " { $link current-source-file } "." }
 { $notes "This is one of the factors of " { $link parse-stream } "." } ;
 
 HELP: parse-stream
@@ -261,12 +261,12 @@ HELP: parse-stream
 { $errors "Throws an I/O error if there was an error reading from the stream. Throws a parse error if the input is malformed." } ;
 
 HELP: parse-file
-{ $values { "file" "a pathname string" } { "quot" quotation } }
+{ $values { "path" "a pathname string" } { "quot" quotation } }
 { $description "Parses the Factor source code stored in a file. The initial vocabulary search path is used." }
 { $errors "Throws an I/O error if there was an error reading from the file. Throws a parse error if the input is malformed." } ;
 
 HELP: run-file
-{ $values { "file" "a pathname string" } }
+{ $values { "path" "a pathname string" } }
 { $description "Parses the Factor source code stored in a file and runs it. The initial vocabulary search path is used." }
 { $errors "Throws an error if loading the file fails, there input is malformed, or if a runtime error occurs while calling the parsed quotation." }  ;
 
index e342d172f08d901a321fcb7a6bd6f5df6b31222e..92b9de71fd147ff50463ad31e93ce7a0f05c4391 100644 (file)
@@ -117,7 +117,7 @@ DEFER: foo
     "IN: parser.tests : smudge-me ( -- ) ;" <string-reader> "foo"
     parse-stream drop
 
-    "foo" source-file definitions>> first cardinality
+    "foo" path>source-file definitions>> first cardinality
 ] unit-test
 
 { t } [ "smudge-me" "parser.tests" lookup-word >boolean ] unit-test
@@ -134,21 +134,21 @@ DEFER: foo
     "IN: parser.tests USING: math strings ; GENERIC: smudge-me ( a -- b ) M: integer smudge-me ; M: string smudge-me ;" <string-reader> "foo"
     parse-stream drop
 
-    "foo" source-file definitions>> first cardinality
+    "foo" path>source-file definitions>> first cardinality
 ] unit-test
 
 { 1 } [
     "IN: parser.tests USING: arrays ; M: array smudge-me ;" <string-reader> "bar"
     parse-stream drop
 
-    "bar" source-file definitions>> first cardinality
+    "bar" path>source-file definitions>> first cardinality
 ] unit-test
 
 { 2 } [
     "IN: parser.tests USING: math strings ; GENERIC: smudge-me ( a -- b ) M: integer smudge-me ;" <string-reader> "foo"
     parse-stream drop
 
-    "foo" source-file definitions>> first cardinality
+    "foo" path>source-file definitions>> first cardinality
 ] unit-test
 
 { t } [
index 3a5dbac73b5851251696a958b3d860c577737e19..91dea25487cef3ca6e6f88bce90695987cb3684d 100644 (file)
@@ -8,7 +8,7 @@ vectors vocabs vocabs.parser words words.symbol ;
 IN: parser
 
 : location ( -- loc )
-    file get lexer get line>> 2dup and
+    current-source-file get lexer get line>> 2dup and
     [ [ path>> ] dip 2array ] [ 2drop f ] if ;
 
 : save-location ( definition -- )
@@ -162,13 +162,13 @@ print-use-hook [ [ ] ] initialize
         auto-used? [ print-use-hook get call( -- ) ] when
     ] with-file-vocabs ;
 
-: parsing-file ( file -- )
+: parsing-file ( path -- )
     parser-quiet? get [ drop ] [ "Loading " write print flush ] if ;
 
 : filter-moved ( set1 set2 -- seq )
     swap diff members [
         {
-            { [ dup where dup [ first ] when file get path>> = not ] [ f ] }
+            { [ dup where dup [ first ] when current-source-file get path>> = not ] [ f ] }
             { [ dup reader-method? ] [ f ] }
             { [ dup writer-method? ] [ f ] }
             [ t ]
@@ -202,7 +202,7 @@ print-use-hook [ [ ] ] initialize
     fix-class-words ;
 
 : finish-parsing ( lines quot -- )
-    file get
+    current-source-file get
     [ record-top-level-form ]
     [ record-definitions ]
     [ record-checksum ]
@@ -217,10 +217,10 @@ print-use-hook [ [ ] ] initialize
         ] with-source-file
     ] with-compilation-unit ;
 
-: parse-file-restarts ( file -- restarts )
+: parse-file-restarts ( path -- restarts )
     "Load " " again" surround t 2array 1array ;
 
-: parse-file ( file -- quot )
+: parse-file ( path -- quot )
     [
         [ parsing-file ] keep
         [ utf8 <file-reader> ] keep
@@ -230,7 +230,7 @@ print-use-hook [ [ ] ] initialize
         drop parse-file
     ] recover ;
 
-: run-file ( file -- )
+: run-file ( path -- )
     parse-file call( -- ) ;
 
 : ?run-file ( path -- )
index 7580c04b4300f467d0a4745b86919efb0bd8cc1b..54e5f24ad194270a4b0ca741cf55848a221ff24c 100644 (file)
@@ -13,9 +13,9 @@ M: object error-line drop f ;
 M: condition error-file error>> error-file ;
 M: condition error-line error>> error-line ;
 
-TUPLE: source-file-error error asset file line# ;
+TUPLE: source-file-error error asset path line# ;
 
-M: source-file-error error-file [ error>> error-file ] [ file>> ] bi or ;
+M: source-file-error error-file [ error>> error-file ] [ path>> ] bi or ;
 M: source-file-error error-line [ error>> error-line ] [ line#>> ] bi or ;
 M: source-file-error compute-restarts error>> compute-restarts ;
 
@@ -23,7 +23,7 @@ M: source-file-error compute-restarts error>> compute-restarts ;
     [ [ line#>> 0 or ] sort-with ] { } assoc-map-as sort-keys ;
 
 : group-by-source-file ( errors -- assoc )
-    H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ;
+    H{ } clone [ [ push-at ] curry [ dup path>> ] prepose each ] keep ;
 
 TUPLE: error-type-holder type word plural icon quot forget-quot { fatal? initial: t } ;
 
@@ -33,7 +33,7 @@ GENERIC: error-type ( error -- type )
     new
         swap
         [ >>asset ]
-        [ where [ first2 [ >>file ] [ >>line# ] bi* ] when* ] bi
+        [ where [ first2 [ >>path ] [ >>line# ] bi* ] when* ] bi
         swap >>error ; inline
 
 SYMBOL: error-types
@@ -83,7 +83,7 @@ SYMBOL: error-observers
 
 : delete-file-errors ( seq file type -- )
     [
-        [ swap file>> = ] [ swap error-type = ]
+        [ swap path>> = ] [ swap error-type = ]
         bi-curry* bi and not
     ] 2curry filter! drop
     notify-error-observers ;
index 9668abdfcede0663f987608f0b5e39eaa829f877..c473f6d2cf8b21f504c34eaff743282d10c37509 100644 (file)
@@ -23,18 +23,20 @@ $nl
 ABOUT: "source-files"
 
 HELP: source-files
-{ $var-description "An assoc mapping pathname strings to " { $link source-file-tuple } " instances, representing loaded source files." } ;
+{ $var-description "An assoc mapping pathname strings to " { $link source-file } " instances, representing loaded source files." } ;
 
-HELP: source-file
-{ $values { "path" "a pathname string" } { "source-file" source-file-tuple } }
+HELP: path>source-file
+{ $values { "path" "a pathname string" } { "source-file" source-file } }
 { $description "Outputs the source file associated to a path name, creating the source file first if it doesn't exist. Source files are retained in the " { $link source-files } " variable." } ;
 
-HELP: source-file-tuple
+HELP: source-file
 { $class-description "Instances retain information about loaded source files, and have the following slots:"
     { $list
         { { $slot "path" } " - a pathname string." }
+        { { $slot "top-level-form" } " - a " { $link quotation } " composed of any code not used to define new words and classes" }
         { { $slot "checksum" } " - the CRC32 checksum of the source file's contents at the time it was most recently loaded." }
         { { $slot "definitions" } " - a pair of assocs, containing definitions and classes defined in this source file, respectively" }
+        { { $slot "main" } " - a word that gets called if you " { $link run } " the vocabulary" }
     }
 } ;
 
@@ -52,12 +54,12 @@ HELP: forget-source
 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
 
 HELP: record-definitions
-{ $values { "file" source-file } }
+{ $values { "source-file" source-file } }
 { $description "Records that all " { $link new-definitions } " were defined in " { $snippet "file" } "." } ;
 
 HELP: rollback-source-file
-{ $values { "file" source-file } }
+{ $values { "source-file" source-file } }
 { $description "Records information to the source file after an incomplete parse which ended with an error." } ;
 
-HELP: file
+HELP: current-source-file
 { $var-description "Stores the " { $link source-file } " being parsed. The " { $snippet "path" } " of this object comes from the input parameter to " { $link with-source-file } "." } ;
index 0b6774d0fc1c534bda2bd2039377e6f23890c75d..37a03b2f8e33661e9fcdefd72a248569326de547 100644 (file)
@@ -9,31 +9,31 @@ IN: source-files
 
 SYMBOL: source-files
 
-TUPLE: source-file-tuple
+TUPLE: source-file
 path
 top-level-form
 checksum
 definitions
 main ;
 
-: record-top-level-form ( quot file -- )
+: record-top-level-form ( quot source-file -- )
     top-level-form<<
     [ ] [ f notify-definition-observers ] if-bootstrapping ;
 
 : record-checksum ( lines source-file -- )
     [ crc32 checksum-lines ] dip checksum<< ;
 
-: record-definitions ( file -- )
+: record-definitions ( source-file -- )
     new-definitions get >>definitions drop ;
 
 : <source-file> ( path -- source-file )
-    source-file-tuple new
+    \ source-file new
         swap >>path
         <definitions> >>definitions ;
 
 ERROR: invalid-source-file-path path ;
 
-: source-file ( path -- source-file )
+: path>source-file ( path -- source-file )
     dup string? [ invalid-source-file-path ] unless
     source-files get [ <source-file> ] cache ;
 
@@ -53,26 +53,26 @@ M: pathname where string>> 1 2array ;
 M: pathname forget*
     string>> forget-source ;
 
-: rollback-source-file ( file -- )
+: rollback-source-file ( source-file -- )
     [
         new-definitions get [ union ] 2map
     ] change-definitions drop ;
 
-SYMBOL: file
+SYMBOL: current-source-file
 
 : wrap-source-file-error ( error -- * )
-    file get rollback-source-file
+    current-source-file get rollback-source-file
     source-file-error new
         f >>line#
-        file get path>> >>file
+        current-source-file get path>> >>path
         swap >>error rethrow ;
 
 : with-source-file ( name quot -- )
     #! Should be called from inside with-compilation-unit.
     [
         [
-            source-file
-            [ file set ]
+            path>source-file
+            [ current-source-file set ]
             [ definitions>> old-definitions set ] bi
         ] dip
         [ wrap-source-file-error ] recover
index a3e6859447bf21e71bcb5c721c9485a8176a8e74..38517329388e1b29114b38fc90011ac8215f1b79 100644 (file)
@@ -246,7 +246,7 @@ IN: bootstrap.syntax
         scan-word
         dup ( -- ) check-stack-effect
         [ current-vocab main<< ]
-        [ file get [ main<< ] [ drop ] if* ] bi
+        [ current-source-file get [ main<< ] [ drop ] if* ] bi
     ] define-core-syntax
 
     "<<" [
index 6ae6743f26b8dc76eb547533e6f5289b5b3d17a4..1738a90b4a3932e1450861927ffebd60f2cda7bd 100644 (file)
@@ -46,7 +46,7 @@ IN: vocabs.loader.tests
 
     [ t ] [
         "resource:core/vocabs/loader/test/a/a.factor"
-        source-file definitions>> dup USE: prettyprint .
+        path>source-file definitions>> dup USE: prettyprint .
         "v-l-t-a-hello" "vocabs.loader.test.a" lookup-word dup .
         swap first in?
     ] unit-test