Writing a regular grammar for a regex of decimals So I've got the regex /[1-9][0-9]*(\.[0-9]*[1-9])?/ and I'm trying to write a regular grammar for it.

I started off like this:

S ∶≔ EAB
A ∶≔ DA | ε
B ∶≔ .AE | ε 
D ∶≔ 0 | 1 |  2 | 3 |  4 | 5 |  6 | 7 |  8 | 9
E ∶≔ 1 | 2 |  3 | 4 |  5 | 6 |  7 | 8 |  9


But I realised that this does not follow Chomsky's rules for regular grammars. So I was wondering how could I adapt this logic into proper notation.

Thanks!

EDIT: So below is the NDFA generated from the regex above:
Regular grammars (of the right-regular variety) are essentially equivalent to NFAs, in the sense that they include roughly the same information. Once you convert your regular expression to an NFA, you can easily construct from it a right-regular grammar.

What doesn't seem possible is adapting your logic to construct a regular grammar. Unfortunately, there is no simple way to convert an arbitrary context-free grammar to a regular one; indeed, it is undecidable to determine whether a given context-free grammar corresponds to a regular language.