Pep and Nom

home | documentation | examples | translators | download | blog | all blog posts

the ℕ𝕠𝕞 "escape" command

The escape command puts an escape character in front of all occurences of the given character in the workspace buffer.

It is possible that this command was made redundant by the replace command. I am not completely sure.

use the ℕ𝕠𝕞 replace command to escape characters
 replace '"' '\"'; # or replace '"' '\\"';

This is actually a tricky topic because each language may have a different strategy for escaping characters.

An important nom command for tokenising the text input stream of a given pattern or formal)language (which could be a text data format like JSON , CSS , a computer language like lisp or a simple pattern like a palindrome ) is the until command. It reads the input stream until the workspace buffer end in the given text, or else ends with the text that is in the current tape cell.

But for this command to work properly it needs to be aware of escaped characters. Lets take an example

parse quoted text


    read; 
    '"' { 
      until '"'; put; clear; add "quoted*"; push; .reparse
    }
  

to be continued ...