updated comment count

This commit is contained in:
Partho Bhattacharya
2025-02-13 20:02:42 -05:00
parent 3c6d3be9b4
commit 52a7c69dae
14 changed files with 123 additions and 110 deletions

BIN
flex.o

Binary file not shown.

View File

@ -824,7 +824,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 27 "lexicalStructure.lex"
{if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {column_number=column_number+yyleng; return T_INTEGER;}}
{if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {return T_INTEGER;}}
YY_BREAK
case 2:
YY_RULE_SETUP

View File

@ -23,7 +23,7 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
%%
"integer" {if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {column_number=column_number+yyleng; return T_INTEGER;}}
"integer" {if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {return T_INTEGER;}}
"address" {if(DEBUG) {printf( "T_ADDRESS: %s (%d)\n", yytext, T_ADDRESS);} else {return T_ADDRESS;}}
"Boolean" {if(DEBUG) {printf( "T_BOOLEAN: %s (%d)\n", yytext, T_BOOLEAN);} else {return T_BOOLEAN;}}
"character" {if(DEBUG) {printf( "T_CHARACTER: %s (%d)\n", yytext, T_CHARACTER);} else {return T_CHARACTER;}}

BIN
runner

Binary file not shown.

View File

@ -26,6 +26,17 @@ int main(int argc, char *argv[]) {
if (arg == TOK_ARG) {
fprintf(output, "%d %d %3d \"%s\"\n", line_number, column_number, token, yytext);
}
if(token == COMMENT){
for (int i = 0; i < yyleng; i++) {
if(yytext[i] == '\n'){
line_number++;
column_number = 0;
}
column_number++;
}
continue;
}
column_number += yyleng;
}
if (yyin != NULL) {

View File

@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "flex.h"
#include "typedefs.h"
extern int line_number, column_number;
extern char *yytext;

BIN
runner.o

Binary file not shown.

View File

@ -2,8 +2,8 @@
2 1 700 "(* hello *)"
3 1 700 "(* I'd think this is a legal "string" that contains several \n \t
escaped characters, isn't it? *)"
4 1 700 "(* \ *)"
5 1 700 "(* *)"
6 1 700 "(*{COMMENT}+ *)"
7 1 700 "(* * *)"
8 1 700 "(* (hello) *)"
5 1 700 "(* \ *)"
6 1 700 "(* *)"
7 1 700 "(*{COMMENT}+ *)"
8 1 700 "(* * *)"
9 1 700 "(* (hello) *)"

View File

@ -1,61 +1,61 @@
1 1 101 "This"
1 2 101 "is"
1 3 101 "a"
1 4 101 "test"
1 6 101 "is"
1 9 101 "a"
1 11 101 "test"
2 1 301 "9"
2 1 101 "combined"
2 2 301 "7"
2 2 101 "okens"
2 2 101 "combined"
2 11 301 "7"
2 12 101 "okens"
3 1 301 "12345"
4 1 301 "893247892"
5 1 101 "combined"
5 2 101 "DueToUnknownChar"
5 3 101 "_validtoken"
5 4 101 "__validtoken1"
5 5 101 "_valid_token2"
5 6 101 "validToken3_"
5 10 101 "DueToUnknownChar"
5 27 101 "_validtoken"
5 39 101 "__validtoken1"
5 53 101 "_valid_token2"
5 67 101 "validToken3_"
6 1 305 "true"
6 2 306 "false"
6 6 306 "false"
7 1 302 "null"
7 2 401 "while"
7 3 609 "!"
7 3 101 "wrong"
7 4 402 "if"
7 5 101 "when"
7 6 401 "while"
7 12 609 "!"
7 13 101 "wrong"
7 19 402 "if"
7 22 101 "when"
8 1 404 "else"
8 2 405 "type"
8 3 406 "function"
8 6 405 "type"
8 11 406 "function"
9 1 407 "return"
9 3 408 "external"
9 11 409 "as"
9 9 408 "external"
9 25 409 "as"
10 1 101 "string"
10 2 101 "_NOte_that_was_not_reserved"
10 8 101 "_NOte_that_was_not_reserved"
11 7 508 ":"
11 7 507 ";"
11 7 509 ","
11 7 510 "->"
11 8 507 ";"
11 9 509 ","
11 10 510 "->"
12 1 601 "+"
12 1 602 "-"
12 1 603 "*"
12 1 604 "/"
12 1 605 "%"
12 2 602 "-"
12 3 603 "*"
12 4 604 "/"
12 5 605 "%"
13 1 606 "<"
13 1 607 "="
13 2 607 "="
14 1 608 ":="
15 2 101 "This"
15 3 101 "is"
15 4 101 "not"
15 5 101 "a"
15 6 101 "valid"
15 7 101 "is"
15 10 101 "not"
15 14 101 "a"
15 16 101 "valid"
16 1 101 "String"
17 1 304 ""This is a valid String""
18 1 609 "!"
18 1 611 "|"
19 1 612 "."
18 2 611 "|"
19 1 612 "."
19 2 612 "."
20 1 700 "(* this is a comment *)"
21 2 603 "*"
21 2 101 "Not"
21 3 101 "a"
21 4 101 "comment"
21 3 101 "Not"
21 7 101 "a"
21 9 101 "comment"
22 3 610 "&"

View File

@ -7,7 +7,7 @@
9 1 607 "="
10 1 608 ":="
11 1 607 "="
11 1 508 ":"
11 2 508 ":"
12 1 508 ":"
13 1 607 "="
14 1 609 "!"

View File

@ -4,4 +4,4 @@
4 1 510 "->"
5 1 510 "->"
6 1 602 "-"
6 1 510 "->"
6 2 510 "->"

View File

@ -2,7 +2,7 @@
2 1 301 "123"
3 1 301 "8392"
4 1 301 "40"
4 2 301 "40"
4 4 301 "40"
5 2 301 "200"
5 3 301 "50"
5 4 301 "21783"
5 6 301 "50"
5 9 301 "21783"

View File

@ -1,62 +1,63 @@
1 1 304 ""this is a string""
1 2 301 "721398"
1 3 303 "'g'"
1 5 604 "/"
1 5 101 "n"
1 7 700 "(* should print 3 tokens before this *)"
1 20 301 "721398"
1 27 303 "'g'"
1 32 604 "/"
1 33 101 "n"
1 36 700 "(* should print 3 tokens before this *)"
4 1 301 "12893"
4 3 101 "this"
4 4 101 "is"
4 5 101 "not"
4 6 101 "a"
4 7 101 "string"
4 8 700 "(*one valid token before this*)"
4 8 101 "this"
4 13 101 "is"
4 16 101 "not"
4 20 101 "a"
4 22 101 "string"
4 29 700 "(*one valid token before this*)"
5 1 700 "(* spacey comment here
over multiple lines
will it work? *)"
9 1 306 "false"
10 1 700 "(**)"
12 1 101 "nullfalse"
13 2 101 "nulltrue"
14 1 302 "null"
15 1 303 "'7'"
16 1 305 "true"
17 2 301 "189"
18 1 303 "'\t'"
19 1 303 "'"'"
20 1 303 "'/'"
21 1 303 "'\n'"
22 1 303 "'\''"
23 1 303 "'\t'"
25 1 303 "'n'"
27 2 101 "fdsf"
28 1 700 "(*/jnewjno2893u86^ Lots of random characters /n /t '") *)"
33 1 304 ""STRINGwithnotSPaces""
34 1 303 "' '"
36 1 304 ""J""
37 1 304 """"
38 1 304 "" ""
40 1 304 ""{SCHAR}""
41 1 304 ""SCHAR""
42 1 304 ""[SCHAR]""
43 1 304 ""FINAL: I'd think this is a legal \"string\" that contains \n \t several escaped characters, isn't it?""
44 2 101 "I"
44 3 101 "d"
44 4 101 "think"
44 5 101 "this"
44 6 101 "is"
44 7 101 "a"
44 8 101 "legal"
44 11 101 "string"
44 14 101 "that"
44 15 101 "contains"
44 16 101 "several"
44 19 101 "n"
44 21 101 "t"
44 22 101 "escaped"
44 23 101 "characters"
44 23 509 ","
44 24 101 "isn"
44 25 101 "t"
44 26 101 "it"
45 1 101 "nullLike"
7 18 306 "false"
11 1 306 "false"
12 1 700 "(**)"
14 1 101 "nullfalse"
15 2 101 "nulltrue"
16 1 302 "null"
17 1 303 "'7'"
18 1 305 "true"
19 2 301 "189"
20 1 303 "'\t'"
21 1 303 "'"'"
22 1 303 "'/'"
23 1 303 "'\n'"
24 1 303 "'\''"
25 1 303 "'\t'"
27 1 303 "'n'"
29 2 101 "fdsf"
30 1 700 "(*/jnewjno2893u86^ Lots of random characters /n /t '") *)"
35 1 304 ""STRINGwithnotSPaces""
36 1 303 "' '"
38 1 304 ""J""
39 1 304 """"
40 1 304 "" ""
42 1 304 ""{SCHAR}""
43 1 304 ""SCHAR""
44 1 304 ""[SCHAR]""
45 1 304 ""FINAL: I'd think this is a legal \"string\" that contains \n \t several escaped characters, isn't it?""
46 2 101 "I"
46 4 101 "d"
46 6 101 "think"
46 12 101 "this"
46 17 101 "is"
46 20 101 "a"
46 22 101 "legal"
46 30 101 "string"
46 39 101 "that"
46 44 101 "contains"
46 53 101 "several"
46 63 101 "n"
46 66 101 "t"
46 68 101 "escaped"
46 76 101 "characters"
46 86 509 ","
46 88 101 "isn"
46 92 101 "t"
46 94 101 "it"
47 1 101 "nullLike"

View File

@ -4,7 +4,7 @@
12893 "this is not a string (*one valid token before this*)
(* spacey comment here
over multiple lines
will it work? *)
will it work? *) false
"
'''
'\'