BNF Grammar: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎Pascal: move to pacsal page)
 
(86 intermediate revisions by 25 users not shown)
Line 1: Line 1:
{{DeprecatedTask}}
{{task|BNF GRAMMAR}}
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.
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: Line 6:
There are many extensions and variants of BNF, including Extended and Augmented Backus–Naur Forms (EBNF and ABNF).
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|4D}}==
=={{header|ALGOL 60}}==
<pre>
! ----------------------------------------------------------------------------
! ALGOL 60
!
! (ALGO)rithmic (L)anguage
!
! ALGOL is, by far, the most influential programming language developed to
! date. Although is did not achieve mass use, a large number of syntactic
! and semantic principles and concepts were developed and incorporated into
! the language. As a result, ALGOL is considered the main reference language
! in computer science.
!
! In the late 1950's, many in the study of computer science believed that a
! new universal programming language was needed. This new language would be
! used through the study of computer science and would eventually replace
! other popular languages such as FORTRAN.
!
! The ACM (Association for Computing Machinery) and GAMM (a European
! organization of mathematics and mechanics) created an international
! committee to define and document the new language. This committee
! included computer scientists from both North America and Europe.
!
! The process of developing ALGOL included a number of challenges:
!
! First, the computers of the era varied greatly in the number of characters
! that could be represented. This made it difficult to define the exact
! lexics of the language. For instance, one mainframe could contain an
! ampersand character (&) while another may not.
!
! Another challenge involved an issue that nowadays seems trival - the
! representation of decimal points. In the 50 United States and Canada, real
! numbers are represented using a period. For instance, the value 4 1/2 can
! be written as "4.5". Europe, on the other hand, uses a comma. The same
! value is represented with "4,5". Both sides were steadfast that their
! format was superior. Although the "period" format would eventually
! dominate, this was a major issue at the time.
!
! To describe the syntax of the first version of ALGOL, Peter Naur modified
! Backus Normal Form to create Backus-Naur Form. This format is now used
! universially to describe the syntax of programming languages.
!
! To spite these challenges, ALGOL created a number of language features
! that would be incorporated into its numerious successors. These include:
!
! * Block structure
! * Free-form structure (elements are not required to be in a specific column)
! * Pass by Name (while powerful, it is not used in modern languages)
! * The For-Loop
! * The 'Else' clause on if-statements (LISP's 'cond' predates this though)
! * Reserved words
!
! The grammar below was, for the most part, cut and pasted from "Revised
! Report on the Algorithmic Language: Algol 60" by Peter Naur. The numbered
! sections refer directly to the chapters in the Report.
!
! The grammar was modified to remove ambigities and define terminals using
! regular expressions.
!
! ----------------------------------------------------------------------------


"Name" = 'ALGOL 60'
"Version" = '1960'

"Author" = 'J.W. Backus, F.L. Bauer, J.Green, C. Katz, J. McCarthy, P. Naur,'
| 'A.J. Perlis, H. Rutishauser, K. Samuelson, B. Vauquois,'
| 'J.H. Wegstein, A. van Wijngaarden, M. Woodger'

"About" = 'ALGOL (ALGOrithmic Language) is the most influential'
| 'programming language to date. Although it did not achieve'
| 'mass use, it established multiple syntactic and semantic'
| 'features used in languages today.'


"Start Symbol" = <program>


! ========================================================== Terminals


{String Ch} = {Printable} - [`] - ['']

Identifier = {Letter}{Alphanumeric}*

String = '`' ( '`' {String Ch}* '' | {String Ch} )* ''

IntegerLiteral = {Digit}+
RealLiteral = {Digit}+ '.' {Digit}+ (e {Digit}+)?


! =========================================================== Rules

<unsigned integer>
::= IntegerLiteral
<unsigned number>
::= IntegerLiteral
| RealLiteral


! ====================================================================
! 2.2.2 Logical values.
! ====================================================================

<logical value> ::= true | false



! ====================================================================
! 3. Expressions
! ====================================================================

<expression>
::= <Boolean expression>

! ====================================================================
! 3.1. Variables
! ====================================================================

<subscript expression>
::= <arithmetic expression>

<subscript list>
::= <subscript expression>
| <subscript list> ',' <subscript expression>


<variable>
::= Identifier
| Identifier '[' <subscript list> ']' ! subscripted value

! ====================================================================
! 3.2. Function designators
! ====================================================================

<actual parameter>
::= String
| <expression>

<parameter delimiter>
::= ','
| ')' Identifier ':' '('


<actual parameter list>
::= <actual parameter>
| <actual parameter list> <parameter delimiter> <actual parameter>


! ====================================================================
! 3.3. Arithmetic expressions
! ====================================================================

<adding operator> ::= '+' | '-'

<multiplying operator> ::= '*' | '/' | 'div'

<primary>
::= <unsigned number>
| <variable>
| Identifier '(' <actual parameter list> ')'
| '(' <arithmetic expression> ')'

<factor>
::= <primary>
| <factor> '^' <primary> !Originally an up-arrow
<term>
::= <factor>
| <term> <multiplying operator> <factor>


<simple arithmetic expression>
::= <term>
| <adding operator> <term>
| <simple arithmetic expression> <adding operator> <term>

<if clause> ::= if <Boolean expression> then

<arithmetic expression>
::= <simple arithmetic expression>
| <if clause> <simple arithmetic expression> else <arithmetic expression>



! ====================================================================
! 3.4. Boolean expressions
! ====================================================================

<relational operator> ::= '<' | '<=' | '=' | '>=' | '>' | '~='


<relation>
::= <relation> <relational operator> <simple arithmetic expression>
| <simple arithmetic expression>

<Boolean primary>
::= <logical value>
| <relation>

<Boolean secondary>
::= <Boolean primary>
| not <Boolean primary>


<Boolean factor>
::= <Boolean secondary>
| <Boolean factor> and <Boolean secondary>

<Boolean term>
::= <Boolean factor>
| <Boolean term> or <Boolean factor>

<implication>
::= <Boolean term>
| <implication> implies <Boolean term>

<simple Boolean>
::= <implication>
| <simple Boolean> eqv <implication>


<Boolean expression>
::= <simple Boolean>
| <if clause> <simple Boolean> else <Boolean expression>


! ====================================================================
! 3.5. Designational expressions
! ====================================================================

<label>
::= Identifier
| <Unsigned Integer>

<switch designator>
::= Identifier '[' <subscript expression> ']'

<simple designational expression>
::= <label>
| <switch designator>
| '(' <designational expression> ')'

<designational expression>
::= <simple designational expression>
| <if clause> <simple designational expression> else <designational expression>


! ====================================================================
! 4.1. Compound statements and blocks
! ====================================================================

<unlabelled basic statement>
::= <assignment statement>
| <go to statement>
| !EMPTY !dummy statement
| <procedure statement>


<basic statement>
::= <unlabelled basic statement>
| <label> ':' <basic statement>

<unconditional statement>
::= <basic statement>
| <compound statement>
| <block>

<statement>
::= <unconditional statement>
| <conditional statement>
| <for statement>

<compound tail>
::= <statement> end
| <statement> ';' <compound tail>

<block head>
::= begin <declaration>
| <block head> ';' <declaration>

<unlabelled block>
::= <block head> ';' <compound tail>

<unlabelled compound>
::= begin <compound tail>

<compound statement>
::= <unlabelled compound>
| <label> ':' <compound statement>

<block>
::= <unlabelled block>
| <label> ':' <block>

<program>
::= <block>
| <compound statement>


! ====================================================================
! 4.2. Assignment statements
! ====================================================================

<left part>
::= <variable> ':='


<left part list>
::= <left part>
| <left part list> <left part>

<assignment statement>
::= <left part list> <Boolean expression>


! ====================================================================
! 4.3. Go to statements
! ====================================================================

<go to statement> ::= goto <designational expression>


! ====================================================================
! 4.4. Dummy statements
! ====================================================================

!<dummy statement> ::= <empty>


! ====================================================================
! 4.5. Conditional statements
! ====================================================================

<if statement> ::= <if clause> <unconditional statement>

<conditional statement>
::= <if statement>
| <if statement> else <statement>
| <if clause> <for statement>
| <label> ':' <conditional statement>


! ====================================================================
! 4.6. For statements
! ====================================================================

<for list element>
::= <arithmetic expression>
| <arithmetic expression> step <arithmetic expression> until <arithmetic expression>
| <arithmetic expression> while <Boolean expression>

<for list>
::= <for list element>
| <for list> ',' <for list element>

<for clause> ::= for <variable> ':=' <for list> do

<for statement>
::= <for clause> <statement>
| <label> ':' <for statement>


! ====================================================================
! 4.7. Procedure statements
! ====================================================================


<procedure statement>
::= Identifier '(' <actual parameter list> ')'
| Identifier


! ====================================================================
! 5. Declarations
! ====================================================================

<declaration>
::= <type declaration>
| <array declaration>
| <switch declaration>
| <procedure declaration>


! ====================================================================
! 5.1. Type declarations
! ====================================================================

<type list>
::= Identifier
| Identifier ',' <type list>

<type>
::= real
| integer
| Boolean

<local or own type>
::= <type>
| own <type>

<type declaration>
::= <local or own type> <type list>


! ====================================================================
! 5.2. Array declarations
! ====================================================================
<lower bound> ::= <arithmetic expression>
<upper bound> ::= <arithmetic expression>
<bound pair> ::= <lower bound> ':' <upper bound>
<bound pair list>
::= <bound pair>
| <bound pair list> ',' <bound pair>
<array segment>
::= Identifier '[' <bound pair list> ']'
| Identifier ',' <array segment>
<array list>
::= <array segment>
| <array list> ',' <array segment>
<array declaration>
::= array <array list>
| <local or own type> array <array list>

! ====================================================================
! 5.3. Switch declarations
! ====================================================================

<switch list>
::= <designational expression>
| <switch list> ',' <designational expression>

<switch declaration>
::= switch Identifier ':=' <switch list>


! ====================================================================
! 5.4. Procedure declarations
! ====================================================================

<formal parameter>
::= Identifier

<formal parameter list>
::= <formal parameter>
| <formal parameter list> <parameter delimiter> <formal parameter>

<formal parameter part>
::= !EMPTY
| '(' <formal parameter list> ')'

<identifier list>
::= Identifier
| <identifier list> ',' Identifier

<value part>
::= value <identifier list> ';'
| !EMPTY

<specifier>
::= string
| <type>
| array
| <type> array
| label
| switch
| procedure
| <type> procedure

<specification part>
::= !EMPTY
| <specification>
!=== The following rule was added

<specification>
::= <specifier> <identifier list> ';'
| <specification> <specifier> <identifier list> ';'



<procedure heading>
::= Identifier <formal parameter part> ';' <value part> <specification part>

<procedure body>
::= <statement>
!!! | <code> !<code> refers to any embedded non-Algol code

<procedure declaration>
::= procedure <procedure heading> <procedure body>
| <type> procedure <procedure heading> <procedure body>


==[[:Category:BASIC|BASIC]]==
</pre>
<div style="height:30ex;overflow:scroll"><pre>
=={{header|ALGOL 68}}==
=={{header|APL}}==
=={{header|AWK}}==
=={{header|ActionScript}}==
=={{header|Ada}}==
=={{header|Agda2}}==
=={{header|AmigaE}}==
=={{header|AppleScript}}==
=={{header|Assembly}}==
=={{header|AutoHotkey}}==
=={{header|BASIC}}==
<pre>
! -----------------------------------------------------------------------
! -----------------------------------------------------------------------
! BASIC '64
! BASIC '64
Line 688: Line 173:
| String
| String
| Real
| Real
</pre>
</pre></div>
==[[:Category:BASIC Commodore PET|BASIC Commodore PET]]==
=={{header|Bc}}==
<div style="height:30ex;overflow:scroll"><pre>
=={{header|Befunge}}==
=={{header|Brainf***}}==
=={{header|C}}==
<pre>
! -----------------------------------------------------------------------
! -----------------------------------------------------------------------
! Commodore PET BASIC
! ANSI C
!
!
! Beginner's All-purpose Symbolic Instruction Code
! The C programming language evolved at Bell Labs from a series of
! programming languages: 'CPL', 'BCPL', and then 'B'. As a result, C's
! development was a combined effort between Dennis Ritchie, Ken Thompson,
! and Martin Richards.
!
!
! "It is practically impossible to teach good programming style to students
! C was designed for the creation and implementation of low-level systems
! that have had prior exposure to BASIC; as potential programmers they are
! such as operating systems, device drivers, firmware, etc... To realize
! mentally mutilated beyond hope of regeneration."
! this goal, the language contains the ability to perform operations
! directly on memory and has direct access to system pointers. While this
! gives an enormous amount of control and flexibility, it also makes C a
! professional programming language - not to be used by an inexperienced
! programmer.
!
!
! - Edsger W. Dijkstra
! C (and later C++) quickly became the de facto standard for developing
! operating systems, applications and most other large projects. UNIX as
! well as Windows, Linux, and Mac-OS X were developed using this
! language (and its successors).
!
!
! More information is available at Dennis Ritchie's website:
! http://cm.bell-labs.com/cm/cs/who/dmr/
!
!
! BASIC is one of the oldest programming language and one of the most popular.
! The C grammar is inherently ambigious and requires a large number of
! It was developed in 1964 by John G. Kemeny and Thomas E. Kurtz to teach
! LALR(1) states to parse. As a result, the time required by the GOLD
! students the basics of programming concepts. At the advent of the microcomputer,
! Parser Builder to compile this grammar is extensive.
! BASIC was implemented on numerous platforms such as the Commodore, Atari,
!
! Apple II, Altair, IBM PC computers. Over time, BASIC evolved into GW-BASIC,
! C is not a line-based grammar with the notable exception of compiler
! QBasic, Visual Basic, and recently Visual Basic .NET.
! directives (which are preceeded by a '#' character). These are usually not
! handled directly by the actual parser, but, rather, the pre-processor.
! Before the program is analyzed by the parser, C compilers scan the code and
! act on these commands. The final C program is then passed to the parser.
! -----------------------------------------------------------------------

! -----------------------------------------------------------------------
! This grammar does not contain the compiler directives.
!
!
! In practically all programming languages, the reserved word/symbol that denotes
! Note: This is an ad hoc version of the language. If there are any flaws,
! a comment is treated as a form of whitespace - having no effect in the manner in
! please visit the contact page and tell me.
! which the program runs. Once such type of comment is used to indicate the remainder
! of the line is to be ignored. These can be added to the end of any line without
! changing the meaning of the program. In C++, it is the '//' symbol.
!
!
! However, in the BASIC programming language, the line comment is treated like a
! SPECIAL THANKS TO:
! statement. For instance, if 'REM' was a normal line comment:
! BOB MEAGHER
! MIKE WISDOM
! VLADIMIR MOROZOV
! TOM VAN DIJCK
!
!
! 10 PRINT "Hello World" REM Common first program
! Modified 06/14/2002
! * The correct definition for "return" was added. Thanks to Bob Meagher.
! * Added the missing rules for labels, storage specifications, etc...
! which were left out. Thanks to Mike Wisdom for calling this to
! my attention.
!
!
! would be a valid statement. However, in BASIC, this is illegal. In the example
! Modified 06/21/2002
! above, the comment must be added as an additional statement.
! * I fixed an error in the grammar for declaring functions.
!
!
! 10 PRINT "Hello World" : REM Common first program
! Modified 06/15/2003
! * Vladimir Morozov fixed an error for calling functions with no parameters
!
!
! As a result, the Line Comment terminal that is used in the GOLD Parser cannot be
! Modified 01/31/2004
! used here. In the grammar below, a 'Remark' terminal was created that accepts all
! * Tom van Dijck found a bug in the grammar concerning variable
! series of printable characters starting with the characters "REM ". In some
! initialization.
! implementations of BASIC, any string starting with "REM" is a comment statement.
!
! Examples include "REMARK", "REMARKABLE" and "REMODEL". This grammar requires the space.
! Modified 04/26/2004
! * Some errors in the grammar were fixed.
!
! Modified 01/19/2005
! * The definition for comments was modified. In ANSI C, block comments
! cannot be nested. As a result, they are defined using the whitespace
! terminal.
!
!
! Modified 03/28/2007
! * The commented-out definition for non-nested comments was updated. The
! previous version did not work in all cases.
! -----------------------------------------------------------------------
! -----------------------------------------------------------------------




"Name" = 'ANSI C'
"Name" = 'Commodore PET BASIC'
"Author" = 'Commodore Business Machines'
"Version" = '1973'
"Version" = '2.0'
"Author" = 'Dennis Ritchie, Ken Thompson, Martin Richards'
"About" = 'C is one of the most common, and complex, programming languages in use today.'
"About" = 'This is the version of BASIC that was used on the Commodore 64.'


"Case Sensitive" = True
"Case Sensitive" = False
"Start Symbol" = <Decls>
"Start Symbol" = <Lines>


{Hex Digit} = {Digit} + [abcdefABCDEF]
{String Chars} = {Printable} - ["]
{WS} = {Whitespace} - {CR} - {LF}
{Oct Digit} = [01234567]


{Id Head} = {Letter} + [_]
NewLine = {CR}{LF}|{CR}
{Id Tail} = {Id Head} + {Digit}
Whitespace = {WS}+


{String Ch} = {Printable} - ["]
Remark = REM{Space}{Printable}*
ID = {Letter}{Alphanumeric}?[$%]? !IDs are can only have a maximum of 2 characters
{Char Ch} = {Printable} - ['']
FunctionID = FN {Letter}{Letter}?


DecLiteral = [123456789]{digit}*
String = '"'{String Chars}*'"'
OctLiteral = 0{Oct Digit}*
Integer = {Digit}+
HexLiteral = 0x{Hex Digit}+
Real = {Digit}+'.'{Digit}+
FloatLiteral = {Digit}*'.'{Digit}+


<Lines> ::= <Lines> <Line>
StringLiteral = '"'( {String Ch} | '\'{Printable} )* '"'
CharLiteral = '' ( {Char Ch} | '\'{Printable} )''
| <Line>


<Line> ::= Integer <Statements> NewLine
Id = {Id Head}{Id Tail}*
<Statements> ::= <Statements> ':' <Statement>
| <Statement>


<Statement> ::= CLOSE Integer
| CLR
| CMD <Expression>
| CONT !Continue
| DATA <Constant List>
| DEF FunctionID '(' <ID List> ')' '=' <Expression> !The ID must start with FN
| DIM ID '(' <Expression List> ')'
| END
| FOR ID '=' <Expression> TO <Expression> <Step Opt>
| GET ID
| GET '#' Integer ',' ID
| GOSUB <Expression>
| GOTO <Expression>
| IF <Expression> THEN <Then Clause>
| INPUT <ID List>
| INPUT '#' Integer ',' <ID List>
| LET ID '=' <Expression>
| LIST <Line Range>
| LOAD <Value List>
| ID '=' <Expression>
| NEW
| NEXT <ID List>
| ON ID GOTO <Expression List>
| OPEN <Expression List>
| POKE <Expression> ',' <Expression>
| PRINT <Print list>
| PRINT '#' Integer ',' <Print List>
| READ <ID List>
| RETURN
| RESTORE
| RUN
| RUN <Expression>
| STOP
| SYS <Expression>
| WAIT <Expression List>
| VERIFY <Expression List>
| Remark


<Step Opt> ::= STEP <Expression>
! ===================================================================
|
! Comments
! ===================================================================
<ID List> ::= ID ',' <ID List>
| ID


<Value List> ::= <Value> ',' <Value List>
Comment Start = '/*'
| <Value>
Comment End = '*/'
Comment Line = '//'


<Constant List> ::= <Constant> ',' <Constant List>
| <Constant>
<Expression List> ::= <Expression> ',' <Expression List>
| <Expression>


<Print List> ::= <Expression> ';' <Print List>
! Typically, C comments cannot be nested. As a result, the
| <Expression>
! Comment Start and Comment End terminals cannot be used.
|
!
! To implement non-nested comments, the whitespace terminal is
! modified to accept them. In the definition below, Whitespace
! is defined as one or more {Whitespace} characters OR a series
! of characters delimited by /* and */. Note that the characters
! between the two delimiters cannot contain the */ sequence.
!
! Uncomment the following to prevent block commments. Make sure
! to comment the Comment Start and Comment End definitions.
!
! {Non Slash} = {Printable} - [/]
! {Non Asterisk} = {Printable} - [*]
!
! Whitespace = {Whitespace}+
! | '/*' ( {Non Asterisk} | '*' {Non Slash}? )* '*/'


<Line Range> ::= Integer
!=======================================================
| Integer '-'
| Integer '-' Integer


<Decls> ::= <Decl> <Decls>
<Then Clause> ::= Integer
|
| <Statement>


! ----------------------------------------------- Expressions
<Decl> ::= <Func Decl>
| <Func Proto>
| <Struct Decl>
| <Union Decl>
| <Enum Decl>
| <Var Decl>
| <Typedef Decl>
! ===================================================================
! Function Declaration
! ===================================================================


<Func Proto> ::= <Func ID> '(' <Types> ')' ';'
<Expression> ::= <And Exp> OR <Expression>
| <Func ID> '(' <Params> ')' ';'
| <And Exp>
| <Func ID> '(' ')' ';'


<Func Decl> ::= <Func ID> '(' <Params> ')' <Block>
<And Exp> ::= <Not Exp> AND <And Exp>
| <Func ID> '(' <Id List> ')' <Struct Def> <Block>
| <Not Exp>
| <Func ID> '(' ')' <Block>


<Params> ::= <Param> ',' <Params>
| <Param>
<Param> ::= const <Type> ID
| <Type> ID
<Types> ::= <Type> ',' <Types>
| <Type>
<Id List> ::= Id ',' <Id List>
| Id

<Func ID> ::= <Type> ID
| ID

! ===================================================================
! Type Declaration
! ===================================================================

<Typedef Decl> ::= typedef <Type> ID ';'

<Struct Decl> ::= struct Id '{' <Struct Def> '}' ';'

<Union Decl> ::= union Id '{' <Struct Def> '}' ';'


<Struct Def> ::= <Var Decl> <Struct Def>
| <Var Decl>

! ===================================================================
! Variable Declaration
! ===================================================================

<Var Decl> ::= <Mod> <Type> <Var> <Var List> ';'
| <Type> <Var> <Var List> ';'
| <Mod> <Var> <Var List> ';'
<Var> ::= ID <Array>
| ID <Array> '=' <Op If>

<Array> ::= '[' <Expr> ']'
| '[' ']'
|
<Var List> ::= ',' <Var Item> <Var List>
|

<Var Item> ::= <Pointers> <Var>

<Mod> ::= extern
| static
| register
| auto
| volatile
| const

! ===================================================================
! Enumerations
! ===================================================================

<Enum Decl> ::= enum Id '{' <Enum Def> '}' ';'
<Enum Def> ::= <Enum Val> ',' <Enum Def>
<Not Exp> ::= NOT <Compare Exp>
| <Enum Val>
| <Compare Exp>


<Compare Exp> ::= <Add Exp> '=' <Compare Exp>
<Enum Val> ::= Id
| Id '=' OctLiteral
| <Add Exp> '<>' <Compare Exp>
| Id '=' HexLiteral
| <Add Exp> '>' <Compare Exp>
| Id '=' DecLiteral
| <Add Exp> '>=' <Compare Exp>
| <Add Exp> '<' <Compare Exp>
| <Add Exp> '<=' <Compare Exp>
| <Add Exp>


<Add Exp> ::= <Mult Exp> '+' <Add Exp>
| <Mult Exp> '-' <Add Exp>
| <Mult Exp>


<Mult Exp> ::= <Negate Exp> '*' <Mult Exp>
! ===================================================================
| <Negate Exp> '/' <Mult Exp>
! Types
| <Negate Exp>
! ===================================================================


<Type> ::= <Base> <Pointers>
<Negate Exp> ::= '-' <Power Exp>
| <Power Exp>


<Power Exp> ::= <Power Exp> '^' <Sub Exp> !On the Commodore, the symbol was an up-arrow
<Base> ::= <Sign> <Scalar>
| struct Id
| <Sub Exp>
| struct '{' <Struct Def> '}'
| union Id
| union '{' <Struct Def> '}'
| enum Id


<Sub Exp> ::= '(' <Expression> ')'
| <Value>


<Sign> ::= signed
<Value> ::= ID
| unsigned
| ABS '(' <Expression> ')'
|
| ASC '(' <Expression> ')'
| ATN '(' <Expression> ')'
| 'CHR$' '(' <Expression> ')'
| COS '(' <Expression> ')'
| EXP '(' <Expression> ')'
| FunctionID '(' <Expression List> ')'
| FRE '(' <Value> ')' !The <Value> is irrelevant
| INT '(' <Expression> ')'
| 'LEFT$' '(' <Expression> ',' <Expression> ')'
| LEN '(' <Expression> ')'
| PEEK '(' <Expression> ')'
| POS '(' <Value> ')' !The <Value> is irrelevant
| 'RIGHT$' '(' <Expression> ',' <Expression> ')'
| RND '(' <Expression> ')'
| SGN '(' <Expression> ')'
| SPC '(' <Expression> ')'
| SQR '(' <Expression> ')'
| TAB '(' <Expression> ')'
| TAN '(' <Expression> ')'
| VAL '(' <Expression> ')'
| <Constant>


<Scalar> ::= char
<Constant> ::= Integer
| int
| String
| short
| Real
| long
| short int
| long int
| float
| double
| void


</pre></div>
<Pointers> ::= '*' <Pointers>
|


==[[:Category:Brainf***|Brainf***]]==
! ===================================================================
! Statements
! ===================================================================


Code ::= Command Code | <NONE>
<Stm> ::= <Var Decl>
| Id ':' !Label
Command ::= "+" | "-" | "<" | ">" | "," | "." | "[" Code "]" | <ANY>
| if '(' <Expr> ')' <Stm>
| if '(' <Expr> ')' <Then Stm> else <Stm>
| while '(' <Expr> ')' <Stm>
| for '(' <Arg> ';' <Arg> ';' <Arg> ')' <Stm>
| <Normal Stm>


==[[:Category:PARI/GP|PARI/GP]]==
<Then Stm> ::= if '(' <Expr> ')' <Then Stm> else <Then Stm>
[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].
| while '(' <Expr> ')' <Then Stm>
| for '(' <Arg> ';' <Arg> ';' <Arg> ')' <Then Stm>
| <Normal Stm>


==[[:Category:PowerShell|PowerShell]]==
<Normal Stm> ::= do <Stm> while '(' <Expr> ')'
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.
| switch '(' <Expr> ')' '{' <Case Stms> '}'
| <Block>
| <Expr> ';'
| goto Id ';'
| break ';'
| continue ';'
| return <Expr> ';'
| ';' !Null statement


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
<lang powershell>for () {}</lang>
but the grammar would require
<lang powershell>for (;;) {}</lang>


==[[:Category:VBScript|VBScript]]==
<Arg> ::= <Expr>
<div style="height:30ex;overflow:scroll"><pre>
|
!===============================

! VB Script grammar.
<Case Stms> ::= case <Value> ':' <Stm List> <Case Stms>
| default ':' <Stm List>
|

<Block> ::= '{' <Stm List> '}'

<Stm List> ::= <Stm> <Stm List>
|


! ===================================================================
! Here begins the C's 15 levels of operator precedence.
! ===================================================================

<Expr> ::= <Expr> ',' <Op Assign>
| <Op Assign>

<Op Assign> ::= <Op If> '=' <Op Assign>
| <Op If> '+=' <Op Assign>
| <Op If> '-=' <Op Assign>
| <Op If> '*=' <Op Assign>
| <Op If> '/=' <Op Assign>
| <Op If> '^=' <Op Assign>
| <Op If> '&=' <Op Assign>
| <Op If> '|=' <Op Assign>
| <Op If> '>>=' <Op Assign>
| <Op If> '<<=' <Op Assign>
| <Op If>

<Op If> ::= <Op Or> '?' <Op If> ':' <Op If>
| <Op Or>

<Op Or> ::= <Op Or> '||' <Op And>
| <Op And>

<Op And> ::= <Op And> '&&' <Op BinOR>
| <Op BinOR>

<Op BinOR> ::= <Op BinOr> '|' <Op BinXOR>
| <Op BinXOR>

<Op BinXOR> ::= <Op BinXOR> '^' <Op BinAND>
| <Op BinAND>

<Op BinAND> ::= <Op BinAND> '&' <Op Equate>
| <Op Equate>

<Op Equate> ::= <Op Equate> '==' <Op Compare>
| <Op Equate> '!=' <Op Compare>
| <Op Compare>

<Op Compare> ::= <Op Compare> '<' <Op Shift>
| <Op Compare> '>' <Op Shift>
| <Op Compare> '<=' <Op Shift>
| <Op Compare> '>=' <Op Shift>
| <Op Shift>

<Op Shift> ::= <Op Shift> '<<' <Op Add>
| <Op Shift> '>>' <Op Add>
| <Op Add>

<Op Add> ::= <Op Add> '+' <Op Mult>
| <Op Add> '-' <Op Mult>
| <Op Mult>

<Op Mult> ::= <Op Mult> '*' <Op Unary>
| <Op Mult> '/' <Op Unary>
| <Op Mult> '%' <Op Unary>
| <Op Unary>

<Op Unary> ::= '!' <Op Unary>
| '~' <Op Unary>
| '-' <Op Unary>
| '*' <Op Unary>
| '&' <Op Unary>
| '++' <Op Unary>
| '--' <Op Unary>
| <Op Pointer> '++'
| <Op Pointer> '--'
| '(' <Type> ')' <Op Unary> !CAST
| sizeof '(' <Type> ')'
| sizeof '(' ID <Pointers> ')'
| <Op Pointer>

<Op Pointer> ::= <Op Pointer> '.' <Value>
| <Op Pointer> '->' <Value>
| <Op Pointer> '[' <Expr> ']'
| <Value>

<Value> ::= OctLiteral
| HexLiteral
| DecLiteral
| StringLiteral
| CharLiteral
| FloatLiteral
| Id '(' <Expr> ')'
| Id '(' ')'

| Id
| '(' <Expr> ')'
</pre>

=={{header|C sharp}}==
=={{header|C++}}==
=={{header|Caml}}==
=={{header|Clean}}==
=={{header|Clojure}}==
=={{header|Cobol}}==
<pre>
! -----------------------------------------------------------------------------
! COBOL 85
!
! COmmon Business Oriented Language
!
!
! The COBOL programmming language is one of the oldest still in use today. It
! was originally designed by the United States Department of defense under the
! supervision of the COnference on DAta SYstems Languages (CODASYL) Committee.
! Most of the groundwork and design of COBOL was done by General Grace Hopper
! of the United States Navy.
!
! The COBOL language was designed to be a self-documenting language where
! programs would read as close to English as possible. All interaction
! between the user, the terminal and files are performed through language
! statements rather than third-party libraries. The metaphor used for data
! types is abstract and completely platform independant. As a result of these
! factors, COBOL is a very portable.
!
! The COBOL 85 grammar is complex - containing, over 350 reserved words,
! 950 rules which results in iver 1,600 LALR states.
!
!
!
! To create the grammar I was using Microsoft's VB Script documentation
! Side Note: General Grace Hopper was the engineer who coined the term "bug"
! available from http://msdn.microsoft.com/scripting,
! when she found an "ill-positioned" insect in an early mainframe.
! VB Script parser from ArrowHead project http://www.tripi.com/arrowhead/,
! and Visual Basic .Net grammar file written by Devin Cook.
!
!
! This grammar cannot cover all aspects of VBScript and may have some errors.
! Revisions:
! Feel free to contact me if you find any flaws in the grammar.
! 09-13-06: Devin Cook
! * Fixed a flaw in the Communications Section where a period was added
! to the end of a terminal rather than as a separate terminal. Thanks
! to Jose Ventura for finding this flaw.
!
!
! Vladimir Morozov vmoroz@hotmail.com
! * Fixed a flaw in the PicString terminal. The definition required two or
! more spaces between PIC and the picture characters. Thanks to Jose
! Ventura for finding this flaw.
!
!
! Special thanks to Nathan Baulch for the grammar updates.
! 07-21-06: Devin Cook
! * The grammar was modified to better handle embeded statements and
! message handling clauses.
!
!
! USE GOLD PARSER BUILDER VERSION 2.1 AND LATER TO COMPILE THIS GRAMMAR.
! 06-12-06: Devin Cook
!===============================
! * Grammar was completed
! -----------------------------------------------------------------------------


"Name" = 'COBOL 85'
"Name" = 'VB Script'
"Author" = 'John G. Kemeny and Thomas E. Kurtz'
"Version" = '1.1'
"Version" = '5.0'
"About" = 'VB Script grammar.'
"Case Sensitive" = False
"Start Symbol" = <Program>


!===============================
"Author" = 'General Grace Hopper (United States Navy) and the CODASYL Committee'
! Character sets
!===============================


{String Char} = {All Valid} - ["]
"About" = 'Originally created in 1960, COBOL (COmmon Business Oriented Language)'
{Date Char} = {Printable} - [#]
| 'is one of the top 5 most popular languages in use today. COBOL was designed'
{ID Name Char} = {Printable} - ['['']']
| 'to be self-documenting by using a structure simular to basic English.'
{Hex Digit} = {Digit} + [abcdef]
| 'This is the full 85 grammar. However, However, differ vendors have'
{Oct Digit} = [01234567]
| 'created specialized dialects. As result, this grammar may not parse'
| 'them. This grammar was written by Devin Cook.'
{WS} = {Whitespace} - {CR} - {LF}
{ID Tail} = {Alphanumeric} + [_]


!===============================
"Case Sensitive" = False
! Terminals
"Start Symbol" = <Program>
!===============================


NewLine = {CR} {LF}
| {CR}
| {LF}
| ':'


! Special white space definition. Whitespace is either space or tab, which
{String Chars 1} = {Printable} - ['']
! can be followed by continuation symbol '_' followed by new line character
{String Chars 2} = {Printable} - ["]
Whitespace = {WS}+
{Id Tail Chars} = {Alphanumeric} + [-]
| '_' {WS}* {CR}? {LF}?


! Special comment definition
StringLiteral = ''{String Chars 1}*'' | '"'{String Chars 2}*'"'
IntLiteral = {Digit}+
Comment Line = ''
| 'Rem'
FloatLiteral = {Digit}+'.'{Digit}+
Identifier = {Letter}{Id Tail Chars}*


! Literals
! -----------------------------------------------------------------------------
StringLiteral = '"' ( {String Char} | '""' )* '"'
! Picture Clause
IntLiteral = {Digit}+
! -----------------------------------------------------------------------------
HexLiteral = '&H' {Hex Digit}+ '&'?
OctLiteral = '&' {Oct Digit}+ '&'?
FloatLiteral = {Digit}* '.' {Digit}+ ( 'E' [+-]? {Digit}+ )?
| {Digit}+ 'E' [+-]? {Digit}+
DateLiteral = '#' {Date Char}+ '#'


! Identifier is either starts with letter and followed by letter,
! TYPE SYMBOLS
! number or underscore, or it can be escaped sequence of any printable
! X
! characters ([] and [_$% :-) @] are valid identifiers)
! 9
ID = {Letter} {ID Tail}*
!
| '[' {ID Name Char}* ']'
! EDITED SYMBOLS
! , B 0 / Simple Insertion
! . Special Insertion
! - CR DB $ Fixed Insertion
! + - $ Floating Insertion
! Z * Suppression and Replacement


! White space is not allowed to be before dot, but allowed to be after it.
IDDot = {Letter} {ID Tail}* '.'
| '[' {ID Name Char}* ']' '.'
| 'And.'
| 'ByRef.'
| 'ByVal.'
| 'Call.'
| 'Case.'
| 'Class.'
| 'Const.'
| 'Default.'
| 'Dim.'
| 'Do.'
| 'Each.'
| 'Else.'
| 'ElseIf.'
| 'Empty.'
| 'End.'
| 'Eqv.'
| 'Erase.'
| 'Error.'
| 'Exit.'
| 'Explicit.'
| 'False.'
| 'For.'
| 'Function.'
| 'Get.'
| 'GoTo.'
| 'If.'
| 'Imp.'
| 'In.'
| 'Is.'
| 'Let.'
| 'Loop.'
| 'Mod.'
| 'New.'
| 'Next.'
| 'Not.'
| 'Nothing.'
| 'Null.'
| 'On.'
| 'Option.'
| 'Or.'
| 'Preserve.'
| 'Private.'
| 'Property.'
| 'Public.'
| 'Redim.'
| 'Rem.'
| 'Resume.'
| 'Select.'
| 'Set.'
| 'Step.'
| 'Sub.'
| 'Then.'
| 'To.'
| 'True.'
| 'Until.'
| 'WEnd.'
| 'While.'
| 'With.'
| 'Xor.'


! The following identifiers should only be used in With statement.
{Pic Ch} = [xa9] + [bpz0*+-,]
! This rule must be checked by contextual analyzer.
{WS} = {Space} + {HT} + {NBSP}
DotID = '.' {Letter} {ID Tail}*
| '.' '[' {ID Name Char}* ']'
| '.And'
| '.ByRef'
| '.ByVal'
| '.Call'
| '.Case'
| '.Class'
| '.Const'
| '.Default'
| '.Dim'
| '.Do'
| '.Each'
| '.Else'
| '.ElseIf'
| '.Empty'
| '.End'
| '.Eqv'
| '.Erase'
| '.Error'
| '.Exit'
| '.Explicit'
| '.False'
| '.For'
| '.Function'
| '.Get'
| '.GoTo'
| '.If'
| '.Imp'
| '.In'
| '.Is'
| '.Let'
| '.Loop'
| '.Mod'
| '.New'
| '.Next'
| '.Not'
| '.Nothing'
| '.Null'
| '.On'
| '.Option'
| '.Or'
| '.Preserve'
| '.Private'
| '.Property'
| '.Public'
| '.Redim'
| '.Rem'
| '.Resume'
| '.Select'
| '.Set'
| '.Step'
| '.Sub'
| '.Then'
| '.To'
| '.True'
| '.Until'
| '.WEnd'
| '.While'
| '.With'
| '.Xor'


DotIDDot = '.' {Letter}{ID Tail}* '.'
PicString = PIC(TURE)? {WS}+ (IS {WS}+)? (CR|DB|[$s])? {Pic Ch}+ ( '('{Number}+')' )? ( [v.] {Pic Ch}+ ( '('{Number}+')' )? )? (CR|DB|[$s])?
| PIC(TURE)? {WS}+ (IS {WS}+)? '' {String Chars 1}* ''
| '.' '[' {ID Name Char}* ']' '.'
| PIC(TURE)? {WS}+ (IS {WS}+)? '"' {String Chars 2}* '"'
| '.And.'
| '.ByRef.'
| '.ByVal.'
| '.Call.'
| '.Case.'
| '.Class.'
| '.Const.'
| '.Default.'
| '.Dim.'
| '.Do.'
| '.Each.'
| '.Else.'
| '.ElseIf.'
| '.Empty.'
| '.End.'
| '.Eqv.'
| '.Erase.'
| '.Error.'
| '.Exit.'
| '.Explicit.'
| '.False.'
| '.For.'
| '.Function.'
| '.Get.'
| '.GoTo.'
| '.If.'
| '.Imp.'
| '.In.'
| '.Is.'
| '.Let.'
| '.Loop.'
| '.Mod.'
| '.New.'
| '.Next.'
| '.Not.'
| '.Nothing.'
| '.Null.'
| '.On.'
| '.Option.'
| '.Or.'
| '.Preserve.'
| '.Private.'
| '.Property.'
| '.Public.'
| '.Redim.'
| '.Rem.'
| '.Resume.'
| '.Select.'
| '.Set.'
| '.Step.'
| '.Sub.'
| '.Then.'
| '.To.'
| '.True.'
| '.Until.'
| '.WEnd.'
| '.While.'
| '.With.'
| '.Xor.'


!===============================
! -----------------------------------------------------------------------------
! Rules
! Main program structure
!===============================
! -----------------------------------------------------------------------------


<NL> ::= NewLine <NL>
<Program>
| NewLine
::= <Identification Division> <Environment Division> <Data Division> <Procedure Division>


<Program> ::= <NLOpt> <GlobalStmtList>
! -----------------------------------------------------------------------------
! Optional Keywords - Often used only for readbility
! -----------------------------------------------------------------------------


!===============================
<ADVANCING Opt> ::= ADVANCING | !Optional
! Rules : Declarations
<ALL Opt> ::= ALL | !Optional
!===============================
<ARE Opt> ::= ARE | !Optional
<AREA Opt> ::= AREA | AREAS | !Optional
<AT Opt> ::= AT | !Optional
<BY Opt> ::= BY | !Optional
<CHARACTERS Opt> ::= CHARACTERS | !Optional
<COLLATING Opt> ::= COLLATING | !Optional
<CONTAINS Opt> ::= CONTAINS | !Optional
<DATA Opt> ::= DATA | !Optional
<EVERY Opt> ::= EVERY | !Optional
<FILE Opt> ::= FILE | !Optional
<FINAL Opt> ::= FINAL | !Optional
<FOR Opt> ::= FOR | !Optional
<GLOBAL Opt> ::= GLOBAL | !Optional
<IN Opt> ::= IN | !Optional
<INDICATE Opt> ::= INDICATE | !Optional
<INITIAL Opt> ::= INITIAL | !Optional
<IS Opt> ::= IS | !Optional
<KEY Opt> ::= KEY | !Optional
<LINE Opt> ::= LINE | !Optional
<LINES Opt> ::= LINE | LINES | !Optional
<MESSAGE opt> ::= MESSAGE | !Optional
<MODE Opt> ::= MODE | !Optional
<NEXT Opt> ::= NEXT | !Optional
<NUMBER Opt> ::= NUMBER | !Optional
<OF Opt> ::= OF | !Optional
<ON Opt> ::= ON | !Optional
<ORDER opt> ::= ORDER | !Optional
<PRINTING Opt> ::= PRINTING | !Optional
<RECORD Opt> ::= RECORD | !Optional
<REFERENCES Opt> ::= REFERENCES | !Optional
<RIGHT Opt> ::= RIGHT | !Optional
<ROUNDED Opt> ::= ROUNDED | !Optional
<STANDARD Opt> ::= STANDARD | !Optional
<SIGN Opt> ::= SIGN | !Optional
<SIZE Opt> ::= SIZE | !Optional
<STATUS Opt> ::= STATUS | !Optional
<SYMBOLIC Opt> ::= SYMBOLIC | !Optional
<TAPE Opt> ::= TAPE | !Optional
<THEN Opt> ::= THEN | !Optional
<THAN Opt> ::= THAN | !Optional
<TO Opt> ::= TO | !Optional
<WHEN Opt> ::= WHEN | !Optional
<WITH Opt> ::= WITH | !Optional


<ClassDecl> ::= 'Class' <ExtendedID> <NL> <MemberDeclList> 'End' 'Class' <NL>
! -----------------------------------------------------------------------------
! Equivelent Keywords
! -----------------------------------------------------------------------------


<MemberDeclList> ::= <MemberDecl> <MemberDeclList>
<THRU>
::= THRU
|
| THROUGH


<MemberDecl> ::= <FieldDecl>
<IS ARE Opt>
::= IS
| <VarDecl>
| ARE
| <ConstDecl>
| !Optional
| <SubDecl>
| <FunctionDecl>
| <PropertyDecl>


<FieldDecl> ::= 'Private' <FieldName> <OtherVarsOpt> <NL>
<CORRESPONDING>
| 'Public' <FieldName> <OtherVarsOpt> <NL>
::= CORRESPONDING
| CORR


<FieldName> ::= <FieldID> '(' <ArrayRankList> ')'
! -----------------------------------------------------------------------------
| <FieldID>
! Clauses Shared By Multiple Rules
! -----------------------------------------------------------------------------


<FieldID> ::= ID
<Giving Clause Opt>
::= GIVING Identifier
| 'Default'
| !Optional
| 'Erase'
| 'Error'
| 'Explicit'
<Pointer Clause>
::= <WITH Opt> POINTER <Variable>
| 'Step'
| !Optional
<File Name>
::= Identifier
| StringLiteral


<VarDecl> ::= 'Dim' <VarName> <OtherVarsOpt> <NL>
<File Name List>
::= <File Name List> <File Name>
| <File Name>


<VarName> ::= <ExtendedID> '(' <ArrayRankList> ')'
<Int Constant>
::= Identifier
| <ExtendedID>
| <Integer>


<OtherVarsOpt> ::= ',' <VarName> <OtherVarsOpt>
<Index Clause>
::= INDEXED <BY Opt> Identifier
|
| !Optional


<ArrayRankList> ::= <IntLiteral> ',' <ArrayRankList>
<BEFORE AFTER>
::= BEFORE
| <IntLiteral>
| AFTER
|


<ConstDecl> ::= <AccessModifierOpt> 'Const' <ConstList> <NL>
! -----------------------------------------------------------------------------
! Values, Literals, etc...
! -----------------------------------------------------------------------------


<ConstList> ::= <ExtendedID> '=' <ConstExprDef> ',' <ConstList>
<Symbolic Value>
::= <Literal>
| <ExtendedID> '=' <ConstExprDef>
| <Variable>
| <Figurative>


<ConstExprDef> ::= '(' <ConstExprDef> ')'
<Values>
::= <Values> <Value>
| '-' <ConstExprDef>
| <Value>
| '+' <ConstExprDef>
| <ConstExpr>
<Value>
::= <Literal>
| <Variable>
<Numeric>
::= <Integer>
| Identifier
<Literal>
::= <Integer>
| FloatLiteral
| StringLiteral
| QUOTE
| QUOTES


<SubDecl> ::= <MethodAccessOpt> 'Sub' <ExtendedID> <MethodArgList> <NL> <MethodStmtList> 'End' 'Sub' <NL>
<Integer>
| <MethodAccessOpt> 'Sub' <ExtendedID> <MethodArgList> <InlineStmt> 'End' 'Sub' <NL>
::= IntLiteral
| '66'
| '77'
| '88'
<Figurative>
::= ZERO
| ZEROS
| ZEROES
| SPACE
| SPACES
| HIGH-VALUE
| HIGH-VALUES
| LOW-VALUE
| LOW-VALUES
| ALL StringLiteral
| NULL
| NULLS


<FunctionDecl> ::= <MethodAccessOpt> 'Function' <ExtendedID> <MethodArgList> <NL> <MethodStmtList> 'End' 'Function' <NL>
<Identifiers>
| <MethodAccessOpt> 'Function' <ExtendedID> <MethodArgList> <InlineStmt> 'End' 'Function' <NL>
::= <Identifiers> Identifier
| Identifier


<MethodAccessOpt> ::= 'Public' 'Default'
<Variables>
| <AccessModifierOpt>
::= <Variables> Identifier
| Identifier


<AccessModifierOpt> ::= 'Public'
<Variable>
::= Identifier
| 'Private'
| Identifier '(' <Subsets> ')'
|


<MethodArgList> ::= '(' <ArgList> ')'
<Subsets>
::= <Subsets> ':' <Numeric>
| '(' ')'
| <Numeric>
|


<ArgList> ::= <Arg> ',' <ArgList>
! -----------------------------------------------------------------------------
| <Arg>
! ------------------------- IDENTIFICATION DIVISION ---------------------------
! -----------------------------------------------------------------------------
<Identification Division>
::= IDENTIFICATION DIVISION '.' <Prog ID> <Program Info Items>
<Prog ID>
::= PROGRAM-ID '.' <Word List> <Prog Name Opt> '.'


<Arg> ::= <ArgModifierOpt> <ExtendedID> '(' ')'
<Program Info Items>
| <ArgModifierOpt> <ExtendedID>
::= <Program Info Items> <Program Info Item>
| !Zero or more
<Program Info Item>
::= AUTHOR '.' <Word List> '.'
| INSTALLATION '.' <Word List> '.'
| DATE-WRITTEN '.' <Word List> '.'
| DATE-COMPILED '.' <Word List> '.'
| SECURITY '.' <Word List> '.'
<Word List>
::= <Word List> <Word Item>
| <Word Item>


<ArgModifierOpt> ::= 'ByVal'
<Word Item>
::= Identifier
| 'ByRef'
| <Integer>
|
| FloatLiteral
| StringLiteral
| '/'
| ','
<Prog Name Opt>
::= <IS Opt> <Common Initial> <Program Opt>
| !Optional
<Common Initial>
::= COMMON
| INITIAL
<Program Opt>
::= PROGRAM
| !Optional
! -----------------------------------------------------------------------------
! -------------------------- ENVIRONMENT DIVISION -----------------------------
! -----------------------------------------------------------------------------


<PropertyDecl> ::= <MethodAccessOpt> 'Property' <PropertyAccessType> <ExtendedID> <MethodArgList> <NL> <MethodStmtList> 'End' 'Property' <NL>
<Environment Division>
::= ENVIRONMENT DIVISION '.' <Config Section> <Input-Output Section>
| !Optional
! -----------------------------------------------------------------------------
! CONFIGURATION SECTION
! -----------------------------------------------------------------------------


<PropertyAccessType> ::= 'Get'
<Config Section>
| 'Let'
::= CONFIGURATION SECTION '.' <Config Section Items>
| !Optional
| 'Set'


!===============================
<Config Section Items>
! Rules : Statements
::= <Config Section Items> <Config Section Item>
!===============================
| !Zero or more


<GlobalStmt> ::= <OptionExplicit>
<Config Section Item>
::= <Source Computer>
| <ClassDecl>
| <Object Computer>
| <FieldDecl>
| <Special Names>
| <ConstDecl>
| <SubDecl>
| <FunctionDecl>
! -----------------------------------------------------------------------------
| <BlockStmt>
! SOURCE-COMPUTER
! -----------------------------------------------------------------------------


<MethodStmt> ::= <ConstDecl>
<Source Computer>
| <BlockStmt>
::= SOURCE-COMPUTER '.' <Source Computer Clause Opt>


<BlockStmt> ::= <VarDecl>
<Source Computer Clause Opt>
| <RedimStmt>
::= Identifier <Source Debug Opt> '.'
| !Optional
| <IfStmt>
| <WithStmt>
| <SelectStmt>
<Source Debug Opt>
::= <WITH Opt> DEBUGGING MODE
| <LoopStmt>
| <ForStmt>
| <InlineStmt> <NL>
! -----------------------------------------------------------------------------
! OBJECT-COMPUTER
! -----------------------------------------------------------------------------
<Object Computer>
::= OBJECT-COMPUTER '.' <Object Computer Clause Opt>


<InlineStmt> ::= <AssignStmt>
<Object Computer Clause Opt>
| <CallStmt>
::= Identifier <Object Clauses> '.'
| !Optional
| <SubCallStmt>
| <ErrorStmt>
| <ExitStmt>
<Object Clauses>
| 'Erase' <ExtendedID>
::= <Object Clause> <Object Clauses>
| !Optional


<GlobalStmtList> ::= <GlobalStmt> <GlobalStmtList>
<Object Clause>
::= <Program Opt> <COLLATING Opt> SEQUENCE <IS Opt> Identifier
|
| SEGMENT-LIMIT <IS Opt> <Integer>
! -----------------------------------------------------------------------------
! SPECIAL-NAMES
! -----------------------------------------------------------------------------
<Special Names>
::= SPECIAL-NAMES '.' <Special Name List>
<Special Name List>
::= <Special Name List> <Special Names Item>
| !Zero or more
<Special Names Item>
::= Identifier <IS Opt> Identifier <Name Status Items> '.'
| Identifier <Name Status Items> '.'
| SYMBOLIC <CHARACTERS Opt> <Symbolic Char List> '.'
| ALPHABET Identifier <IS Opt> <Alphabet Item> '.'
| CLASS Identifier <IS Opt> <Special Ranges> '.'
| CURRENCY <SIGN Opt> <IS Opt> <Literal> '.'
| DECIMAL-POINT <IS Opt> COMMA '.'
<Name Status Items>
::= <Name Status Items> <Name Status Item>
| !Zero or more


<MethodStmtList> ::= <MethodStmt> <MethodStmtList>
<Name Status Item>
::= ON <STATUS Opt> <IS Opt> Identifier
|
| OFF <STATUS Opt> <IS Opt> Identifier
<BlockStmtList> ::= <BlockStmt> <BlockStmtList>
|
<OptionExplicit> ::= 'Option' 'Explicit' <NL>


<ErrorStmt> ::= 'On' 'Error' 'Resume' 'Next'
! -----------------------------------------------
| 'On' 'Error' 'GoTo' IntLiteral ! must be 0


<ExitStmt> ::= 'Exit' 'Do'
<Alphabet Item>
::= STANDARD-1
| 'Exit' 'For'
| STANDARD-2
| 'Exit' 'Function'
| NATIVE
| 'Exit' 'Property'
| Identifier
| 'Exit' 'Sub'
| <Special Ranges>


<AssignStmt> ::= <LeftExpr> '=' <Expr>
<Special Ranges>
::= <Special Ranges> ALSO <Special Range>
| 'Set' <LeftExpr> '=' <Expr>
| <Special Range>
| 'Set' <LeftExpr> '=' 'New' <LeftExpr>


! Hack: VB Script allows to have construct a = b = c, which means a = (b = c)
<Special Range>
! In this grammar we do not allow it in order to prevent complications with
::= <Literal> <THRU> <Literal>
! interpretation of a(1) = 2, which may be considered as array element assignment
! or a subroutine call: a ((1) = 2).
! Note: VBScript allows to have missed parameters: a ,,2,3,
! VM: If somebody knows a better way to do it, please let me know
<SubCallStmt> ::= <QualifiedID> <SubSafeExprOpt> <CommaExprList>
| <QualifiedID> <SubSafeExprOpt>
| <QualifiedID> '(' <Expr> ')' <CommaExprList>
| <QualifiedID> '(' <Expr> ')'
| <QualifiedID> '(' ')'
| <QualifiedID> <IndexOrParamsList> '.' <LeftExprTail> <SubSafeExprOpt> <CommaExprList>
| <QualifiedID> <IndexOrParamsListDot> <LeftExprTail> <SubSafeExprOpt> <CommaExprList>
| <QualifiedID> <IndexOrParamsList> '.' <LeftExprTail> <SubSafeExprOpt>
| <QualifiedID> <IndexOrParamsListDot> <LeftExprTail> <SubSafeExprOpt>


! This very simplified case - the problem is that we cannot use parenthesis in aaa(bbb).ccc (ddd)
! -----------------------------------------------
<SubSafeExprOpt> ::= <SubSafeExpr>
|


<CallStmt> ::= 'Call' <LeftExpr>
<Symbolic Char List>
::= <Symbolic Characters>
| <Symbolic Characters> IN Identifier


<LeftExpr> ::= <QualifiedID> <IndexOrParamsList> '.' <LeftExprTail>
<Symbolic Characters>
| <QualifiedID> <IndexOrParamsListDot> <LeftExprTail>
::= <Symbolic Character> <Symbolic Value>
| <Symbolic Character>
| <QualifiedID> <IndexOrParamsList>
| <QualifiedID>
| <SafeKeywordID>


<LeftExprTail> ::= <QualifiedIDTail> <IndexOrParamsList> '.' <LeftExprTail>
<Symbolic Character>
| <QualifiedIDTail> <IndexOrParamsListDot> <LeftExprTail>
::= Identifier <IS ARE Opt> <Literal>
| <QualifiedIDTail> <IndexOrParamsList>
| <QualifiedIDTail>


! VB Script does not allow to have space between Identifier and dot:
! -----------------------------------------------------------------------------
! a . b - Error ; a. b or a.b - OK
! INPUT-OUTPUT SECTION
<QualifiedID> ::= IDDot <QualifiedIDTail>
! -----------------------------------------------------------------------------
| DotIDDot <QualifiedIDTail>
| ID
<Input-Output Section>
| DotID
::= INPUT-OUTPUT SECTION '.' <File-Control> <I-O-Control>
| !Optional
! -----------------------------------------------------------------------------
! FILE-CONTROL
! -----------------------------------------------------------------------------
<File-Control>
::= FILE-CONTROL '.' <Select Block>
| !Optional
<Select Block>
::= <Select Block> <Select Paragraph>
| !Optional
<Select Paragraph>
::= SELECT <Optional Opt> Identifier ASSIGN <TO Opt> Identifier <Select Opt List> '.'


<QualifiedIDTail> ::= IDDot <QualifiedIDTail>
<Optional Opt>
::= OPTIONAL
| ID
| !Null
| <KeywordID>
<Select Opt List>
::= <Select Option> <Select Opt List>
| !Zero or more
<Select Option>
::= RESERVE <Integer> <AREA Opt>
| ORGANIZATION <IS Opt> <Organization Kind>
| <Organization Kind>
| PADDING <Character Opt> <IS Opt> <Padding Kind>
| RECORD DELIMITER <IS Opt> <Record Delimiter Kind>
| RECORD <KEY Opt> <IS Opt> Identifier
| ALTERNATIVE RECORD <KEY Opt> <IS Opt> Identifier <Duplicates Clause Opt>


| ACCESS <MODE Opt> <IS Opt> <Access Mode>
<KeywordID> ::= <SafeKeywordID>
| <FILE Opt> STATUS <IS Opt> Identifier
| 'And'
| 'ByRef'
| 'ByVal'
<Access Mode>
::= SEQUENTIAL
| 'Call'
| RANDOM
| 'Case'
| DYNAMIC
| 'Class'
| 'Const'
| 'Dim'
<Organization Kind>
::= SEQUENTIAL
| 'Do'
| LINE SEQUENTIAL
| 'Each'
| RELATIVE <Relative Key Opt>
| 'Else'
| INDEXED
| 'ElseIf'
| 'Empty'
| 'End'
<Relative Key Opt>
::= <KEY Opt> <IS Opt> Identifier
| 'Eqv'
| !Optional
| 'Exit'
| 'False'
| 'For'
<Record Delimiter Kind>
::= STANDARD-1
| 'Function'
| Identifier
| 'Get'
| 'GoTo'
| 'If'
| 'Imp'
| 'In'
| 'Is'
| 'Let'
| 'Loop'
| 'Mod'
| 'New'
| 'Next'
| 'Not'
| 'Nothing'
| 'Null'
| 'On'
| 'Option'
| 'Or'
| 'Preserve'
| 'Private'
| 'Public'
| 'Redim'
| 'Resume'
| 'Select'
| 'Set'
| 'Sub'
| 'Then'
| 'To'
| 'True'
| 'Until'
| 'WEnd'
| 'While'
| 'With'
| 'Xor'


<SafeKeywordID> ::= 'Default'
<Padding Kind>
::= Identifier
| 'Erase'
| <Literal>
| 'Error'
| 'Explicit'
| 'Property'
| 'Step'


<ExtendedID> ::= <SafeKeywordID>
<Duplicates Clause Opt>
::= <WITH Opt> DUPLICATES
| ID
| !Optional


<IndexOrParamsList> ::= <IndexOrParams> <IndexOrParamsList>
! -----------------------------------------------------------------------------
| <IndexOrParams>
! I-O CONTROL
! -----------------------------------------------------------------------------


<IndexOrParams> ::= '(' <Expr> <CommaExprList> ')'
<I-O-Control>
::= I-O-CONTROL '.' <Rerun List> <Same List> <Multiple List> '.'
| '(' <CommaExprList> ')'
| '(' <Expr> ')'
| '(' ')'
<Rerun List>
::= <Rerun List> <Rerun Item>
| !Zero or more


<IndexOrParamsListDot> ::= <IndexOrParams> <IndexOrParamsListDot>
<Rerun Item>
| <IndexOrParamsDot>
::= RERUN <Rerun Clause Opt> <EVERY Opt> <Every Clause>
<Rerun Clause Opt>
::= ON <File Name>
| !Optional


<IndexOrParamsDot> ::= '(' <Expr> <CommaExprList> ').'
<Every Clause>
::= <End Of Opt> <Every End Target> <OF Opt> <File Name>
| '(' <CommaExprList> ').'
| <Integer> RECORDS
| '(' <Expr> ').'
| <Integer> CLOCK-UNITS
| '(' ').'
| Identifier


<CommaExprList> ::= ',' <Expr> <CommaExprList>
<End Of Opt>
::= END <OF Opt>
| ',' <CommaExprList>
| !Optional
| ',' <Expr>
| ','


!========= Redim Statement
<Every End Target>
::= REEL
| UNIT


<RedimStmt> ::= 'Redim' <RedimDeclList> <NL>
! -----------------------------------------------
| 'Redim' 'Preserve' <RedimDeclList> <NL>


<RedimDeclList> ::= <RedimDecl> ',' <RedimDeclList>
<Same List>
::= <Same List> <Same Item>
| <RedimDecl>
| !Zero or more


<RedimDecl> ::= <ExtendedID> '(' <ExprList> ')'
<Same Item>
::= SAME <Same Source> <AREA Opt> <File Name> <File Name List>


!========= If Statement
<Same Source>
::= RECORD
| SORT
| SORT-MERGE


<IfStmt> ::= 'If' <Expr> 'Then' <NL> <BlockStmtList> <ElseStmtList> 'End' 'If' <NL>
<Multiple List>
| 'If' <Expr> 'Then' <InlineStmt> <ElseOpt> <EndIfOpt> <NL>
::= <Multiple List> <Multiple Item>
| !Zero or more


<ElseStmtList> ::= 'ElseIf' <Expr> 'Then' <NL> <BlockStmtList> <ElseStmtList>
<Multiple Item>
| 'ElseIf' <Expr> 'Then' <InlineStmt> <NL> <ElseStmtList>
::= MULTIPLE FILE <TAPE Opt> <CONTAINS Opt> <Contain List>
| 'Else' <InlineStmt> <NL>
| 'Else' <NL> <BlockStmtList>
|


<ElseOpt> ::= 'Else' <InlineStmt>
<Contain List>
::= <Contain List> <Contain Item>
|
| <Contain Item>


<EndIfOpt> ::= 'End' 'If'
<Contain Item>
::= <File Name> POSITION <IS Opt> <Integer>
|
| <File Name>


!========= With Statement
! -----------------------------------------------------------------------------
! ------------------------------ DATA DIVISION --------------------------------
! -----------------------------------------------------------------------------
<Data Division>
::= DATA DIVISION '.' <Data Section List>
<Data Section List>
::= <Data Section Entry> <Data Section List>
| !Zero or more
<Data Section Entry>
::= <File Section>
| <Working-Storage Section>
| <Linkage Section>
| <Screen Section>
| <Communication Section>
| <Report Section>
! -----------------------------------------------------------------------------
! Record Definition
! -----------------------------------------------------------------------------
<Record Entry Block>
::= <Record Entry Block> <Record Entry>
| !Zero or more


<WithStmt> ::= 'With' <Expr> <NL> <BlockStmtList> 'End' 'With' <NL>
<Record Entry>
::= IntLiteral <Level Name> <Record Option List> '.' !Normal Record
| '66' <Level Name> RENAMES <Identifier Range> '.'
| '77' <Level Name> <Record Option List> '.' !Constant
| '88' <Level Name> VALUES <IS ARE Opt> <Values> '.'
<Level Name>
::= Identifier
| FILLER
<Times Opt>
::= TIMES
| !Optional


!========= Loop Statement
<Record Option List>
::= <Record Option List> <Record Option>
| !Zero or more


<LoopStmt> ::= 'Do' <LoopType> <Expr> <NL> <BlockStmtList> 'Loop' <NL>
| 'Do' <NL> <BlockStmtList> 'Loop' <LoopType> <Expr> <NL>
| 'Do' <NL> <BlockStmtList> 'Loop' <NL>
| 'While' <Expr> <NL> <BlockStmtList> 'WEnd' <NL>


<LoopType> ::= 'While'
<Record Option>
::= REDEFINES Identifier
| 'Until'
| <IS Opt> EXTERNAL
| <IS Opt> INTERNAL
| <Picture>
| USAGE <IS Opt> <Usage Args>
| <Usage Args>


!========= For Statement
| SIGN <IS Opt> <Sign Args> <Sep Char Option>
| OCCURS <Numeric> <Times Opt> <Key Clause> <Index Clause>
| OCCURS <Numeric> TO <Numeric> <Times Opt> DEPENDING <ON Opt> Identifier <Key Clause> <Index Clause>
| SYNCHRONIZED <Left Right Opt>
| SYNC <Left Right Opt>
| JUSTIFIED <RIGHT Opt>
| JUST <RIGHT Opt>
| BLANK <WHEN Opt> ZERO
| VALUE <IS Opt> <Symbolic Value>


<ForStmt> ::= 'For' <ExtendedID> '=' <Expr> 'To' <Expr> <StepOpt> <NL> <BlockStmtList> 'Next' <NL>
<Picture>
| 'For' 'Each' <ExtendedID> 'In' <Expr> <NL> <BlockStmtList> 'Next' <NL>
::= PicString


<StepOpt> ::= 'Step' <Expr>
<Key Clause>
::= ASCENDING <KEY Opt> <IS Opt> <Identifiers>
|
| DESCENDING <KEY Opt> <IS Opt> <Identifiers>
| !Optional


!========= Select Statement
<Usage Args>
::= BINARY
| COMPUTATIONAL
| COMP
| DISPLAY
| INDEX
| PACKED-DECIMAL
<Sign Args>
::= LEADING
| TRAILING
<Sep Char Option>
::= SEPARATE <Character Opt>
| !Optional
<Character Opt>
::= CHARACTER
| !Optional


<SelectStmt> ::= 'Select' 'Case' <Expr> <NL> <CaseStmtList> 'End' 'Select' <NL>
<Left Right Opt>
::= LEFT
| RIGHT
| !Optional
! -----------------------------------------------------------------------------
! FILE SECTION
! -----------------------------------------------------------------------------


<CaseStmtList> ::= 'Case' <ExprList> <NLOpt> <BlockStmtList> <CaseStmtList>
<File Section>
::= FILE SECTION '.' <File Desc Block>
| 'Case' 'Else' <NLOpt> <BlockStmtList>
|
<File Desc Block>
::= <File Desc Entry> <File Desc Block>
| !Zero ore more
<File Desc Entry>
::= FD Identifier <File Option List> '.' <Record Entry Block>
| SD Identifier <File Option List> '.' <Record Entry Block>
<File Option List>
::= <File Option List> <File Option>
| !Zero or more


<NLOpt> ::= <NL>
<File Option>
::= <File Is Option>
|
| <File Block Option>
| <File Record Option>
| <File Label Option>
| <File Value Option>
| <File Data Option>
| <File Linage Option>
| <File Code-Set Option>


<ExprList> ::= <Expr> ',' <ExprList>
! -----------------------------------------------------------------------------
| <Expr>
! Description Clauses
! -----------------------------------------------------------------------------


!===============================
<File Is Option>
! Rules : Expressions
::= <IS Opt> EXTERNAL
!===============================
| <IS Opt> INTERNAL


<SubSafeExpr> ::= <SubSafeImpExpr>
! -----------------------------------------------


<SubSafeImpExpr> ::= <SubSafeImpExpr> 'Imp' <EqvExpr>
<File Block Option>
::= BLOCK <CONTAINS Opt> <Numeric> <File Block Units>
| <SubSafeEqvExpr>
| BLOCK <CONTAINS Opt> <Numeric> TO <Numeric> <File Block Units>


<SubSafeEqvExpr> ::= <SubSafeEqvExpr> 'Eqv' <XorExpr>
<File Block Units>
| <SubSafeXorExpr>
::= RECORDS
| CHARACTERS
| !Optional - defaults to characters.


<SubSafeXorExpr> ::= <SubSafeXorExpr> 'Xor' <OrExpr>
! -----------------------------------------------
| <SubSafeOrExpr>
<File Record Option>
::= RECORD <CONTAINS Opt> <Numeric> <CHARACTERS Opt>
| RECORD <CONTAINS Opt> <Numeric> TO <Numeric> <CHARACTERS Opt>
| RECORD <IS Opt> VARYING <IN Opt> <SIZE Opt> <File Record Size Clause> <File Record Depending Clause>


<SubSafeOrExpr> ::= <SubSafeOrExpr> 'Or' <AndExpr>
<File Record Size Clause>
| <SubSafeAndExpr>
::= FROM <Numeric> <CHARACTERS Opt>
| TO <Numeric> <CHARACTERS Opt>
| FROM <Numeric> TO <Numeric> <CHARACTERS Opt>
| !Optional


<SubSafeAndExpr> ::= <SubSafeAndExpr> 'And' <NotExpr>
<File Record Depending Clause>
| <SubSafeNotExpr>
::= DEPENDING <ON Opt> Identifier
| !Optional


<SubSafeNotExpr> ::= 'Not' <NotExpr>
! -----------------------------------------------
| <SubSafeCompareExpr>


<SubSafeCompareExpr> ::= <SubSafeCompareExpr> 'Is' <ConcatExpr>
<File Label Option>
::= LABEL RECORD <IS Opt> <File Label Type>
| <SubSafeCompareExpr> 'Is' 'Not' <ConcatExpr>
| LABEL RECORDS <IS Opt> <File Label Type>
| <SubSafeCompareExpr> '>=' <ConcatExpr>
| <SubSafeCompareExpr> '=>' <ConcatExpr>
| <SubSafeCompareExpr> '<=' <ConcatExpr>
| <SubSafeCompareExpr> '=<' <ConcatExpr>
| <SubSafeCompareExpr> '>' <ConcatExpr>
| <SubSafeCompareExpr> '<' <ConcatExpr>
| <SubSafeCompareExpr> '<>' <ConcatExpr>
| <SubSafeCompareExpr> '=' <ConcatExpr>
| <SubSafeConcatExpr>


<SubSafeConcatExpr> ::= <SubSafeConcatExpr> '&' <AddExpr>
<File Label Type>
| <SubSafeAddExpr>
::= STANDARD
| OMITTED


<SubSafeAddExpr> ::= <SubSafeAddExpr> '+' <ModExpr>
! -----------------------------------------------
| <SubSafeAddExpr> '-' <ModExpr>
| <SubSafeModExpr>


<SubSafeModExpr> ::= <SubSafeModExpr> 'Mod' <IntDivExpr>
<File Value Option>
::= VALUE OF <File Value List>
| <SubSafeIntDivExpr>


<SubSafeIntDivExpr> ::= <SubSafeIntDivExpr> '\' <MultExpr>
<File Value List>
::= <File Value List> <File Value Item>
| <SubSafeMultExpr>
| <File Value Item>


<SubSafeMultExpr> ::= <SubSafeMultExpr> '*' <UnaryExpr>
<File Value Item>
| <SubSafeMultExpr> '/' <UnaryExpr>
::= Identifier <IS Opt> Identifier
| Identifier <IS Opt> <Literal>
| <SubSafeUnaryExpr>


<SubSafeUnaryExpr> ::= '-' <UnaryExpr>
! -----------------------------------------------
| '+' <UnaryExpr>
| <SubSafeExpExpr>


<SubSafeExpExpr> ::= <SubSafeValue> '^' <ExpExpr>
<File Data Option>
::= DATA RECORD <IS Opt> <Identifiers>
| <SubSafeValue>
| DATA RECORDS <ARE Opt> <Identifiers>


<SubSafeValue> ::= <ConstExpr>
! -----------------------------------------------
| <LeftExpr>
! | '(' <Expr> ')'


<Expr> ::= <ImpExpr>
<File Linage Option>
::= LINAGE <IS Opt> <Int Constant> <LINES Opt> <File Linage Footing> <File Linage Top> <File Linage Bottom>
<File Linage Footing>
::= <WITH Opt> FOOTING <AT Opt> <Int Constant>
! Optional


<ImpExpr> ::= <ImpExpr> 'Imp' <EqvExpr>
<File Linage Top>
::= <LINES Opt> <AT Opt> TOP <Int Constant>
| <EqvExpr>
! Optional


<EqvExpr> ::= <EqvExpr> 'Eqv' <XorExpr>
<File Linage Bottom>
::= <LINES Opt> <AT Opt> BOTTOM <Int Constant>
| <XorExpr>
! Optional


<XorExpr> ::= <XorExpr> 'Xor' <OrExpr>
! -----------------------------------------------
| <OrExpr>


<OrExpr> ::= <OrExpr> 'Or' <AndExpr>
<File Code-Set Option>
::= CODE-SET <IS Opt> Identifier
| <AndExpr>


<AndExpr> ::= <AndExpr> 'And' <NotExpr>
! -----------------------------------------------------------------------------
| <NotExpr>
! WORKING-STORAGE SECTION
! -----------------------------------------------------------------------------


<NotExpr> ::= 'Not' <NotExpr>
<Working-Storage Section>
| <CompareExpr>
::= WORKING-STORAGE SECTION '.' <Record Entry Block>
! -----------------------------------------------------------------------------
! LINKAGE SECTION
! -----------------------------------------------------------------------------


<CompareExpr> ::= <CompareExpr> 'Is' <ConcatExpr>
<Linkage Section>
| <CompareExpr> 'Is' 'Not' <ConcatExpr>
::= LINKAGE SECTION '.' <Record Entry Block>
| <CompareExpr> '>=' <ConcatExpr>
| <CompareExpr> '=>' <ConcatExpr>
| <CompareExpr> '<=' <ConcatExpr>
| <CompareExpr> '=<' <ConcatExpr>
| <CompareExpr> '>' <ConcatExpr>
| <CompareExpr> '<' <ConcatExpr>
| <CompareExpr> '<>' <ConcatExpr>
| <CompareExpr> '=' <ConcatExpr>
| <ConcatExpr>


<ConcatExpr> ::= <ConcatExpr> '&' <AddExpr>
! -----------------------------------------------------------------------------
| <AddExpr>
! SCREEN SECTION
! -----------------------------------------------------------------------------


<AddExpr> ::= <AddExpr> '+' <ModExpr>
<Screen Section>
::= SCREEN SECTION '.' <Screen Field List>
| <AddExpr> '-' <ModExpr>
| <ModExpr>
<Screen Field List>
::= <Screen Field> <Screen Field List>
| <Screen Field>
<Screen Field>
::= <Integer> <Field Name opt> <Field Def List> '.'
<Field Name opt>
::= Identifier
| !Optional
<Field Def List>
::= <Field Def List> <Field Def Item>
| !Optional
<Field Def Item>
::= LINE <Numeric>
| COLUMN <Numeric>
| FOREGROUND-COLOR <Numeric>
| BACKGROUND-COLOR <Numeric>
| VALUE <IS Opt> <Symbolic Value>
| <Picture>
| FROM Identifier
| USING Identifier
| HIGHLIGHT
| REVERSE-VIDEO
| BLINK
| UNDERLINE
| BLANK SCREEN
! -----------------------------------------------------------------------------
! COMMUNICATION SECTION
! -----------------------------------------------------------------------------


<ModExpr> ::= <ModExpr> 'Mod' <IntDivExpr>
<Communication Section>
| <IntDivExpr>
::= COMMUNICATION SECTION '.' <Comm Desc List>


<IntDivExpr> ::= <IntDivExpr> '\' <MultExpr>
<Comm Desc List>
::= <Comm Desc List> <Comm Desc>
| <MultExpr>
| !Zero or more


<MultExpr> ::= <MultExpr> '*' <UnaryExpr>
<Comm Desc>
::= CD Identifier <FOR Opt> <INITIAL Opt> INPUT <Comm Input Body> '.' <Record Entry Block>
| <MultExpr> '/' <UnaryExpr>
| CD Identifier <FOR Opt> OUTPUT <Comm Output Options> '.' <Record Entry Block>
| <UnaryExpr>
| CD Identifier <FOR Opt> <INITIAL Opt> I-O <Comm I-O Body> '.' <Record Entry Block>


<UnaryExpr> ::= '-' <UnaryExpr>
<Comm Input Body>
::= <Identifiers>
| '+' <UnaryExpr>
| <Comm Input Options>
| <ExpExpr>


<ExpExpr> ::= <Value> '^' <ExpExpr>
<Comm Input Options>
::= <Comm Input Options> <Comm Input Option>
| <Value>
| !Zero ore more


<Value> ::= <ConstExpr>
<Comm Input Option>
::= <SYMBOLIC Opt> QUEUE <IS Opt> Identifier
| <LeftExpr>
| <SYMBOLIC Opt> SUB-QUEUE-1 <IS Opt> Identifier
| '(' <Expr> ')'
| <SYMBOLIC Opt> SUB-QUEUE-2 <IS Opt> Identifier
| <SYMBOLIC Opt> SUB-QUEUE-3 <IS Opt> Identifier
| MESSAGE DATE <IS Opt> Identifier
| MESSAGE TIME <IS Opt> Identifier
| <SYMBOLIC Opt> SOURCE <IS Opt> Identifier
| TEXT LENGTH <IS Opt> <Numeric>
| END KEY <IS Opt> Identifier
| STATUS KEY <IS Opt> Identifier
| MESSAGE COUNT <IS Opt> Identifier
<Comm Output Options>
::= <Comm Output Options> <Comm Output Option>
| !Zero or more


<ConstExpr> ::= <BoolLiteral>
<Comm Output Option>
| <IntLiteral>
::= DESTINATION TABLES OCCURS <Numeric> <TIMES Opt> <Index Clause>
| DESTINATION COUNT <IS Opt> Identifier
| FloatLiteral
| TEXT LENGTH <IS Opt> Identifier
| StringLiteral
| STATUS KEY <IS Opt> Identifier
| DateLiteral
| ERROR KEY <IS Opt> Identifier
| <Nothing>
| SYMBOLIC DESTINATION <IS Opt> Identifier
| DESTINATION <IS Opt> Identifier


<BoolLiteral> ::= 'True'
<Comm I-O Body>
::= <Identifiers>
| 'False'
| <Comm I-O Options>


<IntLiteral> ::= IntLiteral
<Comm I-O Options>
::= <Comm I-O Options> <Comm I-O Option>
| HexLiteral
| !Zero or more
| OctLiteral


<Nothing> ::= 'Nothing'
<Comm I-O Option>
::= MESSAGE DATE <IS Opt> Identifier
| 'Null'
| MESSAGE TIME <IS Opt> Identifier
| 'Empty'
</pre></div>
| <SYMBOLIC Opt> TERMINAL <IS Opt> Identifier
| TEXT LENGTH <IS Opt> <Numeric>
| END KEY <IS Opt> Identifier
| STATUS KEY <IS Opt> Identifier


==[[: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]
! REPORT SECTION
<div style="height:30ex;overflow:scroll"><pre>
! -----------------------------------------------------------------------------
! -----------------------------------------------------------------------
! Visual Basic .NET
!
! Visual Basic .NET is the latest version in the long evoluation of the
! BASIC programming language. The Visual Basic .NET programming language
! is far more "clean" and orthagonal than its predecessors. Although some
! of the old constructs exist, the language is far easier to read and write.
!
! Major syntax changes include, but are not limited to:
!
! 1. The primative file access of VB6 was replaced by a class library. As
! a result, special statements such as
!
! Open "test" For Input As #1
!
! no longer exist.
!
! 2. Class module files were replaced by 'Class ... End Class' declarations
!
! 3. Module files were replaced by 'Module ... End Module' declarations
!
! 4. Structured error handling was added with C++ style Try ... Catch
! statements. The old nonstructured approach is still, unfortunately,
! available.
!
! Unfortnately, the designers of Visual Basic .NET did not remove the
! datatype postfix characters on identifiers. In the original BASIC,
! variables types were determined by $ for strings and % for integers.
! QuickBasic expanded the postix notation to include other symbols
! for long integers, singles, etc...
!
! Part of the ID terminal definition was commented out to prevent the
! old format. You can allow the postfix characters if you like.
!
! This grammar also does not contain the compiler directives.
!
! Note: This is an ad hoc version of the language. If there are any flaws,
! please visit www.DevinCook.com/GOLDParser
!
! Updates:
! 04/082005
! Devin Cook
! 1. Removed minus sign from the IntLiteral and RealLiteral
! definitions. These can cause some parse errors when expressions
! like "2-2" are read. In this case it would have been interpreted
! as "2" and "-2" rather than "2", "-" and "2".
! 2. Members of an enumeration can be defined with any expression.
! 3. Made some very minor comment changes - mainly for readability.
!
! 03/27/2005
! Adrian Moore [adrianrob@hotmail.com]
! 1. Add support for Implements in Class
! 2. Add support for AddressOf keyword
! 3. No longer fails if variable starts with _
!
! 02/24/2004
! Vladimir Morozov [vmoroz@hotmail.com] fixed a few flaws in the
! grammar. 1. The definition for strings did not allow the double
! double-quote override. 2. A real literal does not need to have a
! fraction if followed by an exponent. 3. Escaped identifiers can
! contain a null string and 4. Rem works the same as the '
!
!
! USE GOLD PARSER BUILDER VERSION 2.1 AND LATER TO COMPILE THIS GRAMMAR.
! Earlier versions cannot handle the complexity.
! -----------------------------------------------------------------------


"Name" = 'Visual Basic .NET'
<Report Section>
"Author" = 'John G. Kemeny and Thomas E. Kurtz'
::= REPORT SECTION '.' <Report Desc List>
"Version" = '.NET'
"About" = 'Visual Basic .NET is the latest version in the long evoluation of the'
| 'BASIC programming language.'


"Case Sensitive" = False
<Report Desc List>
"Start Symbol" = <Program>
::= <Report Desc List> <Report Desc>
| !Zero or more


! ----------------------------------------------------------------- Sets
<Report Desc>
::= RD Identifier <Report Options> <Report Entry Block>
<Report Options>
::= <Report Options> <Report Option>
| !Zero or more


{String Chars} = {Printable} - ["]
<Report Option>
{Date Chars} = {Printable} - [#]
::= <IS Opt> GLOBAL
{ID Name Chars} = {Printable} - ['['']']
| CODE <Literal>
{Hex Digit} = {Digit} + [abcdef]
| <CONTROL IS> <FINAL Opt> <Identifiers>
{Oct Digit} = [01234567]
| PAGE <LIMITS IS Opt> <Numeric> <LINES Opt> <Report Heading Opt>


{WS} = {Whitespace} - {CR} - {LF}
<CONTROL IS>
::= CONTROL IS
{Id Tail} = {Alphanumeric} + [_]
| CONTROLS ARE


! ----------------------------------------------------------------- Terminals
<LIMITS IS Opt>
::= LIMIT IS
| LIMITS ARE
| !Optional


NewLine = {CR}{LF} | {CR} | ':'
<Report Heading Opt>
Whitespace = {WS}+ | '_' {WS}* {CR} {LF}?
::= HEADING <Integer>
| !Optional


Comment Line = '' | Rem !Fixed by Vladimir Morozov
<Report Entry Block>
::= <Report Entry Block> <Report Entry>
| !Zero or more


LABEL = {Letter}{ID Tail}*':'
<Report Entry>
::= <Integer> Identifier <Report Entry Options> '.'


!Fixed by Vladimir Morozov
<Report Entry Options>
::= <Report Entry Option> <Report Entry Options>
| !Zero or more


ID = [_]?{Letter}{ID Tail}* ! [%&@!#$]? !Archaic postfix chars
<Report Entry Option>
::= LINE <NUMBER Opt> <IS Opt> <Numeric>
| '[' {ID Name Chars}* ']'
| LINE <NUMBER Opt> <IS Opt> <Numeric> ON NEXT PAGE !Same as above
QualifiedID = ({Letter}{ID Tail}* | '['{ID Name Chars}*']') ( '.'({Letter}{ID Tail}* | '['{ID Name Chars}*']') )+
| LINE <NUMBER Opt> <IS Opt> PLUS <Numeric>
| NEXT GROUP <IS Opt> <Report Entry Next Group>
| TYPE <IS Opt> <Report Entry Type>
| USAGE <IS Opt> DISPLAY
| DISPLAY


MemberID = '.' {Letter}{ID Tail}*
| <Picture>
| SIGN <IS Opt> <Sign Args> <Sep Char Option>
| '.[' {ID Name Chars}* ']'
| JUSTIFIED <RIGHT Opt>
!Fixed by Vladimir Morozov
| JUST <RIGHT Opt>
StringLiteral = '"' ( {String Chars} | '""' )* '"'
| BLANK <WHEN Opt> ZERO
| COLUMN <Number Opt> <IS Opt> <Numeric>
| SOURCE <IS Opt> <Numeric>
| VALUE <IS Opt> <Symbolic Value>
| SUM <Identifiers>
| SUM <Identifiers> UPON <Identifiers> <Report Entry Result Clause>
| GROUP <INDICATE Opt>


<Report Entry Next Group>
::= <Numeric>
| PLUS <Numeric>
| NEXT PAGE


CharLiteral = '"' {String Chars}* '"C'
<Report Entry Type>
IntLiteral = {digit}+ [FRDSIL]?
::= REPORT HEADING
| RH !Report Heading
| PAGE HEADING
| PH !Page Heading
| CONTROL HEADING
| CH !Control Heading
| DETAIL
| DE !Detail
| CONTROL FOOTING
| CF !Control Footing
| PAGE FOOTING
| PF !Page Footing
| REPORT FOOTING
| RF !Report Footing


RealLiteral = {digit}* '.' {digit}+ ( 'E' [+-]? {Digit}+ )? [FR]?
| {digit}+ 'E' [+-]? {Digit}+ [FR]?


<Report Entry Result Clause>
::= RESET <ON Opt> Identifier
| RESET <ON Opt> FINAL
| !Optional


DateLiteral = '#'{Date chars}'#'
! ------------------------------------------------------------------------------
! --------------------------- PROCEDURE DIVISION -------------------------------
! ------------------------------------------------------------------------------
<Procedure Division>
::= PROCEDURE DIVISION <Using Clause Opt> <Declarative Block> '.' <Paragraphs>


HexLiteral = '&H'{Hex Digit}+ [SIL]?
<Using Clause Opt>
OctLiteral = '&O'{Oct Digit}+ [SIL]?
::= USING <Identifiers>
| !Optional
<Paragraphs>
::= <Paragraphs> <Paragraph>
| !Zero or more


! ----------------------------------------------------------------- Rules
<Paragraph>
::= Identifier SECTION '.' Identifier '.' <Sentences>
| Identifier '.' <Sentences>


<Program> ::= <NameSpace Item> <Program>
! -----------------------------------------------------------------------------
| <Imports> <Program>
! Declaratives
| <Option Decl> <Program>
! -----------------------------------------------------------------------------
|
<Declarative Block>
::= DECLARATIVES '.' <Declarative Sections> END DECLARATIVES '.' !No dash - inconsistent
| !Optional


! -------------------------------------------------------------------
<Declarative Sections>
! (Shared attributes)
::= <Declarative Sections> <Declarative Section>
! -------------------------------------------------------------------
| !Zero or more


<NL> ::= NewLine <NL>
<Declarative Section>
| NewLine
::= Identifier SECTION '.' USE <BEFORE AFTER> <STANDARD Opt> ERROR PROCEDURE ON <Error Cause> '.' <Sentences>
| Identifier '.' <Sentences>


<Modifiers> ::= <Modifier> <Modifiers>
<Error Cause>
::= Identifier
|
| INPUT
| OUTPUT
| I-O
| EXTEND


<Modifier> ::= Shadows
! -----------------------------------------------------------------------------
| Shared
! Shared by sentences
| MustInherit
! -----------------------------------------------------------------------------
| NotInheritable


| Overridable
<Sort Keys>
::= <Sort Keys> <Sort Key>
| NotOverridable
| <Sort Key>
| MustOverride
| Overrides
<Sort Key>
| Overloads
::= <ON Opt> ASCENDING <KEY Opt> Identifier
| <ON Opt> DESCENDING <KEY Opt> Identifier
| Default
| ReadOnly
| WriteOnly
| <Access>


<Access Opt> ::= <Access>
<Collating Clause>
::= <COLLATING Opt> SEQUENCE <IS Opt> Identifier
|
| !Optional


<Access> ::= Public
<Sort Source>
::= INPUT PROCEDURE <IS Opt> <Identifier Range>
| Private
| USING <Values>
| Friend
| Protected
<Sort Target>
::= OUTPUT PROCEDURE <IS Opt> <Identifier Range>
| GIVING <Values>
<Identifier Range>
::= Identifier
| Identifier THRU Identifier
| Identifier THROUGH Identifier
<Enabled Disable Mode>
::= INPUT
| INPUT TERMINAL
| I-O TERMINAL
| OUTPUT


<Var Member> ::= <Attributes> <Access> <Var Decl> <NL> !Variables
<Enable Disable Key>
::= <WITH Opt> KEY <Value>
| <Attributes> <Access Opt> Const <Var Decl> <NL> !Constants
| <Attributes> <Access Opt> Static <Var Decl> <NL>
| !Optional

! -----------------------------------------------------------------------------
! Boolean Expressions
! -----------------------------------------------------------------------------

! Note: <Not Opt> is very significant in the operators below

<Boolean Exp>
::= <Boolean Exp> OR <And Exp>
| <And Exp>

<And Exp>
::= <Negation Exp> And <And Exp>
| <Negation Exp>
<Negation Exp>
::= <Compare Exp>
| NOT <Compare Exp>
!<And Exp>
! ::= <And Exp> AND <Compare Exp>
! | <Compare Exp>
<Compare Exp>
::= <Symbolic Value> <Compare Op> <Symbolic Value>
| <Symbolic Value> IS ALPHABETIC
| <Symbolic Value> IS ALPHABETIC-UPPER
| <Symbolic Value> IS ALPHABETIC-LOWER
| '(' <Boolean Exp> ')'
| <Symbolic Value>
<Compare Op>
::= <IS ARE Opt> <Greater Op>
| <IS ARE Opt> NOT <Greater Op>

| <IS ARE Opt> <Greater Eq Op>
| <IS ARE Opt> NOT <Greater Eq Op>

| <IS ARE Opt> <Less Op>
| <IS ARE Opt> NOT <Less Op>

| <IS ARE Opt> <Less Eq Op>
| <IS ARE Opt> NOT <Less Eq Op>

| <IS ARE Opt> <Equal Op>
| <IS ARE Opt> NOT <Equal Op>
<Greater Op>
::= GREATER <THAN Opt>
| '>'
<Greater Eq Op>
::= GREATER <THAN Opt> OR EQUAL <TO Opt>
| '>='
<Less Op>
::= LESS <THAN Opt>
| '<'
<Less Eq Op>
::= LESS <THAN Opt> OR EQUAL <TO Opt>
| '<='

<Equal Op>
::= EQUAL <TO Opt>
| '='


! -----------------------------------------------------------------------------
! Sentences
! -----------------------------------------------------------------------------

! If you add statements to the grammar, make sure to update the corresponding
! <Statement> rules below
<Sentences>
::= <Sentence> <Sentences>
| !Zero or more

<Sentence>
::= <Sent Stm> '.'

<Sent Stm>
::= <Accept Sent>
| <Add Sent>
| <Alter Sent>
| <Call Sent>
| <Cancel Sent>
| <Close Sent>
| <Compute Sent>
| <Continue Sent>
| <Delete Sent>
| <Disable Sent>
| <Display Sent>
| <Divide Sent>
| <Enable Sent>
| <Evaluate Sent>
| <Exit Sent>
| <Generate Sent>
| <Go To Sent>
| <If Sent>
| <Initialize Sent>
| <Initiate Sent>
| <Inspect Sent>
| <Merge Sent>
| <Move Sent>
| <Multiply Sent>
| <Open Sent>
| <Perform Sent>
| <Read Sent>
| <Release Sent>
| <Return Sent>
| <Rewrite Sent>
| <Search Sent>
| <Send Sent>
| <Set Sent>
| <Sort Sent>
| <Start Sent>
| <Stop Sent>
| <String Sent>
| <Subtract Sent>
| <Suppress Sent>
| <Terminate Sent>
| <Unstring Sent>
| <Use Sent>
| <Write Sent>

<Embed Stms>
::= <Embed Stms> <Embed Stm>
| <Embed Stm>
<Implements> ::= Implements <ID List>
<Embed Stm>
::= <Accept Embed>
| <Add Embed>
| <Alter Embed>
| <Call Embed>
| <Cancel Embed>
| <Close Embed>
| <Compute Embed>
| <Continue Embed>
| <Delete Embed>
| <Disable Embed>
| <Display Embed>
| <Divide Embed>
| <Enable Embed>
| <Evaluate Embed>
| <Exit Embed>
| <Generate Embed>
| <Go To Embed>
| <If Embed>
| <Initialize Embed>
| <Initiate Embed>
| <Inspect Embed>
| <Merge Embed>
| <Move Embed>
| <Multiply Embed>
| <Open Embed>
| <Perform Embed>
| <Read Embed>
| <Release Embed>
| <Return Embed>
| <Rewrite Embed>
| <Search Embed>
| <Send Embed>
| <Set Embed>
| <Sort Embed>
| <Start Embed>
| <Stop Embed>
| <String Embed>
| <Subtract Embed>
| <Suppress Embed>
| <Terminate Embed>
| <Unstring Embed>
| <Use Embed>
| <Write Embed>


<ID List> ::= <Identifier> ',' <ID List>
<Imperative Stms>
::= <Imperative Stms> <Imperative Stm>
| <Identifier>
| <Imperative Stm>
<Option Decl> ::= Option <IDs> <NL>
<Imperative Stm>
::= <Accept Imp>
| <Add Imp>
| <Alter Imp>
| <Call Imp>
| <Cancel Imp>
| <Close Imp>
| <Compute Imp>
| <Continue Imp>
| <Delete Imp>
| <Disable Imp>
| <Display Imp>
| <Divide Imp>
| <Enable Imp>
| <Evaluate Imp>
| <Exit Imp>
| <Generate Imp>
| <Go To Imp>
| <If Imp>
| <Initialize Imp>
| <Initiate Imp>
| <Inspect Imp>
| <Merge Imp>
| <Move Imp>
| <Multiply Imp>
| <Open Imp>
| <Perform Imp>
| <Read Imp>
| <Release Imp>
| <Return Imp>
| <Rewrite Imp>
| <Search Imp>
| <Send Imp>
| <Set Imp>
| <Sort Imp>
| <Start Imp>
| <Stop Imp>
| <String Imp>
| <Subtract Imp>
| <Suppress Imp>
| <Terminate Imp>
| <Unstring Imp>
| <Use Imp>
| <Write Imp>
! -----------------------------------------------------------------------------
! Exception Handling
! -----------------------------------------------------------------------------


<IDs> ::= ID <IDs>
<Size Clauses>
::= <Size Clauses> <Size Clause>
| ID
| <Size Clause>

<Size Clause>
::= <ON Opt> SIZE ERROR <Imperative Stms>
| NOT <ON Opt> SIZE ERROR <Imperative Stms>
!-----------------------------------------

<Invalid Key Clauses>
::= <Invalid Key Clauses> <Invalid Key Clause>
| <Invalid Key Clause>

<Invalid Key Clause>
::= INVALID <KEY Opt> <Imperative Stms>
| NOT INVALID <KEY Opt> <Imperative Stms>
<Type> ::= As <Attributes> <Identifier>
!-----------------------------------------
|

<Exception Clauses>
::= <Exception Clauses> <Exception Clause>
| <Exception Clause>

<Exception Clause>
::= <ON Opt> EXCEPTION <Imperative Stms>
| NOT <ON Opt> EXCEPTION <Imperative Stms>
!-----------------------------------------

<Overflow Clauses>
::= <Overflow Clauses> <Overflow Clause>
| <Overflow Clause>

<Overflow Clause>
::= <ON Opt> OVERFLOW <Imperative Stms>
| NOT <ON Opt> OVERFLOW <Imperative Stms>
!-----------------------------------------


<Compare Op> ::= '=' | '<>' | '<' | '>' | '>=' | '<='
<At End Clauses>
::= <At End Clauses> <At End Clause>
| <At End Clause>


! -------------------------------------------------------------------
<At End Clause>
! NameSpace
::= AT END <Imperative Stms>
! -------------------------------------------------------------------
| NOT AT END <Imperative Stms>


<NameSpace> ::= NameSpace ID <NL> <NameSpace Items> End NameSpace <NL>
!-----------------------------------------


<NameSpace Items> ::= <NameSpace Item> <NameSpace Items>
<AT EOP Clauses>
::= <AT EOP Clauses> <AT EOP Clause>
|
| <AT EOP Clause>


<AT EOP Clause>
<NameSpace Item> ::= <Class>
::= AT <End of Page> <Imperative Stms>
| <Declare>
| NOT AT <End of Page> <Imperative Stms>
| <Delegate>
| <Enumeration>
| <Interface>
| <Structure>
| <Module>
| <Namespace>
<End of Page>
::= END-OF-PAGE
| EOP


! -----------------------------------------------------------------------------
! -------------------------------------------------------------------
! Attributes
! ACCEPT Statement
! -----------------------------------------------------------------------------
! -------------------------------------------------------------------


<Attributes> ::= '<' <Attribute List> '>'
<Accept Sent>
::= <Accept Stm>
|


<Attribute List> ::= <Attribute> ',' <Attribute List>
<Accept Embed>
::= <Accept Stm>
| <Attribute>

<Attribute> ::= <Attribute Mod> ID <Argument List Opt>
<Accept Imp>
::= <Accept Stm>

<Accept Stm>
::= ACCEPT Identifier
| ACCEPT Identifier FROM <Accept From Arg>
| ACCEPT Identifier <MESSAGE opt> COUNT !CD
<Accept From Arg>
::= FROM DATE
| FROM DAY
| FROM DAY-OF-WEEK
| FROM TIME
| FROM CONSOLE
| FROM Identifier
| !Optional

! -----------------------------------------------------------------------------
! ADD Statement
! -----------------------------------------------------------------------------

<Add Sent>
::= <Add Stm> <Size Clauses> <END-ADD Opt>
| <Add Stm>

<Add Embed>
::= <Add Stm> <Size Clauses> 'END-ADD'
| <Add Stm>

<Add Imp>
::= <Add Stm>
<Attribute Mod> ::= Assembly
<Add Stm>
::= ADD <Values> TO <Add Items> <Giving Clause>
| Module
| ADD <CORRESPONDING> Identifier TO Identifier <ROUNDED Opt>
|
! -------------------------------------------------------------------
<Giving Clause>
! Delegates
::= GIVING <Add Item>
! -------------------------------------------------------------------
| !Optional
<Delegate> ::= <Attributes> <Modifiers> Delegate <Method>
| <Attributes> <Modifiers> Delegate <Declare>


! -------------------------------------------------------------------
<Add Items>
! Imports
::= <Add Items> <Add Item>
! -------------------------------------------------------------------
| <Add Item>
<Add Item>
::= <Variable> <ROUNDED Opt>


<Imports> ::= Imports <Identifier> <NL>
| Imports ID '=' <Identifier> <NL>


! -------------------------------------------------------------------
<END-ADD Opt>
! Events
::= END-ADD
! -------------------------------------------------------------------
| !Optional


<Event Member> ::= <Attributes> <Modifiers> Event ID <Parameters Or Type> <Implements Opt> <NL>
! -----------------------------------------------------------------------------
! ALTER Statement
! -----------------------------------------------------------------------------


<Parameters Or Type> ::= <Param List>
<Alter Sent>
| As <Identifier>
::= <Alter Stm>


<Implements Opt> ::= <Implements>
<Alter Embed>
::= <Alter Stm>
|
! -------------------------------------------------------------------
! Class
! -------------------------------------------------------------------


<Class> ::= <Attributes> <Modifiers> Class ID <NL> <Class Items> End Class <NL>
<Alter Imp>
::= <Alter Stm>


<Alter Stm>
::= ALTER Identifier TO Identifier
| ALTER Identifier TO PROCEED TO Identifier
! -----------------------------------------------------------------------------
! CALL Statement
! -----------------------------------------------------------------------------


<Class Items> ::= <Class Item> <Class Items>
!Call can call just about anything, it depends on the system.
|


<Class Item> ::= <Declare>
<Call Sent>
::= <Call Stm> <Exception Clauses> <END-CALL Opt>
| <Method>
| <Call Stm> <Overflow Clauses> <END-CALL Opt>
| <Property>
| <Call Stm>
| <Var Member>
| <Enumeration>
| <Inherits>
| <Class Implements>
<Inherits> ::= Inherits <Identifier> <NL>
<Class Implements> ::= Implements <ID List> <NL>


! -------------------------------------------------------------------
<Call Embed>
! Structures
::= <Call Stm> <Exception Clauses> END-CALL
! -------------------------------------------------------------------
| <Call Stm> <Overflow Clauses> END-CALL
| <Call Stm>


<Structure> ::= <Attributes> <Modifiers> Structure ID <NL> <Structure List> End Structure <NL>
<Call Imp>
::= <Call Stm>


<Structure List> ::= <Structure Item> <Structure List>
<Call Stm>
::= CALL <Value>
|
| CALL <Value> USING <Call Items>


<Structure Item> ::= <Implements>
<Call Items>
::= <Call Items> <Call Item>
| <Enumeration>
| <Call Item>
| <Structure>
| <Class>
| <Delegate>
| <Var Member>
| <Event Member>
| <Declare>
| <Method>
| <Property>


! -------------------------------------------------------------------
<Call Item>
! Module
::= <Variable>
! -------------------------------------------------------------------
| <BY Opt> REFERENCE <Variable> !default
| <BY Opt> CONTENT <Variable>


<Module> ::= <Attributes> <Modifiers> Module ID <NL> <Module Items> End Module <NL>
<END-CALL Opt>
::= END-CALL
| !Optional


<Module Items> ::= <Module Item> <Module Items>
! -----------------------------------------------------------------------------
|
! CANCEL Statement
! -----------------------------------------------------------------------------
<Module Item> ::= <Declare>
| <Method>
| <Property>
| <Var Member>
| <Enumeration>
| <Option Decl>


! -------------------------------------------------------------------
<Cancel Sent>
! Interface
::= <Cancel Stm>
! -------------------------------------------------------------------


<Interface> ::= <Attributes> <Modifiers> Interface ID <NL> <Interface Items> End Interface <NL>
<Cancel Embed>
::= <Cancel Stm>


<Cancel Imp>
::= <Cancel Stm>


<Interface Items> ::= <Interface Item> <Interface Items>
<Cancel Stm>
::= CANCEL <Values>
|
<Interface Item> ::= <Implements>
| <Event Member>
| <Enum Member>
| <Method Member>
| <Property Member>


<Enum Member> ::= <Attributes> <Modifiers> Enum ID <NL>
! -----------------------------------------------------------------------------
! CLOSE Statement
! -----------------------------------------------------------------------------


<Method Member> ::= <Attributes> <Modifiers> Sub <Sub ID> <Param List> <Handles Or Implements> <NL>
<Close Sent>
| <Attributes> <Modifiers> Function ID <Param List> <Type> <Handles Or Implements> <NL>
::= <Close Stm>


<Property Member> ::= <Attributes> <Modifiers> Property ID <Param List> <Type> <Handles Or Implements> <NL>
<Close Embed>
::= <Close Stm>

! -------------------------------------------------------------------
<Close Imp>
! Parameters
::= <Close Stm>
! -------------------------------------------------------------------

<Close Stm>
::= CLOSE <Close Items>

<Close Items>
::= <Close Items> <Close Item>
| <Close Item>

<Close Item>
::= Identifier <Close Options>

<Close Options>
::= UNIT <Close Method>
| REEL <Close Method>
| <WITH Opt> LOCK
| <WITH Opt> NO REWIND
| !Empty
<Close Method>
::= <FOR Opt> REMOVAL
| !Optional
! -----------------------------------------------------------------------------
! COMPUTE Statement
! -----------------------------------------------------------------------------

<Compute Sent>
::= <Compute Stm> <Size Clauses> <END-COMPUTE Opt>
| <Compute Stm>

<Compute Embed>
::= <Compute Stm> <Size Clauses> END-COMPUTE
| <Compute Stm>

<Compute Imp>
::= <Compute Stm>

<Compute Stm>
::= COMPUTE Identifier <ROUNDED Opt> <Equal Op> <Math Exp>
<Math Exp>
::= <Math Exp> '+' <Mult Exp>
| <Math Exp> '-' <Mult Exp>
| <Mult Exp>

<Mult Exp>
::= <Mult Exp> '*' <Negate Exp>
| <Mult Exp> '/' <Negate Exp>
| <Negate Exp>

<Negate Exp>
::= '-' <Value>
| <Value>
| '(' <Math Exp> ')'

<END-COMPUTE Opt>
::= END-COMPUTE
| !Optional

! -----------------------------------------------------------------------------
! CONTINUE
! -----------------------------------------------------------------------------

<Continue Sent>
::= <Continue Stm>

<Continue Embed>
::= <Continue Stm>

<Continue Imp>
::= <Continue Stm>

<Continue Stm>
::= CONTINUE

! -----------------------------------------------------------------------------
! DELETE Statement
! -----------------------------------------------------------------------------
<Delete Sent>
::= <Delete Stm> <Invalid Key Clauses> <END-DELETE Opt>
| <Delete Stm>

<Delete Embed>
::= <Delete Stm> <Invalid Key Clauses> END-DELETE
| <Delete Stm>

<Delete Imp>
::= <Delete Stm>

<Delete Stm>
::= DELETE Identifier <RECORD Opt>

<END-DELETE Opt>
::= END-DELETE
| !Optional

! -----------------------------------------------------------------------------
! DISABLE Statement
! -----------------------------------------------------------------------------

<Disable Sent>
::= <Disable Stm>

<Disable Embed>
::= <Disable Stm>

<Disable Imp>
::= <Disable Stm>

<Disable Stm>
::= DISABLE <Enabled Disable Mode> Identifier <Enable Disable Key>
! -----------------------------------------------------------------------------
! DISPLAY Statement
! -----------------------------------------------------------------------------

<Display Sent>
::= <Display Stm>

<Display Embed>
::= <Display Stm>

<Display Imp>
::= <Display Stm>
<Display Stm>
::= DISPLAY <Values> <Display Target> <Advancing Clause>

<Display Target>
::= UPON Identifier
| !Optional

<Advancing Clause>
::= <WITH Opt> NO ADVANCING
| !Optional

! -----------------------------------------------------------------------------
! DIVIDE Statement
! -----------------------------------------------------------------------------

<Divide Sent>
::= <Divide Stm> <Size Clauses> <END-DIVIDE Opt>
| <Divide Stm>

<Divide Embed>
::= <Divide Stm> <Size Clauses> 'END-DIVIDE'
| <Divide Stm>

<Divide Imp>
::= <Divide Stm>


<Param List Opt> ::= <Param List>
<Divide Stm>
::= DIVIDE <Values> BY <Values>
|
| DIVIDE <Values> BY <Values> GIVING <Variable> <ROUNDED Opt>
| DIVIDE <Values> INTO <Values>
| DIVIDE <Values> INTO <Values> GIVING <Variable> <ROUNDED Opt> <Remainder Opt>


<Param List> ::= '(' <Param Items> ')'
<Remainder Opt>
::= REMAINDER <Variable>
| '(' ')'
| !Optional
<Param Items> ::= <Param Item> ',' <Param Items>
<END-DIVIDE Opt>
::= END-DIVIDE
| <Param Item>
| !Optional


<Param Item> ::= <Param Passing> ID <Type>
! -----------------------------------------------------------------------------
! ENABLE Statement
! -----------------------------------------------------------------------------


<Enable Sent>
::= <Enable Stm>


<Param Passing> ::= ByVal
<Enable Embed>
::= <Enable Stm>
| ByRef
| Optional
| ParamArray
|


! -------------------------------------------------------------------
<Enable Imp>
! Arguments
::= <Enable Stm>
! -------------------------------------------------------------------


<Argument List Opt> ::= <Argument List>
<Enable Stm>
::= ENABLE <Enabled Disable Mode> Identifier <Enable Disable Key>
|
<Argument List> ::= '(' <Argument Items> ')'
! -----------------------------------------------------------------------------
! EVALUATE Statement
! -----------------------------------------------------------------------------

<Evaluate Sent>
::= <Evaluate Stm> <END-EVALUATE Opt>

<Evaluate Embed>
::= <Evaluate Stm> END-EVALUATE

<Evaluate Imp>
::= <Evaluate Stm> END-EVALUATE
<Evaluate Stm>
::= EVALUATE <Subjects> <When Clauses>
<Argument Items> ::= <Argument> ',' <Argument Items>
<Subjects>
::= <Subjects> ALSO <Subject>
| <Argument>
| <Subject>


<Argument> ::= <Expression>
<Subject>
::= TRUE
| Id ':=' <Expression>
| <Boolean Exp>
| !NULL
! -------------------------------------------------------------------
! Declares (External Procedures)
! -------------------------------------------------------------------


<Declare> ::= <Attributes> <Modifiers> Declare <Charset> Sub ID Lib StringLiteral <Alias> <Param List Opt> <NL>
<When Clauses>
| <Attributes> <Modifiers> Declare <Charset> Function ID Lib StringLiteral <Alias> <Param List Opt> <Type> <NL>
::= <When Clauses> <When Clause>
| <When Clause>


<Charset> ::= Ansi | Unicode | Auto | !Null
<When Clause>
::= WHEN <Phrases> <THEN Opt> <Embed Stms>
| WHEN OTHER <THEN Opt> <Embed Stms>


<Alias> ::= Alias StringLiteral
<Phrases>
::= <Phrases> ALSO <Phrase>
|
| <Phrase>

<Phrase>
::= ANY
| <Symbolic Value> THROUGH <Symbolic Value>
| <Symbolic Value> THRU <Symbolic Value>
| <Symbolic Value>

<END-EVALUATE Opt>
::= END-EVALUATE
| !Optional

! -----------------------------------------------------------------------------
! EXIT Statement
! -----------------------------------------------------------------------------

<Exit Sent>
::= <Exit Stm>

<Exit Embed>
::= <Exit Stm>

<Exit Imp>
::= <Exit Stm>

<Exit Stm>
::= EXIT
| EXIT PROGRAM
! -----------------------------------------------------------------------------
! GENERATE Statement
! -----------------------------------------------------------------------------

<Generate Sent>
::= <Generate Stm>

<Generate Embed>
::= <Generate Stm>

<Generate Imp>
::= <Generate Stm>

<Generate Stm>
::= GENERATE Identifier
! -----------------------------------------------------------------------------
! GO TO Statement
! -----------------------------------------------------------------------------

<Go To Sent>
::= <Go To Stm>


<Go To Embed>
::= <Go To Stm>


! -------------------------------------------------------------------
<Go To Imp>
! Methods
::= <Go To Stm>
! -------------------------------------------------------------------


<Method> ::= <Attributes> <Modifiers> Sub <Sub ID> <Param List> <Handles Or Implements> <NL> <Statements> End Sub <NL>
<Go To Stm>
| <Attributes> <Modifiers> Function ID <Param List> <Type> <Handles Or Implements> <NL> <Statements> End Function <NL>
::= GO TO Identifier
| GO TO <Identifiers> DEPENDING ON <Variable>
<Sub ID> ::= ID
! -----------------------------------------------------------------------------
| New !Class creation
! IF Statement
! -----------------------------------------------------------------------------


<Handles Or Implements> ::= <Implements>
<If Sent>
::= <If Stm> <END-IF Opt>
| <Handles>
|


<Handles> ::= Handles <ID List>
<If Embed>
::= <If Stm> END-IF


! -------------------------------------------------------------------
<If Imp>
! Properties
::= <If Stm> END-IF
! -------------------------------------------------------------------
<Property> ::= <Attributes> <Modifiers> Property ID <Param List> <Type> <NL> <Property Items> End Property <NL>


<Property Items> ::= <Property Item> <Property Items>
<If Stm>
::= IF <Boolean Exp> <THEN Opt> <Embed Stms>
|
| IF <Boolean Exp> <THEN Opt> <Embed Stms> ELSE <THEN Opt> <Embed Stms>
| IF <Boolean Exp> <THEN Opt> <Embed Stms> ELSE NEXT SENTENCE


<Property Item> ::= Get <NL> <Statements> End Get <NL>
<END-IF Opt>
| Set <Param List> <NL> <Statements> End Set <NL>
::= END-IF
| !Optional


! -----------------------------------------------------------------------------
! INITIALIZE Statement
! -----------------------------------------------------------------------------


! -------------------------------------------------------------------
<Initialize Sent>
! Enumerations
::= <Initialize Stm>
! -------------------------------------------------------------------


<Enumeration> ::= <Attributes> <Modifiers> Enum ID <NL> <Enum List> End Enum <NL>
<Initialize Embed>
::= <Initialize Stm>


<Enum List> ::= <Enum Item> <Enum List>
<Initialize Imp>
::= <Initialize Stm>
|


<Enum Item> ::= Id '=' <Expression> <NL>
<Initialize Stm>
::= INITIALIZE <Variables> <Replacing Opt>
| Id <NL>
<Replacing Opt>
::= REPLACING <Replacing Items>
<Replacing Items>
::= <Replacing Items> <Replacing Item>
| <Replacing Item>
<Replacing Item>
::= <Replacing Type> <DATA Opt> <Value>


! -------------------------------------------------------------------
<Replacing Type>
! Variable Declaration
::= ALPHABETIC
! -------------------------------------------------------------------
| ALPHANUMERIC
| NUMERIC
| ALPHANUMERIC-EDITED
| NUMERIC-EDITED


<Var Decl> ::= <Var Decl Item> ',' <Var Decl>
! -----------------------------------------------------------------------------
| <Var Decl Item>
! INITIATE Statement
! -----------------------------------------------------------------------------
<Var Decl Item> ::= <Var Decl ID> As <Identifier> <Argument List Opt>
| <Var Decl ID> As <Identifier> '=' <Expression> !Initialize
| <Var Decl ID> As New <Identifier> <Argument List Opt>
| <Var Decl ID>
| <Var Decl ID> '=' <Expression> !Initialize


<Var Decl ID> ::= ID <Argument List Opt>
<Initiate Sent>
::= <Initiate Stm>

<Initiate Embed>
::= <Initiate Stm>

<Initiate Imp>
::= <Initiate Stm>

<Initiate Stm>
::= INITIATE <Identifiers>
! -----------------------------------------------------------------------------
! INSPECT Statement
! -----------------------------------------------------------------------------

<Inspect Sent>
::= <Inspect Stm>

<Inspect Embed>
::= <Inspect Stm>

<Inspect Imp>
::= <Inspect Stm>

<Inspect Stm>
::= INSPECT <Variable> TALLYING <Tally Variables>
| INSPECT <Variable> TALLYING <Tally Variables> REPLACING <Replace Chars>
| INSPECT <Variable> REPLACING <Replace Chars>
| INSPECT <Variable> CONVERTING <Value> TO <Value> <Inspect Specs>

! ----------------------------------- Tally group

<Tally Variables>
::= <Tally Variables> <Tally Variable>
| <Tally Variable>
<Tally Variable>
::= <Variable> FOR <Tally Items>

<Tally Items>
::= <Tally Items> <Tally Item>
| <Tally Item>
<Tally Item>
::= CHARACTERS <Inspect Specs>
| ALL <Value> <Inspect Specs>
| LEADING <Value> <Inspect Specs>

! ----------------------------------- Replacing group
<Replace Chars>
::= <Replace Chars> <Replace Char>
| <Replace Char>
<Replace Char>
::= CHARACTERS BY <Value> <Inspect Specs>
| ALL <Replace Items>
| LEADING <Replace Items>
| FIRST <Replace Items>
<Replace Items>
::= <Replace Items> <Replace Item>
| <Replace Item>
! -------------------------------------------------------------------
<Replace Item>
! Normal Statements
::= <Value> BY <Value> <Inspect Specs>
! -------------------------------------------------------------------


<Statements> ::= <Statement> <Statements>
! ----------------------------------- Substring Specifiers
|
<Inspect Specs>
::= <Inspect Specs> <Inspect Spec>
| !Zero or more


<Statement> ::= <Loop Stm>
<Inspect Spec>
::= <BEFORE AFTER> INITIAL <Value>
| <For Stm>
| <If Stm>
| <Select Stm>
! -----------------------------------------------------------------------------
| <SyncLock Stm>
! MERGE Statement
| <Try Stm>
! -----------------------------------------------------------------------------
| <With Stm>
| <Option Decl>
| <Local Decl>
| <Non-Block Stm> <NL> !Note the <NL>. A non-block statement can be a full statement
| LABEL <NL>
<Non-Block Stm> ::= Call <Variable>
| ReDim <Var Decl>
| ReDim Preserve <Var Decl>
| Erase ID
| Throw <Value>
| RaiseEvent <Identifier> <Argument List Opt>
| AddHandler <Expression> ',' <Expression>
| RemoveHandler <Expression> ',' <Expression>
| Exit Do
| Exit For
| Exit Function
| Exit Property
| Exit Select
| Exit Sub
| Exit Try
| Exit While
| GoTo ID !Argh - they still have this
| Return <Value>


| Error <Value> !Raise an error by number
<Merge Sent>
| On Error GoTo IntLiteral ! 0 This is obsolete.
::= <Merge Stm>
| On Error GoTo '-' IntLiteral !-1 This is obsolete.
| On Error GoTo Id
| On Error Resume Next
| Resume ID
| Resume Next
| <Variable> <Assign Op> <Expression>
| <Variable>
| <Method Call>


<Assign Op> ::= '=' | '^=' | '*=' | '/=' | '\=' | '+=' | '-=' | '&=' | '<<=' | '>>='
<Merge Embed>
::= <Merge Stm>


<Merge Imp>
::= <Merge Stm>


! -------------------------------------------------------------------
<Merge Stm>
! Local declarations
::= MERGE Identifier <Sort Keys> <Collating Clause> USING <Identifiers> <Sort Target>
! -------------------------------------------------------------------
! -----------------------------------------------------------------------------
! MOVE Statement
! -----------------------------------------------------------------------------


<Local Decl> ::= Dim <Var Decl> <NL>
<Move Sent>
::= <Move Stm> <Size Clauses> <END-MOVE Opt>
| Const <Var Decl> <NL>
| <Move Stm>
| Static <Var Decl> <NL>


! -------------------------------------------------------------------
<Move Embed>
! Do Statement
::= <Move Stm> <Size Clauses> END-MOVE
! -------------------------------------------------------------------
| <Move Stm>


<Loop Stm> ::= Do <Test Type> <Expression> <NL> <Statements> Loop <NL>
<Move Imp>
| Do <NL> <Statements> Loop <Test Type> <Expression> <NL>
::= <Move Stm>
| While <Expression> <NL> <Statements> End While <NL>


<Test Type> ::= While
<Move Stm>
::= MOVE <Symbolic Value> TO <Variables>
| Until
| MOVE <CORRESPONDING> Identifier TO Identifier
<END-MOVE Opt>
::= END-MOVE
| !Optional


! -----------------------------------------------------------------------------
! -------------------------------------------------------------------
! MULTIPLY Statement
! For Statement
! -----------------------------------------------------------------------------
! -------------------------------------------------------------------


<For Stm> ::= For <Identifier> '=' <Expression> To <Expression> <Step Opt> <NL> <Statements> Next <NL>
<Multiply Sent>
::= <Multiply Stm> <Size Clauses> <END-MULTIPLY Opt>
| For Each <Variable> In <Variable> <NL> <Statements> Next <NL>
| <Multiply Stm>


<Step Opt> ::= Step <Expression>
<Multiply Embed>
::= <Multiply Stm> <Size Clauses> END-MULTIPLY
|
| <Multiply Stm>


<Multiply Imp>
::= <Multiply Stm>


! -------------------------------------------------------------------
<Multiply Stm>
! If Statement
::= MULTIPLY <Variables> BY <Multiply Items> <Giving Clause Opt>
! -------------------------------------------------------------------


<If Stm> ::= If <Expression> <Then Opt> <NL> <Statements> <If Blocks> End If <NL>
<Multiply Items>
::= <Multiply Items> <Multiply Item>
| If <Expression> Then <Non-Block Stm> <NL>
| If <Expression> Then <Non-Block Stm> Else <Non-Block Stm> <NL>
| <Multiply Item>


<Then Opt> ::= Then !!The reserved word 'Then' is optional for Block-If statements
<Multiply Item>
::= <Value> <ROUNDED Opt>
|


<If Blocks> ::= ElseIf <Expression> <Then Opt> <NL> <Statements> <If Blocks>
<END-MULTIPLY Opt>
::= END-MULTIPLY
| Else <NL> <Statements>
| !Optional
|


! -----------------------------------------------------------------------------
! -------------------------------------------------------------------
! OPEN Statement
! Select Statement
! -----------------------------------------------------------------------------
! -------------------------------------------------------------------


<Select Stm> ::= Select <Case Opt> <Expression> <NL> <Select Blocks> End Select <NL>
<Open Sent>
::= <Open Stm>


<Case Opt> ::= Case !!The "Case" after Select is optional in VB.NEt
<Open Embed>
::= <Open Stm>
|


<Open Imp>
::= <Open Stm>


<Select Blocks> ::= Case <Case Clauses> <NL> <Statements> <Select Blocks>
<Open Stm>
::= OPEN <Open List>
| Case Else <NL> <Statements>
|
<Open List>
::= <Open List> <Open Entry>
| <Open Entry>
<Open Entry>
::= INPUT <Variables> <Open No Rewind>
| OUTPUT <Variables> <Open No Rewind>
| EXTEND <Variables> <Open No Rewind>
| I-O <Variables> <Open No Rewind>
<Open No Rewind>
::= <WITH Opt> NO REWIND
| !Optional
! -----------------------------------------------------------------------------
! PERFORM Statement
! -----------------------------------------------------------------------------


<Case Clauses> ::= <Case Clause> ',' <Case Clauses>
<Perform Sent>
::= <Perform Block> <END-PERFORM Opt>
| <Case Clause>
| <Perform Stm>
| <Perform Loop>


<Case Clause> ::= <Is Opt> <Compare Op> <Expression>
<Perform Embed>
::= <Perform Block> END-PERFORM
| <Expression>
| <Perform Stm>
| <Expression> To <Expression>
| <Perform Loop>
<Perform Imp>
::= <Perform Block> END-PERFORM
| <Perform Stm>


<Is Opt> ::= Is
| !Null


! -------------------------------------------------------------------
<Perform Stm>
! SyncLock Statement
::= PERFORM <Identifier Range>
! -------------------------------------------------------------------
| PERFORM <Identifier Range> <Numeric> TIMES


<SyncLock Stm> ::= SyncLock <NL> <Statements> End SyncLock <NL>
<Perform Loop>
::= PERFORM <Identifier Range> <With Test> UNTIL <Boolean Exp>
| PERFORM <Identifier Range> <With Test> VARYING <Perform For List>


! -------------------------------------------------------------------
<Perform Block>
! Try Statement
::= PERFORM <With Test> UNTIL <Boolean Exp> <Embed Stms>
! -------------------------------------------------------------------
| PERFORM <With Test> VARYING <Perform For List> <Embed Stms>
| PERFORM <Numeric> TIMES <Embed Stms>


<Try Stm> ::= Try <NL> <Statements> <Catch Blocks> End Try <NL>
<With Test>
::= <WITH Opt> TEST <BEFORE AFTER>
| !Optional
<Perform For List>
::= <Perform For List> AFTER <Perform For Range>
| <Perform For Range>


<Catch Blocks> ::= <Catch Block> <Catch Blocks>
<Perform For Range>
::= <Variable> FROM <Numeric> BY <Numeric> UNTIL <Boolean Exp>
| <Catch Block>


<Catch Block> ::= Catch <Identifier> As ID <NL> <Statements>
<END-PERFORM Opt>
| Catch <NL> <Statements>
::= END-PERFORM
| !Optional


! -----------------------------------------------------------------------------
! -------------------------------------------------------------------
! READ Statement
! With Statement
! -----------------------------------------------------------------------------
! -------------------------------------------------------------------


<With Stm> ::= With <Value> <NL> <Statements> End With <NL>
<Read Sent>
::= <Read Stm> <Read Msg Clauses> <END-READ Opt>
! -------------------------------------------------------------------
| <Read Stm>
! Expressions
! -------------------------------------------------------------------


<Expression> ::= <And Exp> Or <Expression>
<Read Embed>
::= <Read Stm> <Read Msg Clauses> END-READ
| <And Exp> OrElse <Expression>
| <Read Stm>
| <And Exp> XOr <Expression>
| <And Exp>


<And Exp> ::= <Not Exp> And <And Exp>
<Read Imp>
::= <Read Stm>
| <Not Exp> AndAlso <And Exp>
| <Not Exp>

<Read Stm>
::= READ Identifier <Next Opt> <RECORD Opt>
| READ Identifier <Next Opt> <RECORD Opt> INTO <Variable> <Read Key Opt>
<Read Msg Clauses>
::= <At End Clauses>
| <Invalid Key Clauses>

<Read Key Opt>
::= KEY <IS Opt> Identifier
| !Optional

<END-READ Opt>
::= END-READ
| !Optional

! -----------------------------------------------------------------------------
! RELEASE Statement
! -----------------------------------------------------------------------------

<Release Sent>
::= <Release Stm>

<Release Embed>
::= <Release Stm>

<Release Imp>
::= <Release Stm>

<Release Stm>
::= RELEASE Identifier
| RELEASE Identifier FROM Identifier
! -----------------------------------------------------------------------------
! RETURN Statement
! -----------------------------------------------------------------------------

<Return Sent>
::= <Return Stm>

<Return Embed>
::= <Return Stm>

<Return Imp>
::= <Return Stm>

<Return Stm>
::= RETURN Identifier <RECORD Opt>
| RETURN Identifier <RECORD Opt> INTO Identifier
! -----------------------------------------------------------------------------
! REWRITE Statement
! -----------------------------------------------------------------------------

<Rewrite Sent>
::= <Rewrite Stm> <Invalid Key Clauses> <END-REWRITE Opt>
| <Rewrite Stm>

<Rewrite Embed>
::= <Rewrite Stm> <Invalid Key Clauses> END-REWRITE
| <Rewrite Stm>

<Rewrite Imp>
::= <Rewrite Stm>

<Rewrite Stm>
::= REWRITE Identifier
| REWRITE Identifier FROM Identifier

<END-REWRITE Opt>
::= END-REWRITE
| !Optional

! -----------------------------------------------------------------------------
! SEARCH Statement
! -----------------------------------------------------------------------------

<Search Sent>
::= <Search Stm> <END-SEARCH Opt>

<Search Embed>
::= <Search Stm> END-SEARCH

<Search Imp>
::= <Search Stm> END-SEARCH
<Search Stm>
::= SEARCH Identifier <Varying Opt> <At End Clauses> <When Clauses>
| SEARCH ALL Identifier <At End Clauses> <When Clauses>

<Varying Opt>
::= VARYING <Value>
| !Optional

<END-SEARCH Opt>
::= END-SEARCH
| !Optional

! -----------------------------------------------------------------------------
! SEND Statement
! -----------------------------------------------------------------------------

<Send Sent>
::= <Send Stm>

<Send Embed>
::= <Send Stm>

<Send Imp>
::= <Send Stm>

<Send Stm>
::= SEND Identifier FROM <Variable>
| SEND Identifier FROM <Variable> <Send With> <Send Spec> <Send Replacing Opt>
| SEND Identifier <Send With> <Send Spec> <Send Replacing Opt>

<Send With>
::= <WITH Opt> Identifier
| <WITH Opt> ESI
| <WITH Opt> EMI
| <WITH Opt> EGI
<Send Spec>
::= <BEFORE AFTER> <ADVANCING Opt> <Send Advance>

<Send Advance>
::= <Value> <LINES Opt>
| PAGE
<Send Replacing Opt>
::= REPLACING <LINE Opt>

! -----------------------------------------------------------------------------
! SET Statement
! -----------------------------------------------------------------------------

<Set Sent>
::= <Set Stm>

<Set Embed>
::= <Set Stm>

<Set Imp>
::= <Set Stm>

<Set Stm>
::= SET <Variables> UP BY <Value>
| SET <Variables> DOWN BY <Value>
| SET <Variables> TO <Set Value>
<Set Value>
::= ON
| OFF
| TRUE

! -----------------------------------------------------------------------------
! SORT Statement
! -----------------------------------------------------------------------------

<Sort Sent>
::= <Sort Stm>

<Sort Embed>
::= <Sort Stm>

<Sort Imp>
::= <Sort Stm>

<Sort Stm>
::= SORT <Value> <Sort Keys> <Sort Duplicates Opt> <Collating Opt> <Sort Source> <Sort Target>
<Sort Duplicates Opt>
::= <WITH Opt> DUPLICATES <IN Opt> <ORDER opt>
| !Optional
! -----------------------------------------------------------------------------
! START Statement
! -----------------------------------------------------------------------------

<Start Sent>
::= <Start Stm> <Invalid Key Clauses> <END-START Opt>
| <Start Stm>

<Start Embed>
::= <Start Stm> <Invalid Key Clauses> END-START
| <Start Stm>

<Start Imp>
::= <Start Stm>

<Start Stm>
::= START Identifier <Start Key Opt>

<Start Key Opt>
::= KEY <Compare Op> Identifier
| !Optional

<END-START Opt>
::= END-START
| !Optional

! -----------------------------------------------------------------------------
! STOP Statement
! -----------------------------------------------------------------------------

<Stop Sent>
::= <Stop Stm>

<Stop Embed>
::= <Stop Stm>

<Stop Imp>
::= <Stop Stm>

<Stop Stm>
::= STOP RUN
| STOP <Literal>
! -----------------------------------------------------------------------------
! STRING Statement
! -----------------------------------------------------------------------------

<String Sent>
::= <String Stm> <Overflow Clauses> <END-STRING Opt>
| <String Stm>

<String Embed>
::= <String Stm> <Overflow Clauses> END-STRING
| <String Stm>

<String Imp>
::= <String Stm>

<String Stm>
::= STRING <String Items> INTO <Variable> <Pointer Clause>

<String Items>
::= <String Item> <String Items>
| <String Item>

<String Item>
::= <Values> DELIMITED <BY Opt> <Value>
<END-STRING Opt>
::= END-STRING
| !Optional

! -----------------------------------------------------------------------------
! SUBTRACT Statement
! -----------------------------------------------------------------------------

<Subtract Sent>
::= <Subtract Stm> <Size Clauses> <END-SUBTRACT Opt>
| <Subtract Stm>

<Subtract Embed>
::= <Subtract Stm> <Size Clauses> END-SUBTRACT
| <Subtract Stm>

<Subtract Imp>
::= <Subtract Stm>

<Subtract Stm>
::= SUBTRACT <Values> FROM <Variables> <Giving Clause Opt>
| SUBTRACT <CORRESPONDING> <Value> FROM Identifier
<END-SUBTRACT Opt>
::= END-SUBTRACT
| !Optional

! -----------------------------------------------------------------------------
! SUPPRESS Statement
! -----------------------------------------------------------------------------

<Suppress Sent>
::= <Suppress Stm>

<Suppress Embed>
::= <Suppress Stm>

<Suppress Imp>
::= <Suppress Stm>

<Suppress Stm>
::= SUPPRESS <PRINTING Opt>
! -----------------------------------------------------------------------------
! TERMMINATE Statement
! -----------------------------------------------------------------------------

<Terminate Sent>
::= <Terminate Stm>

<Terminate Embed>
::= <Terminate Stm>

<Terminate Imp>
::= <Terminate Stm>

<Terminate Stm>
::= TERMINATE <Identifiers>
! -----------------------------------------------------------------------------
! UNSTRING Statement
! -----------------------------------------------------------------------------

<Unstring Sent>
::= <Unstring Stm> <Overflow Clauses> <END-UNSTRING Opt>
| <Unstring Stm>

<Unstring Embed>
::= <Unstring Stm> <Overflow Clauses> END-UNSTRING
| <Unstring Stm>

<Unstring Imp>
::= <Unstring Stm>

<Unstring Stm>
::= UNSTRING identifier <Delimiter Clause> INTO Identifier <Unstring Options>

<Delimiter Clause>
::= DELIMITED <BY Opt> <Unstring Delimiter List>
| !Optional

<Unstring Delimiter List>
::= <Unstring Delimiter List> OR <Unstring Delimiter>
| <Unstring Delimiter>

<Unstring Delimiter>
::= <ALL Opt> <Value>

<Unstring Options>
::= <Unstring Options> <Unstring Option>
| !Empty

<Unstring Option>
::= <WITH Opt> POINTER <Variable>
| TALLYING <IN Opt> Identifier
<Not Exp> ::= NOT <Compare Exp>
<END-UNSTRING Opt>
::= END-UNSTRING
| <Compare Exp>
| !Optional


<Compare Exp> ::= <Shift Exp> <Compare Op> <Compare Exp> !e.g. x < y
! -----------------------------------------------------------------------------
| TypeOf <Add Exp> Is <Object>
! USE Statement
| <Shift Exp> Is <Object>
! -----------------------------------------------------------------------------
| <Shift Exp> Like <Value>
| <Shift Exp>


<Shift Exp> ::= <Concat Exp> '<<' <Shift Exp>
<Use Sent>
::= <Use Stm>
| <Concat Exp> '>>' <Shift Exp>
| <Concat Exp>


<Concat Exp> ::= <Add Exp> '&' <Concat Exp>
<Use Embed>
::= <Use Stm>
| <Add Exp>


<Add Exp> ::= <Modulus Exp> '+' <Add Exp>
<Use Imp>
::= <Use Stm>
| <Modulus Exp> '-' <Add Exp>
| <Modulus Exp>


<Modulus Exp> ::= <Int Div Exp> Mod <Modulus Exp>
<Use Stm>
::= USE <GLOBAL Opt> AFTER STANDARD <Use Proc Type> PROCEDURE ON <Use Access>
| <Int Div Exp>
| USE <GLOBAL Opt> BEFORE REPORTING Identifier
| USE <FOR Opt> DEBUGGING <ON Opt> <Use Debug>


<Int Div Exp> ::= <Mult Exp> '\' <Int Div Exp>
<Use Proc Type>
::= EXCEPTION
| <Mult Exp>
| ERROR


<Mult Exp> ::= <Negate Exp> '*' <Mult Exp>
<Use Access>
| <Negate Exp> '/' <Mult Exp>
::= INPUT
| OUTPUT
| <Negate Exp>
| I-O
| EXTEND
| <Value>
<Use Debug>
::= ALL <REFERENCES Opt> <OF Opt> Identifier
| ALL PROCEDURES
| <Value>


<Negate Exp> ::= '-' <Power Exp>
! -----------------------------------------------------------------------------
| <Power Exp>
! WRITE Statement
! -----------------------------------------------------------------------------


<Power Exp> ::= <Power Exp> '^' <Value>
<Write Sent>
::= <Write Stm> <Invalid Key Clauses> <END-WRITE Opt>
| <Value>
| <Write Stm> <AT EOP Clauses> <END-WRITE Opt>
| <Write Stm>

<Write Embed>
::= <Write Stm> <Invalid Key Clauses> END-WRITE
| <Write Stm> <AT EOP Clauses> END-WRITE
| <Write Stm>

<Write Imp>
::= <Write Stm>

<Write Stm>
::= WRITE Identifier <Write Options>
| WRITE Identifier FROM Identifier <Write Options>
<Write Options>
::= <BEFORE AFTER> <ADVANCING Opt> <Write Advance>

<Write Advance>
::= <Value> <LINES Opt>
| PAGE
<END-WRITE Opt>
::= END-WRITE
| !Optional
</pre>

=={{header|ColdFusion}}==
=={{header|Common Lisp}}==
=={{header|Component Pascal}}==
=={{header|Coq}}==
=={{header|D}}==
=={{header|DOS Batch File}}==
=={{header|Dc}}==
=={{header|Delphi}}==
=={{header|E}}==
=={{header|EC}}==
=={{header|ELLA}}==
=={{header|ESQL}}==
=={{header|Eiffel}}==
=={{header|Emacs Lisp}}==
=={{header|Erlang}}==
=={{header|F}}==
=={{header|F Sharp}}==
=={{header|FALSE}}==
=={{header|FP}}==
=={{header|Factor}}==
=={{header|Fan}}==
=={{header|Forth}}==
=={{header|Fortran}}==
=={{header|GAP}}==
=={{header|Gnuplot}}==
=={{header|Groovy}}==
=={{header|HaXe}}==
=={{header|Haskell}}==
=={{header|IDL}}==
=={{header|Icon}}==
=={{header|Io}}==
=={{header|J}}==
=={{header|JSON}}==
=={{header|JScript.NET}}==
=={{header|Java}}==
<pre>
"Name" = 'LALR(1) Java nonunicode grammar'
"Version" = '1.0 alpha 110'
"Author" = 'Dmitry Gazko'
"About" = 'Based on partial conversion of Sun Java 1.0-2.0 specification'

{String Char} = {Printable} - ["]
{Quote} = ['']
{IdLetter} = {Letter} + [_$]
{IdAlphaNumeric} = {Alphanumeric} + [_$]
{HexDigit} = {Digit} + [abcdefABCDEF]
{OctalCharSet} = [01234567]
{NoZeroDigit} = [123456789]
{LongTypeSuffix} =[lL]
{FloatTypeSuffix} =[dfDF]
{ExponentPartIndicator} = [eE]
{Sign} = [-+]
{CharSign} = [abtnfr"\] + {Quote}
{CharSign1} = {String Char} - [\]
{HexEscapeSign} =[uUxX]

Identifier = {IdLetter}{IdAlphaNumeric}*
StringLiteral = '"'{String Char}*'"'
FloatingPointLiteral = {Digit}+'.'{Digit}+{FloatTypeSuffix}? | {Digit}+{FloatTypeSuffix} | '.'{Digit}+{FloatTypeSuffix}?
FloatingPointLiteralExponent = {Digit}+'.'{Digit}+{ExponentPartIndicator}{Sign}?{Digit}+{FloatTypeSuffix}? | {Digit}+{ExponentPartIndicator}{Sign}?{Digit}+{FloatTypeSuffix}? | '.'{Digit}+{ExponentPartIndicator}{Sign}?{Digit}+{FloatTypeSuffix}?
BooleanLiteral = 'true' | 'false'
IndirectCharLiteral = {Quote}{CharSign1}{Quote}
StandardEscapeCharLiteral = {Quote}'\'{CharSign}{Quote}
OctalEscapeCharLiteral ={Quote}'\'{OctalCharSet}+{Quote}
HexEscapeCharLiteral ={Quote}'\'{HexEscapeSign}{HexDigit}+{Quote}
NullLiteral = 'null'
StartWithNoZeroDecimalIntegerLiteral = {NoZeroDigit}{Digit}*{LongTypeSuffix}?
StartWithZeroDecimalIntegerLiteral = '0'{LongTypeSuffix}?
HexIntegerLiteral = '0'('x'|'X'){HexDigit}+{LongTypeSuffix}?
OctalIntegerLiteral = '0'{OctalCharSet}+{LongTypeSuffix}?


"Case Sensitive" = 'True'
"Start Symbol" = <CompilationUnit>

Comment Start = '/*'
Comment End = '*/'
Comment Line = '//'

<CharacterLiteral>
::= IndirectCharLiteral
| StandardEscapeCharLiteral
| OctalEscapeCharLiteral
| HexEscapeCharLiteral

<DecimalIntegerLiteral>
::= StartWithZeroDecimalIntegerLiteral
| StartWithNoZeroDecimalIntegerLiteral

<FloatPointLiteral>
::= FloatingPointLiteral
| FloatingPointLiteralExponent

<IntegerLiteral>
::= <DecimalIntegerLiteral>
| HexIntegerLiteral
| OctalIntegerLiteral


<Literal>
::= <IntegerLiteral>
| <FloatPointLiteral>
| BooleanLiteral
| <CharacterLiteral>
| StringLiteral
| NullLiteral

<Type> ::= <PrimitiveType>
| <ReferenceType>

<PrimitiveType> ::= <NumericType>
| 'boolean'

<NumericType>
::= <IntegralType>
| <FloatingPointType>

<IntegralType>
::= 'byte'
| 'short'
| 'int'
| 'long'
| 'char'

<FloatingPointType>
::= 'float'
| 'double'

<ReferenceType>
::= <ClassOrInterfaceType>
| <ArrayType>

<ClassOrInterfaceType> ::= <Name>

<ClassType> ::= <ClassOrInterfaceType>

<InterfaceType> ::= <ClassOrInterfaceType>

<ArrayType>
::= <PrimitiveType> '[' ']'
| <Name> '[' ']'
| <ArrayType> '[' ']'

<Name>
::= <SimpleName>
| <QualifiedName>

<SimpleName> ::= Identifier

<QualifiedName> ::= <Name> '.' Identifier

<CompilationUnit>
::= <PackageDeclaration> <ImportDeclarations> <TypeDeclarations>
| <PackageDeclaration> <ImportDeclarations>
| <PackageDeclaration> <TypeDeclarations>
| <PackageDeclaration>
| <ImportDeclarations> <TypeDeclarations>
| <ImportDeclarations>
| <TypeDeclarations>
|

<ImportDeclarations>
::= <ImportDeclaration>
| <ImportDeclarations> <ImportDeclaration>

<TypeDeclarations>
::= <TypeDeclaration>
| <TypeDeclarations> <TypeDeclaration>

<PackageDeclaration>
::= 'package' <Name> ';'

<ImportDeclaration>
::= <SingleTypeImportDeclaration>
| <TypeImportOnDemandDeclaration>

<SingleTypeImportDeclaration>
::= 'import' <Name> ';'

<TypeImportOnDemandDeclaration>
::= 'import' <Name> '.' '*' ';'

<TypeDeclaration>
::= <ClassDeclaration>
| <InterfaceDeclaration>
| ';'

<Modifiers>
::= <Modifier>
| <Modifiers> <Modifier>

<Modifier>
::= 'public'
| 'protected'
| 'private'
| 'static'
| 'abstract'
| 'final'
| 'native'
| 'synchronized'
| 'transient'
| 'volatile'

<ClassDeclaration>
::= <Modifiers> 'class' Identifier <Super> <Interfaces> <ClassBody>
| <Modifiers> 'class' Identifier <Super> <ClassBody>
| <Modifiers> 'class' Identifier <Interfaces> <ClassBody>
| <Modifiers> 'class' Identifier <ClassBody>
| 'class' Identifier <Super> <Interfaces> <ClassBody>
| 'class' Identifier <Super> <ClassBody>
| 'class' Identifier <Interfaces> <ClassBody>
| 'class' Identifier <ClassBody>

<Super> ::= 'extends' <ClassType>

<Interfaces> ::= 'implements' <InterfaceTypeList>

<InterfaceTypeList> ::= <InterfaceType>
| <InterfaceTypeList> ',' <InterfaceType>

<ClassBody>
::= '{' <ClassBodyDeclarations> '}'
| '{' '}'

<ClassBodyDeclarations>
::= <ClassBodyDeclaration>
| <ClassBodyDeclarations> <ClassBodyDeclaration>

<ClassBodyDeclaration>
::= <ClassMemberDeclaration>
| <StaticInitializer>
| <ConstructorDeclaration>

<ClassMemberDeclaration>
::= <FieldDeclaration>
| <MethodDeclaration>

<FieldDeclaration>
::= <Modifiers> <Type> <VariableDeclarators> ';'
| <Type> <VariableDeclarators> ';'

<VariableDeclarators>
::= <VariableDeclarator>
| <VariableDeclarators> ',' <VariableDeclarator>

<VariableDeclarator>
::= <VariableDeclaratorId>
| <VariableDeclaratorId> '=' <VariableInitializer>

<VariableDeclaratorId>
::= Identifier
| <VariableDeclaratorId> '[' ']'

<VariableInitializer>
::= <Expression>
| <ArrayInitializer>

<MethodDeclaration> ::= <MethodHeader> <MethodBody>

<MethodHeader>
::= <Modifiers> <Type> <MethodDeclarator> <Throws>
| <Modifiers> <Type> <MethodDeclarator>
| <Type> <MethodDeclarator> <Throws>
| <Type> <MethodDeclarator>
| <Modifiers> 'void' <MethodDeclarator> <Throws>
| <Modifiers> 'void' <MethodDeclarator>
| 'void' <MethodDeclarator> <Throws>
| 'void' <MethodDeclarator>

<MethodDeclarator>
::= Identifier '(' <FormalParameterList> ')'
| Identifier '(' ')'
| <MethodDeclarator> '[' ']'

<FormalParameterList>
::= <FormalParameter>
| <FormalParameterList> ',' <FormalParameter>

<FormalParameter>
::= <Type> <VariableDeclaratorId>

<Throws>
::= 'throws' <ClassTypeList>

<ClassTypeList>
::= <ClassType>
| <ClassTypeList> ',' <ClassType>

<MethodBody>
::= <Block>
| ';'

<StaticInitializer>
::= 'static' <Block>

<ConstructorDeclaration>
::= <Modifiers> <ConstructorDeclarator> <Throws> <ConstructorBody>
| <Modifiers> <ConstructorDeclarator> <ConstructorBody>
| <ConstructorDeclarator> <Throws> <ConstructorBody>
| <ConstructorDeclarator> <ConstructorBody>

<ConstructorDeclarator>
::= <SimpleName> '(' <FormalParameterList> ')'
| <SimpleName> '(' ')'

<ConstructorBody>
::= '{' <ExplicitConstructorInvocation> <BlockStatements> '}'
| '{' <ExplicitConstructorInvocation> '}'
| '{' <BlockStatements> '}'
| '{' '}'

<ExplicitConstructorInvocation>
::= 'this' '(' <ArgumentList> ')' ';'
| 'this' '(' ')' ';'
| 'super' '(' <ArgumentList> ')' ';'
| 'super' '(' ')' ';'
<InterfaceDeclaration>
::= <Modifiers> 'interface' Identifier <ExtendsInterfaces> <InterfaceBody>
| <Modifiers> 'interface' Identifier <InterfaceBody>
| 'interface' Identifier <ExtendsInterfaces> <InterfaceBody>
| 'interface' Identifier <InterfaceBody>

<ExtendsInterfaces>
::= 'extends' <InterfaceType>
| <ExtendsInterfaces> ',' <InterfaceType>

<InterfaceBody>
::= '{' <InterfaceMemberDeclarations> '}'
| '{' '}'

<InterfaceMemberDeclarations>
::= <InterfaceMemberDeclaration>
| <InterfaceMemberDeclarations> <InterfaceMemberDeclaration>

<InterfaceMemberDeclaration>
::= <ConstantDeclaration>
| <AbstractMethodDeclaration>

<ConstantDeclaration> ::= <FieldDeclaration>

<AbstractMethodDeclaration> ::= <MethodHeader> ';'

<ArrayInitializer>
::= '{' <VariableInitializers> ',' '}'
| '{' <VariableInitializers> '}'
| '{' ',' '}'
| '{' '}'

<VariableInitializers> ::= <VariableInitializer>
| <VariableInitializers> ',' <VariableInitializer>

<Block> ::= '{' <BlockStatements> '}'
| '{' '}'

<BlockStatements>
::= <BlockStatement>
| <BlockStatements> <BlockStatement>

<BlockStatement>
::= <LocalVariableDeclarationStatement>
| <Statement>

<LocalVariableDeclarationStatement>
::= <LocalVariableDeclaration> ';'

<LocalVariableDeclaration>
::= <Type> <VariableDeclarators>

<Statement>
::= <StatementWithoutTrailingSubstatement>
| <LabeledStatement>
| <IfThenStatement>
| <IfThenElseStatement>
| <WhileStatement>
| <ForStatement>

<StatementNoShortIf>
::= <StatementWithoutTrailingSubstatement>
| <LabeledStatementNoShortIf>
| <IfThenElseStatementNoShortIf>
| <WhileStatementNoShortIf>
| <ForStatementNoShortIf>

<StatementWithoutTrailingSubstatement>
::= <Block>
| <EmptyStatement>
| <ExpressionStatement>
| <SwitchStatement>
| <DoStatement>
| <BreakStatement>
| <ContinueStatement>
| <ReturnStatement>
| <SynchronizedStatement>
| <ThrowStatement>
| <TryStatement>

<EmptyStatement>
::= ';'

<LabeledStatement>
::= Identifier ':' <Statement>

<LabeledStatementNoShortIf>
::= Identifier ':' <StatementNoShortIf>

<ExpressionStatement>
::= <StatementExpression> ';'

<StatementExpression>
::= <Assignment>
| <PreIncrementExpression>
| <PreDecrementExpression>
| <PostIncrementExpression>
| <PostDecrementExpression>
| <MethodInvocation>
| <ClassInstanceCreationExpression>

<IfThenStatement>
::= 'if' '(' <Expression> ')' <Statement>

<IfThenElseStatement>
::= 'if' '(' <Expression> ')' <StatementNoShortIf> 'else' <Statement>

<IfThenElseStatementNoShortIf>
::= 'if' '(' <Expression> ')' <StatementNoShortIf> 'else' <StatementNoShortIf>

<SwitchStatement>
::= 'switch' '(' <Expression> ')' <SwitchBlock>

<SwitchBlock>
::= '{' <SwitchBlockStatementGroups> <SwitchLabels> '}'
| '{' <SwitchBlockStatementGroups> '}'
| '{' <SwitchLabels> '}'
| '{' '}'

<SwitchBlockStatementGroups>
::= <SwitchBlockStatementGroup>
| <SwitchBlockStatementGroups> <SwitchBlockStatementGroup>

<SwitchBlockStatementGroup>
::= <SwitchLabels> <BlockStatements>

<SwitchLabels>
::= <SwitchLabel>
| <SwitchLabels> <SwitchLabel>

<SwitchLabel>
::= 'case' <ConstantExpression> ':'
| 'default' ':'

<WhileStatement>
::= 'while' '(' <Expression> ')' <Statement>

<WhileStatementNoShortIf>
::= 'while' '(' <Expression> ')' <StatementNoShortIf>

<DoStatement>
::= 'do' <Statement> 'while' '(' <Expression> ')' ';'

<ForStatement>
::= 'for' '(' <ForInit> ';' <Expression> ';' <ForUpdate> ')' <Statement>
| 'for' '(' <ForInit> ';' <Expression> ';' ')' <Statement>
| 'for' '(' <ForInit> ';' ';' <ForUpdate> ')' <Statement>
| 'for' '(' <ForInit> ';' ';' ')' <Statement>
| 'for' '(' ';' <Expression> ';' <ForUpdate> ')' <Statement>
| 'for' '(' ';' <Expression> ';' ')' <Statement>
| 'for' '(' ';' ';' <ForUpdate> ')' <Statement>
| 'for' '(' ';' ';' ')' <Statement>

<ForStatementNoShortIf>
::= 'for' '(' <ForInit> ';' <Expression> ';' <ForUpdate> ')' <StatementNoShortIf>
| 'for' '(' <ForInit> ';' <Expression> ';' ')' <StatementNoShortIf>
| 'for' '(' <ForInit> ';' ';' <ForUpdate> ')' <StatementNoShortIf>
| 'for' '(' <ForInit> ';' ';' ')' <StatementNoShortIf>
| 'for' '(' ';' <Expression> ';' <ForUpdate> ')' <StatementNoShortIf>
| 'for' '(' ';' <Expression> ';' ')' <StatementNoShortIf>
| 'for' '(' ';' ';' <ForUpdate> ')' <StatementNoShortIf>
| 'for' '(' ';' ';' ')' <StatementNoShortIf>

<ForInit> ::= <StatementExpressionList>
| <LocalVariableDeclaration>

<ForUpdate> ::= <StatementExpressionList>

<StatementExpressionList>
::= <StatementExpression>
| <StatementExpressionList> ',' <StatementExpression>

<BreakStatement>
::= 'break' Identifier ';'
| 'break' ';'

<ContinueStatement>
::= 'continue' Identifier ';'
| 'continue' ';'

<ReturnStatement>
::= 'return' <Expression> ';'
| 'return' ';'

<ThrowStatement>
::= 'throw' <Expression> ';'

<SynchronizedStatement>
::= 'synchronized' '(' <Expression> ')' <Block>

<TryStatement>
::= 'try' <Block> <Catches>
| 'try' <Block> <Catches> <Finally>
| 'try' <Block> <Finally>

<Catches>
::= <CatchClause>
| <Catches> <CatchClause>

<CatchClause>
::= 'catch' '(' <FormalParameter> ')' <Block>

<Finally>
::= 'finally' <Block>

<Primary>
::= <PrimaryNoNewArray>
| <ArrayCreationExpression>

<PrimaryNoNewArray>
::= <Literal>
| 'this'
| '(' <Expression> ')'
| <ClassInstanceCreationExpression>
| <FieldAccess>
| <MethodInvocation>
| <ArrayAccess>

<ClassInstanceCreationExpression>
::= 'new' <ClassType> '(' <ArgumentList> ')'
| 'new' <ClassType> '(' ')'

<ArgumentList>
::= <Expression>
| <ArgumentList> ',' <Expression>

<ArrayCreationExpression>
::= 'new' <PrimitiveType> <DimExprs> <Dims>
| 'new' <PrimitiveType> <DimExprs>
| 'new' <ClassOrInterfaceType> <DimExprs> <Dims>
| 'new' <ClassOrInterfaceType> <DimExprs>

<DimExprs>
::= <DimExpr>
| <DimExprs> <DimExpr>

<DimExpr> ::= '[' <Expression> ']'

<Dims> ::= '[' ']'
| <Dims> '[' ']'

<FieldAccess>
::= <Primary> '.' Identifier
| 'super' '.' Identifier

<MethodInvocation>
::= <Name> '(' <ArgumentList> ')'
| <Name> '(' ')'
| <Primary> '.' Identifier '(' <ArgumentList> ')'
| <Primary> '.' Identifier '(' ')'
| 'super' '.' Identifier '(' <ArgumentList> ')'
| 'super' '.' Identifier '(' ')'

<ArrayAccess>
::= <Name> '[' <Expression> ']'
| <PrimaryNoNewArray> '[' <Expression> ']'

<PostfixExpression>
::= <Primary>
| <Name>
| <PostIncrementExpression>
| <PostDecrementExpression>

<PostIncrementExpression>
::= <PostfixExpression> '++'

<PostDecrementExpression>
::= <PostfixExpression> '--'

<UnaryExpression>
::= <PreIncrementExpression>
| <PreDecrementExpression>
| '+' <UnaryExpression>
| '-' <UnaryExpression>
| <UnaryExpressionNotPlusMinus>

<PreIncrementExpression>
::= '++' <UnaryExpression>

<PreDecrementExpression>
::= '--' <UnaryExpression>

<UnaryExpressionNotPlusMinus>
::= <PostfixExpression>
| '~' <UnaryExpression>
| '!' <UnaryExpression>
| <CastExpression>

<CastExpression>
::= '(' <PrimitiveType> <Dims> ')' <UnaryExpression>
| '(' <PrimitiveType> ')' <UnaryExpression>
| '(' <Expression> ')' <UnaryExpressionNotPlusMinus>
| '(' <Name> <Dims> ')' <UnaryExpressionNotPlusMinus>

<MultiplicativeExpression>
::= <UnaryExpression>
| <MultiplicativeExpression> '*' <UnaryExpression>
| <MultiplicativeExpression> '/' <UnaryExpression>
| <MultiplicativeExpression> '%' <UnaryExpression>

<AdditiveExpression>
::= <MultiplicativeExpression>
| <AdditiveExpression> '+' <MultiplicativeExpression>
| <AdditiveExpression> '-' <MultiplicativeExpression>

<ShiftExpression>
::= <AdditiveExpression>
| <ShiftExpression> '<<' <AdditiveExpression>
| <ShiftExpression> '>>' <AdditiveExpression>
| <ShiftExpression> '>>>' <AdditiveExpression>

<RelationalExpression>
::= <ShiftExpression>
| <RelationalExpression> '<' <ShiftExpression>
| <RelationalExpression> '>' <ShiftExpression>
| <RelationalExpression> '<=' <ShiftExpression>
| <RelationalExpression> '>=' <ShiftExpression>
| <RelationalExpression> 'instanceof' <ReferenceType>

<EqualityExpression>
::= <RelationalExpression>
| <EqualityExpression> '==' <RelationalExpression>
| <EqualityExpression> '!=' <RelationalExpression>

<AndExpression>
::= <EqualityExpression>
| <AndExpression> '&' <EqualityExpression>

<ExclusiveOrExpression>
::= <AndExpression>
| <ExclusiveOrExpression> '^' <AndExpression>

<InclusiveOrExpression>
::= <ExclusiveOrExpression>
| <InclusiveOrExpression> '|' <ExclusiveOrExpression>

<ConditionalAndExpression>
::= <InclusiveOrExpression>
| <ConditionalAndExpression> '&&' <InclusiveOrExpression>

<ConditionalOrExpression>
::= <ConditionalAndExpression>
| <ConditionalOrExpression> '||' <ConditionalAndExpression>

<ConditionalExpression>
::= <ConditionalOrExpression>
| <ConditionalOrExpression> '?' <Expression> ':' <ConditionalExpression>

<AssignmentExpression>
::= <ConditionalExpression>
| <Assignment>


<Value> ::= '(' <Expression> ')'
<Assignment>
::= <LeftHandSide> <AssignmentOperator> <AssignmentExpression>
| New <Identifier> <Argument List Opt>
| IntLiteral
| HexLiteral
| OctLiteral
| StringLiteral
| CharLiteral
| RealLiteral
| DateLiteral
| True
| False
| Me
| MyClass
| MyBase
| Nothing
| <Variable>
| AddressOf <Identifier>


<Object> ::= <Identifier> !Object identifiers
<LeftHandSide>
::= <Name>
| Me
| <FieldAccess>
| MyClass
| <ArrayAccess>
| MyBase
| Nothing


<Variable> ::= <Identifier> <Argument List Opt> <Method Calls>
<AssignmentOperator>
::= '='
<Method Calls> ::= <Method Call> <Method Calls>
| '*='
| '/='
|
| '%='
| '+='
| '-='
| '<<='
| '>>='
| '>>>='
| '&='
| '^='
| '|='


<Method Call> ::= MemberID <Argument List Opt>
<Expression> ::= <AssignmentExpression>


<ConstantExpression> ::= <Expression>
</pre>


<Identifier> ::= ID | QualifiedID !Any type of identifier
=={{header|JavaScript}}==
</pre></div>
=={{header|JoCaml}}==
=={{header|Joy}}==
=={{header|JudoScript}}==
=={{header|Korn Shell}}==
=={{header|LSE64}}==
=={{header|LaTeX}}==
=={{header|LabVIEW}}==
=={{header|Lisaac}}==
=={{header|Lisp}}==
=={{header|Logo}}==
=={{header|Logtalk}}==
=={{header|LotusScript}}==
=={{header|Lua}}==
=={{header|Lucid}}==
=={{header|M4}}==
=={{header|MAXScript}}==
=={{header|MIRC Scripting Language}}==
=={{header|MS SQL}}==
=={{header|Make}}==
=={{header|Maple}}==
=={{header|Mathematica}}==
=={{header|Maxima}}==
=={{header|Metafont}}==
=={{header|Modula-3}}==
=={{header|NewLISP}}==
=={{header|Nial}}==
=={{header|OCaml}}==
=={{header|Oberon-2}}==
=={{header|Object Pascal}}==
=={{header|Objective-C}}==
=={{header|Octave}}==
=={{header|Omega}}==
=={{header|OpenEdge/Progress}}==
=={{header|Oz}}==
=={{header|PHP}}==
=={{header|PL/I}}==
=={{header|PL/SQL}}==
=={{header|Pascal}}==
=={{header|Perl}}==
=={{header|Pike}}==
=={{header|PlainTeX}}==
=={{header|Pop11}}==
=={{header|PostScript}}==
=={{header|PowerShell}}==
=={{header|Prolog}}==
=={{header|Python}}==
=={{header|Q}}==
=={{header|R}}==
=={{header|REXX}}==
=={{header|RapidQ}}==
=={{header|Raven}}==
=={{header|Rhope}}==
=={{header|Ruby}}==
=={{header|SAS}}==
=={{header|SETL}}==
=={{header|SMEQL}}==
=={{header|SNUSP}}==
=={{header|SQL}}==
=={{header|Scala}}==
=={{header|Scheme}}==
=={{header|Script3D}}==
=={{header|Seed7}}==
=={{header|Self}}==
=={{header|Slate}}==
=={{header|Smalltalk}}==
=={{header|Standard ML}}==
=={{header|TI-83 BASIC}}==
=={{header|TI-89 BASIC}}==
=={{header|Tcl}}==
=={{header|Toka}}==
=={{header|Tr}}==
=={{header|Transact-SQL}}==
=={{header|Twelf}}==
=={{header|UNIX Shell}}==
=={{header|UnixPipes}}==
=={{header|Unlambda}}==
=={{header|V}}==
=={{header|VBScript}}==
=={{header|Vedit macro language}}==
=={{header|Visual Basic}}==
=={{header|Visual Basic .NET}}==
=={{header|Visual Objects}}==
=={{header|Wrapl}}==
=={{header|XSLT}}==
=={{header|XTalk}}==

Latest revision as of 10:13, 17 August 2012

BNF Grammar was a programming task. It has been deprecated for reasons that are discussed in its talk page.

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.

BNF is widely used as a notation for the grammars of computer programming languages, instruction sets and communication protocols, as well as a notation for representing parts of natural language grammars. Many textbooks for programming language theory and/or semantics document the programming language in BNF.

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.

BASIC

! -----------------------------------------------------------------------
! BASIC '64 
!
! Beginner's All-purpose Symbolic Instruction Code 
!
!    "It is practically impossible to teach good programming style to students 
!     that have had prior exposure to BASIC; as potential programmers they are 
!     mentally mutilated beyond hope of regeneration." 
!
!     - Edsger W. Dijkstra 
!
! BASIC is one of the oldest programming language and one of the most popular. 
! It was developed in 1964 by John G. Kemeny and Thomas E. Kurtz to teach 
! students the basics of programming concepts. At the advent of the microcomputer,
! BASIC was implemented on numerous platforms such as the Commodore, Atari, 
! Apple II, Altair, IBM PC computers. Over time, BASIC evolved into GW-BASIC, 
! QBasic, Visual Basic, and recently Visual Basic .NET.
!
! In practically all programming languages, the reserved word/symbol that denotes
! a comment is treated as a form of whitespace - having no effect in the manner in
! which the program runs. Once such type of comment is used to indicate the remainder
! of the line is to be ignored. These can be added to the end of any line without
! changing the meaning of the program. In C++, it is the '//' symbol;
! in BASIC '64 it is 'REM'.
!
! However, in the BASIC programming language, the line comment is treated like a 
! statement. For instance, if 'REM' was a normal line comment:
!
!    10  PRINT "Hello World" REM Common first program
!
! would be a valid statement. However, in BASIC, this is illegal. In the example 
! above, the comment must be added as an additional statement.
!
!    10  PRINT "Hello World" : REM Common first program
!
! As a result, the Line Comment terminal that is used in the GOLD Parser cannot be
! used here. In the grammar below, a 'Remark' terminal was created that accepts all 
! series of printable characters starting with the characters "REM ". In some 
! implementations of BASIC, any string starting with "REM" is a comment statement.
! Examples include "REMARK", "REMARKABLE" and "REMODEL". This grammar requires the space.
!
! This grammar does not include the editor statements such as NEW, SAVE, LOAD, etc...
!
! Note: This is an ad hoc version of the language. If there are any flaws, please 
! e-mail GOLDParser@DevinCook.com and I will update the grammar. Most likely I have
! included features not available in BASIC '64.
! -----------------------------------------------------------------------


"Name"    = 'BASIC (Beginners All-purpose Symbolic Instruction Code)'
"Author"  = 'John G. Kemeny and Thomas E. Kurtz' 
"Version" = '1964 - Original - before Microsoft enhanced the language for the IBM PC.'
"About"   = 'BASIC is one of most common and popular teaching languages ever created. '

"Case Sensitive" = False 
"Start Symbol"   = <Lines>

{String Chars} = {Printable} - ["]
{WS}           = {Whitespace} - {CR} - {LF}

NewLine        = {CR}{LF}|{CR}
Whitespace     = {WS}+

Remark         = REM{Space}{Printable}*
ID             = {Letter}[$%]? 
String         = '"'{String Chars}*'"' 
Integer        = {digit}+ 
Real           = {digit}+.{digit}+ 

<Lines>       ::= Integer <Statements> NewLine <Lines> 
                | Integer <Statements> NewLine

<Statements>  ::= <Statement> ':' <Statements>
                | <Statement>

<Statement>   ::= CLOSE '#' Integer
                | DATA <Constant List> 
                | DIM ID '(' <Integer List> ')'
                | END          
                | FOR ID '=' <Expression> TO <Expression>     
                | FOR ID '=' <Expression> TO <Expression> STEP Integer      
                | GOTO <Expression> 
                | GOSUB <Expression> 
                | IF <Expression> THEN <Statement>         
                | INPUT <ID List>       
                | INPUT '#' Integer ',' <ID List>       
                | LET Id '=' <Expression> 
                | NEXT <ID List>               
                | OPEN <Value> FOR <Access> AS '#' Integer
                | POKE <Value List>
                | PRINT <Print list>
                | PRINT '#' Integer ',' <Print List>
                | READ <ID List>           
                | RETURN
                | RESTORE
                | RUN
                | STOP
                | SYS <Value>
                | WAIT <Value List>
                | Remark

<Access>   ::= INPUT
             | OUPUT
                   
<ID List>  ::= ID ',' <ID List> 
             | ID 

<Value List>      ::= <Value> ',' <Value List> 
                    | <Value> 

<Constant List>   ::= <Constant> ',' <Constant List> 
                    | <Constant> 

<Integer List>    ::= Integer ',' <Integer List>
                    | Integer
                 
<Expression List> ::= <Expression> ',' <Expression List> 
                    | <Expression> 

<Print List>      ::= <Expression> ';' <Print List>
                    | <Expression> 
                    |  

<Expression>  ::= <And Exp> OR <Expression> 
                | <And Exp> 

<And Exp>     ::= <Not Exp> AND <And Exp> 
                | <Not Exp> 
 
<Not Exp>     ::= NOT <Compare Exp> 
                | <Compare Exp> 

<Compare Exp> ::= <Add Exp> '='  <Compare Exp> 
                | <Add Exp> '<>' <Compare Exp> 
                | <Add Exp> '><' <Compare Exp> 
                | <Add Exp> '>'  <Compare Exp> 
                | <Add Exp> '>=' <Compare Exp> 
                | <Add Exp> '<'  <Compare Exp> 
                | <Add Exp> '<=' <Compare Exp> 
                | <Add Exp> 

<Add Exp>     ::= <Mult Exp> '+' <Add Exp> 
                | <Mult Exp> '-' <Add Exp> 
                | <Mult Exp> 

<Mult Exp>    ::= <Negate Exp> '*' <Mult Exp> 
                | <Negate Exp> '/' <Mult Exp> 
                | <Negate Exp> 

<Negate Exp>  ::= '-' <Power Exp> 
                | <Power Exp> 

<Power Exp>   ::= <Power Exp> '^' <Value> 
                | <Value> 

<Value>       ::= '(' <Expression> ')'
                | ID 
                | ID '(' <Expression List> ')'
                | <Constant> 

<Constant> ::= Integer 
             | String 
             | Real 

BASIC Commodore PET

! -----------------------------------------------------------------------
! Commodore PET BASIC 
!
! Beginner's All-purpose Symbolic Instruction Code 
!
!    "It is practically impossible to teach good programming style to students 
!    that have had prior exposure to BASIC; as potential programmers they are 
!    mentally mutilated beyond hope of regeneration."    
!
!    - Edsger W. Dijkstra 
!
!
! BASIC is one of the oldest programming language and one of the most popular. 
! It was developed in 1964 by John G. Kemeny and Thomas E. Kurtz to teach 
! students the basics of programming concepts. At the advent of the microcomputer,
! BASIC was implemented on numerous platforms such as the Commodore, Atari, 
! Apple II, Altair, IBM PC computers. Over time, BASIC evolved into GW-BASIC, 
! QBasic, Visual Basic, and recently Visual Basic .NET.
!
! In practically all programming languages, the reserved word/symbol that denotes
! a comment is treated as a form of whitespace - having no effect in the manner in
! which the program runs. Once such type of comment is used to indicate the remainder
! of the line is to be ignored. These can be added to the end of any line without
! changing the meaning of the program. In C++, it is the '//' symbol.
!
! However, in the BASIC programming language, the line comment is treated like a 
! statement. For instance, if 'REM' was a normal line comment:
!
!    10  PRINT "Hello World" REM Common first program
!
! would be a valid statement. However, in BASIC, this is illegal. In the example 
! above, the comment must be added as an additional statement.
!
!    10  PRINT "Hello World" : REM Common first program
!
! As a result, the Line Comment terminal that is used in the GOLD Parser cannot be
! used here. In the grammar below, a 'Remark' terminal was created that accepts all 
! series of printable characters starting with the characters "REM ". In some 
! implementations of BASIC, any string starting with "REM" is a comment statement.
! Examples include "REMARK", "REMARKABLE" and "REMODEL". This grammar requires the space.
!
! -----------------------------------------------------------------------


"Name"    = 'Commodore PET BASIC'
"Author"  = 'Commodore Business Machines'
"Version" = '2.0'
"About"   = 'This is the version of BASIC that was used on the Commodore 64.'

"Case Sensitive" = False 
"Start Symbol"   = <Lines>

{String Chars} = {Printable} - ["]
{WS}           = {Whitespace} - {CR} - {LF}

NewLine        = {CR}{LF}|{CR}
Whitespace     = {WS}+

Remark         = REM{Space}{Printable}*
ID             = {Letter}{Alphanumeric}?[$%]?      !IDs are can only have a maximum of 2 characters
FunctionID     = FN {Letter}{Letter}?

String         = '"'{String Chars}*'"' 
Integer        = {Digit}+ 
Real           = {Digit}+'.'{Digit}+ 

<Lines>       ::= <Lines> <Line>
                | <Line>

<Line>        ::= Integer <Statements> NewLine 
                                
<Statements>  ::= <Statements> ':' <Statement>
                | <Statement>

<Statement>   ::= CLOSE Integer
                | CLR
                | CMD  <Expression>
                | CONT                                          !Continue
                | DATA <Constant List> 
                | DEF FunctionID '(' <ID List> ')' '=' <Expression>    !The ID must start with FN
                | DIM ID '(' <Expression List> ')'
                | END          
                | FOR ID '=' <Expression> TO <Expression> <Step Opt>     
                | GET ID
                | GET '#' Integer ',' ID
                | GOSUB <Expression> 
                | GOTO <Expression>                 
                | IF <Expression> THEN <Then Clause>                
                | INPUT <ID List>       
                | INPUT '#' Integer ',' <ID List>       
                | LET ID '=' <Expression> 
                | LIST <Line Range>
                | LOAD <Value List>        
                | ID '=' <Expression> 
                | NEW
                | NEXT <ID List>               
                | ON ID GOTO <Expression List>
                | OPEN <Expression List>         
                | POKE <Expression> ',' <Expression>
                | PRINT <Print list>
                | PRINT '#' Integer ',' <Print List>
                | READ <ID List>           
                | RETURN
                | RESTORE
                | RUN
                | RUN <Expression>
                | STOP
                | SYS <Expression>
                | WAIT <Expression List>     
                | VERIFY <Expression List>     
                | Remark

<Step Opt> ::= STEP <Expression>
             | 
                   
<ID List>  ::= ID ',' <ID List> 
             | ID 

<Value List>      ::= <Value> ',' <Value List> 
                    | <Value> 

<Constant List>   ::= <Constant> ',' <Constant List> 
                    | <Constant> 
                 
<Expression List> ::= <Expression> ',' <Expression List> 
                    | <Expression> 

<Print List>      ::= <Expression> ';' <Print List>
                    | <Expression> 
                    |  

<Line Range>  ::= Integer 
                | Integer '-'
                | Integer '-' Integer 

<Then Clause> ::= Integer
                | <Statement>

! ----------------------------------------------- Expressions

<Expression>  ::= <And Exp> OR <Expression> 
                | <And Exp> 

<And Exp>     ::= <Not Exp> AND <And Exp> 
                | <Not Exp> 
 
<Not Exp>     ::= NOT <Compare Exp> 
                | <Compare Exp> 

<Compare Exp> ::= <Add Exp> '='  <Compare Exp> 
                | <Add Exp> '<>' <Compare Exp> 
                | <Add Exp> '>'  <Compare Exp> 
                | <Add Exp> '>=' <Compare Exp> 
                | <Add Exp> '<'  <Compare Exp> 
                | <Add Exp> '<=' <Compare Exp> 
                | <Add Exp> 

<Add Exp>     ::= <Mult Exp> '+' <Add Exp> 
                | <Mult Exp> '-' <Add Exp> 
                | <Mult Exp> 

<Mult Exp>    ::= <Negate Exp> '*' <Mult Exp> 
                | <Negate Exp> '/' <Mult Exp> 
                | <Negate Exp> 

<Negate Exp>  ::= '-' <Power Exp> 
                | <Power Exp> 

<Power Exp>   ::= <Power Exp> '^' <Sub Exp>        !On the Commodore, the symbol was an up-arrow
                | <Sub Exp> 

<Sub Exp>     ::= '(' <Expression> ')'
                | <Value>

<Value>       ::= ID 
                | ABS        '(' <Expression> ')'
                | ASC        '(' <Expression> ')'
                | ATN        '(' <Expression> ')'
                | 'CHR$'     '(' <Expression> ')'
                | COS        '(' <Expression> ')'
                | EXP        '(' <Expression> ')'
                | FunctionID '(' <Expression List> ')'
                | FRE        '(' <Value> ')'                  !The <Value> is  irrelevant
                | INT        '(' <Expression> ')'
                | 'LEFT$'    '(' <Expression> ',' <Expression> ')'
                | LEN        '(' <Expression> ')'
                | PEEK       '(' <Expression> ')'
                | POS        '(' <Value> ')'                  !The <Value> is  irrelevant
                | 'RIGHT$'   '(' <Expression> ',' <Expression> ')'
                | RND        '(' <Expression> ')'
                | SGN        '(' <Expression> ')' 
                | SPC        '(' <Expression> ')' 
                | SQR        '(' <Expression> ')' 
                | TAB        '(' <Expression> ')' 
                | TAN        '(' <Expression> ')' 
                | VAL        '(' <Expression> ')' 
                
                | <Constant> 

<Constant>    ::= Integer 
                | String 
                | Real 

Brainf***

 Code ::= Command Code | <NONE>
 Command ::= "+" | "-" | "<" | ">" | "," | "." | "[" Code "]" | <ANY>

PARI/GP

parse.y contains a grammar for GP. The grammar for PARI is that of C.

PowerShell

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 PDF form on the publisher's site.

This grammar does not accurately represent the PowerShell language, though, as for example the for loop mandates semicolons in the grammar but in practice does not require them when arguments are omitted. The infinite loop may be represented by <lang powershell>for () {}</lang> but the grammar would require <lang powershell>for (;;) {}</lang>

VBScript

!===============================
! VB Script grammar.
!
! To create the grammar I was using Microsoft's VB Script documentation
! available from http://msdn.microsoft.com/scripting,
! VB Script parser from ArrowHead project http://www.tripi.com/arrowhead/,
! and Visual Basic .Net grammar file written by Devin Cook.
!
! This grammar cannot cover all aspects of VBScript and may have some errors.
! Feel free to contact me if you find any flaws in the grammar.
!
! Vladimir Morozov   vmoroz@hotmail.com
!
! Special thanks to Nathan Baulch for the grammar updates. 
!
! USE GOLD PARSER BUILDER VERSION 2.1 AND LATER TO COMPILE THIS GRAMMAR.
!===============================

"Name"            = 'VB Script'
"Author"          = 'John G. Kemeny and Thomas E. Kurtz'
"Version"         = '5.0'
"About"           = 'VB Script grammar.'
"Case Sensitive"  = False
"Start Symbol"    = <Program>

!===============================
! Character sets
!===============================

{String Char}   = {All Valid} - ["]
{Date Char}     = {Printable} - [#]
{ID Name Char}  = {Printable} - ['['']']
{Hex Digit}     = {Digit} + [abcdef]
{Oct Digit}     = [01234567]
{WS}            = {Whitespace} - {CR} - {LF}
{ID Tail}       = {Alphanumeric} + [_]

!===============================
! Terminals
!===============================

NewLine        = {CR} {LF}
               | {CR}
               | {LF}
               | ':'

! Special white space definition. Whitespace is either space or tab, which
! can be followed by continuation symbol '_' followed by new line character
Whitespace     = {WS}+
               | '_' {WS}* {CR}? {LF}?

! Special comment definition
Comment Line   = ''
               | 'Rem'

! Literals
StringLiteral  = '"' ( {String Char} | '""' )* '"'
IntLiteral     = {Digit}+
HexLiteral     = '&H' {Hex Digit}+ '&'?
OctLiteral     = '&' {Oct Digit}+ '&'?
FloatLiteral   = {Digit}* '.' {Digit}+ ( 'E' [+-]? {Digit}+ )?
               | {Digit}+ 'E' [+-]? {Digit}+
DateLiteral    = '#' {Date Char}+ '#'

! Identifier is either starts with letter and followed by letter,
! number or underscore, or it can be escaped sequence of any printable
! characters ([] and [_$% :-) @] are valid identifiers)
ID             = {Letter} {ID Tail}*
               | '[' {ID Name Char}* ']'

! White space is not allowed to be before dot, but allowed to be after it.
IDDot          = {Letter} {ID Tail}* '.'
               | '[' {ID Name Char}* ']' '.'
               | 'And.'
               | 'ByRef.'
               | 'ByVal.'
               | 'Call.'
               | 'Case.'
               | 'Class.'
               | 'Const.'
               | 'Default.'
               | 'Dim.'
               | 'Do.'
               | 'Each.'
               | 'Else.'
               | 'ElseIf.'
               | 'Empty.'
               | 'End.'
               | 'Eqv.'
               | 'Erase.'
               | 'Error.'
               | 'Exit.'
               | 'Explicit.'
               | 'False.'
               | 'For.'
               | 'Function.'
               | 'Get.'
               | 'GoTo.'
               | 'If.'
               | 'Imp.'
               | 'In.'
               | 'Is.'
               | 'Let.'
               | 'Loop.'
               | 'Mod.'
               | 'New.'
               | 'Next.'
               | 'Not.'
               | 'Nothing.'
               | 'Null.'
               | 'On.'
               | 'Option.'
               | 'Or.'
               | 'Preserve.'
               | 'Private.'
               | 'Property.'
               | 'Public.'
               | 'Redim.'
               | 'Rem.'
               | 'Resume.'
               | 'Select.'
               | 'Set.'
               | 'Step.'
               | 'Sub.'
               | 'Then.'
               | 'To.'
               | 'True.'
               | 'Until.'
               | 'WEnd.'
               | 'While.'
               | 'With.'
               | 'Xor.'

! The following identifiers should only be used in With statement.
! This rule must be checked by contextual analyzer.
DotID          = '.' {Letter} {ID Tail}*
               | '.' '[' {ID Name Char}* ']'
               | '.And'
               | '.ByRef'
               | '.ByVal'
               | '.Call'
               | '.Case'
               | '.Class'
               | '.Const'
               | '.Default'
               | '.Dim'
               | '.Do'
               | '.Each'
               | '.Else'
               | '.ElseIf'
               | '.Empty'
               | '.End'
               | '.Eqv'
               | '.Erase'
               | '.Error'
               | '.Exit'
               | '.Explicit'
               | '.False'
               | '.For'
               | '.Function'
               | '.Get'
               | '.GoTo'
               | '.If'
               | '.Imp'
               | '.In'
               | '.Is'
               | '.Let'
               | '.Loop'
               | '.Mod'
               | '.New'
               | '.Next'
               | '.Not'
               | '.Nothing'
               | '.Null'
               | '.On'
               | '.Option'
               | '.Or'
               | '.Preserve'
               | '.Private'
               | '.Property'
               | '.Public'
               | '.Redim'
               | '.Rem' 
               | '.Resume'
               | '.Select'
               | '.Set'
               | '.Step'
               | '.Sub'
               | '.Then'
               | '.To'
               | '.True'
               | '.Until'
               | '.WEnd'
               | '.While'
               | '.With'
               | '.Xor'

DotIDDot       = '.' {Letter}{ID Tail}* '.'
               | '.' '[' {ID Name Char}* ']' '.'
               | '.And.'
               | '.ByRef.'
               | '.ByVal.'
               | '.Call.'
               | '.Case.'
               | '.Class.'
               | '.Const.'
               | '.Default.'
               | '.Dim.'
               | '.Do.'
               | '.Each.'
               | '.Else.'
               | '.ElseIf.'
               | '.Empty.'
               | '.End.'
               | '.Eqv.'
               | '.Erase.'
               | '.Error.'
               | '.Exit.'
               | '.Explicit.'
               | '.False.'
               | '.For.'
               | '.Function.'
               | '.Get.'
               | '.GoTo.'
               | '.If.'
               | '.Imp.'
               | '.In.'
               | '.Is.'
               | '.Let.'
               | '.Loop.'
               | '.Mod.'
               | '.New.'
               | '.Next.'
               | '.Not.'
               | '.Nothing.'
               | '.Null.'
               | '.On.'
               | '.Option.'
               | '.Or.'
               | '.Preserve.'
               | '.Private.'
               | '.Property.'
               | '.Public.'
               | '.Redim.'
               | '.Rem.'
               | '.Resume.'
               | '.Select.'
               | '.Set.'
               | '.Step.'
               | '.Sub.'
               | '.Then.'
               | '.To.'
               | '.True.'
               | '.Until.'
               | '.WEnd.'
               | '.While.'
               | '.With.'
               | '.Xor.'

!===============================
! Rules
!===============================

<NL>                   ::= NewLine <NL>
                         | NewLine

<Program>              ::= <NLOpt> <GlobalStmtList>

!===============================
! Rules : Declarations
!===============================

<ClassDecl>            ::= 'Class' <ExtendedID> <NL> <MemberDeclList> 'End' 'Class' <NL>

<MemberDeclList>       ::= <MemberDecl> <MemberDeclList>
                         |

<MemberDecl>           ::= <FieldDecl>
                         | <VarDecl>
                         | <ConstDecl>
                         | <SubDecl>
                         | <FunctionDecl>
                         | <PropertyDecl>

<FieldDecl>            ::= 'Private' <FieldName> <OtherVarsOpt> <NL>
                         | 'Public' <FieldName> <OtherVarsOpt> <NL>

<FieldName>            ::= <FieldID> '(' <ArrayRankList> ')'
                         | <FieldID>

<FieldID>              ::= ID
                         | 'Default'
                         | 'Erase'
                         | 'Error'
                         | 'Explicit'
                         | 'Step'

<VarDecl>              ::= 'Dim' <VarName> <OtherVarsOpt> <NL>

<VarName>              ::= <ExtendedID> '(' <ArrayRankList> ')'
                         | <ExtendedID>

<OtherVarsOpt>         ::= ',' <VarName> <OtherVarsOpt>
                         |

<ArrayRankList>        ::= <IntLiteral> ',' <ArrayRankList>
                         | <IntLiteral>
                         |

<ConstDecl>            ::= <AccessModifierOpt> 'Const' <ConstList> <NL>

<ConstList>            ::= <ExtendedID> '=' <ConstExprDef> ',' <ConstList>
                         | <ExtendedID> '=' <ConstExprDef>

<ConstExprDef>         ::= '(' <ConstExprDef> ')'
                         | '-' <ConstExprDef>
                         | '+' <ConstExprDef> 
                         | <ConstExpr> 

<SubDecl>              ::= <MethodAccessOpt> 'Sub' <ExtendedID> <MethodArgList> <NL> <MethodStmtList> 'End' 'Sub' <NL>
                         | <MethodAccessOpt> 'Sub' <ExtendedID> <MethodArgList> <InlineStmt> 'End' 'Sub' <NL>

<FunctionDecl>         ::= <MethodAccessOpt> 'Function' <ExtendedID> <MethodArgList> <NL> <MethodStmtList> 'End' 'Function' <NL>
                         | <MethodAccessOpt> 'Function' <ExtendedID> <MethodArgList> <InlineStmt> 'End' 'Function' <NL>

<MethodAccessOpt>      ::= 'Public' 'Default'
                         | <AccessModifierOpt>

<AccessModifierOpt>    ::= 'Public'
                         | 'Private'
                         |

<MethodArgList>        ::= '(' <ArgList> ')'
                         | '(' ')'
                         |

<ArgList>              ::= <Arg> ',' <ArgList>
                         | <Arg>

<Arg>                  ::= <ArgModifierOpt> <ExtendedID> '(' ')'
                         | <ArgModifierOpt> <ExtendedID>

<ArgModifierOpt>       ::= 'ByVal'
                         | 'ByRef'
                         |

<PropertyDecl>         ::= <MethodAccessOpt> 'Property' <PropertyAccessType> <ExtendedID> <MethodArgList> <NL> <MethodStmtList> 'End' 'Property' <NL>                        

<PropertyAccessType>   ::= 'Get'
                         | 'Let'
                         | 'Set'

!===============================
! Rules : Statements
!===============================

<GlobalStmt>           ::= <OptionExplicit>
                         | <ClassDecl>
                         | <FieldDecl>
                         | <ConstDecl>
                         | <SubDecl>
                         | <FunctionDecl>
                         | <BlockStmt>

<MethodStmt>           ::= <ConstDecl>
                         | <BlockStmt>

<BlockStmt>            ::= <VarDecl>
                         | <RedimStmt>
                         | <IfStmt>
                         | <WithStmt>
                         | <SelectStmt>
                         | <LoopStmt>
                         | <ForStmt>
                         | <InlineStmt> <NL>

<InlineStmt>           ::= <AssignStmt>
                         | <CallStmt>
                         | <SubCallStmt>
                         | <ErrorStmt>
                         | <ExitStmt>
                         | 'Erase' <ExtendedID>

<GlobalStmtList>       ::= <GlobalStmt> <GlobalStmtList>
                         | 

<MethodStmtList>       ::= <MethodStmt> <MethodStmtList>
                         |
                        
<BlockStmtList>        ::= <BlockStmt> <BlockStmtList>
                         |
                        
<OptionExplicit>       ::= 'Option' 'Explicit' <NL>

<ErrorStmt>            ::= 'On' 'Error' 'Resume' 'Next'
                         | 'On' 'Error' 'GoTo' IntLiteral  ! must be 0

<ExitStmt>             ::= 'Exit' 'Do'
                         | 'Exit' 'For'
                         | 'Exit' 'Function'
                         | 'Exit' 'Property'
                         | 'Exit' 'Sub'

<AssignStmt>           ::= <LeftExpr> '=' <Expr>
                         | 'Set' <LeftExpr> '=' <Expr>
                         | 'Set' <LeftExpr> '=' 'New' <LeftExpr>

! Hack: VB Script allows to have construct a = b = c, which means a = (b = c)
! In this grammar we do not allow it in order to prevent complications with
! interpretation of a(1) = 2, which may be considered as array element assignment
! or a subroutine call: a ((1) = 2).
! Note: VBScript allows to have missed parameters: a ,,2,3,
! VM: If somebody knows a better way to do it, please let me know
<SubCallStmt>          ::= <QualifiedID> <SubSafeExprOpt> <CommaExprList>
                         | <QualifiedID> <SubSafeExprOpt>
                         | <QualifiedID> '(' <Expr> ')' <CommaExprList>
                         | <QualifiedID> '(' <Expr> ')'
                         | <QualifiedID> '(' ')'
                         | <QualifiedID> <IndexOrParamsList> '.' <LeftExprTail> <SubSafeExprOpt> <CommaExprList>
                         | <QualifiedID> <IndexOrParamsListDot> <LeftExprTail> <SubSafeExprOpt> <CommaExprList>
                         | <QualifiedID> <IndexOrParamsList> '.' <LeftExprTail> <SubSafeExprOpt>
                         | <QualifiedID> <IndexOrParamsListDot> <LeftExprTail> <SubSafeExprOpt>

! This very simplified case - the problem is that we cannot use parenthesis in aaa(bbb).ccc (ddd)
<SubSafeExprOpt>       ::= <SubSafeExpr>
                         |

<CallStmt>             ::= 'Call' <LeftExpr>

<LeftExpr>             ::= <QualifiedID> <IndexOrParamsList> '.' <LeftExprTail>
                         | <QualifiedID> <IndexOrParamsListDot> <LeftExprTail>
                         | <QualifiedID> <IndexOrParamsList>
                         | <QualifiedID>
                         | <SafeKeywordID>

<LeftExprTail>         ::= <QualifiedIDTail> <IndexOrParamsList> '.' <LeftExprTail>
                         | <QualifiedIDTail> <IndexOrParamsListDot> <LeftExprTail>
                         | <QualifiedIDTail> <IndexOrParamsList>
                         | <QualifiedIDTail>

! VB Script does not allow to have space between Identifier and dot:
! a . b - Error ; a. b or a.b - OK
<QualifiedID>          ::= IDDot <QualifiedIDTail>
                         | DotIDDot <QualifiedIDTail>
                         | ID
                         | DotID

<QualifiedIDTail>      ::= IDDot <QualifiedIDTail>
                         | ID
                         | <KeywordID>

<KeywordID>            ::= <SafeKeywordID>
                         | 'And'
                         | 'ByRef'
                         | 'ByVal'
                         | 'Call'
                         | 'Case'
                         | 'Class'
                         | 'Const'
                         | 'Dim'
                         | 'Do'
                         | 'Each'
                         | 'Else'
                         | 'ElseIf'
                         | 'Empty'
                         | 'End'
                         | 'Eqv'
                         | 'Exit'
                         | 'False'
                         | 'For'
                         | 'Function'
                         | 'Get'
                         | 'GoTo'
                         | 'If'
                         | 'Imp'
                         | 'In'
                         | 'Is'
                         | 'Let'
                         | 'Loop'
                         | 'Mod'
                         | 'New'
                         | 'Next'
                         | 'Not'
                         | 'Nothing'
                         | 'Null'
                         | 'On'
                         | 'Option'
                         | 'Or'
                         | 'Preserve'
                         | 'Private'
                         | 'Public'
                         | 'Redim'
                         | 'Resume'
                         | 'Select'
                         | 'Set'
                         | 'Sub'
                         | 'Then'
                         | 'To'
                         | 'True'
                         | 'Until'
                         | 'WEnd'
                         | 'While'
                         | 'With'
                         | 'Xor'

<SafeKeywordID>        ::= 'Default'
                         | 'Erase'
                         | 'Error'
                         | 'Explicit'
                         | 'Property'
                         | 'Step'

<ExtendedID>           ::= <SafeKeywordID>
                         | ID

<IndexOrParamsList>    ::= <IndexOrParams> <IndexOrParamsList>
                         | <IndexOrParams>

<IndexOrParams>        ::= '(' <Expr> <CommaExprList> ')'
                         | '(' <CommaExprList> ')'
                         | '(' <Expr> ')'
                         | '(' ')'

<IndexOrParamsListDot> ::= <IndexOrParams> <IndexOrParamsListDot>
                         | <IndexOrParamsDot>

<IndexOrParamsDot>     ::= '(' <Expr> <CommaExprList> ').'
                         | '(' <CommaExprList> ').'
                         | '(' <Expr> ').'
                         | '(' ').'

<CommaExprList>        ::= ',' <Expr> <CommaExprList>
                         | ',' <CommaExprList>
                         | ',' <Expr>
                         | ','

!========= Redim Statement

<RedimStmt>            ::= 'Redim' <RedimDeclList> <NL>
                         | 'Redim' 'Preserve' <RedimDeclList> <NL>

<RedimDeclList>        ::= <RedimDecl> ',' <RedimDeclList>
                         | <RedimDecl>

<RedimDecl>            ::= <ExtendedID> '(' <ExprList> ')'

!========= If Statement

<IfStmt>               ::= 'If' <Expr> 'Then' <NL> <BlockStmtList> <ElseStmtList> 'End' 'If' <NL>
                         | 'If' <Expr> 'Then' <InlineStmt> <ElseOpt> <EndIfOpt> <NL>

<ElseStmtList>         ::= 'ElseIf' <Expr> 'Then' <NL> <BlockStmtList> <ElseStmtList>
                         | 'ElseIf' <Expr> 'Then' <InlineStmt> <NL> <ElseStmtList>
                         | 'Else' <InlineStmt> <NL>
                         | 'Else' <NL> <BlockStmtList>
                         |

<ElseOpt>              ::= 'Else' <InlineStmt>
                         |

<EndIfOpt>             ::= 'End' 'If'
                         |

!========= With Statement

<WithStmt>             ::= 'With' <Expr> <NL> <BlockStmtList> 'End' 'With' <NL>

!========= Loop Statement

<LoopStmt>             ::= 'Do' <LoopType> <Expr> <NL> <BlockStmtList> 'Loop' <NL>
                         | 'Do' <NL> <BlockStmtList> 'Loop' <LoopType> <Expr> <NL>
                         | 'Do' <NL> <BlockStmtList> 'Loop' <NL>
                         | 'While' <Expr> <NL> <BlockStmtList> 'WEnd' <NL>

<LoopType>             ::= 'While'
                         | 'Until'

!========= For Statement

<ForStmt>              ::= 'For' <ExtendedID> '=' <Expr> 'To' <Expr> <StepOpt> <NL> <BlockStmtList> 'Next' <NL>
                         | 'For' 'Each' <ExtendedID> 'In' <Expr> <NL> <BlockStmtList> 'Next' <NL>

<StepOpt>              ::= 'Step' <Expr>
                         |

!========= Select Statement

<SelectStmt>           ::= 'Select' 'Case' <Expr> <NL> <CaseStmtList> 'End' 'Select' <NL>

<CaseStmtList>         ::= 'Case' <ExprList> <NLOpt> <BlockStmtList> <CaseStmtList>
                         | 'Case' 'Else' <NLOpt> <BlockStmtList>
                         |

<NLOpt>                ::= <NL>
                         |

<ExprList>             ::= <Expr> ',' <ExprList>
                         | <Expr>

!===============================
! Rules : Expressions
!===============================

<SubSafeExpr>          ::= <SubSafeImpExpr>

<SubSafeImpExpr>       ::= <SubSafeImpExpr> 'Imp' <EqvExpr>
                         | <SubSafeEqvExpr>

<SubSafeEqvExpr>       ::= <SubSafeEqvExpr> 'Eqv' <XorExpr>
                         | <SubSafeXorExpr>

<SubSafeXorExpr>       ::= <SubSafeXorExpr> 'Xor' <OrExpr>
                         | <SubSafeOrExpr>

<SubSafeOrExpr>        ::= <SubSafeOrExpr> 'Or' <AndExpr>
                         | <SubSafeAndExpr>

<SubSafeAndExpr>       ::= <SubSafeAndExpr> 'And' <NotExpr>
                         | <SubSafeNotExpr>

<SubSafeNotExpr>       ::= 'Not' <NotExpr>
                         | <SubSafeCompareExpr>

<SubSafeCompareExpr>   ::= <SubSafeCompareExpr> 'Is' <ConcatExpr>
                         | <SubSafeCompareExpr> 'Is' 'Not' <ConcatExpr>
                         | <SubSafeCompareExpr> '>=' <ConcatExpr>
                         | <SubSafeCompareExpr> '=>' <ConcatExpr>
                         | <SubSafeCompareExpr> '<=' <ConcatExpr>
                         | <SubSafeCompareExpr> '=<' <ConcatExpr>
                         | <SubSafeCompareExpr> '>'  <ConcatExpr>
                         | <SubSafeCompareExpr> '<'  <ConcatExpr>
                         | <SubSafeCompareExpr> '<>' <ConcatExpr>
                         | <SubSafeCompareExpr> '='  <ConcatExpr>
                         | <SubSafeConcatExpr>

<SubSafeConcatExpr>    ::= <SubSafeConcatExpr> '&' <AddExpr>
                         | <SubSafeAddExpr>

<SubSafeAddExpr>       ::= <SubSafeAddExpr> '+' <ModExpr>
                         | <SubSafeAddExpr> '-' <ModExpr>
                         | <SubSafeModExpr>

<SubSafeModExpr>       ::= <SubSafeModExpr> 'Mod' <IntDivExpr>
                         | <SubSafeIntDivExpr>

<SubSafeIntDivExpr>    ::= <SubSafeIntDivExpr> '\' <MultExpr>
                         | <SubSafeMultExpr>

<SubSafeMultExpr>      ::= <SubSafeMultExpr> '*' <UnaryExpr>
                         | <SubSafeMultExpr> '/' <UnaryExpr>
                         | <SubSafeUnaryExpr>

<SubSafeUnaryExpr>     ::= '-' <UnaryExpr>
                         | '+' <UnaryExpr>
                         | <SubSafeExpExpr>

<SubSafeExpExpr>       ::= <SubSafeValue> '^' <ExpExpr>
                         | <SubSafeValue>

<SubSafeValue>         ::= <ConstExpr>
                         | <LeftExpr>
!                         | '(' <Expr> ')'

<Expr>                 ::= <ImpExpr>

<ImpExpr>              ::= <ImpExpr> 'Imp' <EqvExpr>
                         | <EqvExpr>

<EqvExpr>              ::= <EqvExpr> 'Eqv' <XorExpr>
                         | <XorExpr>

<XorExpr>              ::= <XorExpr> 'Xor' <OrExpr>
                         | <OrExpr>

<OrExpr>               ::= <OrExpr> 'Or' <AndExpr>
                         | <AndExpr>

<AndExpr>              ::= <AndExpr> 'And' <NotExpr>
                         | <NotExpr>

<NotExpr>              ::= 'Not' <NotExpr>
                         | <CompareExpr>

<CompareExpr>          ::= <CompareExpr> 'Is' <ConcatExpr>
                         | <CompareExpr> 'Is' 'Not' <ConcatExpr>
                         | <CompareExpr> '>=' <ConcatExpr>
                         | <CompareExpr> '=>' <ConcatExpr>
                         | <CompareExpr> '<=' <ConcatExpr>
                         | <CompareExpr> '=<' <ConcatExpr>
                         | <CompareExpr> '>'  <ConcatExpr>
                         | <CompareExpr> '<'  <ConcatExpr>
                         | <CompareExpr> '<>' <ConcatExpr>
                         | <CompareExpr> '='  <ConcatExpr>
                         | <ConcatExpr>

<ConcatExpr>           ::= <ConcatExpr> '&' <AddExpr>
                         | <AddExpr>

<AddExpr>              ::= <AddExpr> '+' <ModExpr>
                         | <AddExpr> '-' <ModExpr>
                         | <ModExpr>

<ModExpr>              ::= <ModExpr> 'Mod' <IntDivExpr>
                         | <IntDivExpr>

<IntDivExpr>           ::= <IntDivExpr> '\' <MultExpr>
                         | <MultExpr>

<MultExpr>             ::= <MultExpr> '*' <UnaryExpr>
                         | <MultExpr> '/' <UnaryExpr>
                         | <UnaryExpr>

<UnaryExpr>            ::= '-' <UnaryExpr>
                         | '+' <UnaryExpr>
                         | <ExpExpr>

<ExpExpr>              ::= <Value> '^' <ExpExpr>
                         | <Value>

<Value>                ::= <ConstExpr>
                         | <LeftExpr>
                         | '(' <Expr> ')'

<ConstExpr>            ::= <BoolLiteral>
                         | <IntLiteral>
                         | FloatLiteral
                         | StringLiteral
                         | DateLiteral
                         | <Nothing>

<BoolLiteral>          ::= 'True'
                         | 'False'

<IntLiteral>           ::= IntLiteral
                         | HexLiteral
                         | OctLiteral

<Nothing>              ::= 'Nothing'
                         | 'Null'
                         | 'Empty'

Visual Basic .NET

The following link (Appedix B) has a simple BNF Syntax VB Syntax

! -----------------------------------------------------------------------
! Visual Basic .NET
! 
! Visual Basic .NET is the latest version in the long evoluation of the 
! BASIC programming language. The Visual Basic .NET programming language 
! is far more "clean" and orthagonal than its predecessors. Although some 
! of the old constructs exist, the language is far easier to read and write.
! 
! Major syntax changes include, but are not limited to:
! 
! 1. The primative file access of VB6 was replaced by a class library. As 
!    a result, special statements such as 
!    
!    Open "test" For Input As #1
!    
!    no longer exist. 
! 
! 2. Class module files were replaced by 'Class ... End Class' declarations
! 
! 3. Module files were replaced by 'Module ... End Module' declarations
!
! 4. Structured error handling was added with C++ style Try ... Catch 
!    statements. The old nonstructured approach is still, unfortunately,
!    available.
! 
! Unfortnately, the designers of Visual Basic .NET did not remove the 
! datatype postfix characters on identifiers. In the original BASIC, 
! variables types were determined by $ for strings and % for integers.
! QuickBasic expanded the postix notation to include other symbols 
! for long integers, singles, etc... 
!
! Part of the ID terminal definition was commented out to prevent the
! old format. You can allow the postfix characters if you like.
!
! This grammar also does not contain the compiler directives.
!
! Note: This is an ad hoc version of the language. If there are any flaws, 
! please visit www.DevinCook.com/GOLDParser
!
! Updates:
!     04/082005
!         Devin Cook
!         1. Removed minus sign from the IntLiteral and RealLiteral 
!            definitions. These can cause some parse errors when expressions
!            like "2-2" are read. In this case it would have been interpreted
!            as "2" and "-2" rather than "2", "-" and "2".
!         2. Members of an enumeration can be defined with any expression.
!         3. Made some very minor comment changes - mainly for readability.
!
!     03/27/2005
!         Adrian Moore [adrianrob@hotmail.com]
!         1. Add support for Implements in Class
!         2. Add support for AddressOf keyword
!         3. No longer fails if variable starts with _
!
!     02/24/2004
!         Vladimir Morozov [vmoroz@hotmail.com] fixed a few flaws in the
!         grammar. 1. The definition for strings did not allow the double 
!         double-quote override. 2. A real literal does not need to have a 
!         fraction if followed by an exponent. 3. Escaped identifiers can 
!         contain a null string and 4. Rem works the same as the '
!
!
! USE GOLD PARSER BUILDER VERSION 2.1 AND LATER TO COMPILE THIS GRAMMAR.
! Earlier versions cannot handle the complexity.
! -----------------------------------------------------------------------

"Name"     = 'Visual Basic .NET' 
"Author"   = 'John G. Kemeny and Thomas E. Kurtz'
"Version"  = '.NET'
"About"    = 'Visual Basic .NET is the latest version in the long evoluation of the'
           | 'BASIC programming language.'
                 

"Case Sensitive" = False 
"Start Symbol"   = <Program>

! ----------------------------------------------------------------- Sets

{String Chars}  = {Printable} - ["]
{Date Chars}    = {Printable} - [#]
{ID Name Chars} = {Printable} - ['['']']
{Hex Digit}     = {Digit} + [abcdef]
{Oct Digit}     = [01234567]

{WS}            = {Whitespace} - {CR} - {LF}
{Id Tail}       = {Alphanumeric} + [_]

! ----------------------------------------------------------------- Terminals

NewLine        = {CR}{LF} | {CR} | ':' 
Whitespace     = {WS}+  | '_' {WS}* {CR} {LF}?

Comment Line   = '' | Rem                !Fixed by Vladimir Morozov 

LABEL          = {Letter}{ID Tail}*':'

!Fixed by Vladimir Morozov 

ID             = [_]?{Letter}{ID Tail}*           ! [%&@!#$]?   !Archaic postfix chars
               | '[' {ID Name Chars}* ']'
     
QualifiedID    = ({Letter}{ID Tail}* | '['{ID Name Chars}*']')  ( '.'({Letter}{ID Tail}* | '['{ID Name Chars}*']') )+

MemberID       = '.' {Letter}{ID Tail}* 
               | '.[' {ID Name Chars}* ']'
               
!Fixed by Vladimir Morozov 
StringLiteral  = '"' ( {String Chars} | '""' )* '"'


CharLiteral    = '"' {String Chars}* '"C'
IntLiteral     = {digit}+ [FRDSIL]?

RealLiteral    = {digit}* '.' {digit}+ ( 'E' [+-]? {Digit}+ )? [FR]?
               | {digit}+ 'E' [+-]? {Digit}+  [FR]?


DateLiteral    = '#'{Date chars}'#'

HexLiteral     = '&H'{Hex Digit}+ [SIL]?
OctLiteral     = '&O'{Oct Digit}+ [SIL]?

! ----------------------------------------------------------------- Rules

<Program>    ::= <NameSpace Item>  <Program>
               | <Imports>         <Program>
               | <Option Decl>     <Program>
               |

! -------------------------------------------------------------------
! (Shared attributes)
! -------------------------------------------------------------------

<NL>    ::= NewLine <NL> 
          | NewLine

<Modifiers> ::= <Modifier> <Modifiers>
              | 

<Modifier> ::= Shadows
             | Shared
             | MustInherit 
             | NotInheritable

             | Overridable 
             | NotOverridable 
             | MustOverride 
             | Overrides 
             | Overloads
                  
             | Default 
             | ReadOnly
             | WriteOnly
            
             | <Access>

<Access Opt> ::= <Access>
               |

<Access>  ::= Public
            | Private
            | Friend
            | Protected
            

<Var Member>   ::=  <Attributes> <Access> <Var Decl> <NL>               !Variables                    
                 |  <Attributes> <Access Opt> Const  <Var Decl> <NL>    !Constants
                 |  <Attributes> <Access Opt> Static <Var Decl> <NL>                         
                
<Implements>   ::= Implements <ID List> 

<ID List>  ::= <Identifier> ',' <ID List>
             | <Identifier>
               
<Option Decl>  ::= Option <IDs> <NL>

<IDs> ::= ID <IDs> 
        | ID
   
<Type>  ::= As <Attributes> <Identifier> 
          |

<Compare Op>  ::= '=' | '<>' | '<' | '>' | '>=' | '<='

! -------------------------------------------------------------------
! NameSpace
! -------------------------------------------------------------------

<NameSpace>       ::= NameSpace ID <NL> <NameSpace Items> End NameSpace <NL>

<NameSpace Items> ::= <NameSpace Item> <NameSpace Items>                    
                    | 

<NameSpace Item> ::= <Class>      
                   | <Declare>
                   | <Delegate>
                   | <Enumeration> 
                   | <Interface>
                   | <Structure> 
                   | <Module>              
                   | <Namespace>
          

! -------------------------------------------------------------------
! Attributes
! -------------------------------------------------------------------

<Attributes> ::= '<' <Attribute List> '>'
               |

<Attribute List> ::= <Attribute> ',' <Attribute List>
                   | <Attribute>
                   
<Attribute>     ::= <Attribute Mod> ID <Argument List Opt>                  
   
<Attribute Mod> ::= Assembly 
                  | Module 
                  | 
                             
! -------------------------------------------------------------------
! Delegates
! -------------------------------------------------------------------
<Delegate> ::= <Attributes> <Modifiers> Delegate <Method>   
             | <Attributes> <Modifiers> Delegate <Declare>   
            

! -------------------------------------------------------------------
! Imports
! -------------------------------------------------------------------

<Imports> ::= Imports <Identifier> <NL> 
            | Imports ID '=' <Identifier> <NL>

! -------------------------------------------------------------------
! Events
! -------------------------------------------------------------------

<Event Member> ::= <Attributes> <Modifiers> Event ID <Parameters Or Type> <Implements Opt> <NL>

<Parameters Or Type> ::= <Param List>
                       | As <Identifier> 

<Implements Opt> ::= <Implements>
                   |
                                         
! -------------------------------------------------------------------
! Class
! -------------------------------------------------------------------

<Class>       ::= <Attributes> <Modifiers> Class ID <NL> <Class Items> End Class <NL>


<Class Items> ::= <Class Item> <Class Items>                
                |

<Class Item>  ::= <Declare>
                | <Method>        
                | <Property>   
                | <Var Member>                
                | <Enumeration>
                | <Inherits>
                | <Class Implements>
                
<Inherits> ::= Inherits <Identifier> <NL>
               
<Class Implements> ::= Implements <ID List> <NL>

! -------------------------------------------------------------------
! Structures
! -------------------------------------------------------------------

<Structure>    ::= <Attributes> <Modifiers> Structure ID <NL> <Structure List> End Structure <NL>

<Structure List> ::= <Structure Item> <Structure List>
                   | 

<Structure Item> ::= <Implements>
                   | <Enumeration>
                   | <Structure>
                   | <Class>
                   | <Delegate>   
                   | <Var Member>                    
                   | <Event Member>
                   | <Declare>
                   | <Method>
                   | <Property>

! -------------------------------------------------------------------
! Module
! -------------------------------------------------------------------

<Module>       ::= <Attributes> <Modifiers> Module ID <NL> <Module Items> End Module <NL>

<Module Items> ::= <Module Item> <Module Items>
                 | 
                 
<Module Item>  ::= <Declare>
                 | <Method>                 
                 | <Property>   
                 | <Var Member> 
                 | <Enumeration>
                 | <Option Decl>

! -------------------------------------------------------------------
! Interface
! -------------------------------------------------------------------

<Interface> ::= <Attributes> <Modifiers> Interface ID <NL> <Interface Items> End Interface <NL>


<Interface Items> ::= <Interface Item> <Interface Items>
                    | 
               
<Interface Item>  ::= <Implements>
                    | <Event Member>
                    | <Enum Member>                   
                    | <Method Member>                   
                    | <Property Member>

<Enum Member>     ::= <Attributes> <Modifiers> Enum ID <NL>

<Method Member>   ::= <Attributes> <Modifiers> Sub <Sub ID> <Param List> <Handles Or Implements> <NL>
                    | <Attributes> <Modifiers> Function ID  <Param List> <Type> <Handles Or Implements> <NL> 

<Property Member> ::= <Attributes> <Modifiers> Property ID  <Param List> <Type> <Handles Or Implements> <NL> 
               
               
! -------------------------------------------------------------------
! Parameters
! -------------------------------------------------------------------

<Param List Opt> ::= <Param List>
                   |

<Param List>     ::= '(' <Param Items> ')'
                   | '(' ')'
 
<Param Items>    ::= <Param Item> ',' <Param Items>
                   | <Param Item>

<Param Item>     ::= <Param Passing> ID <Type> 


<Param Passing>  ::= ByVal
                   | ByRef
                   | Optional 
                   | ParamArray
                   |

! -------------------------------------------------------------------
! Arguments 
! -------------------------------------------------------------------

<Argument List Opt> ::= <Argument List>
                      |
                       
<Argument List>  ::= '(' <Argument Items> ')'
              
<Argument Items> ::= <Argument> ',' <Argument Items>
                   | <Argument> 

<Argument>       ::= <Expression>
                   | Id ':=' <Expression>
                   |                          !NULL
                   
                  
! -------------------------------------------------------------------
! Declares (External Procedures)   
! -------------------------------------------------------------------

<Declare> ::= <Attributes> <Modifiers> Declare <Charset> Sub      ID Lib StringLiteral <Alias> <Param List Opt> <NL>
            | <Attributes> <Modifiers> Declare <Charset> Function ID Lib StringLiteral <Alias> <Param List Opt> <Type> <NL>

<Charset> ::= Ansi | Unicode | Auto |  !Null

<Alias> ::= Alias StringLiteral
          |


! -------------------------------------------------------------------
! Methods
! -------------------------------------------------------------------

<Method> ::= <Attributes> <Modifiers> Sub <Sub ID> <Param List>        <Handles Or Implements> <NL> <Statements> End Sub <NL>
           | <Attributes> <Modifiers> Function ID  <Param List> <Type> <Handles Or Implements> <NL> <Statements> End Function <NL>
                
<Sub ID>     ::= ID
               | New     !Class creation

<Handles Or Implements> ::= <Implements> 
                          | <Handles>
                          | 

<Handles>      ::= Handles <ID List>

! -------------------------------------------------------------------
! Properties
! -------------------------------------------------------------------
                 
<Property>   ::= <Attributes> <Modifiers> Property ID <Param List> <Type> <NL> <Property Items> End Property <NL>

<Property Items> ::= <Property Item> <Property Items>          
                   |

<Property Item> ::= Get <NL> <Statements> End Get <NL>
                  | Set <Param List> <NL> <Statements> End Set <NL>


! ------------------------------------------------------------------- 
! Enumerations
! ------------------------------------------------------------------- 

<Enumeration>   ::= <Attributes> <Modifiers> Enum ID <NL> <Enum List> End Enum <NL>

<Enum List>     ::= <Enum Item> <Enum List>
                  | 

<Enum Item>     ::= Id '=' <Expression> <NL>
                  | Id <NL>

! -------------------------------------------------------------------
! Variable Declaration
! -------------------------------------------------------------------

<Var Decl> ::= <Var Decl Item> ',' <Var Decl>
             | <Var Decl Item>
                  
<Var Decl Item>  ::= <Var Decl ID> As <Identifier> <Argument List Opt>             
                   | <Var Decl ID> As <Identifier> '=' <Expression>         !Initialize                                        
                   | <Var Decl ID> As New <Identifier> <Argument List Opt>
                   | <Var Decl ID>
                   | <Var Decl ID> '=' <Expression>                          !Initialize 

<Var Decl ID> ::= ID <Argument List Opt> 
                
! ------------------------------------------------------------------- 
! Normal Statements
! -------------------------------------------------------------------

<Statements>  ::= <Statement> <Statements>
                | 

<Statement>   ::= <Loop Stm>
                | <For Stm>
                | <If Stm>                 
                | <Select Stm> 
                | <SyncLock Stm>
                | <Try Stm>               
                | <With Stm>
                | <Option Decl>                   
                | <Local Decl>    
                | <Non-Block Stm> <NL>       !Note the <NL>. A non-block statement can be a full statement
                | LABEL           <NL>  
                                
                              
<Non-Block Stm> ::= Call <Variable>
                  | ReDim <Var Decl>  
                  | ReDim Preserve <Var Decl>
                  | Erase ID 
     
                  | Throw <Value>                                    
                  | RaiseEvent <Identifier>  <Argument List Opt>
                  | AddHandler <Expression> ',' <Expression>
                  | RemoveHandler  <Expression> ',' <Expression>
    
                  | Exit Do 
                  | Exit For                  
                  | Exit Function            
                  | Exit Property                   
                  | Exit Select      
                  | Exit Sub    
                  | Exit Try
                  | Exit While
                  | GoTo ID                   !Argh - they still have this
                  | Return <Value>           

                  | Error <Value>                      !Raise an error by number
                  | On Error GoTo IntLiteral           ! 0  This is obsolete.   
                  | On Error GoTo '-' IntLiteral       !-1  This is obsolete.
                  | On Error GoTo Id      
                  | On Error Resume Next 
                  | Resume ID 
                  | Resume Next 
                  
                  | <Variable> <Assign Op> <Expression> 
                  | <Variable>       
                  | <Method Call>         

<Assign Op>   ::= '=' | '^=' | '*=' | '/=' | '\=' | '+=' | '-=' | '&=' | '<<=' | '>>='


! ------------------------------------------------------------------- 
! Local declarations
! -------------------------------------------------------------------

<Local Decl>  ::= Dim    <Var Decl>  <NL>
                | Const  <Var Decl>  <NL>
                | Static <Var Decl>  <NL> 

! ------------------------------------------------------------------- 
! Do Statement
! -------------------------------------------------------------------

<Loop Stm>   ::= Do <Test Type> <Expression> <NL> <Statements> Loop <NL>
               | Do <NL> <Statements> Loop <Test Type> <Expression> <NL>                
               | While <Expression> <NL> <Statements> End While <NL>

<Test Type>  ::= While
               | Until                 

! -------------------------------------------------------------------
! For Statement
! -------------------------------------------------------------------

<For Stm>   ::= For <Identifier>  '=' <Expression> To <Expression> <Step Opt> <NL> <Statements> Next <NL>    
              | For Each <Variable> In <Variable> <NL> <Statements> Next <NL>

<Step Opt>  ::= Step <Expression>
              |


! -------------------------------------------------------------------
! If Statement
! -------------------------------------------------------------------

<If Stm>    ::= If <Expression> <Then Opt> <NL> <Statements> <If Blocks> End If <NL> 
              | If <Expression> Then <Non-Block Stm> <NL>
              | If <Expression> Then <Non-Block Stm> Else <Non-Block Stm> <NL>

<Then Opt>  ::= Then         !!The reserved word 'Then' is optional for Block-If statements
              |

<If Blocks> ::= ElseIf <Expression> <Then Opt> <NL> <Statements> <If Blocks>
              | Else <NL> <Statements>
              |

! -------------------------------------------------------------------
! Select Statement
! -------------------------------------------------------------------

<Select Stm>    ::= Select <Case Opt> <Expression> <NL> <Select Blocks> End Select <NL>

<Case Opt>      ::= Case                         !!The "Case" after Select is optional in VB.NEt
                  |


<Select Blocks> ::= Case <Case Clauses> <NL> <Statements>  <Select Blocks>
                  | Case Else <NL> <Statements>  
                  |                 

<Case Clauses>  ::= <Case Clause> ',' <Case Clauses>
                  | <Case Clause> 

<Case Clause>   ::= <Is Opt> <Compare Op> <Expression>
                  | <Expression> 
                  | <Expression> To <Expression>

<Is Opt> ::= Is 
           | !Null

! -------------------------------------------------------------------
! SyncLock Statement
! -------------------------------------------------------------------

<SyncLock Stm> ::= SyncLock <NL> <Statements> End SyncLock <NL>             

! -------------------------------------------------------------------
! Try Statement
! -------------------------------------------------------------------

<Try Stm>      ::= Try <NL> <Statements> <Catch Blocks> End Try <NL>  

<Catch Blocks> ::= <Catch Block> <Catch Blocks>
                 | <Catch Block>

<Catch Block>  ::= Catch <Identifier>  As ID <NL> <Statements> 
                 | Catch <NL> <Statements>

! -------------------------------------------------------------------
! With Statement
! -------------------------------------------------------------------

<With Stm> ::= With <Value> <NL> <Statements> End With <NL>
                  
! -------------------------------------------------------------------
! Expressions
! -------------------------------------------------------------------

<Expression>  ::= <And Exp> Or     <Expression> 
                | <And Exp> OrElse <Expression> 
                | <And Exp> XOr    <Expression> 
                | <And Exp> 

<And Exp>     ::= <Not Exp> And     <And Exp> 
                | <Not Exp> AndAlso <And Exp> 
                | <Not Exp> 
 
<Not Exp>     ::= NOT <Compare Exp>
                | <Compare Exp>

<Compare Exp> ::= <Shift Exp> <Compare Op> <Compare Exp>       !e.g.  x < y
                | TypeOf <Add Exp> Is <Object>
                | <Shift Exp> Is <Object>
                | <Shift Exp> Like <Value>
                | <Shift Exp>

<Shift Exp>   ::= <Concat Exp> '<<' <Shift Exp>  
                | <Concat Exp> '>>' <Shift Exp>  
                | <Concat Exp> 

<Concat Exp>  ::= <Add Exp> '&' <Concat Exp>
                | <Add Exp>

<Add Exp>     ::= <Modulus Exp> '+' <Add Exp> 
                | <Modulus Exp> '-' <Add Exp> 
                | <Modulus Exp>  

<Modulus Exp> ::= <Int Div Exp> Mod <Modulus Exp> 
                | <Int Div Exp>

<Int Div Exp> ::= <Mult Exp> '\' <Int Div Exp>                 
                | <Mult Exp>

<Mult Exp>    ::= <Negate Exp> '*' <Mult Exp> 
                | <Negate Exp> '/' <Mult Exp> 
                | <Negate Exp> 

<Negate Exp>  ::= '-' <Power Exp> 
                | <Power Exp> 

<Power Exp>   ::= <Power Exp> '^' <Value> 
                | <Value> 

<Value>       ::= '(' <Expression> ')'                
                | New <Identifier> <Argument List Opt>
                | IntLiteral 
                | HexLiteral
                | OctLiteral
                | StringLiteral 
                | CharLiteral
                | RealLiteral
                | DateLiteral 
                | True
                | False
                | Me 
                | MyClass 
                | MyBase
                | Nothing
                | <Variable>
                | AddressOf <Identifier>

<Object>      ::= <Identifier>        !Object identifiers 
                | Me 
                | MyClass 
                | MyBase
                | Nothing

<Variable>    ::= <Identifier> <Argument List Opt> <Method Calls> 
                                
<Method Calls> ::= <Method Call> <Method Calls>
                 | 

<Method Call>  ::= MemberID <Argument List Opt>                    


<Identifier>   ::= ID | QualifiedID       !Any type of identifier