Pep & Nom

home | Syntagma | docs | examples | translators | download | journal | blog | all blog posts

Traveller, there is no path. You make the path as you walk. Traveller, there is no path. Your tracks are the path, and when you look behind, you will see the road that never again you will traverse. Traveller, there is no path, just the wake that is left in the sea. Antonio Machado

the nom "mark" command

Mark the current tape cell with the given name.

The mark command adds a text “tag” to the current tape-cell. This allows the tape cell to be accessed later in the script with the go command. The mark and go commands should allow “offside ” or indent parsing (such as for the python language)

The mark command has 2 formats, one with a parameter and one without:

The different formats of mark
 mark; mark "here";

When the mark command has no explicit text tag, then the text in the workspace will be used as the mark to label the current cell with.

See the go command for an example.

fix: modify tocfoot.tohtml.pss for the new implicit mark command behaviour.

See the script /eg/tocfoot.tohtml.pss for an example of using the “mark” and “go” commands to create a table of contents for a document from markdown-style underline headings.

notes

It has occurred to me that it would be convenient to introduce a new version of the get command that would take a text tag as an argument, as below:

implementation of the 'get "tag";' command
 mark 'here'; go 'tag'; get; go 'here';

As can be seen above the get "<mark>"; command could be implemented as a macro that just goes to a particular mark, gets the text at that tapecell (appends it to the workspace buffer) and then return to the original tape cell.

examples

The technique of using mark and go for creating footers and headers seems to work well. But I haven't yet used it to do type-checking in nom.

reserve 2 cells at the top of the tape and name them

   begin {
     mark "header"; ++; mark "footer"; ++;
   }
   # script.
 

using mark and go to make a header with word by word parsing

   begin { mark "top"; ++; }
   while [:space:]; clear;
   whilenot [:space:]; !"" { 
     put; 
     "fluffy","fofo","flop" {
       mark "here"; go "top";
       # ... create a reference here
       go "here";
     }
     clear; add "word*"; push; .reparse
   }
  parse>
   pop;pop;
   "word*word*","text*word*" {
      # reduce here  
   }
   (eof) { quit; }
   push;push;