Last active
October 8, 2021 02:03
-
-
Save elrui/c2a119982e2b7057fde6afa12acff8d9 to your computer and use it in GitHub Desktop.
Gramática para reconocer integers and floats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?start: num | |
num: integer | |
| float | |
| "-" num -> neg // Este cubre el caso de los números negativos | |
integer: /[1-9][0-9]*/ // Cualquier entero que no tenga ceros a la izquierda | |
| /(0)/ // El entero cero | |
float: /(\.)[0-9]*/ // Cualquier secuencia de dígitos que comience en . | |
| /(0)(\.)[0-9]*/ // Cualquier float menor a 1 | |
| /[1-9]+[0-9]*(\.)[0-9]*/ // Cualquier float mayor o igual a 1 | |
// Es válido que un float termine en . sin nada después | |
%import common.WS_INLINE | |
%ignore " " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment