SRegEx works!!!!

Its not a full flegged transpiler but it works at least on RDP's lexer. I can expand on demand.
This commit is contained in:
2022-07-17 07:32:57 -04:00
parent 5ae405e284
commit 17c3b8fe36
6 changed files with 653 additions and 490 deletions

View File

@ -1,7 +1,7 @@
## Concatenation
Regex : `/^AB$/`
Psuedo: `start str(AB) end`
Regex : `/^AB$/`
Psuedo: `start AB end`
Machine:
```
@ -12,8 +12,8 @@ Submachine_A --epsilon--> Submachine_B
## Union
Regex : `/^A|B$/`
Psuedo: `start glyph(A) | glyph(B) end`
Regex : `/^A|B$/`
Psuedo: `start A | B end`
Machine:
```
@ -26,8 +26,8 @@ Machine:
## Kleene Closure
Regex : `/^A*$/`
Psuedo: `start glyph(A).repeating end`
Regex : `/^A*$/`
Psuedo: `start A.repeat(0-) end`
Machine:
```

View File

@ -0,0 +1,30 @@
# Complex Machines
Ex:
RegEx : `/xy*|z`
SRegEx: `x y.repeat(0-) | z`
## Decomposition
### Stage 1: Union
```
->o.start (o)
\epsilon-> o --xy*-> o -epsilon-->/
\epsilon-> o --z---> o -epsilon->/
```
### Stage 2: Concatenation
```
->o.start (o)
\epsilon -> o --x--> o -epsilon-> o --y* -epsilon->/
\epsilon -> o --z--> o -epsilon------------------>/
```
### Stage 2: Kleene Closure
```
|<------------<|
->epsi -> o -x-> o -epsi-> o -epsi-> o -y-> -epsi-> o ->epsi->|
| |>---------------------->| /
->o.start (o)
\epsi -> o -z-> o -epsi------------------------------------>/
```

View File

@ -0,0 +1,11 @@
# Syntactic Sugar
Ex:
RegEx : `/a+|[0-3]/`
SRegEx: `a.repeat(1-) | set(0-3)`
`A+` === `AA*` === `A.repeat(1-)` === `AA.repeat(0-)`
`A?` === `A|ε` === `A.repeat(0-1)`
`[0-9]` === `0|1|2|3|4|5|6|7|8|9` === `set(0-9)`