Skip to content

Made lexer and parser for given grammer using JFlex, JCup.

Notifications You must be signed in to change notification settings

lukamilo99/c-like-lexer-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grammar

Program -> MAIN() Block
Block -> { VarList StatementList }
VarList -> VarList VarDecl | VarDecl
VarDecl -> Namelist = Type ;
NameList -> NameList , ID | ID
Type -> INT | CHAR | REAL | BOOL | Structure
Structure -> STRUCT ID { VarList StructureStatementList }
StructureStatementList -> StructureStatementList StructureStatement | StructureStatement
StructureStatement -> ID = Expression ;
StatenentList -> StatementList Statement | Statement
Statment -> Loop | IfStatement | ID = Expression ; | READ ( NameList ) ; | WRITE ( ExpressionList) ; | Block
IfStatement -> IF ( Expression ) THEN Statement | IF ( Expression ) THEN Statement ELSE Statement
Loop -> WHILE ( Expression ) THEN Statement
Expression -> Expression || AndExpression | AndExpression
AndExpression -> AndExpression && RelExpression | RelExpresion
ArExpression -> ArExpression + Term | ArExpression - Term | Term
RelExpression -> ArExpression RelOp ArExpresion | ArExpresion
RelOp -> < | > | == | != | <= | >=
Term -> Term * Factor | Term / Factor | Term ^ Factor | Factor
Factor -> ID | CONST | (Expression)
ExpressionList -> ExpressionList, Expression | Expression

About

Made lexer and parser for given grammer using JFlex, JCup.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published