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

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #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

    Joined:
    Aug 9, 2009
    #2
    Isn't this what lex and yacc (or Flex and Bison) do?
     
  3. macrumors 68040

    Joined:
    Feb 2, 2008
    #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

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #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

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #5
    I believe Perl 6 can do this as well.
     

Share This Page