Advertisement
Guest User

Untitled

a guest
May 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 2.72 KB | None | 0 0
  1. Statement :=        ' '* ({Control} | {Operation | {Assignment}) ' '* ';'
  2.  
  3. Control :=      'if(' {CompBooleanOperation} ')' '\n'* '{' '\n'* {Statement}* '\n'* '}' ('\n'* 'else' '\n'* '{' {Statement}* '\n'* '}')?  
  4.             | 'while(' {BooleanOp} ')' '\n'* '{' '\n'* {Statement}* '\n'* '}'
  5.  
  6. Operation :=        {String} '(', (,({MathOperation} | {RealNumber} | {Variable} | {StringLiteral}) , (,',', ({MathOperation} | {RealNumber} | {Variable} | {StringLiteral},),)*,)? ,')'
  7.  
  8. Assignment :=       {Variable} ' '* '=' ' '* ({MathOperation} | {RealNumber})
  9.  
  10. MathOperation :=    {MathOperand} {BinaryMathOp} {MathOperand}
  11.  
  12. ParenMathOperation :=   '(', ({MathOperation} | {Variable} | {RealNumber}), ')'
  13.  
  14. MathOperand := {Variable} | {RealNumber} | {MathOperation} | {ParenMathOperation}
  15.  
  16. Variable := {String}
  17.  
  18. CompBoolOperation :=    {BooleanOperation}
  19.             | {UnaryLogicalOp} '(' {BooleanOperation} ')'  
  20.             | {CompBooleanOperation} {BinaryLogicalOp} {CompBooleanOperation}
  21.  
  22. BinaryLogicalOp :=  '&&'
  23.             | '||'
  24.             | '^'
  25.  
  26. UnaryLogicalOp :=   '!'
  27.  
  28. BooleanOperation :=     {Variable} {BooleanOp} {Variable}
  29.             | {Variable} {BooleanOp} {RealNumber}
  30.             | {Variable} {BooleanOp} {MathOperation}
  31.             | {Variable} {BooleanOp} {BooleanOperation}
  32.             | {RealNumber} {BooleanOp} {Variable}
  33.             | {RealNumber} {BooleanOp} {RealNumber}
  34.             | {RealNumber} {BooleanOp} {MathOperation}
  35.             | {RealNumber} {BooleanOp} {BooleanOperation}
  36.             | {MathOperation} {BooleanOp} {Variable}    
  37.             | {MathOperation} {BooleanOp} {RealNumber}
  38.             | {MathOperation} {BooleanOp} {MathOperation}
  39.             | {MathOperation} {BooleanOp} {BooleanOperation}
  40.    
  41. ParenBoolOperation :=   '(', {BooleanOperation}, ')'
  42.  
  43. BooleanOp :=        '=='
  44.             | '!='
  45.             | '<'
  46.             | '>'
  47.             | '<='
  48.             | '>='
  49.  
  50. RealNumber :=       {DigitList}
  51.             | {DigitList} '.' {DigitList}
  52.             | '-' {DigitList}
  53.             | '-' {DigitList} '.' {DigitList}
  54.  
  55. DigitList :=        {Digit}
  56.             | {Digit} {DigitList}
  57.  
  58. Digit :=        '0'
  59.             | '1'
  60.             | '2'
  61.             | '3'
  62.             | '4'
  63.             | '5'
  64.             | '6'
  65.             | '7'
  66.             | '8'
  67.             | '9'
  68.    
  69. String :=       {Character}
  70.             | {Character} {String}
  71.  
  72. Character :=        'a'
  73.             | 'b'
  74.             | 'c'
  75.             | 'd'
  76.             | 'e'
  77.             | 'f'
  78.             | 'g'
  79.             | 'h'
  80.             | 'i'
  81.             | 'j'
  82.             | 'k'
  83.             | 'l'
  84.             | 'm'
  85.             | 'n'
  86.             | 'o'
  87.             | 'p'
  88.             | 'q'
  89.             | 'r'
  90.             | 's'
  91.             | 't'
  92.             | 'u'
  93.             | 'v'
  94.             | 'w'
  95.             | 'x'
  96.             | 'y'
  97.             | 'z'
  98.             | 'A'
  99.             | 'B'
  100.             | 'C'
  101.             | 'D'
  102.             | 'E'    
  103.             | 'F'    
  104.             | 'G'
  105.             | 'H'
  106.             | 'I'
  107.             | 'J'
  108.             | 'K'
  109.             | 'L'
  110.             | 'M'
  111.             | 'N'
  112.             | 'O'
  113.             | 'P'
  114.             | 'Q'
  115.             | 'R'
  116.             | 'S'
  117.             | 'T'
  118.             | 'U'
  119.             | 'V'
  120.             | 'W'
  121.             | 'X'
  122.             | 'Y'
  123.             | 'Z'
  124.  
  125. BinaryMathOp :=     '+'
  126.             | '-'
  127.             | '*'
  128.             | '/'
  129.  
  130. StringLiteral :=     '"' {String} '"'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement