Difference between revisions of "GenAsm (language)"

From Mill Computing Wiki
Jump to: navigation, search
(Added inline functions, both for definition and call)
Line 33:Line 33:
 
                         [widthTag, ":"] number  |  
 
                         [widthTag, ":"] number  |  
 
                         boundId |  
 
                         boundId |  
                         i["inline"], funcId |  
+
                         ["inline"], funcId |  
 
                         opId |
 
                         opId |
 
                         "(" expression ")";
 
                         "(" expression ")";
 
     binding        ::=  "-:" identifier |  
 
     binding        ::=  "-:" identifier |  
 
                         "-:" "{", identifier, {",", identifier}, "}";
 
                         "-:" "{", identifier, {",", identifier}, "}";
     opId          ::=  identifier
+
     opId          ::=  identifier;
     boundId        ::=  identifier
+
     boundId        ::=  identifier;
     funcId        ::=  identifier
+
     funcId        ::=  identifier;
     identifier    ::=  alpha, {alnum}
+
     identifier    ::=  alpha, {alnum};
     alpha          ::=  "_" | <"a"-"z"> | <"A"-"Z">
+
    alnum          ::=  decDigit | alpha;
     digit          ::=  <"0"-"9">
+
     alpha          ::=  "_" | <"a"-"z"> | <"A"-"Z">;
     alnum          ::=  digit | alpha
+
     decDigit      ::=  <"0"-"9">;
     comment        ::=  "//", {<char>}, <EOL> | "/*", {<char>}, "*/"
+
     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>}, "*/";

Revision as of 04:40, 14 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    ::=  ["inline"], "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, ["inline"], funcId, [secondary]
                       expression, "?", expression, ":", expression;
   secondary      ::=  primary | 
                       secondary, "(", [expression, {",", expression}], ")";
   primary        ::=  widthTag |
                       [widthTag, ":"] number  | 
                       boundId | 
                       ["inline"], funcId | 
                       opId |
                       "(" expression ")";
   binding        ::=  "-:" identifier | 
                       "-:" "{", identifier, {",", identifier}, "}";
   opId           ::=  identifier;
   boundId        ::=  identifier;
   funcId         ::=  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>}, "*/";