0
$\begingroup$

I'm currently working in the following excercise:

Write the pattern based on regular extensions for real numbers.

$$letter → [A-Za-z] $$ $$digit→ [0-9]$$ $$id→letter(letter|digit)$$

I'm defining the pattern as a regular definition:

$$digit \rightarrow [0-9]$$ $$number \rightarrow digit(digit|\epsilon)^{*}$$

I'm not sure about my approximation and how much I'm missing in the definition of the pattern.

I would really appreciate any hint or help and thank you for taking the time to read my question.

$\endgroup$
1
$\begingroup$

Regular expressions for numbers.
(+|-)digit*.digit** expresses the reals as infinite decimals.
(+|-)digit*.digit* expresses only the reals that are finite decimals.
(+|-)digit*.(digit*|digit**) expresses the reals as infinite and finite decimals.

Context free grammar for numbers.
S -> (+|-)digitD
D -> (digitD|.E)
E -> (digitE|digit)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.