The translation file should be a text file, expressions are free form and can span multiple lines; whitespace is ignored.
replace 'x' with 'y' ; replace from 'x1' to 'x2' with 'y' ; replace from 'x1' to 'x2' with 'y1' to 'y2' ; replace_parenthesis 'f' with 'g' ; replace_parenthesis 'f' with 'g1' to 'g2' ;
Comments begin # until the the end of the line.
The replace command in its simplest form changes one word (string of characters without whitespace) to any string of characters.
replace 'DECISION_CASE' with 'case' ;
However, if you have start and end words that you wish to replace with others, and preserve the string in between, you can use:
replace from 'cout' to 'endl' with 'cout << "["' to ' "]" << endl' ;
The above would take:
cout << "Hello world!" << endl ;
and replace it with:
cout << "[" << "Hello world!" << "]" << endl ;
You can also replace start and end words, and the code between them, with a single fixed string of characters, e.g.:
replace from 'cout' to 'endl' with '//No output' ;
The replace_parenthesis command locates the first open parenthesis after the specified identifier and then locates the closing parenthesis. Everything in between these parentheses is stored so that it may be put back, if required.
For example:
replace_parenthesis 'BEGIN_COM_MAP' with 'BEGIN_COM_MAP(' to ') ;' ;
applied to the line:
BEGIN_COM_MAP ( a, b, (3*c) )
would result in:
BEGIN_COM_MAP( a, b, (3*c) ) ;
ATL defines often are not closed with a semi-colon (because the semi-colon appears in the actual define) and are therefore not syntactically correct. The command above would replace the syntax exactly, add add the important semi-colon. Another option would be to delete the entire call:
replace_parenthesis 'BEGIN_COM_MAP' with '' ;
A similar effect could be achieved using the simple replace command:
replace 'BEGIN_COM_MAP' with '// BEGIN_COM_MAP' ;
This would, however, mean that the comments ratio was affected and would only allow for calls that spanned only 1 line. To multi-line comment out the above, you could use:
replace_parenthesis 'BEGIN_COM_MAP' with '/* BEGIN_COM_MAP(' to ') */' ;