diff --git a/libs/parser/rules/pslang.l b/libs/parser/rules/pslang.l index 8a47dd0..c9f9852 100644 --- a/libs/parser/rules/pslang.l +++ b/libs/parser/rules/pslang.l @@ -88,6 +88,14 @@ f64 { return bp::make_f64(ctx.location); } [0-9]+\.[0-9]+ { return bp::make_lit_f32(yytext, ctx.location); } [0-9]+\.[0-9]+l { return bp::make_lit_f64(yytext, ctx.location); } +'.' { return bp::make_lit_char8(yytext[1], ctx.location); } +'\\n' { return bp::make_lit_char8(10, ctx.location); } +'\\t' { return bp::make_lit_char8(11, ctx.location); } +'\\r' { return bp::make_lit_char8(13, ctx.location); } +'\\\"' { return bp::make_lit_char8(22, ctx.location); } +'\\'' { return bp::make_lit_char8(27, ctx.location); } +'\\\\' { return bp::make_lit_char8(134, ctx.location); } + <> { return bp::make_end(ctx.location); } . { throw ::pslang::parser::parse_error("unexpected character \"" + std::string(yytext) + "\"", ctx.location); } diff --git a/libs/parser/rules/pslang.y b/libs/parser/rules/pslang.y index 67231dd..ab211f7 100644 --- a/libs/parser/rules/pslang.y +++ b/libs/parser/rules/pslang.y @@ -101,6 +101,8 @@ template %token lit_f32 %token lit_f64 +%token lit_char8 + %token name %token const @@ -310,6 +312,7 @@ literal | lit_u64 { $$ = parse_numeric_literal($1, ctx.location); } | lit_f32 { $$ = parse_numeric_literal($1, ctx.location); } | lit_f64 { $$ = parse_numeric_literal($1, ctx.location); } +| lit_char8 { $$ = ast::u8_literal{static_cast($1), ctx.location}; } ; %%