Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The translation process includes an authoring step that uses a "String Machine" to generate the target code.  The string machine is like a runtime execution engine (e.g., like the .NET CLR that executes the IL operation streams ) but it has that are stored in assemblies).  But, there is a critical difference: instead of performing the operations, it the string machine authors the code described by those operations.  This is what we mean by semantic translation as opposed to syntax translation.  It may help you to think of gmBasic as a sophisticated VB6/ASP/COM to .NET compiler-decompiler.   

The form of that the target code for each operation is defined in terms of patterns associated with operations in the metalanguage files. There are many details in how information in the operation stream may be emitted during the expression of target code.  Some of these details may be controlled by special codes and escape sequences in the pattern strings.    For convenience, an excerpt from the gmBasic Language reference page that describes pattern strings these special codes and escape sequences in more detail is included herebelow

Insert excerpt
gmplPatternsStatement
gmplPatternsStatement


Limitations of pattern strings

Generally speaking, pattern strings relate individual elemental operations in the source code to corresponding individual elemental operations in the target code.  In some cases, you may have to author more complex target forms.  It may be difficult to do this in general, but it can work out well if the source and target operations closely follow consistent conventions.  Consider for example is from the MSXML upgrade rules.  This is not a general pattern, it will work some of the time, but not always.

Code Block
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Samples\ScanTool\proj_csh\usr\msxml6.dll.Refactor.xml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49    <Migrate id="IXMLDOMDocument.load" 
	nPram="2" 
	cshPattern="try{\p%1d.Load(%2d);\q}catch{}\n%1d.HasChildNodes" 
	vbnPattern="%1d.Load(%2d)\n%1d.HasChildNodes" />
  50    <Migrate id="IXMLDOMDocument.loadXML" 
	nPram="2" 
	cshPattern="try{%1d.LoadXml(%2d);}catch{}\n%1d.HasChildNodes" 
	vbnPattern="%1d.LoadXml(%2d)\n%1d.HasChildNodes" />

If more complex or dynamic transformations are required, you will typically have to use dynamic translation rules built with gmSL or gmAPI as discussed elsewhere in this site.

See Also