WaifuGrammar/README.md

54 lines
10 KiB
Markdown
Raw Permalink Normal View History

2022-09-26 17:43:23 +10:00
### Dotnet
- install dotnet 6
- install antlr
- cd WaifuGrammar
- antlr4 -Dlanguage=CSharp \
-o WaifuGrammar/grammar_out/waifu \
-package waifu -listener -visitor \
-lib WaifuGrammar/grammar \
WaifuGrammar/grammar/Waifu2.g4
- Develop in grammar/Waifu2.g4 and Program.cs
### Notes
-
- Final implementation in rust? Althought rantlr4 doesn't have rust support. So we will have to write parser and lexer from sctach
| character | meaning | p | z |
|-----------|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ~ | Unused | Negation | |
| ` | Unused | Infix maybe | |
| ! | Unused | unsafe unwrap, far future | |
| @ | Unused | maybe a valid starting character for ID | |
| # | Comments | Use # for single line ## for multiline comments | |
| $ | Unused | I don't like using this anywhere. Useless. | |
| % | OP_MOD | | |
| ^ | OP_POWER | Not xor. | |
| & | OP_AND | Not bitwise and. | |
| * | OP_MULT | | |
| ( | Grouping | Also range, non inclusive | |
| ) | Grouping | Also range, non inclusive | |
| - | OP_MINUS, Number negation | Maybe in ranges? - makes more sense than .. however that becomes a problem with negative numbers, unless we force the whistespace | |
| _ | Unused | Not sure, doesn't seem like a useful symbol. we could use it for digit grouping in integers like a lot of modern languages do | |
| = | OP_EQUALS | | |
| + | OP_PLUS | Not allowed as a number prefix. It's ugly and serves no purpose. +X is X. - is useful to flip the sign, we shouldn't add this 'for symetries' | |
| [ | Unused | Inclusive Range | |
| ] | Unused | Inclusive range | |
| { | Unused | Should be used to define a struct. { WS NL fields functions NL } NL | |
| } | Unused | struct close | |
| ; | Unused | no idea. | |
| : | Type prefix. very nice. | Very nice. | |
| " | Unused | No idea. | |
| ' | Strings | Should be used both for single and multiline strings. Should be able to specify multiple in a row in order to require that many to close without escaping any lower number of quotes in the string | |
| PIPE LOl | OP_OR | | |
| < | OP_LESS_THAN | | |
| > | OP_GREATER_THAN | | |
| , | Unused | ? | |
| . | Unused | Object navigation is an obvious one, but I'd like to explore other possiblities. One idea is to have . act as a "value of the expression in the line above, which would be very useful for using values without assigning them to variables, 'auto piping' | |
| ? | Unused | Prefix for 'if' and 'switch' like thing. ? EXPR NL INDENT (VAL WS expr)+ (_ WS expr)? | |
| / | OP_DIV | | |
| \ | UNUSED | I'm not 100% opposed but i don't like the idea of using this as an escape character. | |