BNF Grammar: Difference between revisions

2,248 bytes removed ,  11 years ago
m
→‎Pascal: move to pacsal page
(→‎{{header|Cobol}}: fix spelling)
m (→‎Pascal: move to pacsal page)
 
(17 intermediate revisions by 14 users not shown)
Line 1:
{{taskDeprecatedTask}}
In computer science, Backus–Naur Form (BNF) is a metasyntax used to express context-free grammars: that is, a formal way to describe formal languages. John Backus and Peter Naur developed a context free grammar to define the syntax of a programming language by using two sets of rules: i.e., lexical rules and syntactic rules.
 
Line 6:
There are many extensions and variants of BNF, including Extended and Augmented Backus–Naur Forms (EBNF and ABNF).
 
'''This is a deprecated task. Please move these grammars to the language's category page, or somewhere else.'''
The task here is establish a BNF grammar for as many languages as possible to facilitate language categorization and translation.
=={{header|Ada}}==
A BNF description of the language syntax is a part of its standard, [http://www.adaic.org/standards/1zrm/html/RM-P.html see Ada Reference Manual, Annex P].
=={{header|ALGOL 60}}==
A BNF description of the language syntax is a part of following,
[http://eli-project.sourceforge.net/a60_html/a60.html#s2 ALGOL 60 ][http://www.masswerk.at/algol60/syntax.txt -Syntax of ALGOL 60]
 
=={{header[[:Category:BASIC|BASIC}}]]==
<div style="height:30ex;overflow:scroll"><pre>
! -----------------------------------------------------------------------
Line 179 ⟶ 174:
| Real
</pre></div>
=={{header[[:Category:BASIC Commodore PET|BASIC Commodore PET}}]]==
<div style="height:30ex;overflow:scroll"><pre>
! -----------------------------------------------------------------------
Line 386 ⟶ 381:
</pre></div>
 
=={{header[[:Category:Brainf***|Brainf***}}]]==
See syntax [http://ninh.nl/blog/2008/10/25/brainfck-birds-of-a-feather-session-take-2/ p.4 BNF BrainF*** Syntax]
 
Code ::= Command Code | <NONE>
=={{header|C}}==
Command ::= "+" | "-" | "<" | ">" | "," | "." | "[" Code "]" | <ANY>
The Syntax follows, [http://c.comsci.us/syntax/index.html C Syntax]
 
==[[:Category:PARI/GP|PARI/GP]]==
=={{header|C++}}==
[http://pari.math.u-bordeaux.fr/cgi-bin/viewcvs.cgi/trunk/src/language/parse.y?view=markup&revision=12950&root=pari parse.y] contains a grammar for GP. The grammar for PARI is that of [http://c.comsci.us/syntax/ C].
The Syntax follows, [http://cpp.comsci.us/syntax/statement/index.html C++ Syntax]
 
==[[:Category:PowerShell|PowerShell]]==
=={{header|C sharp}}==
An annotated version of the PowerShell grammar can be found in Bruce Payette's book ''Windows PowerShell in Action''. The appendix containing the grammar is available in [http://www.manning.com/payette/AppCexcerpt.pdf PDF form] on the publisher's site.
See the following, [http://csharp.comsci.us/syntax/expression/ebnf.html C-sharp syntax]
 
This grammar does not accurately represent the PowerShell language, though, as for example the <code>for</code> loop mandates semicolons in the grammar but in practice does not require them when arguments are omitted. The infinite loop may be represented by
=={{header|COBOL}}==
<lang powershell>for () {}</lang>
See link [http://www.cs.vu.nl/~x/grammars/cobol/ COBOL Grammer]
but the grammar would require
<lang powershell>for (;;) {}</lang>
 
==[[:Category:VBScript|VBScript]]==
=={{header|Delphi}}==
IEBNF Syntax follows [http://www.felix-colibri.com/papers/compilers/delphi_5_grammar/delphi_5_grammar.html Dephi 5 Syntax]
 
=={{header|Fortran}}==
The BNF description follows, [http://fortran.comsci.us/syntax/statement/index.html Fortran Syntax]
 
=={{header|Java}}==
The BNF description follows, [http://www.cui.unige.ch/db-research/Enseignement/analyseinfo/JAVA/BNFindex.html BNF index of Java Language Grammar]
 
=={{header|JavaScript}}==
The BNF description follows, [http://javascript.comsci.us/syntax/statement/bnf.html JavaScript Syntax]
 
=={{header|Lisp}}==
See link on syntax [http://cui.unige.ch/db-research/Enseignement/analyseinfo/LISP/BNFindex.html Lisp Syntax]
Outside of particularly restricted variants, no static grammar can exactly describe Lisp due to macros and reader-macros.
 
=={{header|Modula2}}==
See link on syntax [http://cui.unige.ch/db-research/Enseignement/analyseinfo/Modula2/BNFindex.html BNF Modula2]
 
=={{header|Pascal}}==
The [[wp:ISO 7185|ISO 7185]] standard for Pascal uses [[wp:Extended Backus–Naur Form|Extended Backus–Naur Form]].
Also [[wp:Van Wijngaarden grammar|Van Wijngaarden's grammar]] can be used to define
[[Pascal]]'s grammar[http://www-users.cs.york.ac.uk/~fisher/software/yoyovwg/exs/pascal.vwg].
 
=={{header|Perl}}==
The BNF description follows, [http://perl.comsci.us/syntax/statement/index.html Perl Syntax]
 
=={{header|PHP}}==
The BNF description follows, [http://php.comsci.us/syntax/statement/index.html PHP Syntax]
 
=={{header|Python}}==
The best EBNF syntax so far is at, [http://www.martinrinehart.com/articles/python-grammar.html Python EBNF Syntax]
=={{header|Ruby}}==
Syntax follows [http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/yacc.html Ruby Syntax]
 
=={{header|SQL}}==
Syntax for SQL follows, [http://savage.net.au/SQL/sql-2003-2.bnf.html BNF Sytax for SQL Database Language]
 
=={{header|Smalltalk}}==
Smalltalk Syntax follows, [http://github.com/aquasync/ruby-ometa/blob/60deea23abe7eb07d200233dde4213d74041b81f/smalltalk.syntax Smalltalk Syntax]
 
=={{header|Tcl}}==
Though Tcl is not typically described using BNF, an approximation of the base language grammar can be written in a [[:Category:Tcl#Grammar|BNF-like grammar]]. Note however that the grammar properly omits things present in other languages (notably keywords) because it lacks them entirely; the analogs of them are merely parts of the standard language library.
 
=={{header|VBScript}}==
<div style="height:30ex;overflow:scroll"><pre>
!===============================
Line 1,189 ⟶ 1,141:
</pre></div>
 
=={{header[[:Category:Visual Basic .NET|Visual Basic .NET}}]]==
The following link (Appedix B) has a simple BNF Syntax [http://laser.physics.sunysb.edu/~amol/papers/mollypaper.pdf VB Syntax]
<div style="height:30ex;overflow:scroll"><pre>