Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /trunk/src/compiler/gen/opt/rules.grm
ViewVC logotype

View of /trunk/src/compiler/gen/opt/rules.grm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1484 - (download) (annotate)
Sun Sep 4 14:35:20 2011 UTC (9 years ago) by jhr
File size: 844 byte(s)
  Created a compiler/gen directory to hold code for the generation tools.  Moved
  compiler/IL/gen to compiler/gen/il and created compiler/gen/opt for Charisee's tool.
(* rules.grm
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

%name Rules;

%header (functor RulesParseFn (Lex:ANTLR_LEXER));

%tokens
  : OPER of Atom.atom
  | ID of Atom.atom
  | LP                  ("(")
  | RP                  (")")
  | LANGLE              ("<")
  | RANGLE              (">")
  | COMMA               (",")
  | SEMI                (";")
  | ARROW               ("=>")
  ;
 
Specification
	: Rule*
		=> (ParseTree.Spec Rule)
	;

Rule
	: Pattern "=>" Pattern ";"
		=> (ParseTree.Rule(Pattern1, Pattern2))
	;

Pattern
	: ID
		=> (ParseTree.IdPat ID)
	| Operator "(" Pattern ("," Pattern)* ")"
		=> (ParseTree.OpPat(Operator, Pattern::SR))
	;

Operator
        : ID TypeArgs?
                => (ID)
        ;

TypeArgs
        : "<" ID ("," ID)* ">"
        ;

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