diff options
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | appl/cmd/limbo/lex.b | 39 | ||||
| -rw-r--r-- | dis/limbo.dis | bin | 343331 -> 343636 bytes | |||
| -rw-r--r-- | doc/limbo/limbo.ms | 9 | ||||
| -rw-r--r-- | doc/limbo/limbo.pdf | bin | 158824 -> 159031 bytes | |||
| -rw-r--r-- | doc/limbo/mkfile | 4 | ||||
| -rw-r--r-- | doc/limbotk/mkfile | 2 | ||||
| -rw-r--r-- | doc/mkfile | 2 | ||||
| -rw-r--r-- | include/version.h | 2 | ||||
| -rw-r--r-- | limbo/lex.c | 65 |
10 files changed, 94 insertions, 31 deletions
@@ -1,3 +1,5 @@ +20111221 + add `...` uninterpreted string literals to limbo/lex.c, appl/cmd/limbo/lex.b 20111215 liblogfs,libnandfs: use logfsos.h (added to include) to make library source independent of os add fonts/vera diff --git a/appl/cmd/limbo/lex.b b/appl/cmd/limbo/lex.b index 0aca4925..9bdf278c 100644 --- a/appl/cmd/limbo/lex.b +++ b/appl/cmd/limbo/lex.b @@ -736,7 +736,8 @@ lexstring() { s := ""; i := 0; -loop: for(;;){ +Loop: + for(;;){ case c := getc(){ '\\' => c = escchar(); @@ -744,14 +745,41 @@ loop: for(;;){ s[i++] = c; Bufio->EOF => yyerror("end of file in string constant"); - break loop; + break Loop; '\n' => yyerror("newline in string constant"); lineno++; linepos = Linestart; - break loop; + break Loop; '"' => - break loop; + break Loop; + * => + s[i++] = c; + } + } + yyctxt.lval.tok.v.idval = enterstring(s); +} + +lexrawstring() +{ + s := ""; + i := 0; + startlno := lineno; +Loop: + for(;;){ + case c := getc(){ + Bufio->EOF => + t := lineno; + lineno = startlno; + yyerror("end of file in raw string constant"); + lineno = t; + break Loop; + '\n' => + s[i++] = c; + lineno++; + linepos = Linestart; + '`' => + break Loop; * => s[i++] = c; } @@ -787,6 +815,9 @@ lex(): int '"' => lexstring(); return Lsconst; + '`' => + lexrawstring(); + return Lsconst; '\'' => c = getc(); if(c == '\\') diff --git a/dis/limbo.dis b/dis/limbo.dis Binary files differindex 72b54cc2..2ba236d5 100644 --- a/dis/limbo.dis +++ b/dis/limbo.dis diff --git a/doc/limbo/limbo.ms b/doc/limbo/limbo.ms index 213372c8..feda59fa 100644 --- a/doc/limbo/limbo.ms +++ b/doc/limbo/limbo.ms @@ -438,7 +438,14 @@ quotes. They cannot extend across source lines. The same escape sequences listed above for character constants are usable within string constants. -Strings have type +.PP +Raw (uninterpreted) string constants are sequences of Unicode characters +contained in backquotes. +They can extend across source lines and thus include newlines. +They contain no character escapes. +The only character that cannot appear inside an uninterpreted string is a backquote, because that delimits the string. +.PP +Both forms of string constant have type .CW string . .NH 3 The nil constant diff --git a/doc/limbo/limbo.pdf b/doc/limbo/limbo.pdf Binary files differindex e385dfd3..dc2a65b8 100644 --- a/doc/limbo/limbo.pdf +++ b/doc/limbo/limbo.pdf diff --git a/doc/limbo/mkfile b/doc/limbo/mkfile index 39cd3ee5..ce43ab56 100644 --- a/doc/limbo/mkfile +++ b/doc/limbo/mkfile @@ -3,10 +3,10 @@ all:V: limbo.pdf addendum.pdf limbo.ps:D: limbo.ms limbo.rc synsum mkfile - rc limbo.rc | troff -mpm | lp -d stdout >limbo.ps + rc limbo.rc | troff -mpm | dpost >limbo.ps %.pdf: %.ps ps2pdf <$stem.ps >$stem.pdf addendum.ps:D: addendum.ms mkfile - cat addendum.ms |troff -mpm | lp -d stdout >$target + cat addendum.ms |troff -mpm | dpost >$target diff --git a/doc/limbotk/mkfile b/doc/limbotk/mkfile index c33c14f8..decc062d 100644 --- a/doc/limbotk/mkfile +++ b/doc/limbotk/mkfile @@ -1,7 +1,7 @@ <../fonts.pal tk.ps:D: tk.ms f1.ps f2.ps mkfile - {echo $FONTS; cat tk.ms} | tbl | troff -mpm -mpictures | lp -d stdout >$target + {echo $FONTS; cat tk.ms} | tbl | troff -mpm -mpictures | dpost >$target #%.ps: %.gif mkfile # fb/gif2pic $stem.gif | fb/pic2ps -c >$stem.ps #%.ps: %.gif mkfile @@ -61,7 +61,7 @@ title.ps:D: title troff $prereq | lp -dstdout > $target changes.ps:D: changes.ms - tbl changes.ms | troff -ms | lp -d stdout >$target + tbl changes.ms | troff -ms | dpost >$target %.pdf: %.ps ps2pdf <$stem.ps >$stem.pdf diff --git a/include/version.h b/include/version.h index 46317ac1..47753558 100644 --- a/include/version.h +++ b/include/version.h @@ -1 +1 @@ -#define VERSION "Fourth Edition (20111215)" +#define VERSION "Fourth Edition (20111222)" diff --git a/limbo/lex.c b/limbo/lex.c index 749f2a7a..d75e28f2 100644 --- a/limbo/lex.c +++ b/limbo/lex.c @@ -815,37 +815,57 @@ escchar(void) } void -lexstring(void) +lexstring(int israw) { char *str; - int c; + int c, t, startlno; Rune r; int len, alloc; alloc = 32; len = 0; str = allocmem(alloc * sizeof(str)); + startlno = lineno; for(;;){ c = getrune(); - switch(c){ - case '\\': - c = escchar(); - if(c != Beof) + if(israw){ + switch(c){ + case '`': + yylval.tok.v.idval = enterstring(str, len); + return; + case '\n': + lineno++; + linepos = Linestart; break; - /* fall through */ - case Beof: - yyerror("end of file in string constant"); - yylval.tok.v.idval = enterstring(str, len); - return; - case '\n': - yyerror("newline in string constant"); - lineno++; - linepos = Linestart; - yylval.tok.v.idval = enterstring(str, len); - return; - case '"': - yylval.tok.v.idval = enterstring(str, len); - return; + case Beof: + t = lineno; + lineno = startlno; + yyerror("end of file in raw string constant"); + lineno = t; + yylval.tok.v.idval = enterstring(str, len); + return; + } + }else{ + switch(c){ + case '\\': + c = escchar(); + if(c != Beof) + break; + /* fall through */ + case Beof: + yyerror("end of file in string constant"); + yylval.tok.v.idval = enterstring(str, len); + return; + case '\n': + yyerror("newline in string constant"); + lineno++; + linepos = Linestart; + yylval.tok.v.idval = enterstring(str, len); + return; + case '"': + yylval.tok.v.idval = enterstring(str, len); + return; + } } while(len+UTFmax+1 >= alloc){ alloc += 32; @@ -893,7 +913,10 @@ loop: case '\f': goto loop; case '"': - lexstring(); + lexstring(0); + return Lsconst; + case '`': + lexstring(1); return Lsconst; case '\'': c = getrune(); |
