Skip to content

Commit

Permalink
Add BNF grammar definitions to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed Sep 30, 2023
1 parent f7fb8f6 commit 089f6b0
Show file tree
Hide file tree
Showing 471 changed files with 53,570 additions and 16 deletions.
97 changes: 97 additions & 0 deletions Documentation/Grammar/GrammarGeneric.bnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<program> ::= <line> | <program> <line> | ε

<line> ::= <optWhitespace> <lineBody> <optWhitespace> <optComment> <optWhitespace> <EOL>
<lineBody> ::= <instruction> | <label> | ε
<instruction> ::= <mnemonic> | <mnemonic> <whitespace> <operands> <optOperandSeparator> | <directiveMac>

<directiveMac> ::= <caseInsensitiveM> <caseInsensitiveA> <caseInsensitiveC> <whitespaceChar> <freeText> "," <freeText>

<mnemonic> ::= <mnemonicChar> | <mnemonic> <mnemonicChar>
<mnemonicChar> ::= <letter> | "_"

<operands> ::= <operand> | <operands> <operandSeparator> <operand>
<operand> ::= <numericLiteral> | <stringLiteral> | <label> | <pointer> | <register>

<optOperandSeparator> ::= <operandSeparator> | ε
<operandSeparator> ::= <optWhitespace> "," <optWhitespace>

<stringLiteral> ::= "\"" <stringContent> "\""
<stringContent> ::= <stringChar> | <stringContent> <stringChar>
<stringChar> ::= <letter> | <digit> | <stringSymbol> | <stringBackslash>
<stringBackslash> ::= "\\" <stringEscapeChar>
<stringEscapeChar> ::= "\\" | "\"" | "'" | "0" | "a" | "b" | "f" | "n" | "r" | "t" | "v" | <stringUnicodeEscapeFour> | <stringUnicodeEscapeEight>
<stringUnicodeEscapeFour> ::= "u" <hexadecimalChar> <hexadecimalChar> <hexadecimalChar> <hexadecimalChar>
<stringUnicodeEscapeEight> ::= "U" <hexadecimalChar> <hexadecimalChar> <hexadecimalChar> <hexadecimalChar> <hexadecimalChar> <hexadecimalChar> <hexadecimalChar> <hexadecimalChar>

<numericLiteral> ::= <staticNumericLiteral> | <labelLiteral>
<staticNumericLiteral> ::= <hexadecimalNumber> | <anyDecimalNumber> | <binaryNumber>
<labelLiteral> ::= ":&" <labelName>
<label> ::= ":" <labelName>
<pointer> ::= "*" <register>
<register> ::= <caseInsensitiveR> <caseInsensitiveP> <caseInsensitiveO> | <caseInsensitiveR> <caseInsensitiveS> <caseInsensitiveO> | <caseInsensitiveR> <caseInsensitiveS> <caseInsensitiveB> | <caseInsensitiveR> <caseInsensitiveS> <caseInsensitiveF> | <caseInsensitiveR> <caseInsensitiveR> <caseInsensitiveV> | <caseInsensitiveR> <caseInsensitiveF> <caseInsensitiveP> | <caseInsensitiveR> <caseInsensitiveG> "0" | <caseInsensitiveR> <caseInsensitiveG> "1" | <caseInsensitiveR> <caseInsensitiveG> "2" | <caseInsensitiveR> <caseInsensitiveG> "3" | <caseInsensitiveR> <caseInsensitiveG> "4" | <caseInsensitiveR> <caseInsensitiveG> "5" | <caseInsensitiveR> <caseInsensitiveG> "6" | <caseInsensitiveR> <caseInsensitiveG> "7" | <caseInsensitiveR> <caseInsensitiveG> "8" | <caseInsensitiveR> <caseInsensitiveG> "9"

<hexadecimalNumber> ::= "0x" <hexadecimalNumberDigits>
<hexadecimalNumberDigits> ::= <hexadecimalDigit> | <hexadecimalNumberDigits> <hexadecimalDigit>
<hexadecimalDigit> ::= <decimalDigit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"
<hexadecimalChar> ::= <digit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"

<anyDecimalNumber> ::= <floatingPointDecimalNumber> | <negativeFloatingPointDecimalNumber> | <negativeDecimalNumber> | <decimalNumber>
<negativeFloatingPointDecimalNumber> ::= "-" <floatingPointDecimalNumber>
<floatingPointDecimalNumber> ::= <decimalNumber> "." <optDecimalNumber> | <optDecimalNumber> "." <decimalNumber>
<negativeDecimalNumber> ::= "-" <decimalNumber>
<optDecimalNumber> ::= <decimalNumber> | ε
<decimalNumber> ::= <digit> | <decimalNumber> <decimalDigit>
<decimalDigit> ::= <digit> | "_"

<binaryNumber> ::= "0b" <binaryNumberDigits>
<binaryNumberDigits> ::= <binaryDigit> | <binaryNumberDigits> <binaryDigit>
<binaryDigit> ::= "0" | "1" | "_"

<labelName> ::= <labelStartChar> | <labelName> <labelChar>
<labelChar> ::= <labelStartChar> | <digit>
<labelStartChar> ::= <letter> | "_"

<optComment> ::= <comment> | ε
<comment> ::= ";" <optText>

<optWhitespace> ::= <whitespace> | ε
<whitespace> ::= <whitespaceChar> | <whitespace> <whitespaceChar>
<whitespaceChar> ::= " " | "\t"

<optText> ::= <freeText> | ε
<freeText> ::= <anyChar> | <freeText> <anyChar>
<anyChar> ::= <letter> | <digit> | <symbol>

<caseInsensitiveA> ::= "A" | "a"
<caseInsensitiveB> ::= "B" | "b"
<caseInsensitiveC> ::= "C" | "c"
<caseInsensitiveD> ::= "D" | "d"
<caseInsensitiveE> ::= "E" | "e"
<caseInsensitiveF> ::= "F" | "f"
<caseInsensitiveG> ::= "G" | "g"
<caseInsensitiveH> ::= "H" | "h"
<caseInsensitiveI> ::= "I" | "i"
<caseInsensitiveJ> ::= "J" | "j"
<caseInsensitiveK> ::= "K" | "k"
<caseInsensitiveL> ::= "L" | "l"
<caseInsensitiveM> ::= "M" | "m"
<caseInsensitiveN> ::= "N" | "n"
<caseInsensitiveO> ::= "O" | "o"
<caseInsensitiveP> ::= "P" | "p"
<caseInsensitiveQ> ::= "Q" | "q"
<caseInsensitiveR> ::= "R" | "r"
<caseInsensitiveS> ::= "S" | "s"
<caseInsensitiveT> ::= "T" | "t"
<caseInsensitiveU> ::= "U" | "u"
<caseInsensitiveV> ::= "V" | "v"
<caseInsensitiveW> ::= "W" | "w"
<caseInsensitiveX> ::= "X" | "x"
<caseInsensitiveY> ::= "Y" | "y"
<caseInsensitiveZ> ::= "Z" | "z"

<letter> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<stringSymbol> ::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | ">" | "=" | "<" | "?" | "@" | "[" | "]" | "^" | "_" | "`" | "{" | "}" | "~" | "\t" | "'"
<symbol> ::= <stringSymbol> | "\\" | "\""

<EOL> ::= "\r" | "\n" | "\r\n"
62 changes: 62 additions & 0 deletions Documentation/Grammar/GrammarGenericDiagram/diagram/EOL.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions Documentation/Grammar/GrammarGenericDiagram/diagram/anyChar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 089f6b0

Please sign in to comment.