Grammatica does not handle Semantic instructions in grammar file. Thus, the those productions need to be described in a C# class.

After the execution of /etc/exec.sh, Grammatica will create four files in parser directory:
  • XXXAnalyzer.cs, an abstract class with onEnter and onExit methods for each token and production;
  • XXXConstants.cs, the constants (Tokens) of our grammar;
  • XXXParser.cs, the parser;
  • XXXTokenizer.cs, the lexical tokenizer.

To include basic/local semantic instructions we must extend the XXXAnalyzer, overriding onEnter and onExit methods and adding the behavior needed. In our case, we replace all one-to-one tokens, adding a GLSL version of a token in the values attribute and keeping on the original HLSL version in image attribute.

// Replacing #elseif to #elif.
public override Node ExitPreElseif(Token node) {
	node.AddValue("#elif");
	return node;
}


We reconstruct the shader joining the image attribute when there are no value added.

Last edited Feb 7, 2008 at 7:16 PM by vfpamp, version 3

Comments

No comments yet.