Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /gen/gl-spec.grm
ViewVC logotype

View of /gen/gl-spec.grm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 261 - (download) (annotate)
Thu Sep 25 09:42:19 2008 UTC (11 years, 2 months ago) by jhr
File size: 2257 byte(s)
  Added support for <instance> tag.
(* gl-spec.grm
 *
 * COPYRIGHT (c) 2008 John Reppy (http://cs.uchicago.edu/~jhr)
 * All rights reserved.
 *
 * This is a parser for the XML file that is used to specify information
 * about the OpenGL interfaces and extensions.
 *)

%name GLSpec;

%tokens : TAG_constant		("constant")
	| TAG_constants		("constants")
	| TAG_extension		("extension")
	| TAG_extensions	("extensions")
	| TAG_function		("function")
	| TAG_functions		("functions")
	| TAG_instance		("instance")
	| TAG_param		("param")
	| ATR_name		("name")
	| ATR_value		("value")
	| ATR_returnType	("returnType")
	| ATR_type		("type")
	| LOPEN			("<")
	| ROPEN			(">")
	| LCLOSE		("</")
	| RCLOSE		("/>")
	| EQ			("=")
	| TAG_gl		("gl")
	| TAG_wgl		("wgl")
	| TAG_glx		("glx")
	| TAG_agl		("agl")
	| STR of string
	;

%defs (
  structure Ext = Extensions
);

File
	: "<" "extensions" ">" Group* "</" "extensions" ">"
		=> (Group)
	;

Group
	: "<" "gl" ">" Extension* "</" "gl" ">"
		=> (Ext.Group{name = "gl", exts = Extension})
	| "<" "wgl" ">" Extension* "</" "wgl" ">"
		=> (Ext.Group{name = "wgl", exts = Extension})
	| "<" "glx" ">" Extension* "</" "glx" ">"
		=> (Ext.Group{name = "glx", exts = Extension})
	;

Extension
	: "<" "extension" "name" "=" STR ">" Constants Functions "</" "extension" ">"
		=> (Ext.Ext{name = STR, consts = Constants, funcs = Functions})
	;

Constants
	: "<" "constants" ">" Constant* "</" "constants" ">"
		=> (Constant)
	| "<" "constants" "/>"
		=> ([])
	;

Constant
	: "<" "constant" "name" "=" STR "value" "=" STR "/>"
		=> ({name = STR1, value = STR2})
	;

Functions
	: "<" "functions" ">" Function* "</" "functions" ">"
		=> (Function)
	| "<" "functions" "/>"
		=> ([])
	;

Function
	: "<" "function" "name" "=" STR "returnType" "=" STR FunctionRest
		=> (let
		  val (params, instances) = FunctionRest
		  in
		    Ext.Func{
			name = STR1, retTy = STR2,
			params = #1 FunctionRest,
			instances = #2 FunctionRest
		      }
		  end)
	;

FunctionRest
	: ">" Param* Instance* "</" "function" ">"	=> (Param, Instance)
	| "/>"						=> ([], [])
	;

Instance
	: "<" "instance" "name" "=" STR "type" "=" STR "/>"
		=> (Ext.Inst{name = STR1, ty = STR2})
	;

Param
	: "<" "param" "type" "=" STR "name" "=" STR "/>"
		=> (Ext.Param{ty = STR1, name = STR2})
	;


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0