Advertisement
Guest User

Untitled

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