From 5a5ba70c21fb96b4ae8930da7571373180f675ae Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sun, 29 Mar 2020 00:22:31 +0000 Subject: [PATCH] Tidied up the inter tool --- README.md | 2 +- build.txt | 4 +- docs/inbuild/1-mn.html | 107 +++-- docs/inter/1-mn.html | 447 ++++++++++-------- docs/inter/1-ut.html | 165 ------- docs/inter/index.html | 6 +- inbuild/Chapter 1/Main.w | 21 +- inter/Chapter 1/Main.w | 296 ++++++------ inter/Chapter 1/Unit Tests.w | 73 --- inter/Contents.w | 1 - inter/Pipelines/assimilate.interpipeline | 2 +- .../Duplex/_Results_Ideal/PluggedInOut+A.txt | 21 + .../Duplex/_Results_Ideal/PluggedInOut+B.txt | 197 ++++++++ inter/Tests/inter.intest | 6 +- 14 files changed, 708 insertions(+), 640 deletions(-) delete mode 100644 docs/inter/1-ut.html delete mode 100755 inter/Chapter 1/Unit Tests.w create mode 100644 inter/Tests/Duplex/_Results_Ideal/PluggedInOut+A.txt create mode 100644 inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt diff --git a/README.md b/README.md index 5521bca86..c8fd0c099 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Inform 7 -v10.1.0-alpha.1+6Q29 'Krypton' (28 March 2020) +v10.1.0-alpha.1+6Q30 'Krypton' (29 March 2020) ## About Inform 7 diff --git a/build.txt b/build.txt index a87752817..e6d011f8a 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: alpha.1 -Build Date: 28 March 2020 -Build Number: 6Q29 +Build Date: 29 March 2020 +Build Number: 6Q30 diff --git a/docs/inbuild/1-mn.html b/docs/inbuild/1-mn.html index b8a762966..61dcb8763 100644 --- a/docs/inbuild/1-mn.html +++ b/docs/inbuild/1-mn.html @@ -59,9 +59,26 @@

A command-line interface for Inbuild functions which are not part of the normal operation of the Inform compiler.

-
+
-

§1. Main routine. When Inbuild is called at the command line, it begins at main, like all C +

§1. Settings variables. The following will be set at the command line. +

+ + +
+    pathname *path_to_inbuild = NULL;
+
+    int inbuild_task = INSPECT_TTASK;
+    pathname *path_to_tools = NULL;
+    int dry_run_mode = FALSE, build_trace_mode = FALSE;
+    inbuild_nest *destination_nest = NULL;
+    text_stream *filter_text = NULL;
+    text_stream *unit_test = NULL;
+
+ +

+ +

§2. Main routine. When Inbuild is called at the command line, it begins at main, like all C programs.

@@ -74,21 +91,13 @@ on; then to carry out that work, and then shut down again.
-    int inbuild_task = INSPECT_TTASK;
-    pathname *path_to_inbuild = NULL;
-    pathname *path_to_tools = NULL;
-    int dry_run_mode = FALSE, build_trace_mode = FALSE;
-    inbuild_nest *destination_nest = NULL;
-    text_stream *filter_text = NULL;
-    text_stream *unit_test = NULL;
-
     int main(int argc, char **argv) {
-        <Start up the modules 1.1>;
-        <Read the command line 1.7>;
+        <Start up the modules 2.1>;
+        <Read the command line 2.7>;
         CommandLine::play_back_log();
-        <Complete the list of targets 1.2>;
-        <Act on the targets 1.3>;
-        <Shut down the modules 1.4>;
+        <Complete the list of targets 2.2>;
+        <Act on the targets 2.3>;
+        <Shut down the modules 2.4>;
         if (Errors::have_occurred()) return 1;
         return 0;
     }
@@ -98,8 +107,8 @@ on; then to carry out that work, and then shut down again.
 
 

The function main is used in 1/ic (§23), 5/kts (§1), 6/st (§1).

-

§1.1. -<Start up the modules 1.1> = +

§2.1. +<Start up the modules 2.1> =

@@ -114,9 +123,9 @@ on; then to carry out that work, and then shut down again.

-

This code is used in §1.

+

This code is used in §2.

-

§1.2. Targets can arise in three ways: +

§2.2. Targets can arise in three ways:

  • (1) They can be specified at the command line, either as bare names of files @@ -142,7 +151,7 @@ error in this case.

-<Complete the list of targets 1.2> = +<Complete the list of targets 2.2> =

@@ -165,15 +174,15 @@ error in this case.

-

This code is used in §1.

+

This code is used in §2.

-

§1.3. We make the function call Inbuild::go_operational to signal to inbuild +

§2.3. We make the function call Inbuild::go_operational to signal to inbuild that we want to start work now.

-<Act on the targets 1.3> = +<Act on the targets 2.3> =

@@ -192,15 +201,15 @@ that we want to start work now. linked_list *L = Main::list_of_targets(); inbuild_copy *C; LOOP_OVER_LINKED_LIST(C, inbuild_copy, L) - <Carry out the required task on the copy C 1.3.2>; + <Carry out the required task on the copy C 2.3.2>; }

-

This code is used in §1.

+

This code is used in §2.

-

§1.3.1. The list of possible tasks is as follows; they basically all correspond to +

§2.3.1. The list of possible tasks is as follows; they basically all correspond to utility functions in the inbuild module, which we call.

@@ -219,8 +228,8 @@ utility functions in the inbuildenum COPY_TO_TTASK enum SYNC_TO_TTASK -

§1.3.2. -<Carry out the required task on the copy C 1.3.2> = +

§2.3.2. +<Carry out the required task on the copy C 2.3.2> =

@@ -249,10 +258,10 @@ utility functions in the inbuild

-

This code is used in §1.3.

+

This code is used in §2.3.

-

§1.4. -<Shut down the modules 1.4> = +

§2.4. +<Shut down the modules 2.4> =

@@ -267,9 +276,9 @@ utility functions in the inbuild

-

This code is used in §1.

+

This code is used in §2.

-

§1.5. Preform is the crowning jewel of the words module, and parses excerpts of +

§2.5. Preform is the crowning jewel of the words module, and parses excerpts of natural-language text against a "grammar". The inform7 executable makes very heavy-duty use of Preform, but we use a much coarser grammar, which simply breaks down source text into sentences, headings and so on. That grammar is @@ -291,9 +300,9 @@ for use.

-

The function Main::load_preform is used in §1.2.

+

The function Main::load_preform is used in §2.2.

-

§1.6. Target list. This where we keep the list of targets, in which no copy occurs more than +

§2.6. Target list. This where we keep the list of targets, in which no copy occurs more than once. The following code runs quadratically in the number of targets, but for Inbuild this number is never likely to be more than about 100 at a time.

@@ -357,17 +366,17 @@ Inbuild this number is never likely to be more than about 100 at a time.

-

The function Main::add_target is used in §1.2.

+

The function Main::add_target is used in §2.2.

-

The function Main::list_of_targets is used in §1.2, §1.3.

+

The function Main::list_of_targets is used in §2.2, §2.3.

-

The function Main::add_search_results_as_targets is used in §1.2.

+

The function Main::add_search_results_as_targets is used in §2.2.

-

The function Main::add_directory_contents_targets is used in §2.

+

The function Main::add_directory_contents_targets is used in §3.

-

The function Main::add_file_or_path_as_target is used in §3.

+

The function Main::add_file_or_path_as_target is used in §4.

-

§1.7. Command line. Note the call below to Inbuild::declare_options, which adds a whole lot of +

§2.7. Command line. Note the call below to Inbuild::declare_options, which adds a whole lot of other options to the selection defined here.

@@ -395,7 +404,7 @@ other options to the selection defined here.

-<Read the command line 1.7> = +<Read the command line 2.7> =

@@ -452,9 +461,9 @@ other options to the selection defined here.

-

This code is used in §1.

+

This code is used in §2.

-

§2. Here we handle those options not handled by the inbuild module. +

§3. Here we handle those options not handled by the inbuild module.

@@ -494,9 +503,9 @@ other options to the selection defined here.

-

The function Main::option is used in §1.7.

+

The function Main::option is used in §2.7.

-

§3. This is called for a command-line argument which doesn't appear as +

§4. This is called for a command-line argument which doesn't appear as subordinate to any switch; we take it as the name of a copy.

@@ -509,9 +518,9 @@ subordinate to any switch; we take it as the name of a copy.

-

The function Main::bareword is used in §1.7.

+

The function Main::bareword is used in §2.7.

-

§4. Interface to Words module. We use the mighty Preform natural-language parser only a little when +

§5. Interface to Words module. We use the mighty Preform natural-language parser only a little when Inbuild runs on its own, but it needs to be told what C type to use when identifying natural languages.

@@ -520,7 +529,7 @@ identifying natural languages.
     define PREFORM_LANGUAGE_TYPE struct inform_language
 
-

§5. Interface to Syntax module. Again, we make a fairly light use of syntax when Inbuild runs alone. +

§6. Interface to Syntax module. Again, we make a fairly light use of syntax when Inbuild runs alone.

diff --git a/docs/inter/1-mn.html b/docs/inter/1-mn.html index 0988e7896..394668a9d 100644 --- a/docs/inter/1-mn.html +++ b/docs/inter/1-mn.html @@ -57,49 +57,214 @@
-

The top level, which decides what is to be done and then carries this plan out.

+

A command-line interface for Inter functions which are not part of the normal operation of the Inform compiler.

-
+
-

§1. Main routine.

+

§1. Settings variables. The following will be set at the command line. +

+ + +
+    pathname *path_to_inter = NULL;
+
+    pathname *kit_to_assimilate = NULL;
+    pathname *domain_path = NULL;
+    linked_list *inter_file_list = NULL;     of filename
+    filename *output_textually = NULL;
+    filename *output_binarily = NULL;
+    dictionary *pipeline_vars = NULL;
+    filename *pipeline_as_file = NULL;
+    text_stream *pipeline_as_text = NULL;
+
+    void Main::add_pipeline_variable(text_stream *name, text_stream *value) {
+        Str::copy(Dictionaries::create_text(pipeline_vars, name), value);
+    }
+    void Main::add_pipeline_variable_from_filename(text_stream *name, filename *F) {
+        TEMPORARY_TEXT(fullname);
+        WRITE_TO(fullname, "%f", F);
+        Main::add_pipeline_variable(name, fullname);
+        DISCARD_TEXT(fullname);
+    }
+
+ +

+ +

The function Main::add_pipeline_variable is used in §2.3, §3.1.

+ +

The function Main::add_pipeline_variable_from_filename is used in §2.3.

+ +

§2. Main routine. When Inter is called at the command line, it begins at main, like all C +programs. +

+ +

Inter can do three different things: assimilate a kit, run a pipeline of +code generation stages, and verify/transcode files of Inter code. In fact, +though, that's really only two different things, because assimilation is +also done with a pipeline. +

+ + +
+    int main(int argc, char **argv) {
+        <Start up the modules 2.1>;
+        <Begin with an empty file list and variables dictionary 2.2>;
+        <Read the command line 2.7>;
+        if (kit_to_assimilate) <Set up a pipeline for assimilation 2.3>;
+        if ((pipeline_as_file) || (pipeline_as_text))
+            <Run the pipeline 2.4>
+        else
+            <Read the list of inter files, and perhaps transcode them 2.5>;
+        <Shut down the modules 2.6>;
+        if (Errors::have_occurred()) return 1;
+        return 0;
+    }
+
+ +

+ +

The function main is used in 2/pck (§3), 2/cnn (§1), 1/bs (§2), 3/fc (§1).

+ +

§2.1. +<Start up the modules 2.1> = +

+ + +
+        Foundation::start();     must be started first
+        ArchModule::start();
+        InterModule::start();
+        BuildingModule::start();
+        CodegenModule::start();
+
+ +

+ +

This code is used in §2.

+ +

§2.2. +<Begin with an empty file list and variables dictionary 2.2> = +

+ + +
+        inter_file_list = NEW_LINKED_LIST(filename);
+        pipeline_vars = CodeGen::Pipeline::basic_dictionary(I"output.i6");
+
+ +

+ +

This code is used in §2.

+ +

§2.3. This pipeline is supplied built in to the installation of inter. In fact, +it only ever writes the binary form of the code it produces, so only *out +is used. But at times in the past it has been useful to debug with the text +form, which would be written to *outt. +

+ + +

+<Set up a pipeline for assimilation 2.3> = +

+ + +
+        inter_architecture *A = CodeGen::Architecture::current();
+        if (A == NULL) Errors::fatal("no -architecture given");
+
+        pathname *path_to_pipelines = Pathnames::subfolder(path_to_inter, I"Pipelines");
+        pipeline_as_file = Filenames::in_folder(path_to_pipelines, I"assimilate.interpipeline");
+        pipeline_as_text = NULL;
+
+        Main::add_pipeline_variable(I"*kit",
+            Pathnames::directory_name(kit_to_assimilate));
+        Main::add_pipeline_variable_from_filename(I"*out",
+            Architectures::canonical_binary(kit_to_assimilate, A));
+        Main::add_pipeline_variable_from_filename(I"*outt",
+            Architectures::canonical_textual(kit_to_assimilate, A));
+
+ +

+ +

This code is used in §2.

+ +

§2.4. +<Run the pipeline 2.4> = +

+ + +
+        if (LinkedLists::len(inter_file_list) > 0)
+            Errors::fatal("-pipeline-text and -pipeline-file cannot be combined with inter files");
+        if ((pipeline_as_file) && (pipeline_as_text))
+            Errors::fatal("-pipeline-text and -pipeline-file are mutually exclusive");
+        linked_list *inter_paths = NEW_LINKED_LIST(pathname);
+        if (kit_to_assimilate) ADD_TO_LINKED_LIST(kit_to_assimilate, pathname, inter_paths);
+        codegen_pipeline *SS;
+        if (pipeline_as_file)
+            SS = CodeGen::Pipeline::parse_from_file(pipeline_as_file, pipeline_vars);
+        else
+            SS = CodeGen::Pipeline::parse(pipeline_as_text, pipeline_vars);
+        linked_list *requirements_list = NEW_LINKED_LIST(inter_library);
+        if (SS) CodeGen::Pipeline::run(domain_path, SS, inter_paths, requirements_list);
+        else Errors::fatal("pipeline could not be parsed");
+
+ +

+ +

This code is used in §2.

+ +

§2.5. +<Read the list of inter files, and perhaps transcode them 2.5> = +

+ + +
+        inter_tree *I = Inter::Tree::new();
+        filename *F;
+        LOOP_OVER_LINKED_LIST(F, filename, inter_file_list) {
+            if (Inter::Binary::test_file(F))
+                Inter::Binary::read(I, F);
+            else
+                Inter::Textual::read(I, F);
+        }
+        if (output_textually) {
+            text_stream C_struct; text_stream *OUT = &C_struct;
+            if (STREAM_OPEN_TO_FILE(OUT, output_textually, UTF8_ENC) == FALSE)
+                Errors::fatal_with_file("unable to open textual inter file for output: %f",
+                    output_textually);
+            Inter::Textual::write(OUT, I, NULL, 1);
+            STREAM_CLOSE(OUT);
+        }
+        if (output_binarily) Inter::Binary::write(output_binarily, I);
+
+ +

+ +

This code is used in §2.

+ +

§2.6. +<Shut down the modules 2.6> = +

+ + +
+        InterModule::end();
+        BuildingModule::end();
+        CodegenModule::end();
+        ArchModule::end();
+        Foundation::end();     must be ended last
+
+ +

+ +

This code is used in §2.

+ +

§2.7. Command line.

     define INTOOL_NAME "inter"
-
-

§2. The modules included in inter make use of the Inform 7 module kinds, -but when we are using inter on its own, kinds have no meaning for us. -We are required to create a kind type, in order for kinds to compile; -but no instances of this kind will ever in fact exist. K_value is a -global constant meaning "any kind at all", and that also must exist. -

- - -
-    typedef void kind;
-    kind *K_value = NULL;
-
- -

- -

§3. We need to allocate one additional type of structure in memory, so: -

- - -
-    enum inter_file_MT
-
- -
-    ALLOCATE_INDIVIDUALLY(inter_file)
-
- -

- -

§4.

- - -
     enum TEXTUAL_CLSW
     enum BINARY_CLSW
     enum PIPELINE_CLSW
@@ -110,27 +275,12 @@ global constant meaning "any kind at all", and that also must exist.
     enum ASSIMILATE_CLSW
 
-
-    pathname *path_to_inter = NULL;
-    pathname *path_to_pipelines = NULL;
-    pathname *kit_path = NULL;
-    int template_action = -1;
-    pathname *domain_path = NULL;
-    filename *output_textually = NULL;
-    filename *output_binarily = NULL;
-    filename *unit_test_file = NULL;
-    dictionary *pipeline_vars = NULL;
-    filename *pipeline_as_file = NULL;
-    text_stream *pipeline_as_text = NULL;
-    linked_list *requirements_list = NULL;
+

+<Read the command line 2.7> = +

- int main(int argc, char **argv) { - <Start up the modules 4.1>; - - path_to_inter = Pathnames::installation_path("INTER_PATH", I"inter"); - path_to_pipelines = Pathnames::subfolder(path_to_inter, I"Pipelines"); - requirements_list = NEW_LINKED_LIST(inter_library); +
         CommandLine::declare_heading(
             L"[[Purpose]]\n\n"
             L"usage: inter file1 file2 ... [options]\n");
@@ -152,100 +302,28 @@ global constant meaning "any kind at all", and that also must exist.
         CommandLine::declare_switch(ASSIMILATE_CLSW, L"assimilate", 2,
             L"assimilate (i.e., build) Inter kit X for the current architecture");
 
-        pipeline_vars = CodeGen::Pipeline::basic_dictionary(I"output.i6");
-
         CommandLine::read(argc, argv, NULL, &Main::respond, &Main::add_file);
 
-        if (template_action == ASSIMILATE_CLSW) {
-            inter_architecture *A = CodeGen::Architecture::current();
-            if (A == NULL) Errors::fatal("no -architecture given");
-            filename *assim = Architectures::canonical_binary(kit_path, A);
-            filename *assim_t = Architectures::canonical_textual(kit_path, A);
-            pipeline_as_file = Filenames::in_folder(path_to_pipelines, I"assimilate.interpipeline");
-            TEMPORARY_TEXT(fullname);
-            WRITE_TO(fullname, "%f", assim);
-            Str::copy(Dictionaries::create_text(pipeline_vars, I"*out"), fullname);
-            Str::clear(fullname);
-            WRITE_TO(fullname, "%f", assim_t);
-            Str::copy(Dictionaries::create_text(pipeline_vars, I"*outt"), fullname);
-            DISCARD_TEXT(fullname);
-            Str::copy(Dictionaries::create_text(pipeline_vars, I"*attach"), Pathnames::directory_name(kit_path));
-        }
-
-        Main::act();
-
-        <Shut down the modules 4.2>;
-
-        if (Errors::have_occurred()) return 1;
-        return 0;
-    }
+        path_to_inter = Pathnames::installation_path("INTER_PATH", I"inter");
 

-

The function main is used in 2/pck (§3), 2/cnn (§1), 1/bs (§2), 3/fc (§1).

+

This code is used in §2.

-

§4.1. -<Start up the modules 4.1> = -

- - -
-        Foundation::start();     must be started first
-        ArchModule::start();
-        InterModule::start();
-        BuildingModule::start();
-        CodegenModule::start();
-
- -

- -

This code is used in §4.

- -

§4.2. -<Shut down the modules 4.2> = -

- - -
-        InterModule::end();
-        BuildingModule::end();
-        CodegenModule::end();
-        ArchModule::end();
-        Foundation::end();     must be ended last
-
- -

- -

This code is used in §4.

- -

§5.

+

§3.

     void Main::respond(int id, int val, text_stream *arg, void *state) {
         switch (id) {
             case TEXTUAL_CLSW: output_textually = Filenames::from_text(arg); break;
-            case BINARY_CLSW: output_binarily = Filenames::from_text(arg); pipeline_as_text = NULL; break;
+            case BINARY_CLSW: output_binarily = Filenames::from_text(arg); break;
             case PIPELINE_CLSW: pipeline_as_text = Str::duplicate(arg); break;
             case PIPELINE_FILE_CLSW: pipeline_as_file = Filenames::from_text(arg); break;
-            case PIPELINE_VARIABLE_CLSW: {
-                match_results mr = Regexp::create_mr();
-                if (Regexp::match(&mr, arg, L"(%c+)=(%c+)")) {
-                    if (Str::get_first_char(arg) != '*') {
-                        Errors::fatal("-variable names must begin with '*'");
-                    } else {
-                        Str::copy(Dictionaries::create_text(pipeline_vars, mr.exp[0]), mr.exp[1]);
-                    }
-                } else {
-                    Errors::fatal("-variable should take the form 'name=value'");
-                }
-                Regexp::dispose_of(&mr);
-                break;
-            }
-            case DOMAIN_CLSW: domain_path = Pathnames::from_text(arg); pipeline_as_text = NULL; break;
-            case ASSIMILATE_CLSW: kit_path = Pathnames::from_text(arg);
-                pipeline_as_text = NULL; template_action = id; break;
+            case PIPELINE_VARIABLE_CLSW: <Add a pipeline variable to the dictionary 3.1>; break;
+            case DOMAIN_CLSW: domain_path = Pathnames::from_text(arg); break;
+            case ASSIMILATE_CLSW: kit_to_assimilate = Pathnames::from_text(arg); break;
             case ARCHITECTURE_CLSW:
                 if (CodeGen::Architecture::set(arg) == FALSE)
                     Errors::fatal("no such -architecture");
@@ -256,74 +334,61 @@ global constant meaning "any kind at all", and that also must exist.
 
 

-

The function Main::respond is used in §4.

+

The function Main::respond is used in §2.7.

-

§6.

+

§3.1. +<Add a pipeline variable to the dictionary 3.1> = +

-
-    typedef struct inter_file {
-        struct filename *inter_filename;
-        MEMORY_MANAGEMENT
-    } inter_file;
-
-    void Main::add_file(int id, text_stream *arg, void *state) {
-        inter_file *IF = CREATE(inter_file);
-        IF->inter_filename = Filenames::from_text(arg);
-    }
-
- -

- -

The function Main::add_file is used in §4.

- -

The structure inter_file is private to this section.

- -

§7.

- - -
-    void Main::act(void) {
-        if ((pipeline_as_file) || (pipeline_as_text)) {
-            if (NUMBER_CREATED(inter_file) > 0)
-                Errors::fatal("-pipeline-text and -pipeline-file cannot be combined with inter file parameters");
-            linked_list *inter_paths = NEW_LINKED_LIST(pathname);
-            ADD_TO_LINKED_LIST(kit_path, pathname, inter_paths);
-            codegen_pipeline *SS;
-            if (pipeline_as_file) SS = CodeGen::Pipeline::parse_from_file(pipeline_as_file, pipeline_vars);
-            else SS = CodeGen::Pipeline::parse(pipeline_as_text, pipeline_vars);
-            if (SS) CodeGen::Pipeline::run(domain_path, SS, inter_paths, requirements_list);
-            else Errors::fatal("pipeline could not be parsed");
-        } else if (unit_test_file) {
-            UnitTests::run(unit_test_file);
+
+        match_results mr = Regexp::create_mr();
+        if (Regexp::match(&mr, arg, L"(%c+)=(%c+)")) {
+            if (Str::get_first_char(arg) != '*') {
+                Errors::fatal("-variable names must begin with '*'");
+            } else {
+                Main::add_pipeline_variable(mr.exp[0], mr.exp[1]);
+            }
         } else {
-            inter_tree *I = Inter::Tree::new();
-            inter_file *IF;
-            LOOP_OVER(IF, inter_file) {
-                if (Inter::Binary::test_file(IF->inter_filename))
-                    Inter::Binary::read(I, IF->inter_filename);
-                else
-                    Inter::Textual::read(I, IF->inter_filename);
-            }
-            if (output_textually) {
-                text_stream C_struct; text_stream *OUT = &C_struct;
-                if (STREAM_OPEN_TO_FILE(OUT, output_textually, UTF8_ENC) == FALSE)
-                    Errors::fatal_with_file("unable to open textual inter file for output: %f",
-                        output_textually);
-                Inter::Textual::write(OUT, I, NULL, 1);
-                STREAM_CLOSE(OUT);
-            }
-            if (output_binarily) Inter::Binary::write(output_binarily, I);
+            Errors::fatal("-variable should take the form 'name=value'");
         }
+        Regexp::dispose_of(&mr);
+
+ +

+ +

This code is used in §3.

+ +

§4.

+ + +
+    void Main::add_file(int id, text_stream *arg, void *state) {
+        filename *F = Filenames::from_text(arg);
+        ADD_TO_LINKED_LIST(F, filename, inter_file_list);
     }
 

-

The function Main::act is used in §4.

+

The function Main::add_file is used in §2.7.

+ +

§5. The modules included in inter make use of the Inform 7 module kinds, +but when we are using inter on its own, kinds have no meaning for us. +We are required to create a kind type, in order for kinds to compile; +but no instances of this kind will ever in fact exist. K_value is a +global constant meaning "any kind at all", and that also must exist. +

+ + +
+    typedef void kind;
+    kind *K_value = NULL;
+
+ +


-
diff --git a/docs/inter/1-ut.html b/docs/inter/1-ut.html deleted file mode 100644 index 976b05511..000000000 --- a/docs/inter/1-ut.html +++ /dev/null @@ -1,165 +0,0 @@ - - - - 1/mn - - - - - - - -
- - -

Scaffolding code to run unit tests not otherwise represented as inter stages.

- -

§1.

- - -
-    void UnitTests::run(filename *F) {
-        inter_tree *dummy = Inter::Tree::new();
-        inter_bookmark IBM = Inter::Bookmarks::at_start_of_this_repository(dummy);
-        Primitives::emit(dummy, &IBM);
-        Streams::enable_debugging(STDOUT);
-        text_stream *FORMER_DL = DL;
-        DL = STDOUT;
-        inter_unit_test iut;
-        iut.to_perform = NO_IUT;
-        iut.test_input = Str::new();
-        TextFiles::read(F, FALSE, "unable to read tests file", TRUE,
-            &UnitTests::test_harvester, NULL, &iut);
-        Streams::disable_debugging(STDOUT);
-        DL = FORMER_DL;
-    }
-
- -

- -

The function UnitTests::run is used in 1/mn (§7).

- -

§2.

- - -
-    enum NO_IUT from 0
-    enum SCHEMA_IUT
-    enum SCHEMA_WORKINGS_IUT
-
- -
-    typedef struct inter_unit_test {
-        int to_perform;
-        struct text_stream *test_input;
-    } inter_unit_test;
-
-    void UnitTests::test_harvester(text_stream *text, text_file_position *tfp, void *v_iut) {
-        inter_unit_test *iut = (inter_unit_test *) v_iut;
-        if (Str::eq(text, I"schema")) {
-            iut->to_perform = SCHEMA_IUT;
-            Str::clear(iut->test_input);
-        } else if (Str::eq(text, I"schema-workings")) {
-            iut->to_perform = SCHEMA_WORKINGS_IUT;
-            Str::clear(iut->test_input);
-        } else if (Str::eq(text, I"end")) {
-            switch (iut->to_perform) {
-                case SCHEMA_WORKINGS_IUT:
-                    Log::set_aspect(SCHEMA_COMPILATION_DETAILS_DA, TRUE);
-                    <Perform the schema test 2.1>;
-                    Log::set_aspect(SCHEMA_COMPILATION_DETAILS_DA, FALSE);
-                    break;
-                case SCHEMA_IUT:
-                    <Perform the schema test 2.1>;
-                    break;
-                default: Errors::in_text_file("unimplemented test", tfp); break;
-            }
-            iut->to_perform = NO_IUT;
-        } else {
-            if (iut->to_perform == NO_IUT) {
-                if (Str::len(text) == 0) return;
-                Errors::in_text_file("content outside of test", tfp);
-            } else {
-                WRITE_TO(iut->test_input, "%S\n", text);
-            }
-        }
-    }
-
- -

- -

The function UnitTests::test_harvester is used in §1.

- -

The structure inter_unit_test is private to this section.

- -

§2.1. -<Perform the schema test 2.1> = -

- - -
-        LOG("Test: parse schema from:\n%S\n", iut->test_input);
-        Str::trim_white_space(iut->test_input);
-        inter_schema *sch = InterSchemas::from_text(iut->test_input, FALSE, 0, NULL);
-        if (sch == NULL) LOG("<null schema>\n");
-        else if (sch->node_tree == NULL) LOG("<nodeless scheme\n");
-        else InterSchemas::log(DL, sch);
-        LOG("=========\n");
-
- -

- -

This code is used in §2 (twice).

- -
-
- -
- - - diff --git a/docs/inter/index.html b/docs/inter/index.html index 55e7c1c38..15a16441c 100644 --- a/docs/inter/index.html +++ b/docs/inter/index.html @@ -106,11 +106,7 @@
  • Main - - The top level, which decides what is to be done and then carries this plan out.

    -
  • -
  • -

    Unit Tests - - Scaffolding code to run unit tests not otherwise represented as inter stages.

    + A command-line interface for Inter functions which are not part of the normal operation of the Inform compiler.

diff --git a/inbuild/Chapter 1/Main.w b/inbuild/Chapter 1/Main.w index 950ecbe5f..41fb529e4 100644 --- a/inbuild/Chapter 1/Main.w +++ b/inbuild/Chapter 1/Main.w @@ -3,6 +3,19 @@ A command-line interface for Inbuild functions which are not part of the normal operation of the Inform compiler. +@h Settings variables. +The following will be set at the command line. + += +pathname *path_to_inbuild = NULL; + +int inbuild_task = INSPECT_TTASK; +pathname *path_to_tools = NULL; +int dry_run_mode = FALSE, build_trace_mode = FALSE; +inbuild_nest *destination_nest = NULL; +text_stream *filter_text = NULL; +text_stream *unit_test = NULL; + @h Main routine. When Inbuild is called at the command line, it begins at |main|, like all C programs. @@ -14,14 +27,6 @@ set the following variables as needed, and produce a list of targets to work on; then to carry out that work, and then shut down again. = -int inbuild_task = INSPECT_TTASK; -pathname *path_to_inbuild = NULL; -pathname *path_to_tools = NULL; -int dry_run_mode = FALSE, build_trace_mode = FALSE; -inbuild_nest *destination_nest = NULL; -text_stream *filter_text = NULL; -text_stream *unit_test = NULL; - int main(int argc, char **argv) { @; @; diff --git a/inter/Chapter 1/Main.w b/inter/Chapter 1/Main.w index e47382892..ec9236b91 100644 --- a/inter/Chapter 1/Main.w +++ b/inter/Chapter 1/Main.w @@ -1,30 +1,133 @@ [Main::] Main. -The top level, which decides what is to be done and then carries -this plan out. +A command-line interface for Inter functions which are not part of the +normal operation of the Inform compiler. -@h Main routine. - -@d INTOOL_NAME "inter" - -@ The modules included in |inter| make use of the Inform 7 module |kinds|, -but when we are using |inter| on its own, kinds have no meaning for us. -We are required to create a |kind| type, in order for |kinds| to compile; -but no instances of this kind will ever in fact exist. |K_value| is a -global constant meaning "any kind at all", and that also must exist. - -= (early code) -typedef void kind; -kind *K_value = NULL; - -@ We need to allocate one additional type of structure in memory, so: - -@e inter_file_MT +@h Settings variables. +The following will be set at the command line. = -ALLOCATE_INDIVIDUALLY(inter_file) +pathname *path_to_inter = NULL; -@ +pathname *kit_to_assimilate = NULL; +pathname *domain_path = NULL; +linked_list *inter_file_list = NULL; /* of |filename| */ +filename *output_textually = NULL; +filename *output_binarily = NULL; +dictionary *pipeline_vars = NULL; +filename *pipeline_as_file = NULL; +text_stream *pipeline_as_text = NULL; + +void Main::add_pipeline_variable(text_stream *name, text_stream *value) { + Str::copy(Dictionaries::create_text(pipeline_vars, name), value); +} +void Main::add_pipeline_variable_from_filename(text_stream *name, filename *F) { + TEMPORARY_TEXT(fullname); + WRITE_TO(fullname, "%f", F); + Main::add_pipeline_variable(name, fullname); + DISCARD_TEXT(fullname); +} + +@h Main routine. +When Inter is called at the command line, it begins at |main|, like all C +programs. + +Inter can do three different things: assimilate a kit, run a pipeline of +code generation stages, and verify/transcode files of Inter code. In fact, +though, that's really only two different things, because assimilation is +also done with a pipeline. + += +int main(int argc, char **argv) { + @; + @; + @; + if (kit_to_assimilate) @; + if ((pipeline_as_file) || (pipeline_as_text)) + @ + else + @; + @; + if (Errors::have_occurred()) return 1; + return 0; +} + +@ = + Foundation::start(); /* must be started first */ + ArchModule::start(); + InterModule::start(); + BuildingModule::start(); + CodegenModule::start(); + +@ = + inter_file_list = NEW_LINKED_LIST(filename); + pipeline_vars = CodeGen::Pipeline::basic_dictionary(I"output.i6"); + +@ This pipeline is supplied built in to the installation of |inter|. In fact, +it only ever writes the binary form of the code it produces, so only |*out| +is used. But at times in the past it has been useful to debug with the text +form, which would be written to |*outt|. + +@ = + inter_architecture *A = CodeGen::Architecture::current(); + if (A == NULL) Errors::fatal("no -architecture given"); + + pathname *path_to_pipelines = Pathnames::subfolder(path_to_inter, I"Pipelines"); + pipeline_as_file = Filenames::in_folder(path_to_pipelines, I"assimilate.interpipeline"); + pipeline_as_text = NULL; + + Main::add_pipeline_variable(I"*kit", + Pathnames::directory_name(kit_to_assimilate)); + Main::add_pipeline_variable_from_filename(I"*out", + Architectures::canonical_binary(kit_to_assimilate, A)); + Main::add_pipeline_variable_from_filename(I"*outt", + Architectures::canonical_textual(kit_to_assimilate, A)); + +@ = + if (LinkedLists::len(inter_file_list) > 0) + Errors::fatal("-pipeline-text and -pipeline-file cannot be combined with inter files"); + if ((pipeline_as_file) && (pipeline_as_text)) + Errors::fatal("-pipeline-text and -pipeline-file are mutually exclusive"); + linked_list *inter_paths = NEW_LINKED_LIST(pathname); + if (kit_to_assimilate) ADD_TO_LINKED_LIST(kit_to_assimilate, pathname, inter_paths); + codegen_pipeline *SS; + if (pipeline_as_file) + SS = CodeGen::Pipeline::parse_from_file(pipeline_as_file, pipeline_vars); + else + SS = CodeGen::Pipeline::parse(pipeline_as_text, pipeline_vars); + linked_list *requirements_list = NEW_LINKED_LIST(inter_library); + if (SS) CodeGen::Pipeline::run(domain_path, SS, inter_paths, requirements_list); + else Errors::fatal("pipeline could not be parsed"); + +@ = + inter_tree *I = Inter::Tree::new(); + filename *F; + LOOP_OVER_LINKED_LIST(F, filename, inter_file_list) { + if (Inter::Binary::test_file(F)) + Inter::Binary::read(I, F); + else + Inter::Textual::read(I, F); + } + if (output_textually) { + text_stream C_struct; text_stream *OUT = &C_struct; + if (STREAM_OPEN_TO_FILE(OUT, output_textually, UTF8_ENC) == FALSE) + Errors::fatal_with_file("unable to open textual inter file for output: %f", + output_textually); + Inter::Textual::write(OUT, I, NULL, 1); + STREAM_CLOSE(OUT); + } + if (output_binarily) Inter::Binary::write(output_binarily, I); + +@ = + InterModule::end(); + BuildingModule::end(); + CodegenModule::end(); + ArchModule::end(); + Foundation::end(); /* must be ended last */ + +@h Command line. + +@d INTOOL_NAME "inter" @e TEXTUAL_CLSW @e BINARY_CLSW @@ -35,27 +138,7 @@ ALLOCATE_INDIVIDUALLY(inter_file) @e ARCHITECTURE_CLSW @e ASSIMILATE_CLSW -= -pathname *path_to_inter = NULL; -pathname *path_to_pipelines = NULL; -pathname *kit_path = NULL; -int template_action = -1; -pathname *domain_path = NULL; -filename *output_textually = NULL; -filename *output_binarily = NULL; -filename *unit_test_file = NULL; -dictionary *pipeline_vars = NULL; -filename *pipeline_as_file = NULL; -text_stream *pipeline_as_text = NULL; -linked_list *requirements_list = NULL; - -int main(int argc, char **argv) { - @; - - path_to_inter = Pathnames::installation_path("INTER_PATH", I"inter"); - path_to_pipelines = Pathnames::subfolder(path_to_inter, I"Pipelines"); - requirements_list = NEW_LINKED_LIST(inter_library); - +@ = CommandLine::declare_heading( L"[[Purpose]]\n\n" L"usage: inter file1 file2 ... [options]\n"); @@ -76,73 +159,21 @@ int main(int argc, char **argv) { L"generate Inter with architecture X"); CommandLine::declare_switch(ASSIMILATE_CLSW, L"assimilate", 2, L"assimilate (i.e., build) Inter kit X for the current architecture"); - - pipeline_vars = CodeGen::Pipeline::basic_dictionary(I"output.i6"); CommandLine::read(argc, argv, NULL, &Main::respond, &Main::add_file); - if (template_action == ASSIMILATE_CLSW) { - inter_architecture *A = CodeGen::Architecture::current(); - if (A == NULL) Errors::fatal("no -architecture given"); - filename *assim = Architectures::canonical_binary(kit_path, A); - filename *assim_t = Architectures::canonical_textual(kit_path, A); - pipeline_as_file = Filenames::in_folder(path_to_pipelines, I"assimilate.interpipeline"); - TEMPORARY_TEXT(fullname); - WRITE_TO(fullname, "%f", assim); - Str::copy(Dictionaries::create_text(pipeline_vars, I"*out"), fullname); - Str::clear(fullname); - WRITE_TO(fullname, "%f", assim_t); - Str::copy(Dictionaries::create_text(pipeline_vars, I"*outt"), fullname); - DISCARD_TEXT(fullname); - Str::copy(Dictionaries::create_text(pipeline_vars, I"*attach"), Pathnames::directory_name(kit_path)); - } - - Main::act(); - - @; - - if (Errors::have_occurred()) return 1; - return 0; -} - -@ = - Foundation::start(); /* must be started first */ - ArchModule::start(); - InterModule::start(); - BuildingModule::start(); - CodegenModule::start(); - -@ = - InterModule::end(); - BuildingModule::end(); - CodegenModule::end(); - ArchModule::end(); - Foundation::end(); /* must be ended last */ + path_to_inter = Pathnames::installation_path("INTER_PATH", I"inter"); @ = void Main::respond(int id, int val, text_stream *arg, void *state) { switch (id) { case TEXTUAL_CLSW: output_textually = Filenames::from_text(arg); break; - case BINARY_CLSW: output_binarily = Filenames::from_text(arg); pipeline_as_text = NULL; break; + case BINARY_CLSW: output_binarily = Filenames::from_text(arg); break; case PIPELINE_CLSW: pipeline_as_text = Str::duplicate(arg); break; case PIPELINE_FILE_CLSW: pipeline_as_file = Filenames::from_text(arg); break; - case PIPELINE_VARIABLE_CLSW: { - match_results mr = Regexp::create_mr(); - if (Regexp::match(&mr, arg, L"(%c+)=(%c+)")) { - if (Str::get_first_char(arg) != '*') { - Errors::fatal("-variable names must begin with '*'"); - } else { - Str::copy(Dictionaries::create_text(pipeline_vars, mr.exp[0]), mr.exp[1]); - } - } else { - Errors::fatal("-variable should take the form 'name=value'"); - } - Regexp::dispose_of(&mr); - break; - } - case DOMAIN_CLSW: domain_path = Pathnames::from_text(arg); pipeline_as_text = NULL; break; - case ASSIMILATE_CLSW: kit_path = Pathnames::from_text(arg); - pipeline_as_text = NULL; template_action = id; break; + case PIPELINE_VARIABLE_CLSW: @; break; + case DOMAIN_CLSW: domain_path = Pathnames::from_text(arg); break; + case ASSIMILATE_CLSW: kit_to_assimilate = Pathnames::from_text(arg); break; case ARCHITECTURE_CLSW: if (CodeGen::Architecture::set(arg) == FALSE) Errors::fatal("no such -architecture"); @@ -150,48 +181,31 @@ void Main::respond(int id, int val, text_stream *arg, void *state) { } } -@ = -typedef struct inter_file { - struct filename *inter_filename; - MEMORY_MANAGEMENT -} inter_file; - -void Main::add_file(int id, text_stream *arg, void *state) { - inter_file *IF = CREATE(inter_file); - IF->inter_filename = Filenames::from_text(arg); -} - -@ = -void Main::act(void) { - if ((pipeline_as_file) || (pipeline_as_text)) { - if (NUMBER_CREATED(inter_file) > 0) - Errors::fatal("-pipeline-text and -pipeline-file cannot be combined with inter file parameters"); - linked_list *inter_paths = NEW_LINKED_LIST(pathname); - ADD_TO_LINKED_LIST(kit_path, pathname, inter_paths); - codegen_pipeline *SS; - if (pipeline_as_file) SS = CodeGen::Pipeline::parse_from_file(pipeline_as_file, pipeline_vars); - else SS = CodeGen::Pipeline::parse(pipeline_as_text, pipeline_vars); - if (SS) CodeGen::Pipeline::run(domain_path, SS, inter_paths, requirements_list); - else Errors::fatal("pipeline could not be parsed"); - } else if (unit_test_file) { - UnitTests::run(unit_test_file); +@ = + match_results mr = Regexp::create_mr(); + if (Regexp::match(&mr, arg, L"(%c+)=(%c+)")) { + if (Str::get_first_char(arg) != '*') { + Errors::fatal("-variable names must begin with '*'"); + } else { + Main::add_pipeline_variable(mr.exp[0], mr.exp[1]); + } } else { - inter_tree *I = Inter::Tree::new(); - inter_file *IF; - LOOP_OVER(IF, inter_file) { - if (Inter::Binary::test_file(IF->inter_filename)) - Inter::Binary::read(I, IF->inter_filename); - else - Inter::Textual::read(I, IF->inter_filename); - } - if (output_textually) { - text_stream C_struct; text_stream *OUT = &C_struct; - if (STREAM_OPEN_TO_FILE(OUT, output_textually, UTF8_ENC) == FALSE) - Errors::fatal_with_file("unable to open textual inter file for output: %f", - output_textually); - Inter::Textual::write(OUT, I, NULL, 1); - STREAM_CLOSE(OUT); - } - if (output_binarily) Inter::Binary::write(output_binarily, I); + Errors::fatal("-variable should take the form 'name=value'"); } + Regexp::dispose_of(&mr); + +@ = +void Main::add_file(int id, text_stream *arg, void *state) { + filename *F = Filenames::from_text(arg); + ADD_TO_LINKED_LIST(F, filename, inter_file_list); } + +@ The modules included in |inter| make use of the Inform 7 module |kinds|, +but when we are using |inter| on its own, kinds have no meaning for us. +We are required to create a |kind| type, in order for |kinds| to compile; +but no instances of this kind will ever in fact exist. |K_value| is a +global constant meaning "any kind at all", and that also must exist. + += (early code) +typedef void kind; +kind *K_value = NULL; diff --git a/inter/Chapter 1/Unit Tests.w b/inter/Chapter 1/Unit Tests.w deleted file mode 100755 index 246f52a21..000000000 --- a/inter/Chapter 1/Unit Tests.w +++ /dev/null @@ -1,73 +0,0 @@ -[UnitTests::] Unit Tests. - -Scaffolding code to run unit tests not otherwise represented as inter stages. - -@ - -= -void UnitTests::run(filename *F) { - inter_tree *dummy = Inter::Tree::new(); - inter_bookmark IBM = Inter::Bookmarks::at_start_of_this_repository(dummy); - Primitives::emit(dummy, &IBM); - Streams::enable_debugging(STDOUT); - text_stream *FORMER_DL = DL; - DL = STDOUT; - inter_unit_test iut; - iut.to_perform = NO_IUT; - iut.test_input = Str::new(); - TextFiles::read(F, FALSE, "unable to read tests file", TRUE, - &UnitTests::test_harvester, NULL, &iut); - Streams::disable_debugging(STDOUT); - DL = FORMER_DL; -} - -@ - -@e NO_IUT from 0 -@e SCHEMA_IUT -@e SCHEMA_WORKINGS_IUT - -typedef struct inter_unit_test { - int to_perform; - struct text_stream *test_input; -} inter_unit_test; - -void UnitTests::test_harvester(text_stream *text, text_file_position *tfp, void *v_iut) { - inter_unit_test *iut = (inter_unit_test *) v_iut; - if (Str::eq(text, I"schema")) { - iut->to_perform = SCHEMA_IUT; - Str::clear(iut->test_input); - } else if (Str::eq(text, I"schema-workings")) { - iut->to_perform = SCHEMA_WORKINGS_IUT; - Str::clear(iut->test_input); - } else if (Str::eq(text, I"end")) { - switch (iut->to_perform) { - case SCHEMA_WORKINGS_IUT: - Log::set_aspect(SCHEMA_COMPILATION_DETAILS_DA, TRUE); - @; - Log::set_aspect(SCHEMA_COMPILATION_DETAILS_DA, FALSE); - break; - case SCHEMA_IUT: - @; - break; - default: Errors::in_text_file("unimplemented test", tfp); break; - } - iut->to_perform = NO_IUT; - } else { - if (iut->to_perform == NO_IUT) { - if (Str::len(text) == 0) return; - Errors::in_text_file("content outside of test", tfp); - } else { - WRITE_TO(iut->test_input, "%S\n", text); - } - } -} - -@ = - LOG("Test: parse schema from:\n%S\n", iut->test_input); - Str::trim_white_space(iut->test_input); - inter_schema *sch = InterSchemas::from_text(iut->test_input, FALSE, 0, NULL); - if (sch == NULL) LOG("\n"); - else if (sch->node_tree == NULL) LOG(" void +primitive !goto lab -> void + +package main _plain + symbol public misc K_number + symbol public misc K_func + symbol public misc awkward + symbol public misc troublesome + symbol external misc secret --> /main/my_fn/secret + kind K_number int32 + kind K_func function K_number -> K_number + # Exported my_fn here + constant awkward K_number = secret + constant troublesome K_number = 12 + package connectors _linkage + symbol socket misc secret --> /main/my_fn/secret + symbol plug misc plug00002 --? C_majors diff --git a/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt b/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt new file mode 100644 index 000000000..27c8ce41c --- /dev/null +++ b/inter/Tests/Duplex/_Results_Ideal/PluggedInOut+B.txt @@ -0,0 +1,197 @@ +# This is a miscellany of tests. + +packagetype _plain +packagetype _code +packagetype _linkage + +version 7 + +primitive !return val -> void +primitive !modulo val val -> val +primitive !plus val val -> val +primitive !if val code -> void +primitive !goto lab -> void + +pragma target_I6 "$MAX_STATIC_DATA=180000" + +package main _plain + symbol public misc K_number + symbol public misc K_truth_state + symbol public misc V_banana + symbol public misc C_death + symbol public misc C_taxes + symbol public misc V_anxiety + symbol public misc C_x + symbol public misc cornelius + symbol public misc gaius + symbol public misc mark_my_words + symbol external misc peach + symbol public misc K_colour + symbol public misc I_green + symbol public misc I_red + symbol public misc V_shade + symbol public misc K_list_of_number + symbol public misc C_primes + symbol public misc C_concealed + symbol public misc V_watch_list + symbol public misc 718_varieties + symbol public misc K_text + symbol public misc C_complaint + symbol public misc C_raw + symbol public misc K_odour + symbol public misc I_citrus + symbol public misc I_leather + symbol public misc P_strength + symbol public misc pp_auto_1 + symbol public misc P_lingeringness + symbol public misc pp_auto_2 + symbol public misc K_table + symbol public misc K_column_of_number + symbol public misc K_column_of_colour + symbol public misc C_egtable_col1 + symbol public misc C_egtable_col2 + symbol public misc C_egtable + symbol public misc K_object + symbol public misc I_board + symbol public misc K_piece + symbol public misc I_bishop + symbol public misc I_rook + symbol public misc K_list_of_objects + symbol public misc C_majors + symbol public misc pp_auto_3 + symbol public misc K_func + symbol public misc K_rule + symbol public misc K_rulebook + symbol public misc K_stuff + symbol public misc S_stuff + symbol public misc R_after1 + symbol public misc R_after2 + symbol public misc RB_after + symbol public misc K_colour____colour + symbol public misc R_101 + symbol public misc R_102 + symbol public misc amount + symbol public misc R_101_A + kind K_number int32 + kind K_truth_state int2 + defaultvalue K_number = 47 + variable V_banana K_number = 100 + constant C_death K_number = -5 + constant C_taxes K_number = 14 + variable V_anxiety K_number = C_death + constant C_x K_number = 0x7f2a __hex + link early "alpha" "beta" "gamma" "delta" + link before "alpha" "" "" "" + link instead "" "beta" "" "" + link after "" "" "gamma" "" + constant cornelius K_number = dw'frogs' + constant gaius K_number = dw'toads' + splat &"Sing a song of \"six splats\"...\nand don't wait up" + kind K_colour enum + instance I_green K_colour = 1 + instance I_red K_colour = 17 + variable V_shade K_colour = I_red + kind K_list_of_number list of K_number + constant C_primes K_list_of_number = { 2, 3, 5, 7, 11, 13, 17, 19 } + constant C_concealed K_list_of_number = C_primes + variable V_watch_list K_list_of_number = C_concealed + kind K_text text + constant C_complaint K_text = "This is already quite a long test case." + constant C_raw K_number = &"SOME_I6_DRIVEL" + kind K_odour enum + instance I_citrus K_odour = 5 + instance I_leather K_odour = 10 + property P_strength K_number __property_name="strength" + permission P_strength K_odour + propertyvalue P_strength I_citrus = 20 + propertyvalue P_strength I_leather = 7 + property P_lingeringness K_number + permission P_lingeringness K_odour + propertyvalue P_lingeringness I_citrus = 1 + propertyvalue P_lingeringness I_leather = 3 + propertyvalue P_lingeringness K_odour = 2 + kind K_table table + kind K_column_of_number column of K_number + kind K_column_of_colour column of K_colour + constant C_egtable_col1 K_column_of_number = { 1, 4, 9, 16 } + constant C_egtable_col2 K_column_of_colour = { I_green, undef, I_red } + constant C_egtable K_table = { C_egtable_col1, C_egtable_col2 } + kind K_object enum + instance I_board K_object = 1 + kind K_piece <= K_object + instance I_bishop K_piece = 2 + instance I_rook K_piece = 3 + kind K_list_of_objects list of K_object + constant C_majors K_list_of_objects = { I_bishop, I_rook } + permission P_lingeringness I_bishop + kind K_func function K_colour K_number -> K_odour + kind K_rule rule void -> void + kind K_rulebook rulebook of K_rule + kind K_stuff struct K_number K_colour K_odour + constant S_stuff K_stuff = { 5, I_red, I_citrus } + package R_after1_B _code + package R_after2_B _code + constant R_after1 K_rule = R_after1_B + constant R_after2 K_rule = R_after2_B + constant RB_after K_rulebook = { R_after1, R_after2 } + kind K_colour____colour function K_colour -> K_colour + package R_101_B _code + symbol private misc x + symbol external misc K_colour --> /main/K_colour + symbol external misc R_102 --> /main/R_102 + symbol external misc I_green --> /main/I_green + symbol external misc K_number --> /main/K_number + symbol external misc K_truth_state --> /main/K_truth_state + local x K_colour __call_parameter + code + inv R_102 + val K_colour I_green + inv !return + inv !modulo + inv !plus + cast K_number <- K_colour + val K_colour x + val K_number 1 + val K_truth_state &"a b" + constant R_101 K_colour____colour = R_101_B + package R_102_B _code + symbol private misc x + symbol external misc K_colour --> /main/K_colour + symbol external misc I_red --> /main/I_red + local x K_colour __call_parameter + code + inv !return + val K_colour I_red + constant R_102 K_colour____colour = R_102_B + constant amount K_number = sum{ 2, C_taxes } + response R_101_A R_101 0 = C_taxes + package connectors _linkage + symbol socket misc C_majors --> /main/C_majors + symbol plug misc plug_00001 --? secret + symbol plug misc plug_00001_1 --? C_majors + symbol plug misc plug_00002 --? /main/troublesome + symbol socket misc secret --> /main/connectors/secret + # Imported my_fn here + package my_fn _plain + symbol public misc R_101 + symbol public misc secret + symbol external misc K_func --> /main/K_func + symbol external misc K_number --> /main/K_number + symbol external misc plug00002 --> /main/connectors/plug_00001_1 + symbol public misc tricksy + package R_101_B _code + symbol private misc x + symbol private label .begin + symbol external misc K_number --> /main/K_number + symbol external misc troublesome --> /main/connectors/plug_00002 + local x K_number __call_parameter + code + .begin + inv !if + val K_number plug_00002 + code + inv !goto + lab .begin + constant R_101 K_func = R_101_B + constant secret K_number = 7 + constant tricksy K_number = plug_00001_1 diff --git a/inter/Tests/inter.intest b/inter/Tests/inter.intest index 9d4dce288..6e5a82a08 100644 --- a/inter/Tests/inter.intest +++ b/inter/Tests/inter.intest @@ -59,7 +59,7 @@ mkdir: $PATH/_Results_Ideal mkdir: $PATH/_Console - step: inter/Tangled/inter -architecture 16d -template inform7/Internal/I6T/standard_rules -variable '*in=$O' -variable '*out=$A' -pipeline-file $P >$T 2>&1 + step: inter/Tangled/inter -architecture 16d -variable '*in=$O' -variable '*out=$A' -pipeline-file $P >$T 2>&1 or: 'failed to produce output' $T show: $A @@ -87,7 +87,7 @@ mkdir: $PATH/_Console mkdir: $PATH/_Binaries - step: inter/Tangled/inter -template inform7/Internal/I6T -variable '*inA=$OA' -variable '*inB=$OB' -variable '*binA=$BA' -variable '*binB=$BB' -variable '*outA=$AA' -variable '*outB=$AB' -pipeline-file $P >$T 2>&1 + step: inter/Tangled/inter -variable '*inA=$OA' -variable '*inB=$OB' -variable '*binA=$BA' -variable '*binB=$BB' -variable '*outA=$AA' -variable '*outB=$AB' -pipeline-file $P >$T 2>&1 or: 'failed to produce output' $T show: $A @@ -110,7 +110,7 @@ mkdir: $PATH/_Results_Actual mkdir: $PATH/_Results_Ideal - fail step: inter/Tangled/inter -template inform7/Internal/I6T -variable '*in=$O' -pipeline-file $P >$A 2>&1 + fail step: inter/Tangled/inter -variable '*in=$O' -pipeline-file $P >$A 2>&1 or: 'failed to produce errors' $A show: $A