1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Grammar/BNF Detection Library

Discussion in 'Mac Programming' started by MorphingDragon, Feb 26, 2012.

  1. MorphingDragon, Feb 26, 2012
    Last edited: Feb 26, 2012

    macrumors 603

    MorphingDragon

    #1
    Is there any C (Preferred) or C++ libraries that will take a string and check if it matches a formal grammar or its BNF notation? Writing a robust library (as I found out) is not a trivial task.
     
  2. macrumors 603

    #2
    Isn't this what lex and yacc (or Flex and Bison) do?
     
  3. macrumors 68040

    #3
    Yacc/Bison are parser generators, and should already installed as well. They will generate a parser from a set of rules similar to BNF. I have never used any of them though, writing a recursive descent parser is not that hard though depending on what you are up to, (I have done it for math expressions).
     
  4. macrumors 6502a

    #4
    I know you said C preferred but perhaps "Spirit" a member of the BOOST project.

    <http://www.ibm.com/developerworks/aix/library/au-boost_parser/>
     
  5. macrumors 6502a

    #5
    I believe Perl 6 can do this as well.
     

Share This Page