Advertisement
Guest User

Untitled

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