Starting out with minimal BNF

Just to test this idea, I'm going to start out with this simplified
BNF of just literals
This commit is contained in:
greg 2018-03-10 20:17:51 -08:00
parent 3bfd251a68
commit 2431a074b0
1 changed files with 12 additions and 0 deletions

View File

@ -9,6 +9,18 @@ struct AutoParser {
tokens: Vec<Token>,
}
/* BNF
* all terminals in this BNF refer to TokenType values
literal := Kw::True | Kw::False | StrLiteral | number_literal
number_literal := int_literal | float_literal
float_literal := digits float_continued
float_continued := ε | Period digits
int_literal := HexLiteral | nonhex_int
nonhex_int := BinNumberSigil+ digits
digits := (DigitGroup Underscore)+
*/
impl AutoParser {
fn new(tokens: Vec<Token>) -> AutoParser {
AutoParser { tokens: tokens.into_iter().rev().collect() }