Advertisement
Guest User

S# - BNF

a guest
Jan 1st, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 1.15 KB | None | 0 0
  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 // if statement
  17.     | writesym, lparen, expression, rparen, semicolon, expression
  18.     | readsym
  19.     | ident, lparen, expression, rparen; // function
  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 = ">";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement