Backus Naur(BNF)

Cards (25)

  • What is an integer?
    A whole number
  • What does BNF stand for?
    Backus-Naur Form
  • What is the purpose of BNF?
    To define the syntax of a language
  • What does syntax refer to in programming?
    The definition of allowed patterns in a language
  • What is an example of a defined format for 'char'?
    One character in length
  • What characters are allowed in the 'char' format?
    1. z, A-Z, 0-9, @£$
  • What does the notation ': : =' mean in BNF?
    Means is defined by / consists of
  • What does '< >' signify in BNF?
    It indicates a syntactic item
  • What does '|' represent in BNF?
    It means OR
  • What does '{ }' denote in BNF?
    It means optional
  • What does ',' signify in BNF?
    It means AND
  • What is the purpose of defining 'char2' in BNF?
    To create a new data type
  • What does the meta level refer to in BNF?
    Decomposing elements into smallest parts
  • How is a number defined in BNF?
    As 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  • How is a letter defined in BNF?
    As 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
  • What are the components of the BNF definition for 'char2'?
    • <char2> : : = <number> <number>
    • <number> <letter>
    • <letter> <number>
    • <letter> <letter>
  • Why is BNF important in programming?
    It standardizes language syntax definitions
  • Name two scenarios where BNF might be used.
    Defining programming languages and data formats
  • How does BNF make programming easier?
    By providing clear syntax rules
  • What does the notation <WORD> : : = <LETTER> <LETTER> represent?
    Definition of a word with 2 letters
  • How can you define a word using BNF notation?
    <WORD> : : = <LETTER> | <LETTER> <LETTER> | <LETTER> <LETTER> <LETTER>
  • How would you define a sentence using BNF incorporating the definition of a word?
    <SENTENCE> : : = <WORD> | <WORD> ‘,’ {<WORD>}
  • What is a syntax diagram?
    • A visual representation of BNF
    • Shows how symbols are connected
    • Helps in understanding language structure
  • How are the symbols for LETTER defined in the syntax diagram?
    <LETTER> : : = A | B | C | D
  • What is the role of circles in the syntax diagram?
    To represent undefined symbols like LETTER