From 6126db10df2426fbc8919cafbd53ef62488a7f64 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Mon, 29 Oct 2012 13:56:00 +0100 Subject: [PATCH] digraphs --- lexer.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lexer.c b/lexer.c index 3730093..e08a5f6 100644 --- 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; } -- 2.39.2