]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
digraphs
authorWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 29 Oct 2012 12:56:00 +0000 (13:56 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 29 Oct 2012 12:56:00 +0000 (13:56 +0100)
lexer.c

diff --git a/lexer.c b/lexer.c
index 373009394e811a47f0c31ccc944d92b8867c3ad9..e08a5f6d93a8b60622d7543e073c7d37e2c421e8 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -225,6 +225,24 @@ static int lex_try_trigraph(lex_file *lex, int old)
     }
 }
 
+static int lex_try_digraph(lex_file *lex, int ch)
+{
+    int c2;
+    c2 = fgetc(lex->file);
+    if      (ch == '<' && c2 == ':')
+        return '[';
+    else if (ch == ':' && c2 == '>')
+        return ']';
+    else if (ch == '<' && c2 == '%')
+        return '{';
+    else if (ch == '%' && c2 == '>')
+        return '}';
+    else if (ch == '%' && c2 == ':')
+        return '#';
+    lex_ungetch(lex, c2);
+    return ch;
+}
+
 static int lex_getch(lex_file *lex)
 {
     int ch;
@@ -241,6 +259,8 @@ static int lex_getch(lex_file *lex)
         lex->line++;
     else if (ch == '?')
         return lex_try_trigraph(lex, ch);
+    else if (ch == '<' || ch == ':' || ch == '%')
+        return lex_try_digraph(lex, ch);
     return ch;
 }