Repository of BNF Grammars?

后端 未结 5 1852
广开言路
广开言路 2020-12-04 16:16

Is there a place I can find Backus–Naur Form or BNF grammars for popular languages? Whenever I do a search I don\'t turn up much, but I figure they must be published somewh

相关标签:
5条回答
  • 2020-12-04 16:28

    you have to search on tools used to create grammars: "lex/yacc grammar", "antlr grammar" "railroad diagram"

    http://www.antlr3.org/grammar/list.html

    Here's some grammar files

    objective-c

    • http://www.omnigroup.com/mailman/archive/macosx-dev/2001-March/022979.html

    • http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/Concepts/ObjectiveC/B_Grammar/Grammar.htmld/index.html

    • https://github.com/pornel/objc2grammar

    python

    • http://www.python.org/dev/summary/2006-04-16_2006-04-30/#the-grammar-file-and-syntaxerrors

    javascript

    • http://tomcopeland.blogs.com/EcmaScript.html

    • http://www.ccs.neu.edu/home/dherman/javascript/

    ruby

    • http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/yacc.html
    0 讨论(0)
  • 2020-12-04 16:28

    FWIW, the MySQL grammar file (mysql-server/sql/sql_yacc.y) is open source and browseable at launchpad.net (though it's a bit slow and I got an error when I tried to pull up the specific file).

    Also, a snapshot of the whole MySQL Server source is downloadable from dev.mysql.com.

    0 讨论(0)
  • 2020-12-04 16:32

    I also searched this and i collected this repository

    http://slps.github.io/zoo/

    0 讨论(0)
  • 2020-12-04 16:40

    There are some links from w:BNF#Language Grammars.

    • BNF Grammars for SQL-92, SQL-99 and SQL-2003

    I also found a page that lists grammars for Objective C.

    • Objective-C grammar for Lex/Yacc Flex/Bison
    • Reference Manual for the Objective-C Language
    0 讨论(0)
  • 2020-12-04 16:43

    IIRC, BNF grammars are just different enough from what yacc/bison want as input to be really annoying :) If you intend to feed these files into a parser generator, you may want to look for files in the appropriate format. I recall seeing such files for Java, JavaScript and C++ at one point. Probably as part of Eclipse, Firefox and GCC, respectively, but I can't remember for sure. I would assume you can find pretty much any parser input file by finding an open source project that uses that language.

    0 讨论(0)
提交回复
热议问题