Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/cm/parse/cm.grm
ViewVC logotype

View of /sml/trunk/src/cm/parse/cm.grm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 364 - (download) (annotate)
Fri Jul 2 07:33:12 1999 UTC (20 years, 2 months ago) by blume
File size: 6706 byte(s)
more inching towards a usable system
(* -*- sml -*-
 *
 * ML-Yacc grammar for CM description files
 *
 * (C) 1999 Lucent Technologies, Bell Laboratories
 *
 * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
 *)

structure S = CMSemant

%%

%term EOF
    | FILE_STANDARD of string
    | FILE_NATIVE of string
    | CM_ID of string
    | ML_ID of string
    | NUMBER of int
    | ALIAS | GROUP | LIBRARY | IS
    | LPAREN | RPAREN | COLON
    | IF | ELIF | ELSE | ENDIF
    | ERROR of string
    | STRUCTURE | SIGNATURE | FUNCTOR | FUNSIG
    | DEFINED
    | PLUS | MINUS | TIMES | DIV | MOD | TILDE
    | ANDALSO | ORELSE | NOT
    | LT | LE | GT | GE | EQ | NE

%nonterm description of S.group
       | alias of S.group
       | group of S.group
       | gprivspec of S.privilegespec
       | lprivspec of S.privilegespec
       | wrapspec of S.privilegespec -> S.privilegespec
       | mand_exports of S.exports
       | opt_exports of S.exports option
       | exports of S.exports
       | export of S.exports
       | guarded_exports of S.exports * S.exports
       | else_exports of S.exports
       | members of S.members
       | member of S.members
       | guarded_members of S.members * S.members
       | else_members of S.members
       | aexp of S.aexp
       | boolexp of S.exp
       | exp of S.exp
       | ml_symbol of S.ml_symbol
       | pathname of S.pathname
       | cmpath of S.pathname
       | nativepath of S.pathname
       | sym of S.cm_symbol
       | word of S.cm_symbol

%pos int
%verbose
%arg (grouppath, context, error, recParse, doMember, gp) :
    S.pathname *
    S.context *
    (pos * pos -> string -> unit) *
    (pos * pos -> S.pathname -> S.group) *
    (S.pathname * pos * pos * S.cm_symbol option -> S.members) *
    GeneralParams.info
%start description
%eop EOF
%noshift EOF

%name CM

%keyword ALIAS GROUP LIBRARY IS IF ELIF ELSE ENDIF DEFINED
  STRUCTURE SIGNATURE FUNCTOR FUNSIG

%prefer LPAREN

%left ORELSE
%left ANDALSO
%nonassoc LT LE GT GE
%nonassoc EQ NE
%left PLUS MINUS
%left TIMES DIV MOD
%left NOT TILDE

%%

description : alias				(alias)
	    | group				(group)

alias : ALIAS pathname				(recParse
						 (pathnameleft, pathnameright)
						 pathname)

group : gprivspec opt_exports IS members        (S.group
						 (grouppath,
						  gprivspec, opt_exports,
						  members, gp))
      | lprivspec mand_exports IS members       (S.library
						 (grouppath,
						  lprivspec, mand_exports,
						  members, gp))

wrapspec : (* empty *)                         (fn p => p)
          | wrapspec word                      (fn p =>
						 S.wrap (wrapspec p, word,
							  error (wordleft,
								 wordright)))

gprivspec : GROUP                               (S.initialPrivilegeSpec)
          | word gprivspec                      (S.require (gprivspec, word,
							    error (wordleft,
								   wordright)))

lprivspec : LIBRARY                             (S.initialPrivilegeSpec)
          | word lprivspec                      (S.require (lprivspec, word,
							    error (wordleft,
								   wordright)))
          | LPAREN wrapspec RPAREN lprivspec    (wrapspec lprivspec)

mand_exports : export				(export)
	     | mand_exports export	        (S.exports (mand_exports,
							    export))

opt_exports : (* empty *)                       (NONE)
            | mand_exports                      (SOME mand_exports)

exports : (* empty *)                           (S.emptyExports)
        | exports export                        (S.exports (exports, export))

export : ml_symbol				(S.export
						 (ml_symbol,
						  error (ml_symbolleft,
							 ml_symbolright)))
       | IF exp guarded_exports			(S.guarded_exports
						  (exp, guarded_exports,
						   error (expleft, expright)))
       | ERROR                                  (S.error_export
						 (fn () =>
						  error (ERRORleft, ERRORright)
						        ERROR))

guarded_exports : exports else_exports	        ((exports, else_exports))

else_exports : ENDIF				(S.emptyExports)
	     | ELSE exports ENDIF		(exports)
             | ELIF exp guarded_exports		(S.guarded_exports
						 (exp, guarded_exports,
						  error (expleft, expright)))

members : (* empty *)				(S.emptyMembers)
	| member members			(S.members (member, members))

member : pathname				(doMember (pathname,
							   pathnameleft,
							   pathnameright,
							   NONE))
       | pathname COLON word			(doMember (pathname,
							   pathnameleft,
							   pathnameright,
							   SOME word))
       | IF exp guarded_members			(S.guarded_members
						 (exp, guarded_members,
						  error (expleft, expright)))
       | ERROR                                  (S.error_member
						 (fn () =>
						  error (ERRORleft, ERRORright)
						        ERROR))

guarded_members : members else_members	        ((members, else_members))

else_members : ENDIF				(S.emptyMembers)
	     | ELSE members ENDIF		(members)
	     | ELIF exp guarded_members		(S.guarded_members
						 (exp, guarded_members,
						  error (expleft, expright)))

word : FILE_STANDARD                            (S.cm_symbol FILE_STANDARD)

sym : CM_ID                                     (S.cm_symbol CM_ID)

exp : boolexp					(boolexp)

aexp : NUMBER				        (S.number NUMBER)
     | sym					(S.variable gp sym)
     | LPAREN aexp RPAREN		        (aexp)
     | aexp PLUS aexp		                (S.plus (aexp1, aexp2))
     | aexp MINUS aexp		                (S.minus (aexp1, aexp2))
     | aexp TIMES aexp		                (S.times (aexp1, aexp2))
     | aexp DIV aexp		                (S.divide (aexp1, aexp2))
     | aexp MOD aexp		                (S.modulus (aexp1, aexp2))
     | TILDE aexp		                (S.negate aexp)

boolexp : DEFINED LPAREN ml_symbol RPAREN	(S.ml_defined ml_symbol)
	| DEFINED LPAREN sym RPAREN		(S.cm_defined gp sym)
	| LPAREN boolexp RPAREN			(boolexp)
	| boolexp ANDALSO boolexp		(S.conj (boolexp1, boolexp2))
	| boolexp ORELSE boolexp		(S.disj (boolexp1, boolexp2))
	| boolexp EQ boolexp			(S.beq (boolexp1, boolexp2))
	| boolexp NE boolexp			(S.bne (boolexp1, boolexp2))
	| NOT boolexp				(S.not boolexp)
	| aexp LT aexp			        (S.lt (aexp1, aexp2))
	| aexp LE aexp			        (S.le (aexp1, aexp2))
	| aexp GT aexp			        (S.gt (aexp1, aexp2))
	| aexp GE aexp			        (S.ge (aexp1, aexp2))
	| aexp EQ aexp			        (S.eq (aexp1, aexp2))
	| aexp NE aexp			        (S.ne (aexp1, aexp2))

ml_symbol : STRUCTURE ML_ID			(S.ml_structure ML_ID)
	  | SIGNATURE ML_ID			(S.ml_signature ML_ID)
	  | FUNCTOR ML_ID			(S.ml_functor ML_ID)
	  | FUNSIG ML_ID			(S.ml_funsig ML_ID)

pathname : FILE_STANDARD			(S.file_standard gp
						 (FILE_STANDARD, context))
	 | FILE_NATIVE				(S.file_native
						 (FILE_NATIVE, context))

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