;========================================================================================================================================== ; WinBatch Studio Tool ; ColonToStrCat ;------------------------------------------------------------------------------------------------------------------------------------------ ; This WBStudio tool "ColonToStrCat" converts the method of string concatenation ; from colon ":" character to function "StrCat ()". ; ; The colon string concatenator was introduced in WB 2006D, Sep 22, 2006, DLL 5.12del. ; This script guarantees backward compatibility. ;------------------------------------------------------------------------------------------------------------------------------------------ ; Note: Sometimes the edited script requires reformatting. ; ; Note: There may exist one or more TXL quirks which will create an erroneous wbt script. ; e.g. ; Switch @TRUE will be changed to Switch@TRUE ; Case @TRUE Case@TRUE ; EndSwitch EndSwitch ;------------------------------------------------------------------------------------------------------------------------------------------ ; This script calls "txl.exe" from the application "The TXL Programming Language". ; - using "WinBatch.grm" ; 2009-08-16, 18:53:05; from: snowsnowsnow gazelle@xmission.com ; - using "ColonToStrCat.txl" ; 2009-08-16, 18:53:05; from: snowsnowsnow gazelle@xmission.com ; ; The "FreeTXL" application is available at "http://www.txl.ca/ndownload.html". ; The application must be installed to use it with this script. Adapt the installpath as needed (see below). ;------------------------------------------------------------------------------------------------------------------------------------------ ; Installation notes: ; ; Create a folder "wbt" in the root folder of the TXL folder ; and put a copy of the additional control files into this folder. ; "C:\Program Files\Txl105e\wbt" (Folder for TXL WinBatch control files) ; "C:\Program Files\Txl105e\wbt\WinBatch.Grm" (TXL WinBatch Grammar file) ; "C:\Program Files\Txl105e\wbt\ColonToStrCat.txl" (TXl script) ;------------------------------------------------------------------------------------------------------------------------------------------ ; 20100108: Version 1.00 : Initial published. ; ; Detlev Dalitz.20100108. ;========================================================================================================================================== ;------------------------------------------------------------------------------------------------------------------------------------------ ; Example for integration into wsp-user.mnu: ; ; _ColonToStrCat ; Convert string concatenation from colon ":" character to "StrCat ()". ; Call ("W:\WBT\WBSTUDIO\WBStudio.ColonToStrCat.wbt",0) ;------------------------------------------------------------------------------------------------------------------------------------------ strFileTxlExe = "D:\ProgPROG\Txl105e\bin\txl.exe" strFileTxlGrm = "D:\ProgPROG\Txl105e\wbt\WinBatch.Grm" strFileTxlTxl = "D:\ProgPROG\Txl105e\wbt\ColonToStrCat.txl" strFileTxlIn = FileCreateTemp ("WBT") strFileTxlOut = FileCreateTemp ("WBT") strTxlParams = '-q -o "' : strFileTxlOut : '" "' : strFileTxlIn : '" "' : strFileTxlTxl : '"' strScriptName = "WBStudio.ColonToStrCat" strMsgTitle = "WinBatch script terminated." strMsgText = "This WinBatch script " : '"' : strScriptName : '"' : @LF : " is designed only to work from user menu in WinBatch Studio." Terminate (RtStatus () != 10, strMsgTitle, strMsgText) strMsgRunning = "Running... " : strScriptName strMsgReady = "Ready. " : strScriptName wStatusMsg (strMsgRunning) intLineNo = wGetLineNo () intColNo = wGetColNo () If !wGetSelstate () wSelectAll () EndIf ; Get selection information. strSelInfo = wSelInfo () intSelStartLine = ItemExtract (1, strSelInfo, @TAB) ; intSelStartCol = ItemExtract (2, strSelInfo, @TAB) ; intSelStopLine = ItemExtract (3, strSelInfo, @TAB) ; intSelStopCol = ItemExtract (4, strSelInfo, @TAB) wCopy () FilePut (strFileTxlIn, ClipGet ()) intResult = RunShell (strFileTxlExe, strTxlParams, "", @HIDDEN, @GETEXITCODE) If intResult != 0 Message ("Txl Error", "Returncode: " : intResult) Goto CANCEL EndIf ClipPut (FileGet (strFileTxlOut)) wPaste () :CANCEL FileDelete (strFileTxlIn) FileDelete (strFileTxlOut) wClearSel () wGotoLine (intLineNo) wGotoCol (intColNo) wStatusMsg (strMsgReady : ". TXL result=" : intResult) Exit
;========================================================================================================================================== ; TXL WinBatch grammar file ; "WinBatch.Grm" ;========================================================================================================================================== % TXL WinBatch language grammar % DD (who else?) % Hacked from a Turing grammar by J.R. Cordy, et al #pragma -width 160 -newline -case -comment -raw tokens wbconst "@\u\i*" wbvarref "(\u\i*)?%\u\i*%" stringlit "\"#\"*(\"\"#\"*)*\"" charlit "'#'*(''#'*)*'" bqlit "`#`*(``#`*)*`" include_token "\#include" end tokens comments ; end comments % Note that 'compounds' is not really necessary, since we are using -raw, % but it is still worth having, I guess... compounds && || end compounds keys 'by 'case 'else 'end 'endif 'endselect 'endswitch 'endwhile 'exit 'for 'if 'next 'return 'select 'switch 'then 'to 'while 'break 'continue end keys % Note that 'program' and 'sub_scope' are always the same thing. define program [repeat scn_or_declaration_or_label] end define define sub_scope [repeat scn_or_declaration_or_label] end define % Non-precedence expression grammar define expn [primary] [opt operator_expn] | [expn] [colon_expn+] end define define operator_expn [SP] [binaryop] [SP] [expn] end define define binaryop << | >> | & | '| | ^ | && | || | ** | 'mod | + | * | - | / | '= | < | > | >= | <= | <> | == | != end define define colon_expn ': [expn] end define define comma_expn ', [expn] end define define primary ( [expn] ) | [dllcall] | [function_call] | [prefix_op] [primary] | [SP] [not_op] [primary] | [WBStringlit] | [number] | [wbconst] | [reference] | [object_ref] end define define dllcall 'dllcall '( [expn] [dllexpn+] ') | 'dllcallcdecl '( [expn] [dllexpn+] ') end define define dllexpn ', [id] ': [expn] | ', 'lpnull end define define object_ref [reference] [dot_id+] [object_args?] end define define dot_id '. [id] end define define object_args '( [expn] [comma_expn*] ') end define define function_call [id] '( [list expn] ') end define define WBStringlit [stringlit] | [charlit] | [bqlit] end define define prefix_op + | - end define define not_op ! | ~ end define define statement 'exit | 'goto [id] | 'return | 'return [SP] [expn] | 'break | 'continue | [include_token] [stringlit] | [assignment] | [if_statement] | [switch_statement] | [for_statement] | [while_statement] | [expn] | [object_ref] end define define tabcomment [TAB] [comment] end define define eol [tabcomment?] [newline+] end define define label ': [id] [eol] end define define statement_comment_newline [statement?] [eol] | [simple_if_statement?] [tabcomment?] [newline*] end define define scn_or_label [statement_comment_newline] | [label] end define define scn_or_declaration [statement_comment_newline] | [functiondeclaration] | [subroutinedeclaration] end define define scn_or_declaration_or_label [scn_or_declaration] | [label] end define % This is the same as the previous (for the time being...) define scn_or_declaration_or_bcl [scn_or_declaration] | [label] end define define functiondeclaration '#definefunction [id] '( [list expn] ') [eol] [repeat scn_or_label] '#endfunction [eol] end define define subroutinedeclaration '#definesubroutine [id] '( [list expn] ') [eol] [repeat scn_or_label] '#endsubroutine [eol] end define define simple_if_statement 'if [SP] [expn] [SP] 'then [statement_comment_newline] [then_or_else_clause*] end define define then_or_else 'then | 'else end define define then_or_else_clause [IN] [then_or_else] [statement_comment_newline] [EX] end define define if_statement 'if [SP] [expn] [eol] [IN] [sub_scope] [EX] [opt else_statement] 'endif end define define else_statement 'else [eol] [IN] [sub_scope] [EX] end define define switch_statement 'switch [expn] [eol] [repeat switch_alternative] 'endswitch end define define switch_alternative 'case [expn] [eol] [IN] [repeat scn_or_declaration_or_bcl] [EX] end define define for_statement 'for [id] [SP] '= [SP] [expn] 'to [expn] [opt by_clause] [eol] [IN] [repeat scn_or_declaration_or_bcl] [EX] 'next end define define by_clause [SP] 'by [SP] [expn] end define define while_statement 'while [SP] [expn] [eol] [IN] [repeat scn_or_declaration_or_bcl] [EX] 'endwhile end define define reference [id] [opt subscript] | [wbvarref] end define define subscript '[ [list expn] '] end define define assignment [reference] [SP] [assignment_operator] [SP] [expn] end define define assignment_operator '= end define #ifdef WBMain function main replace [program] P [program] by P end function #endif ;==========================================================================================================================================
;========================================================================================================================================== ; TXL WinBatch txl file ; "ColonToStrCat.txl" ;========================================================================================================================================== % ??? % DD include "WinBatch.Grm" redefine expn ... | [expn] [comma_expn+] end redefine rule main construct myCommas [repeat comma_expn] % None replace [expn] E1 [expn] E2 [colon_expn+] by 'StrCat( E1 myCommas [fixThem each E2] ') end rule function fixThem E1 [colon_expn] deconstruct E1 ': E2 [expn] construct tmpComma [comma_expn] ', E2 replace [repeat comma_expn] CurrentList [repeat comma_expn] by CurrentList [. tmpComma] end function ;==========================================================================================================================================