These notational conventions are used for presenting syntax:
[ <pattern> ] | optional |
{ <pattern> } | zero or more repetitions |
<pattern>+ | one or more repetitions |
<pat1> | <pat2> | choice |
<nonterm>::=<alt1> | <alt2> | ... <altn>
Quoted identifiers and punctuation symbols are terminals (i.e., keywords), unquoted identifiers are non-terminals, all punctuation symbols with no special meaning are terminals.
Identifiers conform to the usual C rules. There are no “reserved identifiers”: keywords can be used as normal identifiers anywhere that they have no special meaning.
All lists of patterns separated by commas (or semicolons) may have a trailing comma (or semicolon). For example, one may write [a, b, c,] instead of [a, b, c]. This optional punctuation is omitted from the grammar to avoid clutter.
ToDo: The rules for comments and strings aren’t quite right because ’any’ ought to exclude the terminating characters
<file>::={ <lexeme> | <whitespace> }
<lexeme> ::= <ident> | <punctuation> | <string> | <integer> | <literal C> | <doc comment>
<whitespace> ::= ( whitestuff )+
<whitestuff > ::= <whitechar> | <comment> | <ncomment>
<whitechar> ::= <newline> | <formfeed> | <tab> | <space>
<comment> ::= ‘//’ {<any>} <newline>
<ncomment> ::= ‘/*’ {<any>} ‘*/’
<doc comment> ::= ‘/*#’ {<any>} ‘#*/’
<literal C> ::= ‘%{’ {<any>} ‘%}’
<string> ::= ‘"’ {<any>} ‘"’
<ident> ::= (<alpha> | ‘_’) {<idChar>}
|‘'’ {<any>} ‘'’
<idChar> ::= <alpha> | <digit> | ‘_’
<alpha> ::= ‘a’ | ‘b’ | ... ‘z’ | ‘A’ | ‘B’ | ... ‘Z’
<digit> ::= ‘0’ | ‘1’ | ... ‘9’
<punctuation> ::= ‘.’ | ‘,’ | ‘:’ | ‘;’ | ‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’ | ‘=’ | ‘<’ | ‘<=’ | ‘>=’ | ‘<-’ | ‘...’
ToDo: Hack the grammar package so that subscripts come out as subscripts
<file> ::= { <directive> | <decl> }
<directive> ::= ‘directory’ <dirName>
|‘include’ <fileName>
<defn> ::= ‘bundletype’ <bundleTIdent> ‘=’ <bundleType>
|‘flags’ <flagsIdent> ‘=’ <flags>
|‘unit’ <unitIdent> ‘=’ (<unit> | <modUnit>)
|‘property’ <propIdent>
|‘type’ <typeIdent> ‘<=’ <supertypes>
|‘package’ <packageIdent> ‘=’ <package>
|<doc comment>
<bundleType> ::= <bundleTIdent>
|‘{’ <btElement>1 ‘,’ ... <btElement>m [‘,’] ‘}’ m > 0
<btElement> ::= ‘extends’ <bundleTIdent>
|<memberIdent>
<sourceCode> ::= <fileSet> [‘with’ ‘flags’ <flags>]
<fileSet> ::= ‘files’ [<dirName>] ‘{’ <fileName>1 ‘,’ ... <fileName>m [‘,’] ‘}’ m > 0
|<literal C> [‘with’ ‘flags’ <flags>]
<flags> ::= <flagsIdent>
|‘{’ <flag>1 ‘,’ ... <flag>m [‘,’] ‘}’ m > 0
<flag> ::= ‘flags’ <flagsIdent>
|<string>
<constraints> ::= {‘constraints’ ‘{’ <constraint>1 ‘;’ ... <constraint>m [‘;’] ‘}’} m > 0
<constraint> ::= <property> ‘=’ <property>
|<property> ‘<=’ <property>
|<property> ‘>=’ <property>
<property> ::= <typeIdent>
|<propIdent> <atomicObjectSet>
<supertypes> ::= <typeIdent>
|‘(’ <typeIdent>1 ‘,’ ... <typeIdent>m [‘,’] ‘)’ m > 0
<initialization> ::= {‘initializer’ <objectIdent> ‘for’ <objectSet> ‘;’}
{‘finalizer’ <objectIdent> ‘for’ <objectSet> ‘;’}
{‘depends’ ‘{’ <depend>1 ‘;’ ... <depend>m [‘;’] ‘}’ ‘;’} m > 0
<depend> ::= <objectSet> ‘needs’ <objectSet>
|<objectSet> ‘<’ <objectSet>
<objectSet> ::= <objectSetDiff>1 ‘+’ ... <objectSetDiff>m [‘+’] m > 1
|<atomicObjectSet> ‘-’ <atomicObjectSet>
<atomicObjectSet> ::= <bundleIdent>
|‘{’ <objectIdent>1 ‘,’ ... <objectIdent>m [‘,’] ‘}’ m > 0
|‘(’ <objectSet> ‘)’
|‘imports’
|‘exports’
|‘inits’
|‘finis’
<unit> ::= ‘{’
‘imports’ ‘[’ <import>1 ‘,’ ... <import>m [‘,’] ‘]’ ‘;’ m > 0
‘exports’ ‘[’ <export>1 ‘,’ ... <export>m [‘,’] ‘]’ ‘;’ m > 1
<constraints>
<initialization>
[ (‘flatten’ | ‘noflatten’) ‘;’ ]
(<atomicBody> | <compoundBody>) [‘;’]
‘}’
<atomicBody> ::= <sourceCode>1 ‘;’ ... <sourceCode>m [‘;’] m > 1
{ <rename> }
<rename> ::= ‘rename’ ‘{’ <renaming>1 ‘;’ ... <renaming>m [‘;’] ‘}’ ‘;’ m > 0
<renaming> ::= <objectIdent> ‘to’ <CIdent>
|<bundleIdent> ‘with’ ‘prefix’ <CIdent>
|<bundleIdent> ‘with’ ‘suffix’ <CIdent>
<compoundBody> ::= {<globals>}
{<glues>}
{<defaults>}
‘link’ ‘{’ <binding>1 ‘;’ ... <binding>m [‘;’] ‘}’ m > 0
<globals> ::= ‘global’ ‘{’ <global>1 ‘,’ ... <global>m [‘,’] ‘}’ ‘;’ m > 0
<global> ::= <bundleIdent>
<glues> ::= ‘glue’ ‘{’ <glue>1 ‘,’ ... <glue>m [‘,’] ‘}’ ‘;’ m > 0
<glue> ::= ‘package’ <packageIdent>
|<unitIdent>
<package> ::= ‘{’ <glue>1 ‘,’ ... <glue>m [‘,’] ‘}’
<defaults> ::= ‘default’ ‘{’ <default>1 ‘,’ ... <default>m [‘,’] ‘}’ ‘;’ m > 0
<default> ::= <bundleIdent>
<import> ::= <bundleIdent> ‘:’ <bundleType>
<export> ::= <bundleIdent> ‘:’ <bundleType>
<binding> ::= ‘[’ <bundleIdent>1 ‘,’ ... <bundleIdent>m [‘,’] ‘]’ ‘<-’ <unitInstance> m > 1
|<bundleIdent> ‘=’ <bundle>
<unitInstance> ::= <unitIdent> ‘<-’ (<posArgs> | <nameArgs>)
|‘flatten’ <unitInstance>
|‘noflatten’ <unitInstance>
|‘unit’ <unit>
|<literal C>
<posArgs> ::= ‘[’ <posArg>1 ‘,’ ... <posArg>m [‘,’] ‘]’ m > 0
<posArg> ::= <arg>
<nameArgs> ::= ‘{’ <nameArg>1 ‘,’ ... <nameArg>m [‘,’ ‘...’] [‘,’] ‘}’ m > 0
<nameArg> ::= <bundleIdent> ‘=’ <arg>
|<bundleIdent>
<arg> ::= <bundle>
|‘(’ <unitInstance> ‘)’
<bundle> ::= <atomicBundle>1 ‘+’ ... <atomicBundle>m [‘+’] m > 1
<atomicBundle> ::= ‘find’ <bundleType>
|‘{’ <memberBinding>1 ‘,’ ... <memberBinding>m [‘,’] ‘}’ m > 1
|<bundleIdent>
|‘(’ <bundle> ‘)’
<memberBinding> ::= <memberIdent> ‘=’ <objectIdent>
<modUnit> ::= ‘modify’ <unitIdent> ‘deleting’ ‘{’ <remunit> ‘}’ ‘adding’ ‘{’ <addunit> ‘}’
<remunit> ::= {‘imports’ ‘[’ <bundleIdent>1 ‘,’ ... <bundleIdent>m [‘,’] ‘]’ ‘;’} m > 0
{‘exports’ ‘[’ <bundleIdent>1 ‘,’ ... <bundleIdent>m [‘,’] ‘]’ ‘;’} m > 0
{‘constraints’ ‘{’ <constraint>1 ‘,’ ... <constraint>m [‘;’] ‘}’ ‘;’} m > 0
{‘depends’ ‘{’ <depend>1 ‘;’ ... <depend>m [‘;’] ‘}’ ‘;’}) m > 0
{<globals>}
{<glue’>}
{<defaults>}
{‘link’ ‘{’ <bundleIdent>1 ‘,’ ... <bundleIdent>m [‘,’] ‘}’ ‘;’} m > 0
<addunit> ::= {‘imports’ ‘[’ <import>1 ‘,’ ... <import>m [‘,’] ‘]’ ‘;’} m > 0
{‘exports’ ‘[’ <export>1 ‘,’ ... <export>m [‘,’] ‘]’ ‘;’} m > 0
{‘constraints’ ‘{’ <constraint>1 ‘;’ ... <constraint>m [‘;’] ‘)’ ‘;’} m > 0
{‘depends’ ‘{’ <depend>1 ‘;’ ... <depend>m [‘;’] ‘}’ ‘;’} m > 0
{<globals>}
{<glues>}
{<defaults>}
{‘link’ ‘{’ <binding>1 ‘;’ ... <binding>m [‘;’] ‘}’ ‘;’} m > 0
<fileName> ::= <string>
<dirName> ::= <string>
<objectIdent> ::= <objectIdent>
<CIdent> ::= <ident>
<bundleIdent> ::= <ident>
<memberIdent> ::= <ident>
<bundleTIdent> ::= <ident>
<unitIdent> ::= <ident>
<flagsIdent> ::= <ident>
<packageIdent> ::= <ident>
<propIdent> ::= <ident>
<typeIdent> ::= <ident>
<qualIdent> ::= [<bundleIdent> ‘.’] <memberIdent>