0% found this document useful (0 votes)
21 views5 pages

Regular Grammer: Non-Terminals

The document defines the grammar for a regular language that specifies the components of an assembly language program, including non-terminals like Goal, StmtList, Stmt, Stat, and terminals like Label, Instruction, Operand, Register, FloatRegister, AddrImmed, LabelExpr, LabelRef, Data, DataList, DataExpr, SymDef, Expr, Term, Primary, BinaryOp, UnaryOp, and directives. It also defines regular expressions for tokens in the language including whitespace, comments, and operators.

Uploaded by

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

Regular Grammer: Non-Terminals

The document defines the grammar for a regular language that specifies the components of an assembly language program, including non-terminals like Goal, StmtList, Stmt, Stat, and terminals like Label, Instruction, Operand, Register, FloatRegister, AddrImmed, LabelExpr, LabelRef, Data, DataList, DataExpr, SymDef, Expr, Term, Primary, BinaryOp, UnaryOp, and directives. It also defines regular expressions for tokens in the language including whitespace, comments, and operators.

Uploaded by

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

REGULAR GRAMMER

NON-TERMINALS Goal StmtList Stmt Stat -> -> -> -> | | | | | | -> | -> -> | | | | -> | | -> -> | -> -> | | | -> | | StmtList <EOF> Stmt ( StmtList )? Stat ( ";" )? Label Instruction Label Data Label Instruction Data SymDef Directive <IDENTIFIER_COLON> <DECIMAL_COLON> OpCode ( Operand ( "," Operand ( "," Operand )? )? )? Register "(" Register ")" FloatRegister AddrImmed ( "(" Register ")" )? <FLOAT> <DOLLAR_DECIMAL> RegisterName DollarRegisterName <DOLLAR_F_DECIMAL> LabelExpr ( ( "+" | "-" ) Expr )? Expr LabelRef ( "-" LabelRef )? <DECIMAL_B> <DECIMAL_F> <IDENTIFIER> "." DataMode DataList ".ascii" <STRING> ".asciiz" <STRING>

Label Instruction Operand

Register

FloatRegister AddrImmed LabelExpr LabelRef

Data

| DataList DataExpr

".space" Expr

-> DataExpr ( "," DataList )* -> Expr ( ":" Expr )? | <FLOAT> ( ":" <FLOAT> )? -> <IDENTIFIER_EQUAL> Expr

SymDef

Expr Expr_ Term Primary BinaryOp

UnaryOp

-> -> -> | -> | -> | | | | | | | | | -> | | |

Term Expr_ ( BinaryOp Expr Expr_ )* UnaryOp Term Primary Constant "(" Expr ")" "*" "/" "%" "+" "-" "<<" ">>" "^" "|" "+" "-" "~" "!" |sin |cos |tan

REGULAR EXPRESSIONS
SKIP : /* WHITE SPACE */ { <WHITE_SPACE: " " | "\t" | "\n" | "\r" | "\f"> } SPECIAL_TOKEN : /* COMMENTS */ { <SINGLE_LINE_COMMENT: "#" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> } TOKEN : { | < PLUS: "+" > | < MINUS: "-" > | < TIMES: "*" > | < BY: "/" > | < MOD: "%" > | < LSHIFT: "<<" > | < RSHIFT: ">>" > | < AMP: "&" > | < CARET: "^" > | < PIPE: "|" > | < TILDE: "~" > | < BANG: "!" > |<SINE: sin> |<COS: cos> }

COMPILER LAB
SCIENTIFIC CALCULATOR
SUBMITTED BYANUBHAV PANDEY(11103439) APARNA DUTT(11103440) NAVANKUR GARG(11103509) ANKIT KALIA(11104660) BATCH B4

You might also like