Difference between revisions of "GenAsm (language)"

From Mill Computing Wiki
Jump to: navigation, search
Line 1:Line 1:
 
The genAsm assembly language is a low-level [https://en.wikipedia.org/wiki/Dataflow_programming| dataflow language] for writing programs to be executed on the Mill processors. The language is accepted by the [[genAsm (assembler)|genAsm assembler]], which create ELF files suitable as input to the [[prelinker]] or [[specializer]]. The assembler is intended for use when high-level language compilers are unable to provide a desired access to Mill hardware facilities.
 
The genAsm assembly language is a low-level [https://en.wikipedia.org/wiki/Dataflow_programming| dataflow language] for writing programs to be executed on the Mill processors. The language is accepted by the [[genAsm (assembler)|genAsm assembler]], which create ELF files suitable as input to the [[prelinker]] or [[specializer]]. The assembler is intended for use when high-level language compilers are unable to provide a desired access to Mill hardware facilities.
  
Syntax in BNF:
+
Syntax in [https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form EBNF]:
  
BNF:
+
Terminal keywords and symbols are in quotes
Terminal keywords and symbols are italic; meta-symbols are bold.
+
Meta-symbols are bold
 +
  '''::='''      is defined as
 +
  '''|'''        alternatives
 +
  '''[''' ... ''']'''  option (zero or one times
 +
  '''{''' ... '''}'''  repetition (zero or more times)
 +
  ''','''        sequence (in order left-to-right)
 +
  ''';'''        end of definition
 +
 
  
     program ::=       moduleHead moduleBody-option
+
     program       ::= "module", identifier, expDefs;
     moduleHead ::=     ''module'' identifier
+
     expDefs        ::= expDef, {";", expDef};
     moduleBody ::=    functionDef-sequence
+
     expDef        ::= expression | definition;
     functionDef ::=   ''func'' identifier parmsBinding resultSpec-option ''{'' functionBody ''}''
+
     definition    ::=  functionDef;
     parmsBinding ::=   ''('' parmList-option '')''
+
     functionDef   ::= "func", identifier, formals, [results], "{", expDefs, "}";
     parmList ::=       parm '''|''' parm '','' parmList
+
     formals        ::= "(", [formal, {",", formal}], ")";
    arg ::=            widthTag identifier
+
     formal        ::= widthTag, identifier;
     widthTag ::=       ''b'' ''|'' ''h'' ''|'' ''w'' ''|'' ''d'' '''|''' ''q'' '''|''' ''bv'' '''|''' ''hv'' '''|''' ''wv'' '''|''' ''dv'' '''|''' ''qv''
+
     widthTag       ::= "b" | "h" | "w" | "d" | "q" | "bv" | "hv" | "wv" | "dv" | "qv";
     resultSpec ::=     ''->'' widthTag '''|''' -> ( resultList-option )
+
     results        ::= "->", widthTag |
    resultList ::=    widthTag '''|''' widthTag , resultList
+
                        "->", "(", [widthTag, {",", widthTag}], ")";
     functionBody ::=  expressionList-option
+
     expression    ::= [secondary] |  
    expressionList ::= expression '''|''' expression '';'' expressionList
+
                        expression, binding |  
     expression ::=     secondary-option '''|'''
+
                        expression, opId, [secondary] |
                      expression invoke-option '''|'''
+
                        expression, "?", expression, ":", expression;
                      expression binding '''|'''
+
     secondary     ::= primary |  
                      expression pick
+
                        secondary, "(", [expression, {",", expression}], ")";
     secondary ::=     primary '''|''' secondary call
+
     primary       ::= widthTag |
     primary ::=       number widthSpec-option '''|''' argId '''|''' boundId '''|''' funcId '''|''' ''('' expression '')''
+
                        [widthTag, ":"] number |  
     widthSpec ::=     '':'' widthTag
+
                        boundId |  
     call ::=           ''('' argList-option '')''
+
                        funcId |  
     argList ::=       arg '''|''' arg '','' argList
+
                        opId |
     binding ::=       ''-:'' identifier '''|''' ''-:'' bindings
+
                        "(" expression ")";
     bindings ::=       ''{'' idList ''}''
+
     binding        ::= "-:" identifier |
     pick ::=           ''?'' expression '':'' expression
+
                        "-:" "{", identifier, {",", identifier}, "}";
     idList ::=         identifier '''|''' identifier '','' idList
+
     opId          ::= identifier
     invoke ::=         opCall '''|''' opId secondary-option
+
     boundId        ::= identifier
     opCall ::=         opId ''('' argList-option '')''
+
     funcId        ::= identifier
 +
     identifier    ::= alpha, {alnum}
 +
     alpha          ::= "_" | <"a"-"z"> | <"A"-"Z">
 +
     digit          ::= <"0"-"9">
 +
     alnum          ::= digit | alpha
 +
     comment        ::= "//", {<char>}, <EOL> | "/*", {<char>}, "*/"

Revision as of 04:15, 8 September 2014

The genAsm assembly language is a low-level dataflow language for writing programs to be executed on the Mill processors. The language is accepted by the genAsm assembler, which create ELF files suitable as input to the prelinker or specializer. The assembler is intended for use when high-level language compilers are unable to provide a desired access to Mill hardware facilities.

Syntax in EBNF:

Terminal keywords and symbols are in quotes Meta-symbols are bold

  ::=       is defined as
  |         alternatives
  [ ... ]   option (zero or one times
  { ... }   repetition (zero or more times)
  ,         sequence (in order left-to-right)
  ;         end of definition
  
   program        ::=  "module", identifier, expDefs;
   expDefs        ::=  expDef, {";", expDef};
   expDef         ::=  expression | definition;
   definition     ::=  functionDef;
   functionDef    ::=  "func", identifier, formals, [results], "{", expDefs, "}";
   formals        ::=  "(", [formal, {",", formal}], ")";
   formal         ::=  widthTag, identifier;
   widthTag       ::=  "b" | "h" | "w" | "d" | "q" | "bv" | "hv" | "wv" | "dv" | "qv";
   results        ::=  "->", widthTag |
                       "->", "(", [widthTag, {",", widthTag}], ")";
   expression     ::=  [secondary] | 
                       expression, binding | 
                       expression, opId, [secondary] |
                       expression, "?", expression, ":", expression;
   secondary      ::=  primary | 
                       secondary, "(", [expression, {",", expression}], ")";
   primary        ::=  widthTag |
                       [widthTag, ":"] number  | 
                       boundId | 
                       funcId | 
                       opId |
                       "(" expression ")";
   binding        ::=  "-:" identifier | 
                       "-:" "{", identifier, {",", identifier}, "}";
   opId           ::=  identifier
   boundId        ::=  identifier
   funcId         ::=  identifier
   identifier     ::=  alpha, {alnum}
   alpha          ::=  "_" | <"a"-"z"> | <"A"-"Z">
   digit          ::=  <"0"-"9">
   alnum          ::=  digit | alpha
   comment        ::=  "//", {<char>}, <EOL> | "/*", {<char>}, "*/"