X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=lexer.c;h=a495d27fa4cb034305b735ddef884198885e4267;hp=5ad0a90a537f558e2ba0512e79a771f8181426a6;hb=41a76ab91dc6f872b03cd64f51aba86578f330c0;hpb=9cc4fe1ed246e3c37af7cbd7245b0b413372f3b9 diff --git a/lexer.c b/lexer.c index 5ad0a90..a495d27 100644 --- a/lexer.c +++ b/lexer.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013, 2014 + * Copyright (C) 2012, 2013, 2014, 2015 * Wolfgang Bumiller * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -681,7 +681,7 @@ static bool lex_finish_frames(lex_file *lex) static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) { utf8ch_t chr = 0; - int ch = 0; + int ch = 0, texttype = 0; int nextch; bool hex; bool oct; @@ -716,13 +716,12 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) case '\\': break; case '\'': break; case '"': break; - case 'a': ch = '\a'; break; - case 'b': ch = '\b'; break; - case 'r': ch = '\r'; break; - case 'n': ch = '\n'; break; - case 't': ch = '\t'; break; - case 'f': ch = '\f'; break; - case 'v': ch = '\v'; break; + case 'a': ch = '\a'; break; + case 'r': ch = '\r'; break; + case 'n': ch = '\n'; break; + case 't': ch = '\t'; break; + case 'f': ch = '\f'; break; + case 'v': ch = '\v'; break; case 'x': case 'X': /* same procedure as in fteqcc */ @@ -825,7 +824,15 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) else ch = chr; break; - case '\n': ch = '\n'; break; + + /* high bit text */ + case 'b': case 's': + texttype ^= 128; + continue; + + case '\n': + ch = '\n'; + break; default: lexwarn(lex, WARN_UNKNOWN_CONTROL_SEQUENCE, "unrecognized control sequence: \\%c", ch); @@ -833,7 +840,7 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) lex_tokench(lex, '\\'); } /* add the character finally */ - lex_tokench(lex, ch); + lex_tokench(lex, ch | texttype); } else lex_tokench(lex, ch); @@ -1332,6 +1339,8 @@ int lex_do(lex_file *lex) } else if (!strcmp(v, "vector")) { lex->tok.ttype = TOKEN_TYPENAME; lex->tok.constval.t = TYPE_VECTOR; + } else if (!strcmp(v, "_length")) { + lex->tok.ttype = TOKEN_OPERATOR; } else { size_t kw; for (kw = 0; kw < GMQCC_ARRAY_COUNT(keywords_qc); ++kw) {