Go back to previous page
Forum URL: http://www.eyrie-productions.com/Forum/dcboard.cgi
Forum Name: General
Topic ID: 1361
Message ID: 12
#12, RE: Text Transformation Language
Posted by Proginoskes on Jun-24-15 at 08:01 PM
In response to message #0
LAST EDITED ON Jun-24-15 AT 08:29 PM (EDT)
 
Some features I think would be very useful for TTL:

  • Syntactic sugar commands for REPLACE "find" WITH "foo" + "find" + "bar" ONCE and the like. I propose PREPEND "foo" TO "find", APPEND "bar" TO "find", and SURROUND "find" WITH "foo" AND "bar".

  • Speaking of REPLACE ... ONCE, I think that should be the default behaviour. It's certainly what anybody with experience in other text-manipulation languages would expect. How difficult would it be to add a RECURSIVELY word to the language? EDIT: Actually, what would be best would be a behavioral directive, allowing one to put, say, BY DEFAULT REPLACE ONCE at the beginning of a script to add an implicit ONCE to each REPLACE. This has the added benefit that if you later do change the default behaviour, older scripts can be fixed with the single line BY DEFAULT REPLACE RECURSIVELY instead of having to hunt down every REPLACE and add a RECURSIVELY to each one.

  • As a follow-up to the edit above, case-sensitivity directives and modifying words. BY DEFAULT OBSERVE CASE, REPLACE "find" WITH "add" IGNORING CASE, and so on.

  • In general, examine AWK and sed for features that would make sense to steal. In particular, sed has a regular expression language that is simpler than Perl's or PCRE's, but still has most of the really useful features.

As an aside, it's a shame you didn't write this in a descendant of C, because I'd love to hack on the actual source to try to implement these suggestions myself, but I have a slightly irrational fear and loathing of any programming language that has the word "Basic" in its name.