Difference between revisions of "GenAsm (language)"

From Mill Computing Wiki
Jump to: navigation, search
Line 12:Line 12:
 
    
 
    
  
     program        ::=  "module", identifier, expDefs;
+
     program        ::=  "module", moduleId, expDefs;
 
     serial        ::=  [expDef, {";", expDef}];
 
     serial        ::=  [expDef, {";", expDef}];
 
     expDef        ::=  expression | definition;
 
     expDef        ::=  expression | definition;
Line 33:Line 33:
 
                         [widthTag, ":"] number  |  
 
                         [widthTag, ":"] number  |  
 
                         boundId |  
 
                         boundId |  
                         ["inline"], funcId |  
+
                         ["inline"], resolution |  
 
                         gang |
 
                         gang |
 
                         "(" expression ")" |
 
                         "(" expression ")" |
Line 49:Line 49:
 
     elsePart      ::=  "else", serial;
 
     elsePart      ::=  "else", serial;
 
     boundId        ::=  identifier;
 
     boundId        ::=  identifier;
     funcId        ::=  identifier;
+
    resolution    ::=  funcId, [widthPack];
 +
     funcId        ::=  identifier |
 +
                        moduleId, "::", identifier;
 +
    moduleId      ::=  identifier;
 
     identifier    ::=  alpha, {alnum};
 
     identifier    ::=  alpha, {alnum};
 
     alnum          ::=  decDigit | alpha;
 
     alnum          ::=  decDigit | alpha;

Revision as of 10:42, 9 October 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 keyword or symbol
  ::=       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", moduleId, expDefs;
   serial         ::=  [expDef, {";", expDef}];
   expDef         ::=  expression | definition;
   definition     ::=  functionDef;
   functionDef    ::=  ["inline"], "func", identifier, formals, [results], funcBody;
   funcBody       ::=  ":", expression | "outcall" | "forward";
   formals        ::=  "(", [formal, {",", formal}], ")";
   formal         ::=  widthTag, identifier;
   widthTag       ::=  "b" | "h" | "w" | "d" | "q" | "bv" | "hv" | "wv" | "dv" | "qv";
   results        ::=  widthPack;
   widthPack      ::=  "{", [widthTag, {",", widthTag}], "}";
   expression     ::=  [secondary] | 
                       expression, binding | 
                       expression, gang, [secondary] |
                       expression, ["inline"], funcId, [secondary]
                       expression, "?", expression, ":", expression;
   secondary      ::=  primary | 
                       secondary, "(", [expression, {",", expression}], ")";
   primary        ::=  widthTag |
                       [widthTag, ":"] number  | 
                       boundId | 
                       ["inline"], resolution | 
                       gang |
                       "(" expression ")" |
                       "begin", serial, "end" |
                       ifClause;
   binding        ::=  "-:" identifier | 
                       "-:", idenPack;
   idenPack       ::=  "{", identifier, {",", identifier}, "}";
   gang           ::=  opId ["." opId];
   opId           ::=  identifier;
   ifClause       ::=  "if", predPart, thenPart, {elifPart}, [elsePart], "fi";
   predPart       ::=  serial;
   thenPart       ::=  "then", serial;
   elifPart       ::=  "elif", serial;
   elsePart       ::=  "else", serial;
   boundId        ::=  identifier;
   resolution     ::=  funcId, [widthPack];
   funcId         ::=  identifier |
                       moduleId, "::", identifier;
   moduleId       ::=  identifier;
   identifier     ::=  alpha, {alnum};
   alnum          ::=  decDigit | alpha;
   alpha          ::=  "_" | <"a"-"z"> | <"A"-"Z">;
   decDigit       ::=  <"0"-"9">;
   number         ::=  decimal | hexadecimal | float;
   decimal        ::=  digit, { digit };
   hexadecimal    ::=  hexBase, hexDigit, { hexDigit }
   hexBase        ::=  "0x" | "0X"
   hexDigit       ::=  decDigit | <"a"-"f"> | <"A"-"F">
   float          ::=  decimal, ".", [decimal], [exponent] |
                       decimal, ["." [decimal]], exponent
   exponent       ::=  "e", [sign], decimal |
                       "E", [sign], decimal
   sign           ::=  "+" | "-"
   comment        ::=  "//", {<char>}, <EOL> | "/*", {<char>}, "*/";