Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit54df57e7cc0dd58f56a8657cfb68e91164483038 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-10-19 12:50:47 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-10-19 12:50:47 +0300
Filesd58f151edc4a12432ea56076232bada4728044fe
uni-projects-54df57e7cc0dd58f56a8657cfb68e91164483038.tar
uni-projects-54df57e7cc0dd58f56a8657cfb68e91164483038.tar.gz
uni-projects-54df57e7cc0dd58f56a8657cfb68e91164483038.zip
Parent1975a6e8f80d06571c7990e2a3af387889160c36 (diff)
[CI/PA1] Reworked formatting from tabs to spaces
1 files changed, 53 insertions, 51 deletions
-rw-r--r--Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa1/cool.flex104
diff --git a/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa1/cool.flex b/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa1/cool.flex
index 367c149..8a16b94 100644
--- a/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa1/cool.flex
+++ b/Year 3/Compilers, Introduction/coolc-spim/my-code/coursework/pa1/cool.flex
@@ -76,68 +76,70 @@ unsigned openedComments = 0;
* char *error_msg;
*/
-ALL (.|\n)
-ENDL \n|\r\n
+ALL (.|\n)
+ENDL \n|\r\n
BLANK [ \f\t\v\r]
-IDENT [A-Za-z0-9_]
+IDCHR [A-Za-z0-9_]
%x MULTILINE
%%
---[^\n\r]* { }
-<MULTILINE,INITIAL>\(\* { openedComments++; BEGIN(MULTILINE); }
-<MULTILINE>\*\) { if (--openedComments == 0) BEGIN(INITIAL); }
-<MULTILINE>{ENDL} { curr_lineno++; }
-<MULTILINE>. { }
-<MULTILINE><<EOF>> { cool_yylval.error_msg = "EOF in comment"; BEGIN(INITIAL); return (ERROR); }
+--[^\n\r]* { }
+<MULTILINE,INITIAL>\(\* { openedComments++; BEGIN(MULTILINE); }
+<MULTILINE>\*\) { if (--openedComments == 0) BEGIN(INITIAL); }
+<MULTILINE>{ENDL} { curr_lineno++; }
+<MULTILINE>. { }
+<MULTILINE><<EOF>> { cool_yylval.error_msg = "EOF in comment"; BEGIN(INITIAL); return (ERROR); }
-\"([^"\0\n\\]|\\[^\0])*\" { char* str = escapeString(yytext);
- if (strlen(str) >= MAX_STR_CONST) {
- cool_yylval.error_msg = "String constant too long"; return (ERROR);
- }
- else {
- cool_yylval.symbol = inttable.add_string(str); return (STR_CONST);
- }
- }
-\"([^"\0\n\\]|\\[^\0])*{ENDL} { cool_yylval.error_msg = "Unterminated string constant"; curr_lineno++; return (ERROR); }
-\"([^"\0\n\\]|\\{ALL})*(\"|{ENDL}) { cool_yylval.error_msg = "String contains escaped null character."; return (ERROR); }
-\"([^"\n\\]|\\[^\0])*(\"|{ENDL}) { cool_yylval.error_msg = "String contains null character."; return (ERROR); }
-\"([^"\0\n\\]|\\[^\0])* { cool_yylval.error_msg = "EOF in string constant"; return (ERROR); }
-
-\*\) { cool_yylval.error_msg = "Unmatched *)"; return (ERROR); }
+\"([^"\0\n\\]|\\[^\0])*\" {
+ char* str = escapeString(yytext);
+ if (strlen(str) >= MAX_STR_CONST) {
+ cool_yylval.error_msg = "String constant too long";
+ return (ERROR);
+ }
+ else {
+ cool_yylval.symbol = inttable.add_string(str);
+ return (STR_CONST);
+ }
+}
+\"([^"\0\n\\]|\\[^\0])*{ENDL} { cool_yylval.error_msg = "Unterminated string constant"; curr_lineno++; return (ERROR); }
+\"([^"\0\n\\]|\\{ALL})*(\"|{ENDL}) { cool_yylval.error_msg = "String contains escaped null character."; return (ERROR); }
+\"([^"\n\\]|\\[^\0])*(\"|{ENDL}) { cool_yylval.error_msg = "String contains null character."; return (ERROR); }
+\"([^"\0\n\\]|\\[^\0])* { cool_yylval.error_msg = "EOF in string constant"; return (ERROR); }
-(?i:class) { return (CLASS); }
-(?i:else) { return (ELSE); }
-(?i:fi) { return (FI); }
-(?i:if) { return (IF); }
-(?i:in) { return (IN); }
-(?i:inherits) { return (INHERITS); }
-(?i:isvoid) { return (ISVOID); }
-(?i:let) { return (LET); }
-(?i:loop) { return (LOOP); }
-(?i:pool) { return (POOL); }
-(?i:then) { return (THEN); }
-(?i:while) { return (WHILE); }
-(?i:case) { return (CASE); }
-(?i:esac) { return (ESAC); }
-(?i:new) { return (NEW); }
-(?i:of) { return (OF); }
-(?i:not) { return (NOT); }
+\*\) { cool_yylval.error_msg = "Unmatched *)"; return (ERROR); }
-"=>" { return (DARROW); }
-"<=" { return (LE); }
-"<-" { return (ASSIGN); }
-(t(?i:rue)|f(?i:alse)) { cool_yylval.boolean = *yytext == 't'; return (BOOL_CONST); }
+(?i:class) { return (CLASS); }
+(?i:else) { return (ELSE); }
+(?i:fi) { return (FI); }
+(?i:if) { return (IF); }
+(?i:in) { return (IN); }
+(?i:inherits) { return (INHERITS); }
+(?i:isvoid) { return (ISVOID); }
+(?i:let) { return (LET); }
+(?i:loop) { return (LOOP); }
+(?i:pool) { return (POOL); }
+(?i:then) { return (THEN); }
+(?i:while) { return (WHILE); }
+(?i:case) { return (CASE); }
+(?i:esac) { return (ESAC); }
+(?i:new) { return (NEW); }
+(?i:of) { return (OF); }
+(?i:not) { return (NOT); }
+"=>" { return (DARROW); }
+"<=" { return (LE); }
+"<-" { return (ASSIGN); }
+(t(?i:rue)|f(?i:alse)) { cool_yylval.boolean = *yytext == 't'; return (BOOL_CONST); }
-[a-z]{IDENT}* { cool_yylval.symbol = inttable.add_string(yytext); return (OBJECTID); }
-[0-9]+ { cool_yylval.symbol = inttable.add_string(yytext); return (INT_CONST); }
-[A-Z]{IDENT}* { cool_yylval.symbol = inttable.add_string(yytext); return (TYPEID); }
+[a-z]{IDCHR}* { cool_yylval.symbol = inttable.add_string(yytext); return (OBJECTID); }
+[0-9]+ { cool_yylval.symbol = inttable.add_string(yytext); return (INT_CONST); }
+[A-Z]{IDCHR}* { cool_yylval.symbol = inttable.add_string(yytext); return (TYPEID); }
-\{|\}|\(|\)|:|;|,|@|\.|\+|-|\*|\/|~|<|<=|= { return *yytext; }
+\{|\}|\(|\)|:|;|,|@|\.|\+|-|\*|\/|~|<|<=|= { return *yytext; }
-. { cool_yylval.error_msg = yytext; return (ERROR); }
-{ENDL} { curr_lineno++; }
-{BLANK} { }
+{ENDL} { curr_lineno++; }
+{BLANK} { }
+. { cool_yylval.error_msg = yytext; return (ERROR); }
%%