Is it a Lexer's Job to Parse Numbers and Strings?

后端 未结 3 1506
时光取名叫无心
时光取名叫无心 2020-12-03 04:51

Is it a lexer\'s job to parse numbers and strings?

This may or may not sound dumb, given that fact that I\'m asking whether a lexer should parse in

3条回答
  •  盖世英雄少女心
    2020-12-03 05:26

    I assume you want to treat "123.456" as a whole value, in which case you will pass it wholesale to the parser, unless you need to code it somehow, like

    struct DecimalRep{
        double mantissa,
        double exponent 
    
    }
    

    but I guess it depends all on what the parser expects.

提交回复
热议问题