company logo

BNFParser :: create - Create Parser

A string or file according to a given BNF syntax is based on a BNF definition file or string. Before creating and using a BNF definition it should be checked by creating a parser passing a BNF definition file. When the BNF has been tested, one may turn the BNF definition file into an internal program string that may be passed instead the definition file when creating the parser. Parser created by calling create() have to be removed by calling remove().

When the function fails because of an error in the parser definition, the function throws an exception.


Implementation overview

Implementation details

  1. Create parser from BNF definition file
    BNFParser  :: create ( odaba::String &sPath, odaba::String &tracePath, bool bSkipNL, bool bSymbols )

    In order to check BNF definition for the parser it may be passed via file (sPath). In addition, a trace path (tracePath). The file referenced in tracePath contains all analyzing steps for the parser definition as well as detected errors.

    • sPath - File path
    • tracePath - Trace path

      The path refers to a file, the contains trace information after calling the function.

    • bSkipNL - Skip newline symbols

      Newline symbols (0a, 0d0a) are usually skiped automatically. In order to consider newlines as relevat syntax tokens, true has to be passed.

    • bSymbols - List symbols

      When the value is true, symbols found in the parser definition are listed.

  2. to list
  3. Create sub-parser from BNF definition file
    BNFParser  :: create ( odaba::BNFParser &cParser, odaba::String &sPath, odaba::String &tracePath, bool bSkipNL, bool bSymbols )

    In order to support referenced to symbols defined in another parser, the parser containing referenced symbols may be passed to the function. In this case, the BNF passed in file at sPath may contain reference symbols, which are defined in the parser pased in cParser.

    • cParser - BNF Parser
    • sPath - File path
    • tracePath - Trace path

      The path refers to a file, the contains trace information after calling the function.

    • bSkipNL - Skip newline symbols

      Newline symbols (0a, 0d0a) are usually skiped automatically. In order to consider newlines as relevat syntax tokens, true has to be passed.

    • bSymbols - List symbols

      When the value is true, symbols found in the parser definition are listed.

  4. to list
  5. Create parser from BNF definition string
    BNFParser  :: create ( odaba::String &sDefinition, bool bSkipNL )

    In order to avoid changes in the parser definition file, parser definitions may be turned into a string, which is passed to the function instead of the parser file. In this case, no symbols are listed and no trace file is written.

    • sDefinition - Definition string
    • bSkipNL - Skip newline symbols

      Newline symbols (0a, 0d0a) are usually skiped automatically. In order to consider newlines as relevat syntax tokens, true has to be passed.

  6. to list
  7. Create sub-parser from BNF definition string
    BNFParser  :: create ( odaba::BNFParser &cParser, odaba::String &sDefinition, bool bSkipNL )

    In order to support referenced to symbols defined in another parser, the parser containing referenced symbols may be passed to the function. In this case, the BNF passed in sDefinition may contain reference symbols, which are defined in the parser pased in cParser.

    • cParser - BNF Parser
    • sDefinition - Definition string
    • bSkipNL - Skip newline symbols

      Newline symbols (0a, 0d0a) are usually skiped automatically. In order to consider newlines as relevat syntax tokens, true has to be passed.

  8. to list