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 771 - (download) (annotate)
Sat Dec 30 13:06:09 2000 UTC (18 years, 8 months ago) by blume
File size: 8738 byte(s)
merging changes from private branch
(* -*- 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
    | GROUP | LIBRARY | IS
    | LPAREN | RPAREN | COLON
    | IF | ELIF | ELSE | ENDIF
    | ERROR of string
    | STRUCTURE | SIGNATURE | FUNCTOR | FUNSIG
    | DEFINED
    | ADDSYM of CMSemant.addsym
    | MULSYM of CMSemant.mulsym
    | EQSYM of CMSemant.eqsym
    | INEQSYM of CMSemant.ineqsym
    | TILDE
    | ANDALSO | ORELSE | NOT

%nonterm description of S.group
       | group of S.group
       | gprivspec of S.privilegespec
       | lprivspec of S.privilegespec
       | version of S.cm_version
       | opt_version of S.cm_version option
       | 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 { name: string, mkpath: unit -> SrcPath.prefile }
       | sym of S.cm_symbol
       | word of S.cm_symbol
       | owner of SrcPath.file option
       | class of S.cm_class
       | optclass of S.cm_class option
       | toolopts of S.toolopt list
       | ptoolopts of S.toolopt list
       | opttoolopts of S.toolopt list option

%pos int
%verbose
%arg (grouppath, context, obsolete, error, doMember, curlib, gp, ig) :
    SrcPath.file *
    S.context *
    (pos * pos -> unit) *
    (pos * pos -> string -> unit) *
    ({ name: string, mkpath: unit -> SrcPath.prefile } *
     pos * pos * S.cm_class option * S.toolopt list option -> S.members) *
    SrcPath.file option *
    GeneralParams.info *
    S.group
%start description
%eop EOF
%noshift EOF

%name CM

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

%prefer LPAREN

%left ORELSE
%left ANDALSO
%nonassoc INEQSYM
%nonassoc EQSYM
%left ADDSYM
%left MULSYM
%left NOT TILDE

%%

description : group				(group)

group : gprivspec owner opt_exports IS members (S.group
						 { path = grouppath,
						   privileges = gprivspec,
						   exports = opt_exports,
						   members = members,
						   gp = gp,
						   curlib = curlib,
						   owner = owner,
						   initgroup = ig })
      | lprivspec opt_version mand_exports IS members
                                               (S.library
						 { path = grouppath,
						   privileges = lprivspec,
						   exports = mand_exports,
						   version = opt_version,
						   members = members,
						   gp = gp,
						   initgroup = ig })
      | lprivspec IS members                   (S.proxy
						 { path = grouppath,
						   privileges = lprivspec,
						   members = members,
						   error =
						     error (membersleft,
							    membersright) } )

opt_version : (* empty *)                      (NONE)
            | LPAREN version RPAREN            (SOME version)

version : FILE_STANDARD                        (S.cm_version
						(FILE_STANDARD,
						 error (FILE_STANDARDleft,
							FILE_STANDARDright)))

owner : (* empty *)                            (NONE)
      | LPAREN pathname RPAREN                 (SOME (SrcPath.file
							(#mkpath pathname ())))

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))

toolopts : (* empty *)                          ([])
         | pathname toolopts                    (S.string pathname :: toolopts)
	 | pathname COLON ptoolopts toolopts    (S.subopts
						     { name = #name pathname,
						       opts = ptoolopts }
						 :: toolopts)
	 | pathname COLON pathname toolopts     (S.subopts
						     { name = #name pathname1,
						       opts = [S.string
								   pathname2] }
						 :: toolopts)

ptoolopts : LPAREN toolopts RPAREN              (toolopts)

opttoolopts : (* empty *)                       (NONE)
            | ptoolopts                         (SOME ptoolopts)

optclass : (* empty *)                          (NONE)
         | COLON class                          (SOME class)

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

class : word                                    (S.class word)

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 ADDSYM aexp                         (S.add (aexp1, ADDSYM, aexp2))
     | aexp MULSYM aexp                         (S.mul (aexp1, MULSYM, aexp2))
     | TILDE aexp		                (S.negate aexp)
     | ADDSYM aexp %prec TILDE                  (obsolete (ADDSYMleft,
							   ADDSYMright);
						 S.sign (ADDSYM, 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 EQSYM boolexp                 (S.beq (boolexp1, EQSYM,
							boolexp2))
	| NOT boolexp				(S.not boolexp)
	| aexp INEQSYM aexp                     (S.ineq (aexp1, INEQSYM,
							 aexp2))
	| aexp EQSYM aexp                       (S.eq (aexp1, EQSYM, 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			({ name = FILE_STANDARD,
						   mkpath = fn () =>
						     S.file_standard gp
						      (FILE_STANDARD,
						       context, error
						       (FILE_STANDARDleft,
							FILE_STANDARDright)) })
	 | FILE_NATIVE				({ name = FILE_NATIVE,
						   mkpath = fn () =>
						     S.file_native
						       (FILE_NATIVE,
							context, error
							(FILE_NATIVEleft,
							 FILE_NATIVEright)) })

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