From: Jeff H. <Je...@Je...> - 2020-06-29 17:50:51
|
<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <p>I have an (almost) completed PARSE stage proposal to be used as a "light weight SPEC"-type stage. It uses the stageExit method to generate a quick running "inner" stage. <br> </p> <p><tt>/** parse<br> <br> >>--PARSE--parse_template_Dstring---output_template_Dstring--><<br> <br> Records are parsed via the parse_template_delimited_string.<br> Variables are named $n, where n is 1 to 9<br> The values of the variables are put into the output_template_delimited_string<br> <br> */<br> </tt></p> <p>Test:</p> <p><tt> literal aza |<br> parse / 2 $1 +1/ /The center letter is $1./ |<br> cons ?<br> </tt></p> <p>Here is a compile and run of the test, with the generated code for the inner stage (you can see where the arguments have been put into the parse and output lines):</p> <div style="display:inline-block;white-space:pre;background-color:#012456;font-family:'Consolas',monospace;font-size:10pt;padding:4px;"><span style="color:#CCCCCC;background-color:#012456;">************************************************************* 1 class ct_parse_7 extends stage private 2 --trace results 3 4 method run() 5 loop forever 6 line = peekto() 7 parse line 2 $1 +1 8 output('The center letter is '$1'.') 9 readto() 10 catch StageError 11 rc = rc() 12 end 13 exit(rc*(rc<>12)) ************************************************************* PS C:\Users\Jeff\documents\pipe tests> </span><span style="color:#F9F1A5;background-color:#012456;">java</span><span style="color:#CCCCCC;background-color:#012456;"> ct The center letter is z. PS C:\Users\Jeff\documents\pipe tests></span></div> <p>Your comments, ideas, suggestions, and all are solicited and welcomed. One question I have is the name. Should it be something like SPECPARSE to show its relationship? I can think of at least one other new stage that might use parse, that is in a locate-like stage with parse used instead of range.</p> <p>Jeff<br> </p> <p><br> </p> </body> </html> |