How to use the Coco/R for F# ============================ First, if you have already used the version of Coco/R for C#, you'll see that this version is very similar. Differences to Coco/R for C# ============================ • The grammar has been extended to allow the usage of variables. • The comment syntax has been adapted to “//” for line comments, and “(*” to “*)” for nested block comments, like in F#. The structure for a Coco/R grammar for F# is as follows ======================================================= Coco= [Imports] "COMPILER" ident [Declarations] [ "VARIABLES" AnyVariables "INITVARIABLES" AnyVariablesDeclaration ] ScannerSpecification ParserSpecification "END" ident ’.’ . The imports section can be used to call libraries, e.g.: “open System.IO”. The declarations section may be used to declare global methods of the class Parser, e.g.: member x.Print = printf “Value %d” t.value; Use the variables section to declare member variables for the parser class, e.g.: val a : int val d : string Initialize the variables declared in the variables section in the initvariables section. This will be copied into the constructor of the parser class, e.g.: a = 0; b= ""; How to use output attributes? ============================= Input and output attributes can be declared like input and output parameters in F#. Example: <(atrib : int), (rr : string byref)> atrib represents an input attribute of type int, rr represents an output attribute of the type string. Usage of output attributes: To use an output attribute, it is necessary to declare a variable (in the following example: z) in the “caller”: S = (. z = ref 0 in .) Number (. printf "The out value is %d" !z; .) . And to fill it by the “Callee”: Number = number (. value <- Convert.ToInt32(x.t.value); .) . General: ======== The use of the scanner and parser generated by the F# version of Coco/R is the same as of the other versions of Coco/R, thus it’s highly recommended to read the documentation available at http://www.ssw.uni-linz.ac.at/coco/.