1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
rosijanka [135]
4 years ago
15

In this assignment you are to implement a recursive-descent recognizer with a web interface for the BNF grammar given below. Bas

ed on the pseudocode you have done in PL Assignment 1, this is a good opportunity to develop the web programming skills required by today's IT field. You must ask the user for input stream.
EXP ::= EXP + TERM | EXP - TERM | TERM
TERM ::= TERM * FACTOR | TERM / FACTOR | FACTOR
FACTOR ::= ( EXP ) | DIGIT
DIGIT ::= 0 | 1 | 2 | 3

My pseudocode for PL 1:

procedure exp()
term()
if (token == ‘+’){
match(‘+’)
term()
}
Else (if token == ‘-‘){
match(‘-‘)
term()
}
else
errorsfound
procedure term()
factor()
if (token == ‘*’){
match(‘*’)
factor()
}
else if (token == ‘/’){
match(‘/’)
factor()
}
else
errorsfound
procedure factor()
if (token == ‘(‘){
match(‘(‘)
exp()
match(‘)’)
}
else

digit()
procedure digit()
if token == ‘0’
match(‘0’)
else if token == ‘1’
match(‘1’)
else (if token == ‘2’)
match(‘2’)
else if (token ==’3’)
match(‘3’)
else
errorfound
match(t)
if (token == t)
nexttokenpointer
else
errorfound

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Basically create a javascript that can read a user's input thats a simple mathematical expression using ( ) * / + - and ends with $ (so that we know it terminates), and determine if that input is in a valid form or not. Example 2/(3+1)$ is valid, and 1*a$ is not valid
Engineering
1 answer:
Gala2k [10]4 years ago
3 0

Answer:

procedure exp()

term()

if (token == ‘+’)

{

match(‘+’)

term()

}

Else (if token == ‘-‘)

{

match(‘-‘)

term()

}

else

errorsfound

procedure term()

factor()

if (token == ‘*’)

{

match(‘*’)

factor()

}

else if (token == ‘/’)

{

match(‘/’)

factor()

}

else

errorsfound

procedure factor()

if (token == ‘(‘)

{

match(‘(‘)

exp()

match(‘)’)

}

else

digit()

procedure digit()

if token == ‘0’

match(‘0’)

else if token == ‘1’

match(‘1’)

else (if token == ‘2’)

match(‘2’)

else if (token ==’3’)

match(‘3’)

else

errorfound

match(t)

if (token == t)

nexttokenpointer

else

errorfound

Explanation:

You might be interested in
A soil has the following Green-Ampt parameters Effective porosity 0.400 Initial volumetric moisture content-15% Hydraulic Conduc
Rudik [331]

Answer:

The graphs are attached below

Explanation:

Ans) We know,

F(t) = K(t - to) + zΔ∅ ln[(1 + F(t)/zΔ∅]

where K = hydraulic conductivity =0.1 cm/hr

z = capillary suction =20cm

 Δ∅ = ∅ (1 - Se)

 ∅ = effective porosity , Se = initial moisture content

 Δ∅ = 0.40(1 - 0.15)

Δ∅ = 0.34

Now, F(t) = 0.1(t - to) + 20(0.34) ln[ 1 + F(t)/6.8]

F(t) = 0.1(t - to) + 6.8 ln [1+ 0.147 F(t)]

Also, infiltration rate (f),

f = K [(zΔ∅ + F)/F]

f = 0.40 [6.8 + F]/F

Condition of ponding,

Ponding time tp = K zΔ∅ i(i-k)

where, i = rainfall rate (1cm/hr)

tp = 0.40(6.8) / 0.60

tp= 4.53 hours

Now, cumulative infiltraton at ponding Fp = i tp

Fp = 1 x 4.53 or 4.53 cm

For infiltration at time less then ponding time , infiltration rate = rainfall rate

For t = 0.25 hr , f = 1cm/hr ; F = 0.25 x 1 = 0.25 cm

For t = 0.50 hr , f = 1cm/hr ; F = 0.50 cm

For t = 0.75 hr , f = 1cm/hr ; F = 0.75 cm

For t = 1 hr , f = 1cm/hr ; F = 1cm/hr

For t > tp ,

Equivalent time origin(to),

to = tp - 1/K [ Fp - z Δ∅ ln (1+ Fp/zΔ∅)

to = 4.53 - 1/0.40[ 4.53 - 6.8 ln(1 + 0.66)

to = 4.53 - 2.5 ( 4.53 - 3.44)

to = 1.82 hr

Hence,

F = 0.10( t - 1.82) + 6.8 ln[ 1+ 0.147F(t)]

Solving above equation for t by assuming F, and further solving equation for infiltration rate

Ans (a) Following is required curve :

O.S 1-5 2 time Chr)ホー Lt 2 time Chr)

Ans (c) Following is required table :

Ans (d) For time step t = 0.25 hrs

At t < tp ; i = f = 1 cm/hr

F = i x t

F = 1 x 0.25

F = 0.25 cm  

 

5 0
4 years ago
An inductor is energized as in the circuit of Fig. 2-4a. The circuit has L 10 mH and VCC 14 V. (a) Determine the required on tim
Savatey [412]

Answer:

A) 11.1 ms

B) 5.62 Ω

Explanation:

L ( inductance ) = 10 mH

Vcc = 14V

<u>A) determine the required on time of the switch such that the peak energy stored in the inductor is 1.2J </u>

first calculate for the current  ( i )  using the equation for energy stored in an inductor hence

i = \sqrt{\frac{2W}{L} }   ----- ( 1 )

where : W = 1.2j ,  L = 10 mH

Input values into equation 1  

i = 15.49 A

Now determine the time required  with expression below

i( t ) = 15.49 A

L = 10 mH, Vcc = 14

hence the time required ( T-on ) = 11.1 ms

attached below is detailed solution

B) <u>select the value of R such that switching cycle can be repeated every 20 ms </u>

using the expression below

τ = \frac{L}{R}  ---- ( 2 )

but first we will determine the value of τ

τ = t-off / 5 time constants

  = (20 - 11.1 ) / 5  = 1.78 ms

Back to equation 2

R = L / τ

  = (10 * 10^-3) / (1.78 * 10^-3)

  = 5.62 Ω

3 0
3 years ago
A divided multilane highway in a recreational area has four lanes (two lanes in each direction) and is on rolling terrain. The h
sertanlavr [38]

Answer:

Explanation:

Before: PT= 0.10, PB= 0.03 (given) ET = 2.5 ER = 2.0 (Table 6.5)

fHV= 0.847 (Eq. 6.5) PHF = 0.95, fp= 0.90, N=2, V = 2200 (given)

vp= V/[PHF⋅fHVTB⋅fp⋅N] = 1518.9 (Eq. 6.3)

BFFS = 50+5, BFFS =55 (given) fLW= 6.6

TLC=6+3=9 fLC= 0.65

fM= 0.0

fA= 1.0

FFS = BFFS −fLW−fLC–fM–fA= 46.75 (Eq. 6.7)

Use FFS=45 D= vp/S = 33.75pc/mi/ln Eq (6.6)

After: fA= 3.0

FFS = BFFS −fLW−fLC–fM–fA= 44.75 (Eq. 6.7)

Use FFS=45 Vnew= 2600 Vp= Va/[PHF⋅fHB⋅fp⋅N] = 1795 (Eq. 6.3) D= vp/S = 39.89pc/mi/ln

8 0
3 years ago
A car hits a tree at an estimated speed of 10 mi/hr on a 2% downgrade. If skid marks of 100 ft. are observed on dry pavement (F=
Dafna11 [192]

Answer:

v_{o} = 22.703\,\frac{m}{s} \left(50.795\,\frac{m}{s}\right)

Explanation:

The deceleration of the car on the dry pavement is found by the Newton's Law:

\Sigma F = -\mu_{k,1}\cdot m\cdot g \cdot \cos \theta + m\cdot g \cdot \sin \theta = m\cdot a_{1}

Where:

a_{1} = (-\mu_{k,1}\cdot \cos \theta + \sin \theta)\cdot g

a_{1} = (-0.33\cdot \cos 1.146^{\textdegree}+\sin 1.146^{\textdegree})\cdot \left(9.807\,\frac{m}{s^{2}} \right)

a_{1} = -3.040\,\frac{m}{s^{2}}

Likewise, the deceleration of the car on the unpaved shoulder is:

a_{2} = (-\mu_{k,2}\cdot \cos \theta + \sin \theta)\cdot g

a_{2} = (-0.28\cdot \cos 1.146^{\textdegree}+\sin 1.146^{\textdegree})\cdot \left(9.807\,\frac{m}{s^{2}} \right)

a_{2} = -2.549\,\frac{m}{s^{2}}

The speed just before the car entered the unpaved shoulder is:

v_{o} = \sqrt{\left(4.469\,\frac{m}{s} \right)^{2}-2\cdot \left(-2.549\,\frac{m}{s^{2}} \right)\cdot (60.88\,m)}

v_{o} = 18.175\,\frac{m}{s}

And, the speed just before the pavement skid was begun is:

v_{o} = \sqrt{\left(18.175\,\frac{m}{s} \right)^{2}-2\cdot \left(-3.040\,\frac{m}{s^{2}} \right)\cdot (30.44\,m)}

v_{o} = 22.703\,\frac{m}{s} \left(50.795\,\frac{m}{s}\right)

8 0
3 years ago
Marcus wants to pursue a career in civil engineering. He aims to work for the city council as a civil engineer. What examination
Rzqust [24]

Answer:

Marcus would have to take an exam administered by the national council of examiners for engineering and surveying.

Explanation:

Civil engineers design, construct, and maintain projects regarding infrastructure. A civil engineer also looks after the systems in the public and private sectors like roads, buildings, and systems for water supply and sewage treatment.

In order to pursue a career in civil engineering, Marcus aims to work for the city council as a civil engineer. Therefore, he would have to take an exam administered by the national council of examiners for engineering and surveying.

6 0
3 years ago
Other questions:
  • Which sentence about the technology design process is true
    12·1 answer
  • A 75 ohm coaxial transmission line has a length of 2.0 cm and is terminated with a load impedance of 37.5 + j75 Ohm. If the diel
    12·1 answer
  • What’s a pnp transitor?
    5·2 answers
  • Is any one there <br><br>I am 1m b0r3d<br>I will mark you as Brainliest
    5·2 answers
  • 3 MAOP stands for which of the following?
    9·1 answer
  • The 500 lb load is being hoisted at a constant speed using the motor M, which has a weight of 50 lb. The beam has a weight of 40
    8·1 answer
  • A pipe leads from a storage tank on the roof of a building to the ground floor. The absolute pressure of the water in the storag
    7·1 answer
  • In ________ programming, the programming is centered on objects that are created from abstract data types that encapsulate data
    14·1 answer
  • What is the first step in the Design Process *
    5·1 answer
  • Slovee plz asap<br> pzllzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!