0% found this document useful (0 votes)
12 views2 pages

G

The document defines a grammar for a programming language using Backus-Naur Form (BNF) notation. It specifies the rules for expressions, statements, and other language constructs using non-terminals and terminals.

Uploaded by

Fari Rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

G

The document defines a grammar for a programming language using Backus-Naur Form (BNF) notation. It specifies the rules for expressions, statements, and other language constructs using non-terminals and terminals.

Uploaded by

Fari Rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Function -> Type identifier ( ArgList ) CompoundStmt

ArgList -> Arg ArgList_


ArgList_ -> , Arg ArgList_
ArgList_ -> EPSILON
Arg -> Type identifier
Declaration -> Type IdentList ;
Type -> int
Type -> float
IdentList -> identifier IdentList_
IdentList_ -> , IdentList
IdentList_ -> EPSILON
Stmt -> ForStmt
Stmt -> WhileStmt
Stmt -> Expr ;
Stmt -> IfStmt
Stmt -> CompoundStmt
Stmt -> Declaration
Stmt -> ;
ForStmt -> for ( Expr ; ForStmt_
ForStmt_ -> OptExpr ; ForStmt__
ForStmt_ -> ; ForStmt___
ForStmt__ -> OptExpr ) Stmt
ForStmt__ -> ) Stmt
ForStmt___ -> OptExpr ) Stmt
ForStmt___ -> ) Stmt
OptExpr -> Expr
WhileStmt -> while ( Expr ) Stmt
IfStmt -> if ( Expr ) Stmt IfStmt_
IfStmt_ -> ElsePart
IfStmt_ -> EPSILON
ElsePart -> else Stmt
CompoundStmt -> { CompoundStmt_
CompoundStmt -> StmtList }
CompoundStmt -> }
StmtList -> StmtList_
StmtList_ -> Stmt StmtList_
StmtList_ -> EPSILON
Expr -> identifier Expr_
Expr -> ( Expr ) Term_ Mag_ Rvalue_
Expr -> number Term_ Mag_ Rvalue_
Expr_ -> := Expr
Expr_ -> Term_ Mag_ Rvalue_
Rvalue -> Mag Rvalue_
Rvalue_ -> Compare Mag Rvalue_
Rvalue_ -> EPSILON
Compare -> ==
Compare -> <
Compare -> >
Compare -> <=
Compare -> >=
Compare -> !=
Compare -> <>
Mag -> Term Mag_
Mag_ -> + Term Mag_
Mag_ -> - Term Mag_
Mag_ -> EPSILON
Term -> Factor Term_
Term_ -> * Factor Term_
Term_ -> / Factor Term_
Term_ -> EPSILON
Factor -> ( Expr )
Factor -> identifier
Factor -> number

You might also like