Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My grammar is Calc. it calc regular number and binary number. regular number has its grammar and binary has its grammar regular number has 0

My grammar is Calc. it calc regular number and binary number. regular number has its grammar and binary has its grammar regular number has 0 and 1 also binary number has 0 and 1 so my problem is I want write regular number 0 or 1 like 1+1 or 0+1 but it is not work

grammar Expr; // Program is a sequence of statements prog :'<' bi+ '>' | stat+ ; bi : '<' binary '>' | NEWLINE ; binary : binary ('+' | '-' ) binary | binary ('*' | '/' ) binary | Binary_digit ; stat : expr NEWLINE #print | CLEAR #clear | ID '=' expr NEWLINE #assign | INT '=' expr NEWLINE #assign | NEWLINE #blank ; expr : '-' expr #uminus // Unary minus | expr op=('*' | '/' ) expr #MulDiv | expr op=('+' | '-' ) expr #AddSub | INT #int | ID #id | '(' expr ')' #parens ; MUL : '*'; DIV : '/'; ADD : '+'; SUB : '-'; EQ : '=' ; GT : '>' ; LT : '<' ; // Keywords CLEAR : 'clear'; Binary_digit : [01]+ ; INT : ('0' .. '9')+ ('0' .. '1')+ ; DIGIT : ('0' .. '1')+ ; ID : [a-zA-Z]+ ; NEWLINE : [ ]+; WS : [ \t]+ -> skip;

rerror :

C:\Users\F\Desktop\PL>grun Expr prog -gui 1+1 ^Z line 1:0 mismatched input '1' expecting {'(', '-', '<', 'clear', INT, ID, NEWLINE}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+Who are you right now, and where do you want to be?

Answered: 1 week ago

Question

8. Praise the trainees for their success in learning the task.

Answered: 1 week ago