From d28e80274828540a3278ef20c3250afb576773d4 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Fri, 29 Oct 2021 01:35:54 +0900 Subject: v0.5.0 --- src/inpla.l | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/inpla.l') diff --git a/src/inpla.l b/src/inpla.l index f5b386d..85bf522 100644 --- a/src/inpla.l +++ b/src/inpla.l @@ -6,7 +6,6 @@ #undef YY_INPUT #define YY_INPUT(buf,result,max_size) result = mygetinput(buf, max_size); -// lineno de kubetu? static int mygetinput(char *buf, int size) { char *line; if (feof(yyin)) return YY_NULL; @@ -23,6 +22,7 @@ static int mygetinput(char *buf, int size) { return len; } + linenoiseSetMultiLine(1); if (yylineno == 1) { line = linenoise(">>> "); } else { @@ -30,8 +30,10 @@ static int mygetinput(char *buf, int size) { } if(!line) return YY_NULL; if(strlen(line) > size-2){ - fprintf(stderr,"input line too long\n"); return YY_NULL; } - sprintf(buf,"%s\n",line); + fprintf(stderr,"input line too long\n"); + return YY_NULL; + } + sprintf(buf, "%s\n", line); linenoiseHistoryAdd(line); linenoiseHistorySave(".inpla.history.txt"); free(line); @@ -101,7 +103,7 @@ char *Parse_closeStringBuffer() { "/" return (DIV); "%" return (MOD); "_" return (ANY); -"?" return (QUE); +"<<" return (ABR); "int" return(INT); @@ -132,7 +134,7 @@ char *Parse_closeStringBuffer() { "*R" return(ANNOTATE_R); [a-z][a-zA-Z0-9_'\.]* { yylval.chval = strdup(yytext); return (NAME);} -[_A-Z][a-zA-Z0-9_'\.]* { yylval.chval = strdup(yytext); +[A-Z][a-zA-Z0-9_'\.]* { yylval.chval = strdup(yytext); return (AGENT);} [0-9]+ { yylval.intval = atoi(yytext); return (INT_LITERAL);} @@ -143,8 +145,8 @@ char *Parse_closeStringBuffer() { \n ; "*/" BEGIN INITIAL; //comment -\r\n {} -[\n|\r] {} +\r\n ; +[\n|\r] ; [ \t]+ ; <> {return END_OF_FILE;} \" { -- cgit v1.2.3