SHARE
TWEET

S# Grammar (EBNF)

a guest Jan 1st, 2019 206 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. S# =
  2.     (function),
  3.     {function};
  4.  
  5. function = ident, params, body;
  6.  
  7. params = {ident};
  8.  
  9. body = lbrace, expression, rbrace;
  10.  
  11. expression =
  12.     number
  13.     | expression, semicolon, expression
  14.     | expression, arithmeticoperator, expression
  15.     | lparen, expression, rparen
  16.     | ifsym, lparen, condition, rparen, body, body
  17.     | writesym, lparen, expression, rparen, semicolon, expression
  18.     | readsym
  19.     | ident, lparen, expression, rparen;
  20.  
  21. arithmeticoperator = times | slash | plus | minus | mod;
  22.  
  23. condition =
  24.     truesym
  25.     | falsesym
  26.     | expression, conditionaloperator, expression
  27.     | negation, condition
  28.     | condition, logicaloperator, condition;
  29.  
  30. logicaloperator = andsym | orsym;
  31.  
  32. conditionaloperator = eql | neq | lss | gtr;
  33.  
  34. ident = ? alphanumeric characters ?;
  35. number = ? digits ?;
  36. lbrace = "{";
  37. rbrace = "}";
  38. semicolon = ";";
  39. lparen = "(";
  40. rparen = "}";
  41. writesym = "write";
  42. readsym = "read";
  43. times = "*";
  44. slash = "/";
  45. plus = "+";
  46. minus = "-";
  47. mod = "%";
  48. truesym = "1";
  49. falsesym = "0";
  50. negation = "~";
  51. andsym = "&&";
  52. orsym = "||";
  53. eql = "==";
  54. neq = "!=";
  55. lss = "<";
  56. gtr = ">";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top