diff --git a/README.md b/README.md index 456c2c0..d96dc6b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ![swag](./doc/swag.webp) -![diagram](./doc/flap2.png) +![diagram](./doc/flap3.png) # uso diff --git a/doc/flap3.jff b/doc/flap3.jff new file mode 100644 index 0000000..c6654e9 --- /dev/null +++ b/doc/flap3.jff @@ -0,0 +1,534 @@ + + fa + + + + 877.0 + 320.0 + + + 755.0 + 186.0 + + + 645.0 + 136.0 + + + 490.0 + 29.0 + + + + + 869.0 + 136.0 + + + 792.0 + 32.0 + + + + + 985.0 + 169.0 + + + 1046.0 + 87.0 + + + 1179.0 + 28.0 + + + + + 1070.0 + 243.0 + + + 1212.0 + 121.0 + + + 1190.0 + 235.0 + + + 1326.0 + 304.0 + + + 1452.0 + 141.0 + + + + + 1122.0 + 383.0 + + + 1348.0 + 417.0 + + + + + 1259.0 + 471.0 + + + 1332.0 + 559.0 + + + 1087.0 + 520.0 + + + 1110.0 + 690.0 + + + + + 1041.0 + 676.0 + + + + + 979.0 + 687.0 + + + + + 1244.0 + 673.0 + + + + + 921.0 + 670.0 + + + + + 867.0 + 694.0 + + + + + 810.0 + 683.0 + + + + + 743.0 + 701.0 + + + + + 665.0 + 702.0 + + + + + 535.0 + 173.0 + + + 419.0 + 48.0 + + + + + 307.0 + 48.0 + + + + + 464.0 + 217.0 + + + 208.0 + 53.0 + + + + + 92.0 + 52.0 + + + + + 386.0 + 256.0 + + + 39.0 + 132.0 + + + + + 468.0 + 346.0 + + + 85.0 + 249.0 + + + + + 93.0 + 352.0 + + + + + 511.0 + 422.0 + + + 81.0 + 434.0 + + + + + 164.0 + 485.0 + + + + + 455.0 + 504.0 + + + 257.0 + 537.0 + + + + + 339.0 + 625.0 + + + + + 497.0 + 645.0 + + + + + 570.0 + 691.0 + + + + + + 14 + 16 + ch + + + 14 + 15 + aspas + + + 2 + 3 + outro* + + + 0 + 45 + abrechave + + + 28 + 29 + = + + + 0 + 0 + tab, espaco, \n + + + 0 + 2 + letra + + + 0 + 31 + & + + + 6 + 7 + digito + + + 0 + 27 + virgula + + + 9 + 10 + ch + + + 0 + 21 + multiplicacao + + + 2 + 2 + letra, digito, sublinha + + + 4 + 5 + outro* + + + 18 + 0 + \n + + + 39 + 40 + = + + + 42 + 44 + outro* + + + 0 + 46 + fechachave + + + 0 + 39 + > + + + 1 + 1 + sublinha + + + 0 + 9 + apostrofo + + + 31 + 33 + outro* + + + 0 + 28 + = + + + 9 + 11 + \ + + + 34 + 35 + | + + + 0 + 34 + | + + + 11 + 12 + 0, n + + + 17 + 18 + barra + + + 0 + 1 + sublinha + + + 12 + 13 + apostrofo + + + 0 + 14 + aspas + + + 0 + 26 + fechacolchete + + + 31 + 32 + & + + + 36 + 38 + outro* + + + 0 + 19 + mais + + + 0 + 25 + abrecolchete + + + 16 + 15 + aspas + + + 0 + 24 + fechaparenteses + + + 16 + 16 + ch + + + 0 + 4 + digito + + + 0 + 23 + abreparenteses + + + 10 + 13 + apostrofo + + + 1 + 2 + letra + + + 39 + 41 + outro* + + + 0 + 42 + ! + + + 18 + 18 + outro* + + + 36 + 37 + = + + + 0 + 17 + barra + + + 4 + 6 + ponto + + + 28 + 30 + outro* + + + 17 + 22 + outro* + + + 0 + 20 + menos + + + 42 + 43 + = + + + 7 + 8 + outro* + + + 0 + 36 + < + + + 4 + 4 + digito + + + 7 + 7 + digito + + + \ No newline at end of file diff --git a/doc/flap3.png b/doc/flap3.png new file mode 100644 index 0000000..a95a90d Binary files /dev/null and b/doc/flap3.png differ diff --git a/lexer/char.c b/lexer/char.c index cf3f2ca..da58270 100644 --- a/lexer/char.c +++ b/lexer/char.c @@ -83,3 +83,11 @@ bool isNotDigitNorPeriod(char c) { return isNotDigit(c) && c != '.'; } bool isZeroOrN(char c) { return c == '0' || c == 'n'; } bool isIsPrintButNotBackSlash(char c) { return isprint(c) && c != '\\'; } + +bool isCurlyOpen(char c) { + return c == '{'; +} + +bool isCurlyClose(char c) { + return c == '}'; +} diff --git a/lexer/char.h b/lexer/char.h index 75895dd..85ed975 100644 --- a/lexer/char.h +++ b/lexer/char.h @@ -42,5 +42,7 @@ bool isNotRef(char c); bool isNotDigitNorPeriod(char c); bool isZeroOrN(char c); bool isIsPrintButNotBackSlash(char c); +bool isCurlyOpen(char c); +bool isCurlyClose(char c); #endif // !CHAR_H diff --git a/lexer/lexer.c b/lexer/lexer.c index f6d7506..dd50e85 100644 --- a/lexer/lexer.c +++ b/lexer/lexer.c @@ -8,8 +8,8 @@ #include #define MAX_LEXEME_SIZE 50 -#define MAX_STATES 44 -#define MAX_TRANSITIONS 20 +#define MAX_STATES 46 +#define MAX_TRANSITIONS 22 void error(char msg[]) { printf("%s\n", msg); @@ -41,7 +41,9 @@ struct Token lexerGetNextChar(FILE *fd, int *lineCount) { {34, isPipe, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}, {36, isSmallerThan, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}, {39, isLargerThan, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}, - {42, isNeg, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}}, + {42, isNeg, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}, + {45, isCurlyOpen, SIGN, NOT_OTHER, OPEN_CURLY}, + {46, isCurlyClose, SIGN, NOT_OTHER, CLOSE_CURLY}}, // State 1 {{1, isUnderscore, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}, {2, isAlpha, NON_ACCEPTING, NOT_OTHER, NOT_SYMBOL}}, diff --git a/lexer/printer.c b/lexer/printer.c index d3aa3c4..51fe1c6 100644 --- a/lexer/printer.c +++ b/lexer/printer.c @@ -3,7 +3,7 @@ #include #define TOKEN_CATEGORY_QTY 7 -#define SIGN_CATEGORY_QTY 20 +#define SIGN_CATEGORY_QTY 22 struct TokenCategoryHandler tokenCategoryHandleData[TOKEN_CATEGORY_QTY] = { {RSV, handleRsv}, {ID, handleId}, @@ -32,7 +32,8 @@ struct SignCategoryHandler signCategoryHandleData[SIGN_CATEGORY_QTY] = { {DIFFERENT, "DIFFERENT"}, {SMALLER_EQUAL, "SMALLER_EQUAL"}, {LARGER_EQUAL, "LARGER_EQUAL"}, -}; + {OPEN_CURLY, "OPEN_CURLY"}, + {CLOSE_CURLY, "CLOSE_CURLY"}}; void handleRsv(struct Token token) { printf("", token.lexeme); } diff --git a/lexer/types.h b/lexer/types.h index 483534c..615bb58 100644 --- a/lexer/types.h +++ b/lexer/types.h @@ -42,7 +42,9 @@ enum SIGN { NEGATION, DIFFERENT, SMALLER_EQUAL, - LARGER_EQUAL + LARGER_EQUAL, + OPEN_CURLY, + CLOSE_CURLY }; enum IS_OTHER { IS_OTHER, NOT_OTHER };