diff --git a/.DS_Store b/.DS_Store index 3a42259..53d1579 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.vs/.DS_Store b/.vs/.DS_Store index a3430d6..d9cc9b2 100644 Binary files a/.vs/.DS_Store and b/.vs/.DS_Store differ diff --git a/.vs/RuanScript/.DS_Store b/.vs/RuanScript/.DS_Store index 2ce6d35..b49e088 100644 Binary files a/.vs/RuanScript/.DS_Store and b/.vs/RuanScript/.DS_Store differ diff --git a/.vs/RuanScript/FileContentIndex/b7105e4d-1f5b-4659-9f69-e2de8bf6d688.vsidx b/.vs/RuanScript/FileContentIndex/1e0b13bb-3cb7-4263-8d8a-7ed21f0acf55.vsidx similarity index 97% rename from .vs/RuanScript/FileContentIndex/b7105e4d-1f5b-4659-9f69-e2de8bf6d688.vsidx rename to .vs/RuanScript/FileContentIndex/1e0b13bb-3cb7-4263-8d8a-7ed21f0acf55.vsidx index d1b01c6..4932e56 100644 Binary files a/.vs/RuanScript/FileContentIndex/b7105e4d-1f5b-4659-9f69-e2de8bf6d688.vsidx and b/.vs/RuanScript/FileContentIndex/1e0b13bb-3cb7-4263-8d8a-7ed21f0acf55.vsidx differ diff --git a/.vs/RuanScript/FileContentIndex/2a9aedd2-f2e0-426b-bf86-a83bf01ca652.vsidx b/.vs/RuanScript/FileContentIndex/2a9aedd2-f2e0-426b-bf86-a83bf01ca652.vsidx new file mode 100644 index 0000000..fd27240 Binary files /dev/null and b/.vs/RuanScript/FileContentIndex/2a9aedd2-f2e0-426b-bf86-a83bf01ca652.vsidx differ diff --git a/.vs/RuanScript/FileContentIndex/3045e8df-5c94-401d-b7f0-4638bd81000c.vsidx b/.vs/RuanScript/FileContentIndex/3045e8df-5c94-401d-b7f0-4638bd81000c.vsidx new file mode 100644 index 0000000..116294c Binary files /dev/null and b/.vs/RuanScript/FileContentIndex/3045e8df-5c94-401d-b7f0-4638bd81000c.vsidx differ diff --git a/.vs/RuanScript/FileContentIndex/310f0a83-13ff-43e8-b576-7590804d2874.vsidx b/.vs/RuanScript/FileContentIndex/310f0a83-13ff-43e8-b576-7590804d2874.vsidx deleted file mode 100644 index 6fe5282..0000000 Binary files a/.vs/RuanScript/FileContentIndex/310f0a83-13ff-43e8-b576-7590804d2874.vsidx and /dev/null differ diff --git a/.vs/RuanScript/FileContentIndex/3b4fc790-e911-476a-b96e-d71487ca4096.vsidx b/.vs/RuanScript/FileContentIndex/3b4fc790-e911-476a-b96e-d71487ca4096.vsidx deleted file mode 100644 index d421199..0000000 Binary files a/.vs/RuanScript/FileContentIndex/3b4fc790-e911-476a-b96e-d71487ca4096.vsidx and /dev/null differ diff --git a/.vs/RuanScript/FileContentIndex/5f3162b0-b553-44c0-91e7-a3d9a1adabdd.vsidx b/.vs/RuanScript/FileContentIndex/5f3162b0-b553-44c0-91e7-a3d9a1adabdd.vsidx new file mode 100644 index 0000000..03df2ad Binary files /dev/null and b/.vs/RuanScript/FileContentIndex/5f3162b0-b553-44c0-91e7-a3d9a1adabdd.vsidx differ diff --git a/.vs/RuanScript/FileContentIndex/d57f32ae-21ac-4a8d-ba08-7d7df88abf41.vsidx b/.vs/RuanScript/FileContentIndex/d57f32ae-21ac-4a8d-ba08-7d7df88abf41.vsidx deleted file mode 100644 index 16dc71a..0000000 Binary files a/.vs/RuanScript/FileContentIndex/d57f32ae-21ac-4a8d-ba08-7d7df88abf41.vsidx and /dev/null differ diff --git a/.vs/RuanScript/copilot-chat/61f2811d/sessions/4a59b8d3-3f3d-47be-bb77-b26990a3eb77 b/.vs/RuanScript/copilot-chat/61f2811d/sessions/4a59b8d3-3f3d-47be-bb77-b26990a3eb77 new file mode 100644 index 0000000..eee441a Binary files /dev/null and b/.vs/RuanScript/copilot-chat/61f2811d/sessions/4a59b8d3-3f3d-47be-bb77-b26990a3eb77 differ diff --git a/.vs/RuanScript/copilot-chat/61f2811d/sessions/e4e657d8-b129-4cd2-b193-02307e5d5951 b/.vs/RuanScript/copilot-chat/61f2811d/sessions/e4e657d8-b129-4cd2-b193-02307e5d5951 new file mode 100644 index 0000000..c3356eb Binary files /dev/null and b/.vs/RuanScript/copilot-chat/61f2811d/sessions/e4e657d8-b129-4cd2-b193-02307e5d5951 differ diff --git a/.vs/RuanScript/v17/.wsuo b/.vs/RuanScript/v17/.wsuo index 1ca6306..f5b2f77 100644 Binary files a/.vs/RuanScript/v17/.wsuo and b/.vs/RuanScript/v17/.wsuo differ diff --git a/.vs/RuanScript/v17/Browse.VC.db b/.vs/RuanScript/v17/Browse.VC.db index 88a2088..0559edf 100644 Binary files a/.vs/RuanScript/v17/Browse.VC.db and b/.vs/RuanScript/v17/Browse.VC.db differ diff --git a/.vs/RuanScript/v17/Browse.VC.db-shm b/.vs/RuanScript/v17/Browse.VC.db-shm index b595e58..16cc5af 100644 Binary files a/.vs/RuanScript/v17/Browse.VC.db-shm and b/.vs/RuanScript/v17/Browse.VC.db-shm differ diff --git a/.vs/RuanScript/v17/DocumentLayout.json b/.vs/RuanScript/v17/DocumentLayout.json index 9567818..e4855df 100644 --- a/.vs/RuanScript/v17/DocumentLayout.json +++ b/.vs/RuanScript/v17/DocumentLayout.json @@ -6,17 +6,29 @@ "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Scanner.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\Scanner.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}", + "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\launch.vs.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}" + }, { "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainScanner.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\MainScanner.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}", - "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\launch.vs.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}" + "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\input\\INPUT2_Volume.rs||{3B902123-F8A7-4915-9F01-361F908088D0}", + "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:input\\INPUT2_Volume.rs||{3B902123-F8A7-4915-9F01-361F908088D0}" + }, + { + "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Parser.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\Parser.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Scanner.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\Scanner.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainParser.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\MainParser.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Parser.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:code\\Parser.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" } ], "DocumentGroupContainers": [ @@ -26,21 +38,8 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 1, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 2, - "Title": "launch.vs.json", - "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json", - "RelativeDocumentMoniker": "code\\launch.vs.json", - "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json", - "RelativeToolTip": "code\\launch.vs.json", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAIAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|", - "WhenOpened": "2024-07-19T17:07:01.732Z", - "EditorCaption": "" - }, { "$type": "Document", "DocumentIndex": 0, @@ -49,34 +48,87 @@ "RelativeDocumentMoniker": "code\\Scanner.c", "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Scanner.c", "RelativeToolTip": "code\\Scanner.c", - "ViewState": "AQIAAG4BAAAAAAAAAAAWwHoBAAAAAAAA", + "ViewState": "AQIAAA8DAAAAAAAAAAAWwBsDAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|", - "WhenOpened": "2024-07-11T00:32:22.071Z", + "WhenOpened": "2024-07-30T17:58:27.125Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "MainScanner.c", + "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainScanner.c", + "RelativeDocumentMoniker": "code\\MainScanner.c", + "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainScanner.c", + "RelativeToolTip": "code\\MainScanner.c", + "ViewState": "AQIAAJgAAAAAAAAAAAAWwKQAAAACAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|", + "WhenOpened": "2024-07-30T17:45:29.273Z", "EditorCaption": "" }, { "$type": "Document", "DocumentIndex": 3, - "Title": "Scanner.h", - "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Scanner.h", - "RelativeDocumentMoniker": "code\\Scanner.h", - "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Scanner.h", - "RelativeToolTip": "code\\Scanner.h", - "ViewState": "AQIAAJ8BAAAAZ2ZmZiYrwK8BAAAAAAAA", + "Title": "INPUT2_Volume.rs", + "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\input\\INPUT2_Volume.rs", + "RelativeDocumentMoniker": "input\\INPUT2_Volume.rs", + "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\input\\INPUT2_Volume.rs", + "RelativeToolTip": "input\\INPUT2_Volume.rs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAEAAAAVAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|", + "WhenOpened": "2024-07-30T17:21:27.813Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 6, + "Title": "Parser.h", + "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Parser.h", + "RelativeDocumentMoniker": "code\\Parser.h", + "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Parser.h", + "RelativeToolTip": "code\\Parser.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-07-10T02:29:02.968Z" + "WhenOpened": "2024-07-30T17:05:17.62Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 4, + "Title": "Parser.c", + "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Parser.c", + "RelativeDocumentMoniker": "code\\Parser.c", + "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Parser.c", + "RelativeToolTip": "code\\Parser.c", + "ViewState": "AQIAAFgAAAAAAAAAAAAWwGQAAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|", + "WhenOpened": "2024-07-30T17:05:15.256Z", + "EditorCaption": "" }, { "$type": "Document", "DocumentIndex": 1, - "Title": "MainScanner.c", - "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainScanner.c", - "RelativeDocumentMoniker": "code\\MainScanner.c", - "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainScanner.c", - "RelativeToolTip": "code\\MainScanner.c", - "ViewState": "AQIAAJgAAAAAAAAAAAAWwKQAAAAAAAAA", + "Title": "launch.vs.json", + "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json", + "RelativeDocumentMoniker": "code\\launch.vs.json", + "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\launch.vs.json", + "RelativeToolTip": "code\\launch.vs.json", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAIAAAAEAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|", + "WhenOpened": "2024-07-19T17:07:01.732Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "MainParser.c", + "DocumentMoniker": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainParser.c", + "RelativeDocumentMoniker": "code\\MainParser.c", + "ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\MainParser.c", + "RelativeToolTip": "code\\MainParser.c", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|", - "WhenOpened": "2024-07-10T02:26:40.089Z", + "WhenOpened": "2024-07-30T17:05:20.854Z", "EditorCaption": "" } ] diff --git a/.vs/RuanScript/v17/ipch/AutoPCH/52c9afbe93b57e0d/READER.ipch b/.vs/RuanScript/v17/ipch/AutoPCH/52c9afbe93b57e0d/READER.ipch index c02319b..7d676bd 100644 Binary files a/.vs/RuanScript/v17/ipch/AutoPCH/52c9afbe93b57e0d/READER.ipch and b/.vs/RuanScript/v17/ipch/AutoPCH/52c9afbe93b57e0d/READER.ipch differ diff --git a/.vs/RuanScript/v17/ipch/AutoPCH/53dc1c4dcfa7222b/MAINPARSER.ipch b/.vs/RuanScript/v17/ipch/AutoPCH/53dc1c4dcfa7222b/MAINPARSER.ipch new file mode 100644 index 0000000..5524e41 Binary files /dev/null and b/.vs/RuanScript/v17/ipch/AutoPCH/53dc1c4dcfa7222b/MAINPARSER.ipch differ diff --git a/.vs/RuanScript/v17/ipch/AutoPCH/6f26cbfc82f7672a/PARSER.ipch b/.vs/RuanScript/v17/ipch/AutoPCH/6f26cbfc82f7672a/PARSER.ipch new file mode 100644 index 0000000..11f3e84 Binary files /dev/null and b/.vs/RuanScript/v17/ipch/AutoPCH/6f26cbfc82f7672a/PARSER.ipch differ diff --git a/.vs/RuanScript/v17/ipch/AutoPCH/c8e4fd7d876001ca/SCANNER.ipch b/.vs/RuanScript/v17/ipch/AutoPCH/c8e4fd7d876001ca/SCANNER.ipch index 2db1a4f..6041876 100644 Binary files a/.vs/RuanScript/v17/ipch/AutoPCH/c8e4fd7d876001ca/SCANNER.ipch and b/.vs/RuanScript/v17/ipch/AutoPCH/c8e4fd7d876001ca/SCANNER.ipch differ diff --git a/.vs/RuanScript/v17/ipch/AutoPCH/ffa682beba405cad/MAINSCANNER.ipch b/.vs/RuanScript/v17/ipch/AutoPCH/ffa682beba405cad/MAINSCANNER.ipch index fb54b64..4550006 100644 Binary files a/.vs/RuanScript/v17/ipch/AutoPCH/ffa682beba405cad/MAINSCANNER.ipch and b/.vs/RuanScript/v17/ipch/AutoPCH/ffa682beba405cad/MAINSCANNER.ipch differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 29f0959..d83cd8c 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -2,7 +2,6 @@ "ExpandedNodes": [ "", "\\code", - "\\code\\out", "\\input" ], "SelectedNode": "\\input", diff --git a/.vs/cmake.db b/.vs/cmake.db index 2823845..ece5d38 100644 Binary files a/.vs/cmake.db and b/.vs/cmake.db differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 1dac992..921a242 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/code/.DS_Store b/code/.DS_Store index fc25c0a..bfec5dc 100644 Binary files a/code/.DS_Store and b/code/.DS_Store differ diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index bf72129..8fb4679 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -34,8 +34,7 @@ add_executable (Compiler "Compilers.h" "Compilers.c" "Reader.h" "Reader.c" "MainReader.c" "MainScanner.c" "Scanner.c" "Scanner.h" - - #"MainParser.c" "Parser.c" "Parser.h" + "MainParser.c" "Parser.c" "Parser.h" # TO_DO: Add A22 (Scanner) and A32 (Parser) ) diff --git a/code/Compilers.c b/code/Compilers.c index 313ea4f..edbdf89 100644 --- a/code/Compilers.c +++ b/code/Compilers.c @@ -102,7 +102,7 @@ Rs_intg main(int argc, char** argv) { break; case PGM_PARSER: printf("%s%c%s", "\n[Option '", PGM_PARSER, "': Starting PARSER .....]\n\n"); - // mainParser(argc, argv); + mainParser(argc, argv); break; default: printf("%s%c%s%c%s%c%s", "* OPTIONS:\n- [", @@ -130,32 +130,58 @@ Rs_intg main(int argc, char** argv) { /* TO_DO: Update your logo with your own language message */ Rs_void printLogo() { - printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", - "\t=---------------------------------------=\n", - "\t| COMPILERS - ALGONQUIN COLLEGE (S24) |\n", - "\t=---------------------------------------=\n", - "\t @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n", - "\t @@ @@ \n", - "\t @@ %&@@@@@@@@@@@ @@ \n", - "\t @@ @%% (@@@@@@@@@ @ @@ \n", - "\t @@ @& @ @ @ @ @@ \n", - "\t @@ @ @ % / / @@@@@@ @@ \n", - "\t @@ & @ @ @@ @@ \n", - "\t @@ @/ @*@ @ @ @ @@ \n", - "\t @@ @@@@ @@ @ @ @@ \n", - "\t @@ /@@ @@@ @ @@ \n", - "\t @@ @ / / @@ @ @@ \n", - "\t @@ @ @@ /@/ @@@ @ @@ \n", - "\t @@ @@@@@@@@@@@@@@@ @@ \n", - "\t @@ @@ \n", - "\t @@ RUANSCRIPT @@ \n", - "\t @@ @@ \n", - "\t @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n", - "\t \n", - "\t[READER SCRIPT .........................]\n", + const char *logo = + "\t=-------------------------------------------------------------------------=\n" + "\t| COMPILERS - ALGONQUIN COLLEGE (S24) |\n" + "\t=-------------------------------------------------------------------------=\n" + "\t _..-'( RUANSCRIPT )`-.._\n" + "\t ./'. '||\\. (\\_/) .//||` .`\\.\n" + "\t ./'.|'.'||||\\\\|.. )O O( ..|//||||.`|.`\\.\n" + "\t ./'..|'.|| |||||\\`````` '`\"'` ''''''/||||| ||.`|..`\\.\n" + "\t ./'.||'.|||| ||||||||||||. .|||||||||||| |||||.`||.`\\.\n" + "\t /'|||'.|||||| ||||||||||||{ }|||||||||||| ||||||.`|||`\\.\n" + "\t '.|||'.||||||| ||||||||||||{ }|||||||||||| |||||||.`|||.`\n" + "\t '.||| ||||||||| |/' ``\\||`` ''||/'' `\\| ||||||||| |||.`\n" + "\t |/' \\./' `\\./ \\!|\\ /|!/ \\./' `\\./ `\\|\n" + "\t V V V }' `\\ /' `{ V V V\n" + "\t ` ` ` V ' ' '\n" "\t \n" - ); + "\t[READER SCRIPT .............................................................]\n" + "\t \n"; + + printf("%s", logo); } + +// Rs_void printLogo() { +// printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", +// "\t=---------------------------------------=\n", +// "\t| COMPILERS - ALGONQUIN COLLEGE (S24) |\n", +// "\t=---------------------------------------=\n", +// "\t @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n", +// "\t @@ @@ \n", +// "\t @@ %&@@@@@@@@@@@ @@ \n", +// "\t @@ @%% (@@@@@@@@@ @ @@ \n", +// "\t @@ @& @ @ @ @ @@ \n", +// "\t @@ @ @ % / / @@@@@@ @@ \n", +// "\t @@ & @ @ @@ @@ \n", +// "\t @@ @/ @*@ @ @ @ @@ \n", +// "\t @@ @@@@ @@ @ @ @@ \n", +// "\t @@ /@@ @@@ @ @@ \n", +// "\t @@ @ / / @@ @ @@ \n", +// "\t @@ @ @@ /@/ @@@ @ @@ \n", +// "\t @@ @@@@@@@@@@@@@@@ @@ \n", +// "\t @@ @@ \n", +// "\t @@ RUANSCRIPT @@ \n", +// "\t @@ @@ \n", +// "\t @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n", +// "\t \n", +// "\t[READER SCRIPT .........................]\n", +// "\t \n" +// ); +// } + + + diff --git a/code/Compilers.h b/code/Compilers.h index 9c1f4bc..2daa4d5 100644 --- a/code/Compilers.h +++ b/code/Compilers.h @@ -132,7 +132,7 @@ Rs_intg mainReader(Rs_intg argc, Rs_string* argv); TO_DO: Include later mainScaner (A22) and mainParser (A32) */ Rs_intg mainScanner(Rs_intg argc, Rs_string* argv); -// Rs_intg mainParser(Rs_intg argc, Rs_string* argv); +Rs_intg mainParser(Rs_intg argc, Rs_string* argv); Rs_void printLogo(); diff --git a/code/Compilers.o b/code/Compilers.o index 0bd8ca2..7fcef22 100644 Binary files a/code/Compilers.o and b/code/Compilers.o differ diff --git a/code/MainParser.c b/code/MainParser.c new file mode 100644 index 0000000..3e64714 --- /dev/null +++ b/code/MainParser.c @@ -0,0 +1,286 @@ +/* +************************************************************ +* COMPILERS COURSE - Algonquin College +* Code version: Fall, 2023 +* Author: TO_DO +* Professors: Paulo Sousa +************************************************************ +=---------------------------------------= +| COMPILERS - ALGONQUIN COLLEGE (F23) | +=---------------------------------------= +| .... | +| ........::.::::::. | +| .:........::.:^^^~~~: | +| :^^::::::^^^::^!7??7~^. | +| .:^~~^!77777~~7?YY?7??7^. | +| :.^~!??!^::::^^~!?5PY??!~. | +| ~!!7J~.:::^^^^~!!~~?G5J?~ | +| :^~?!~7?Y57^^?PP5YJ!J5Y?: | +| .~!!.:^!7!:.:7JYYJ7~7Y7^ | +| .~77.. . .~^:^^^~7?: | +| .^!^~:::.:^!7?~^~!77J: | +| ^^!Y~^^^^~?YJ77??7JJ^ | +| .^7J?~^~~^~7??7??7JY?~: | +| ::^^~^7?!^~~!7???J?J7~:. | +| ^~~!.^7YPPPP5Y?7J7777~. | +| ..:~..:^!JPP5YJ?!777!^. | +| .~?JJJJJJJJJJYYYYYPPPPPPPPPPPP5PPYY~ | +| :!Y5GGG.___ YYYYYY__._.PPGGGGGG5!. | +| :!Y5G / __| ___ / _(_)__ _ PGP5. | +| :~75 \__ \/ _ \ _| / _` | 5?. | +| 7~7 |___/\___/_| |_\__,_| Y5?. | +| .^~!~.....................P5YY7. | +| .:::::::::::::?JJJJYYYYYYYYYJJJJ7. | +| | +=---------------------------------------= +*/ + +/* +************************************************************ +* File name: MainParser.c +* Compiler: MS Visual Studio 2022 +* Course: CST 8152 � Compilers, Lab Section: [011, 012, 013] +* Assignment: A32. +* Date: May 01 2023 +* Professor: Paulo Sousa +* Purpose: This file is the main code for Parser (A32) +* Function list: (...). +************************************************************ +*/ + +/* +************************************************************ + * IMPORTANT NOTE: + * The #define _CRT_SECURE_NO_WARNINGS should be used in MS Visual Studio projects + * to suppress the warnings about using "unsafe" functions like fopen() + * and standard sting library functions defined in string.h. + * The define does not have any effect in other compilers projects. + ********************************************************* + */ + + +#define _CRT_SECURE_NO_WARNINGS + +#include +#include /* Constants for calls to exit()*/ + +#include +#include + +#ifndef COMPILERS_H_ +#include "Compilers.h" +#endif + +#ifndef READER_H_ +#include "Reader.h" +#endif + +#ifndef SCANNER_H_ +#include "Scanner.h" +#endif + +#ifndef PARSER_H_ +#include "Parser.h" +#endif + + /* Check for ANSI C compliancy */ +#define ANSI_C 0 +#if defined(__STDC__) +#undef ANSI_C +#define ANSI_C 1 +#endif + +/* + * ------------------------------------------------------------- + * Global vars and External vars + * ------------------------------------------------------------- + */ + + /* Global objects - variables */ +static BufferPointer sourceBuffer; /* pointer to input (source) buffer */ +BufferPointer stringLiteralTable; /* This buffer is used as a repository for string literals */ +Rs_intg errorNumber; /* Run-time error number = 0 by default (ANSI) */ + +/* External objects */ +extern Rs_intg syntaxErrorNumber /* number of syntax errors reported by the parser */; +extern Rs_intg line; /* source code line number - defined in scanner.c */ + +extern ParserData psData; + +/* + * ------------------------------------------------------------- + * Function declarations + * ------------------------------------------------------------- + */ + + /* Function declarations (prototypes) */ +extern Rs_void startParser(Rs_void); +extern Rs_intg startScanner(BufferPointer sc_buf); + +static Rs_void printParserError(Rs_string fmt, ...); +static Rs_void displayParser(BufferPointer ptrBuffer); +static Rs_long getParserFileSize(Rs_string fname); +static Rs_void callGarbageCollector(Rs_void); + +/* +************************************************************ + * Parser Main function + * Parameters: + * - argc / argv = Parameters from command prompt + * Return value: + * - Success operation. +*********************************************************** +*/ + +Rs_intg mainParser(Rs_intg argc, Rs_string* argv) { + + numParserErrors = 0; /* Initializes the errors */ + + FILE* fi; /* input file handle */ + Rs_intg loadsize = 0; /*the size of the file loaded in the buffer */ + + /*check for correct arrguments - source file name */ + if (argc <= 1) { + /* __DATE__, __TIME__, __LINE__, __FILE__ are predefined preprocessor macros*/ + printParserError("Date: %s Time: %s", __DATE__, __TIME__); + printParserError("Runtime error at line %d in file %s", __LINE__, __FILE__); + printParserError("%s%s%s", argv[0], ": ", "Missing source file name."); + printParserError("%s%s%s", "Usage: ", "parser", " source_file_name"); + exit(EXIT_FAILURE); + } + + /* create a source code input buffer - multiplicative mode */ + sourceBuffer = readerCreate(READER_DEFAULT_SIZE, READER_DEFAULT_INCREMENT, MODE_MULTI); + if (sourceBuffer == NULL) { + printParserError("%s%s%s", argv[0], ": ", "Could not create source buffer"); + exit(EXIT_FAILURE); + } + + /*open source file */ + if ((fi = fopen(argv[2], "r")) == NULL) { + printParserError("%s%s%s%s", argv[0], ": ", "Cannot open file: ", argv[2]); + exit(EXIT_FAILURE); + } + + /* load source file into input buffer */ + printf("Reading file %s ....Please wait\n", argv[2]); + loadsize = readerLoad(sourceBuffer, fi); + if (loadsize == READER_ERROR) + printParserError("%s%s%s", argv[0], ": ", "Error in loading buffer."); + + /* close source file */ + fclose(fi); + /*find the size of the file */ + if (loadsize == READER_ERROR) { + printf("The input file %s %s\n", argv[2], "is not completely loaded."); + printf("Input file size: %ld\n", getParserFileSize(argv[2])); + } + /* Add SEOF (EOF) to input buffer and display the source buffer */ + if ((loadsize != READER_ERROR) && (loadsize != 0)) { + if (readerAddChar(sourceBuffer, READER_TERMINATOR)) { + displayParser(sourceBuffer); + } + } + /* create string Literal Table */ + stringLiteralTable = readerCreate(READER_DEFAULT_SIZE, READER_DEFAULT_INCREMENT, MODE_ADDIT); + if (stringLiteralTable == NULL) { + printParserError("%s%s%s", argv[0], ": ", "Could not create string literal buffer"); + exit(EXIT_FAILURE); + } + + /* Registrer exit function */ + atexit(callGarbageCollector); + + /* Initialize scanner */ + startScanner(sourceBuffer); + + /* Start parsing */ + printf("\nParsing the source file...\n\n"); + startParser(); + + printf("\nNumber of Parser errors: %d\n", numParserErrors); + + /* Prints the statistics */ + printBNFData(psData); + + return (EXIT_SUCCESS); /* same effect as exit(0) */ + +} + +/* +************************************************************ + * Error printing function with variable number of arguments + * Params: Variable arguments, using formats from C language. + * - Internal vars use list of arguments and types from stdarg.h + * - NOTE: The format is using signature from C Language +************************************************************ +*/ + +Rs_void printParserError(Rs_string fmt, ...) { + + va_list ap; + va_start(ap, fmt); + + (Rs_void)vfprintf(stderr, fmt, ap); + va_end(ap); + + /* Move to new line */ + if (strchr(fmt, '\n') == NULL) + fprintf(stderr, "\n"); +} + +/* +************************************************************ +* The function return the size of an open file +* Param: +* - Filename +* Return: +* - Size of the file +************************************************************ +*/ + +Rs_long getParserFileSize(Rs_string fname) { + FILE* input; + Rs_long flength; + input = fopen(fname, "r"); + if (input == NULL) { + printParserError("%s%s", "Cannot open file: ", fname); + return 0; + } + fseek(input, 0L, SEEK_END); + flength = ftell(input); + fclose(input); + return flength; +} + +/* +************************************************************ +* The function display buffer contents +* Param: +* - Parser to be displayed. +************************************************************ +*/ + +Rs_void displayParser(BufferPointer ptrBuffer) { + printf("\nPrinting input buffer parameters:\n\n"); + printf("The capacity of the buffer is: %d\n", readerGetSize(ptrBuffer)); + printf("The current size of the buffer is: %d\n", readerGetPosWrte(ptrBuffer)); + printf("\nPrinting input buffer contents:\n\n"); + readerRecover(ptrBuffer); + readerPrint(ptrBuffer); +} + +/* +************************************************************ +* The function frees all dynamically allocated memory. +* This function is always called despite how the program terminates - normally or abnormally. +************************************************************ +*/ + +Rs_void callGarbageCollector(Rs_void) { + if (syntaxErrorNumber) + printf("\nSyntax errors: %d\n", syntaxErrorNumber); + printf("\nCollecting garbage...\n"); + readerFree(sourceBuffer); + readerFree(stringLiteralTable); +} diff --git a/code/MainReader.o b/code/MainReader.o index ed09e21..0f7a4ec 100644 Binary files a/code/MainReader.o and b/code/MainReader.o differ diff --git a/code/MainScanner.o b/code/MainScanner.o new file mode 100644 index 0000000..e2ae7fb Binary files /dev/null and b/code/MainScanner.o differ diff --git a/code/Makefile b/code/Makefile index ee47a15..a4aa723 100644 --- a/code/Makefile +++ b/code/Makefile @@ -2,10 +2,10 @@ CC = gcc # Compiler flags -CFLAGS = -Wall -Werror -g +CFLAGS = -Wall -g # Source files -SRCS = Compilers.c MainReader.c Reader.c +SRCS = Compilers.c MainReader.c Reader.c Scanner.c MainScanner.c # Object files OBJS = $(SRCS:.c=.o) diff --git a/code/Parser.c b/code/Parser.c new file mode 100644 index 0000000..48698c9 --- /dev/null +++ b/code/Parser.c @@ -0,0 +1,521 @@ +/* +************************************************************ +* COMPILERS COURSE - Algonquin College +* Code version: Fall, 2023 +* Author: TO_DO +* Professors: Paulo Sousa +************************************************************ +=---------------------------------------= +| COMPILERS - ALGONQUIN COLLEGE (F23) | +=---------------------------------------= +| .... | +| ........::.::::::. | +| .:........::.:^^^~~~: | +| :^^::::::^^^::^!7??7~^. | +| .:^~~^!77777~~7?YY?7??7^. | +| :.^~!??!^::::^^~!?5PY??!~. | +| ~!!7J~.:::^^^^~!!~~?G5J?~ | +| :^~?!~7?Y57^^?PP5YJ!J5Y?: | +| .~!!.:^!7!:.:7JYYJ7~7Y7^ | +| .~77.. . .~^:^^^~7?: | +| .^!^~:::.:^!7?~^~!77J: | +| ^^!Y~^^^^~?YJ77??7JJ^ | +| .^7J?~^~~^~7??7??7JY?~: | +| ::^^~^7?!^~~!7???J?J7~:. | +| ^~~!.^7YPPPP5Y?7J7777~. | +| ..:~..:^!JPP5YJ?!777!^. | +| .~?JJJJJJJJJJYYYYYPPPPPPPPPPPP5PPYY~ | +| :!Y5GGG.___ YYYYYY__._.PPGGGGGG5!. | +| :!Y5G / __| ___ / _(_)__ _ PGP5. | +| :~75 \__ \/ _ \ _| / _` | 5?. | +| 7~7 |___/\___/_| |_\__,_| Y5?. | +| .^~!~.....................P5YY7. | +| .:::::::::::::?JJJJYYYYYYYYYJJJJ7. | +| | +=---------------------------------------= +*/ + +/* +************************************************************ +* File name: Parser.c +* Compiler: MS Visual Studio 2022 +* Course: CST 8152 – Compilers, Lab Section: [011, 012] +* Assignment: A32. +* Date: May 01 2023 +* Purpose: This file contains all functionalities from Parser. +* Function list: (...). +************************************************************ +*/ + +/* TO_DO: Adjust the function header */ + +#ifndef COMPILERS_H_ +#include "Compilers.h" +#endif + +#ifndef PARSER_H_ +#include "Parser.h" +#endif + +/* Parser data */ +extern ParserData psData; /* BNF statistics */ + +/* +************************************************************ + * Process Parser + *********************************************************** + */ +/* TO_DO: This is the function to start the parser - check your program definition */ + +Rs_void startParser() { + /* TO_DO: Initialize Parser data */ + histogramInit(psData.parsHistogram, NUM_BNF_RULES); + + + + Rs_intg i = 0; + for (i = 0; i < NUM_BNF_RULES; i++) { + psData.parsHistogram[i] = 0; + } + /* Proceed parser */ + lookahead = tokenizer(); + if (lookahead.code != SEOF_T) { + program(); + } + matchToken(SEOF_T, NO_ATTR); + printf("%s%s\n", STR_LANGNAME, ": Source file parsed"); +} + + +/* + ************************************************************ + * Match Token + *********************************************************** + */ +/* TO_DO: This is the main code for match - check your definition */ +Rs_void matchToken(Rs_intg tokenCode, Rs_intg tokenAttribute) { + Rs_intg matchFlag = 1; + switch (lookahead.code) { + case KW_T: + if (lookahead.attribute.codeType != tokenAttribute) + matchFlag = 0; + default: + if (lookahead.code != tokenCode) + matchFlag = 0; + } + if (matchFlag && lookahead.code == SEOF_T) + return; + if (matchFlag) { + lookahead = tokenizer(); + if (lookahead.code == ERR_T) { + printError(); + lookahead = tokenizer(); + syntaxErrorNumber++; + } + } + else + syncErrorHandler(tokenCode); +} + +/* + ************************************************************ + * Syncronize Error Handler + *********************************************************** + */ +/* TO_DO: This is the function to handler error - adjust basically datatypes */ +Rs_void syncErrorHandler(Rs_intg syncTokenCode) { + printError(); + syntaxErrorNumber++; + while (lookahead.code != syncTokenCode) { + if (lookahead.code == SEOF_T) + exit(syntaxErrorNumber); + lookahead = tokenizer(); + } + if (lookahead.code != SEOF_T) + lookahead = tokenizer(); +} + +/* + ************************************************************ + * Print Error + *********************************************************** + */ +/* TO_DO: This is the function to error printing - adjust basically datatypes */ +Rs_void printError() { + extern numParserErrors; /* link to number of errors (defined in Parser.h) */ + Token t = lookahead; + printf("%s%s%3d\n", STR_LANGNAME, ": Syntax error: Line:", line); + printf("***** Token code:%3d Attribute: ", t.code); + switch (t.code) { + case ERR_T: + printf("*ERROR*: %s\n", t.attribute.errLexeme); + break; + case SEOF_T: + printf("SEOF_T\t\t%d\t\n", t.attribute.seofType); + break; + case MNID_T: + printf("MNID_T:\t\t%s\t\n", t.attribute.idLexeme); + break; + case STR_T: + printf("STR_T: %s\n", readerGetContent(stringLiteralTable, t.attribute.contentString)); + break; + case KW_T: + printf("KW_T: %s\n", keywordTable[t.attribute.codeType]); + break; + case LPR_T: + printf("LPR_T\n"); + break; + case RPR_T: + printf("RPR_T\n"); + break; + case LBR_T: + printf("LBR_T\n"); + break; + case RBR_T: + printf("RBR_T\n"); + break; + case EOS_T: + printf("NA\n"); + break; + case CMT_T: + printf("CMT_T\n"); + break; + case ADD_T: + printf("ADD_T\n"); + break; + case SUB_T: + printf("SUB_T\n"); + break; + case MUL_T: + printf("MUL_T\n"); + break; + case DIV_T: + printf("DIV_T\n"); + break; + case EQ_T: + printf("EQ_T\n"); + break; + case NE_T: + printf("NE_T\n"); + break; + case GT_T: + printf("GT_T\n"); + break; + case LT_T: + printf("LT_T\n"); + break; + case AND_T: + printf("AND_T\n"); + break; + case OR_T: + printf("OR_T\n"); + break; + case NOT_T: + printf("NOT_T\n"); + break; + case INL_T: + printf("INL_T\n"); + break; + case ID_T: + printf("ID_T: %s\n", t.attribute.idLexeme); + break; + case FLT_T: + printf("FLT_T: %f\n", t.attribute.floatValue); + break; + case INT_T: + printf("INT_T: %d\n", t.attribute.intValue); + break; + case NUM_T: + printf("NUM_T: %d\n", t.attribute.intValue); + break; + case CMA_T: + printf("CMA_T\n"); + break; + case POW_T: + printf("POW_T\n"); + break; + case MOD_T: + printf("MOD_T\n"); + break; + case SBL_T: + printf("SBL_T\n"); + break; + case SBR_T: + printf("SBR_T\n"); + break; + case GE_T: + printf("GE_T\n"); + break; + case LE_T: + printf("LE_T\n"); + break; + case INC_T: + printf("INC_T\n"); + break; + case DEC_T: + printf("DEC_T\n"); + break; + default: + printf("%s%s%d\n", STR_LANGNAME, ": Scanner error: invalid token code: ", t.code); + numParserErrors++; // Updated parser error + } +} + +/* + ************************************************************ + * Program statement + * BNF: -> main& { } + * FIRST()= {CMT_T, MNID_T (main&), SEOF_T}. + *********************************************************** + */ +Rs_void program() { + /* Update program statistics */ + psData.parsHistogram[BNF_program]++; + /* Program code */ + switch (lookahead.code) { + case CMT_T: + comment(); + case MNID_T: + if (strncmp(lookahead.attribute.idLexeme, LANG_MAIN, 5) == 0) { + matchToken(MNID_T, NO_ATTR); + matchToken(LBR_T, NO_ATTR); + // dataSession(); + // codeSession(); + matchToken(RBR_T, NO_ATTR); + break; + } + else { + printError(); + } + case SEOF_T: + ; // Empty + break; + default: + printError(); + } + printf("%s%s\n", STR_LANGNAME, ": Program parsed"); +} + +/* + ************************************************************ + * comment + * BNF: comment + * FIRST()= {CMT_T}. + *********************************************************** + */ +Rs_void comment() { + psData.parsHistogram[BNF_comment]++; + matchToken(CMT_T, NO_ATTR); + printf("%s%s\n", STR_LANGNAME, ": Comment parsed"); +} + +/* + ************************************************************ + * dataSession + * BNF: -> data { } + * FIRST()= {KW_T (KW_data)}. + *********************************************************** + */ +Rs_void dataSession() { + psData.parsHistogram[BNF_dataSession]++; + switch (lookahead.code) { + case CMT_T: + comment(); + default: + matchToken(KW_T, NO_ATTR); //was KW_data + matchToken(LBR_T, NO_ATTR); + optVarListDeclarations(); + matchToken(RBR_T, NO_ATTR); + printf("%s%s\n", STR_LANGNAME, ": Data Session parsed"); + } +} + +/* + ************************************************************ + * Optional Var List Declarations + * BNF: -> | e + * FIRST() = { e, KW_T (KW_int), KW_T (KW_real), KW_T (KW_string)}. + *********************************************************** + */ +Rs_void optVarListDeclarations() { + psData.parsHistogram[BNF_optVarListDeclarations]++; + switch (lookahead.code) { + default: + ; // Empty + } + printf("%s%s\n", STR_LANGNAME, ": Optional Variable List Declarations parsed"); +} + +/* + ************************************************************ + * codeSession statement + * BNF: -> code { } + * FIRST()= {KW_T (KW_code)}. + *********************************************************** + */ +Rs_void codeSession() { + psData.parsHistogram[BNF_codeSession]++; + switch (lookahead.code) { + case CMT_T: + comment(); + default: + matchToken(KW_T, NO_ATTR);// was KW_code + matchToken(LBR_T, NO_ATTR); + optionalStatements(); + matchToken(RBR_T, NO_ATTR); + printf("%s%s\n", STR_LANGNAME, ": Code Session parsed"); + } +} + +/* TO_DO: Continue the development (all non-terminal functions) */ + +/* + ************************************************************ + * Optional statement + * BNF: -> | ϵ + * FIRST() = { ϵ , IVID_T, FVID_T, SVID_T, KW_T(KW_if), + * KW_T(KW_while), MNID_T(print&), MNID_T(input&) } + *********************************************************** + */ +Rs_void optionalStatements() { + psData.parsHistogram[BNF_optionalStatements]++; + switch (lookahead.code) { + case CMT_T: + comment(); + case MNID_T: + if ((strncmp(lookahead.attribute.idLexeme, LANG_WRTE, 6) == 0) || + (strncmp(lookahead.attribute.idLexeme, LANG_READ, 6) == 0)) { + statements(); + break; + } + default: + ; // Empty + } + printf("%s%s\n", STR_LANGNAME, ": Optional statements parsed"); +} + +/* + ************************************************************ + * Statements + * BNF: -> + * FIRST() = { IVID_T, FVID_T, SVID_T, KW_T(KW_if), + * KW_T(KW_while), MNID_T(input&), MNID_T(print&) } + *********************************************************** + */ +Rs_void statements() { + psData.parsHistogram[BNF_statements]++; + statement(); + statementsPrime(); + printf("%s%s\n", STR_LANGNAME, ": Statements parsed"); +} + +/* + ************************************************************ + * Statements Prime + * BNF: -> | ϵ + * FIRST() = { ϵ , IVID_T, FVID_T, SVID_T, + * KW_T(KW_if), KW_T(KW_while), MNID_T(input&), MNID_T(print&) } + *********************************************************** + */ +Rs_void statementsPrime() { + psData.parsHistogram[BNF_statementsPrime]++; + switch (lookahead.code) { + case MNID_T: + if (strncmp(lookahead.attribute.idLexeme, LANG_WRTE, 6) == 0) { + statements(); + break; + } + default: + ; //empty string + } +} + +/* + ************************************************************ + * Single statement + * BNF: -> | | + * | | + * FIRST() = { IVID_T, FVID_T, SVID_T, KW_T(KW_if), KW_T(KW_while), + * MNID_T(input&), MNID_T(print&) } + *********************************************************** + */ +Rs_void statement() { + psData.parsHistogram[BNF_statement]++; + switch (lookahead.code) { + case KW_T: + switch (lookahead.attribute.codeType) { + default: + printError(); + } + break; + case MNID_T: + if (strncmp(lookahead.attribute.idLexeme, LANG_WRTE, 6) == 0) { + outputStatement(); + } + break; + default: + printError(); + } + printf("%s%s\n", STR_LANGNAME, ": Statement parsed"); +} + +/* + ************************************************************ + * Output Statement + * BNF: -> print& (); + * FIRST() = { MNID_T(print&) } + *********************************************************** + */ +Rs_void outputStatement() { + psData.parsHistogram[BNF_outputStatement]++; + matchToken(MNID_T, NO_ATTR); + matchToken(LPR_T, NO_ATTR); + outputVariableList(); + matchToken(RPR_T, NO_ATTR); + matchToken(EOS_T, NO_ATTR); + printf("%s%s\n", STR_LANGNAME, ": Output statement parsed"); +} + +/* + ************************************************************ + * Output Variable List + * BNF: -> | ϵ + * FIRST() = { IVID_T, FVID_T, SVID_T, ϵ } + *********************************************************** + */ +Rs_void outputVariableList() { + psData.parsHistogram[BNF_outputVariableList]++; + switch (lookahead.code) { + case STR_T: + matchToken(STR_T, NO_ATTR); + break; + default: + ; + } + printf("%s%s\n", STR_LANGNAME, ": Output variable list parsed"); +} + +/* + ************************************************************ + * The function prints statistics of BNF rules + * Param: + * - Parser data + * Return: + * - Void (procedure) + *********************************************************** + */ +/* +Rs_void printBNFData(ParserData psData) { +} +*/ +Rs_void printBNFData(ParserData psData) { + /* Print Parser statistics */ + printf("Statistics:\n"); + printf("----------------------------------\n"); + int cont = 0; + for (cont = 0; cont < NUM_BNF_RULES; cont++) { + if (psData.parsHistogram[cont] > 0) + printf("%s%s%s%d%s", "Token[", BNFStrTable[cont], "]=", psData.parsHistogram[cont], "\n"); + } + printf("----------------------------------\n"); +} diff --git a/code/Parser.h b/code/Parser.h new file mode 100644 index 0000000..b0dfb3b --- /dev/null +++ b/code/Parser.h @@ -0,0 +1,178 @@ +/* +************************************************************ +* COMPILERS COURSE - Algonquin College +* Code version: Fall, 2023 +* Author: TO_DO +* Professors: Paulo Sousa +************************************************************ +=---------------------------------------= +| COMPILERS - ALGONQUIN COLLEGE (F23) | +=---------------------------------------= +| .... | +| ........::.::::::. | +| .:........::.:^^^~~~: | +| :^^::::::^^^::^!7??7~^. | +| .:^~~^!77777~~7?YY?7??7^. | +| :.^~!??!^::::^^~!?5PY??!~. | +| ~!!7J~.:::^^^^~!!~~?G5J?~ | +| :^~?!~7?Y57^^?PP5YJ!J5Y?: | +| .~!!.:^!7!:.:7JYYJ7~7Y7^ | +| .~77.. . .~^:^^^~7?: | +| .^!^~:::.:^!7?~^~!77J: | +| ^^!Y~^^^^~?YJ77??7JJ^ | +| .^7J?~^~~^~7??7??7JY?~: | +| ::^^~^7?!^~~!7???J?J7~:. | +| ^~~!.^7YPPPP5Y?7J7777~. | +| ..:~..:^!JPP5YJ?!777!^. | +| .~?JJJJJJJJJJYYYYYPPPPPPPPPPPP5PPYY~ | +| :!Y5GGG.___ YYYYYY__._.PPGGGGGG5!. | +| :!Y5G / __| ___ / _(_)__ _ PGP5. | +| :~75 \__ \/ _ \ _| / _` | 5?. | +| 7~7 |___/\___/_| |_\__,_| Y5?. | +| .^~!~.....................P5YY7. | +| .:::::::::::::?JJJJYYYYYYYYYJJJJ7. | +| | +=---------------------------------------= +*/ + +/* +************************************************************ +* File name: Parser.h +* Compiler: MS Visual Studio 2022 +* Course: CST 8152 � Compilers, Lab Section: [011, 012] +* Assignment: A32. +* Date: May 01 2023 +* Professor: Paulo Sousa +* Purpose: This file is the main header for Parser (.h) +************************************************************ +*/ + +#ifndef PARSER_H_ +#define PARSER_H_ + +/* Inclusion section */ +#include +#include +#include +#include + +#ifndef COMPILERS_H_ +#include "Compilers.h" +#endif +#ifndef READER_H_ +#include "Reader.h" +#endif +#ifndef SCANNER_H_ +#include "Scanner.h" +#endif + +/* Global vars */ +static Token lookahead; +extern BufferPointer stringLiteralTable; +extern Rs_intg line; +extern Token tokenizer(Rs_void); +extern Rs_string keywordTable[KWT_SIZE]; +static Rs_intg syntaxErrorNumber = 0; + +#define LANG_WRTE "print&" +#define LANG_READ "input&" +#define LANG_MAIN "main&" + +/* TO_DO: Create ALL constants for keywords (sequence given in table.h) */ + +/* Constants */ +enum KEYWORDS { + NO_ATTR = -1, + KW_const, + KW_array, + KW_int, + KW_float, + KW_string, + KW_if, + KW_then, + KW_else, + KW_while, + KW_do, + KW_return, + KW_function, + KW_add, + KW_sub, + KW_mul, + KW_div, + KW_and, + KW_or, + KW_not, + KW_true, + KW_false, + KW_sqrt + +}; + +/* TO_DO: Define the number of BNF rules */ +#define NUM_BNF_RULES 12 + +/* Parser */ +typedef struct parserData { + Rs_intg parsHistogram[NUM_BNF_RULES]; /* Number of BNF Statements */ +} ParserData, * pParsData; + +/* Number of errors */ +Rs_intg numParserErrors; + +/* Scanner data */ +ParserData psData; + +/* Function definitions */ +Rs_void startParser(); +Rs_void matchToken(Rs_intg, Rs_intg); +Rs_void syncErrorHandler(Rs_intg); +Rs_void printError(); +Rs_void printBNFData(ParserData psData); + +/* List of BNF statements */ +enum BNF_RULES { + BNF_error, /* 0: Error token */ + BNF_codeSession, /* 1 */ + BNF_comment, /* 2 */ + BNF_dataSession, /* 3 */ + BNF_optVarListDeclarations, /* 4 */ + BNF_optionalStatements, /* 5 */ + BNF_outputStatement, /* 6 */ + BNF_outputVariableList, /* 7 */ + BNF_program, /* 8 */ + BNF_statement, /* 9 */ + BNF_statements, /* 10 */ + BNF_statementsPrime /* 11 */ +}; + + +/* TO_DO: Define the list of keywords */ +static Rs_string BNFStrTable[NUM_BNF_RULES] = { + "BNF_error", + "BNF_codeSession", + "BNF_comment", + "BNF_dataSession", + "BNF_optVarListDeclarations", + "BNF_optionalStatements", + "BNF_outputStatement", + "BNF_outputVariableList", + "BNF_program", + "BNF_statement", + "BNF_statements", + "BNF_statementsPrime" +}; + +/* TO_DO: Place ALL non-terminal function declarations */ +Rs_void codeSession(); +Rs_void comment(); +Rs_void dataSession(); +Rs_void optVarListDeclarations(); +Rs_void optionalStatements(); +Rs_void outputStatement(); +Rs_void outputVariableList(); +Rs_void program(); +Rs_void statement(); +Rs_void statements(); +Rs_void statementsPrime(); + +#endif diff --git a/code/Reader.o b/code/Reader.o index d9d89eb..cc4e946 100644 Binary files a/code/Reader.o and b/code/Reader.o differ diff --git a/code/Scanner.c b/code/Scanner.c index 04c25cd..24c83e5 100644 --- a/code/Scanner.c +++ b/code/Scanner.c @@ -201,17 +201,39 @@ Token tokenizer(Rs_void) { scData.scanHistogram[currentToken.code]++; return currentToken; case '+': + c = readerGetChar(sourceBuffer); + if (c == '+') { + currentToken.code = INC_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; + } else { currentToken.code = ADD_T; scData.scanHistogram[currentToken.code]++; return currentToken; + } case '-': + c = readerGetChar(sourceBuffer); + if (c == '-') { + currentToken.code = DEC_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; + } else { currentToken.code = SUB_T; scData.scanHistogram[currentToken.code]++; return currentToken; + } case '*': currentToken.code = MUL_T; scData.scanHistogram[currentToken.code]++; return currentToken; + case '[': + currentToken.code = SBL_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; + case ']': + currentToken.code = SBR_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; case '/': c = readerGetChar(sourceBuffer); if (c == '/') { @@ -258,14 +280,36 @@ Token tokenizer(Rs_void) { scData.scanHistogram[currentToken.code]++; return currentToken; } + case '^': + currentToken.code = POW_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; + case '%': + currentToken.code = MOD_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; case '>': + c = readerGetChar(sourceBuffer); + if (c == '=') { + currentToken.code = GE_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; + } else { currentToken.code = GT_T; scData.scanHistogram[currentToken.code]++; return currentToken; + } case '<': + c = readerGetChar(sourceBuffer); + if (c == '=') { + currentToken.code = LE_T; + scData.scanHistogram[currentToken.code]++; + return currentToken; + } else { currentToken.code = LT_T; scData.scanHistogram[currentToken.code]++; return currentToken; + } case '&': c = readerGetChar(sourceBuffer); if (c == '&') { @@ -346,7 +390,7 @@ Token tokenizer(Rs_void) { currentToken.code = FLT_T; currentToken.attribute.floatValue = atof(readerGetContent(lexemeBuffer, 0)); } else { - currentToken.code = INT_T; + currentToken.code = INL_T; currentToken.attribute.intValue = atoi(readerGetContent(lexemeBuffer, 0)); } @@ -410,7 +454,7 @@ Token tokenizer(Rs_void) { */ /* TO_DO: Just change the datatypes */ -Rs_intg nextState(Rs_intg state, Rs_char c) { +Rs_intg nextState(Rs_intg state, Rs_char c){ Rs_intg col; Rs_intg next; col = nextClass(c); @@ -447,8 +491,6 @@ Rs_intg nextClass(Rs_char c) { val = 0; else if (isdigit(c)) val = 1; - //else if (c == '.') - //val = 1; else { switch (c) { case '.': @@ -550,8 +592,6 @@ Token funcIL(Rs_string lexeme) { return currentToken; } - - /* ************************************************************ * Acceptance State Function ID @@ -582,47 +622,8 @@ Token funcID(Rs_string lexeme) { // Test if the lexeme is a keyword lexeme[length - 1] = '\0'; currentToken = funcKEY(lexeme); - if (currentToken.code == ERR_T) { - // If not a keyword, check if it is a number - Rs_intg intValue; - Rs_float floatValue; - char* endPtr; - - // Check for integer - intValue = strtol(lexeme, &endPtr, 10); - if (*endPtr == '\0') { - currentToken.code = INT_T; - scData.scanHistogram[currentToken.code]++; - currentToken.attribute.intValue = intValue; - } else { - // Check for float - floatValue = strtof(lexeme, &endPtr); - if (*endPtr == '\0') { - currentToken.code = FLT_T; - scData.scanHistogram[currentToken.code]++; - currentToken.attribute.floatValue = floatValue; - } else { - // If not a number, treat it as an identifier - currentToken.code = ID_T; - scData.scanHistogram[currentToken.code]++; - strncpy(currentToken.attribute.idLexeme, lexeme, VID_LEN); - currentToken.attribute.idLexeme[VID_LEN] = CHARSEOF0; - isID = TRUE; - } - } - - } else { - // It's a keyword - scData.scanHistogram[currentToken.code]++; - } - break; - } - - if (isID == TRUE) { - strncpy(currentToken.attribute.idLexeme, lexeme, VID_LEN); - currentToken.attribute.idLexeme[VID_LEN] = CHARSEOF0; - } - + } + return currentToken; } @@ -688,7 +689,7 @@ Token funcSL(Rs_string lexeme) { Token funcKEY(Rs_string lexeme) { Token currentToken = { 0 }; - Rs_intg kwindex = -1, j = 0; + Rs_intg kwindex = -1; Rs_intg len = (Rs_intg)strlen(lexeme); // Ensure the lexeme is null-terminated properly @@ -698,7 +699,7 @@ Token funcKEY(Rs_string lexeme) { // lexeme[len - 1] = '\0'; // Search for the keyword in the keyword table - for (j = 0; j < KWT_SIZE; j++) { + for (int j = 0; j < KWT_SIZE; j++) { if (!strcmp(lexeme, keywordTable[j])) { kwindex = j; break; @@ -708,7 +709,7 @@ Token funcKEY(Rs_string lexeme) { if (kwindex != -1) { // Keyword found currentToken.code = KW_T; - scData.scanHistogram[currentToken.code]++; + //scData.scanHistogram[currentToken.code]++; currentToken.attribute.codeType = kwindex; } else if (isIdentifier(lexeme)) { // Lexeme is an identifier @@ -867,6 +868,30 @@ Rs_void printToken(Token t) { case CMA_T: printf("CMA_T\n"); break; + case POW_T: + printf("POW_T\n"); + break; + case MOD_T: + printf("MOD_T\n"); + break; + case SBL_T: + printf("SBL_T\n"); + break; + case SBR_T: + printf("SBR_T\n"); + break; + case GE_T: + printf("GE_T\n"); + break; + case LE_T: + printf("LE_T\n"); + break; + case INC_T: + printf("INC_T\n"); + break; + case DEC_T: + printf("DEC_T\n"); + break; default: printf("Scanner error: invalid token code: %d\n", t.code); } diff --git a/code/Scanner.h b/code/Scanner.h index 29eff04..1a8fe66 100644 --- a/code/Scanner.h +++ b/code/Scanner.h @@ -69,7 +69,7 @@ #define RTE_CODE 1 /* Value for run-time error */ /* TO_DO: Define the number of tokens */ -#define NUM_TOKENS 30 +#define NUM_TOKENS 37 /* TO_DO: Define Token codes - Create your token classes */ enum TOKENS { @@ -101,7 +101,15 @@ enum TOKENS { INT_T, /* 26: Integer token */ FLT_T, /* 27: Float token */ NUM_T, /* 28: Number token */ - CMA_T /* 29: Comma token */ + CMA_T, /* 29: Comma token */ + SBL_T, /* 30: Square bracket left token */ + SBR_T, /* 31: Square bracket right token */ + POW_T, /* 31: Power operator token */ + MOD_T, /* 32: Modulus operator token */ + GE_T, /* 33: Greater or equal operator token */ + LE_T, /* 34: Less or equal operator token */ + INC_T, + DEC_T }; /* TO_DO: Define the list of keywords */ @@ -134,11 +142,19 @@ static Rs_string tokenStrTable[NUM_TOKENS] = { "INT_T", "FLT_T", "NUM_T", - "CMA_T" + "CMA_T", + "SBL_T", + "SBR_T", + "POW_T", + "MOD_T", + "GE_T", + "LE_T", + "INC_T", + "DEC_T" }; /* TO_DO: Operators token attributes */ -typedef enum ArithmeticOperators { OP_ADD, OP_SUB, OP_MUL, OP_DIV } AriOperator; +typedef enum ArithmeticOperators { OP_ADD, OP_SUB, OP_MUL, OP_DIV,OP_POW, OP_MOD } AriOperator; typedef enum RelationalOperators { OP_EQ, OP_NE, OP_GT, OP_LT } RelOperator; typedef enum LogicalOperators { OP_AND, OP_OR, OP_NOT } LogOperator; typedef enum SourceEndOfFile { SEOF_0, SEOF_255 } EofOperator; @@ -319,8 +335,8 @@ Language keywords #define KWT_SIZE 22 static Rs_string keywordTable[KWT_SIZE] = { - "data", /* KW00 */ - "code", /* KW01 */ + "const", /* KW00 */ + "array", /* KW01 */ "int", /* KW02 */ "float", /* KW03 */ "string", /* KW04 */ diff --git a/code/Scanner.o b/code/Scanner.o new file mode 100644 index 0000000..df493fc Binary files /dev/null and b/code/Scanner.o differ diff --git a/code/launch.vs.json b/code/launch.vs.json index e309f99..2bbec35 100644 --- a/code/launch.vs.json +++ b/code/launch.vs.json @@ -6,16 +6,8 @@ "projectTarget": "Compiler.exe", "name": "Compiler.exe", "args": [ - "s", - "C:/Mac/Home/Downloads/RuanScript/input/INPUT2_Volume.rs", - //"C:/Mac/Home/Downloads/RuanScript/input/INPUT1_Hello.rs" - //"C:/Mac/Home/Downloads/RuanScript/input/INPUT_Linear.rs" - //"C:/Mac/Home/Downloads/RuanScript/input/INPUT3_Factorial.rs" - //"C:/Mac/Home/Downloads/RuanScript/input/INPUT5_General.rs" - //"C:/Mac/Home/Downloads/RuanScript/input/INPUT_Pytha.rs" - //"C:/Mac/Home/Downloads/RuanScript/input/INPUT_Quad.rs" - - + "p", + "C:/Mac/Home/Downloads/RuanScript/input/INPUT2_Volume.rs" ] } ], diff --git a/code/my_program b/code/my_program index 53bfa9d..8365bf3 100755 Binary files a/code/my_program and b/code/my_program differ diff --git a/code/out/.DS_Store b/code/out/.DS_Store index 4b998dc..1dd363d 100644 Binary files a/code/out/.DS_Store and b/code/out/.DS_Store differ diff --git a/code/out/build/x64-Debug/.cmake/api/v1/reply/codemodel-v2-90ea3ae42aac46d65768.json b/code/out/build/x64-Debug/.cmake/api/v1/reply/codemodel-v2-e555056978caaeca0c88.json similarity index 87% rename from code/out/build/x64-Debug/.cmake/api/v1/reply/codemodel-v2-90ea3ae42aac46d65768.json rename to code/out/build/x64-Debug/.cmake/api/v1/reply/codemodel-v2-e555056978caaeca0c88.json index 9955aa7..547ac6a 100644 --- a/code/out/build/x64-Debug/.cmake/api/v1/reply/codemodel-v2-90ea3ae42aac46d65768.json +++ b/code/out/build/x64-Debug/.cmake/api/v1/reply/codemodel-v2-e555056978caaeca0c88.json @@ -39,7 +39,7 @@ { "directoryIndex" : 0, "id" : "Compiler::@6890427a1f51a3e7e1df", - "jsonFile" : "target-Compiler-Debug-f156b2e44941a220383e.json", + "jsonFile" : "target-Compiler-Debug-0440dda4bc7a25a25784.json", "name" : "Compiler", "projectIndex" : 0 } diff --git a/code/out/build/x64-Debug/.cmake/api/v1/reply/index-2024-07-19T23-26-33-0878.json b/code/out/build/x64-Debug/.cmake/api/v1/reply/index-2024-07-30T17-10-04-0519.json similarity index 90% rename from code/out/build/x64-Debug/.cmake/api/v1/reply/index-2024-07-19T23-26-33-0878.json rename to code/out/build/x64-Debug/.cmake/api/v1/reply/index-2024-07-30T17-10-04-0519.json index 0f35cc1..fc61c16 100644 --- a/code/out/build/x64-Debug/.cmake/api/v1/reply/index-2024-07-19T23-26-33-0878.json +++ b/code/out/build/x64-Debug/.cmake/api/v1/reply/index-2024-07-30T17-10-04-0519.json @@ -26,7 +26,7 @@ "objects" : [ { - "jsonFile" : "codemodel-v2-90ea3ae42aac46d65768.json", + "jsonFile" : "codemodel-v2-e555056978caaeca0c88.json", "kind" : "codemodel", "version" : { @@ -108,7 +108,7 @@ } }, { - "jsonFile" : "codemodel-v2-90ea3ae42aac46d65768.json", + "jsonFile" : "codemodel-v2-e555056978caaeca0c88.json", "kind" : "codemodel", "version" : { diff --git a/code/out/build/x64-Debug/.cmake/api/v1/reply/target-Compiler-Debug-f156b2e44941a220383e.json b/code/out/build/x64-Debug/.cmake/api/v1/reply/target-Compiler-Debug-0440dda4bc7a25a25784.json similarity index 80% rename from code/out/build/x64-Debug/.cmake/api/v1/reply/target-Compiler-Debug-f156b2e44941a220383e.json rename to code/out/build/x64-Debug/.cmake/api/v1/reply/target-Compiler-Debug-0440dda4bc7a25a25784.json index 71d1832..149b9c5 100644 --- a/code/out/build/x64-Debug/.cmake/api/v1/reply/target-Compiler-Debug-f156b2e44941a220383e.json +++ b/code/out/build/x64-Debug/.cmake/api/v1/reply/target-Compiler-Debug-0440dda4bc7a25a25784.json @@ -48,7 +48,9 @@ 3, 4, 5, - 6 + 6, + 8, + 9 ] } ], @@ -87,7 +89,8 @@ [ 0, 2, - 7 + 7, + 10 ] }, { @@ -98,7 +101,9 @@ 3, 4, 5, - 6 + 6, + 8, + 9 ] } ], @@ -148,6 +153,23 @@ "backtrace" : 1, "path" : "Scanner.h", "sourceGroupIndex" : 0 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "MainParser.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "compileGroupIndex" : 0, + "path" : "Parser.c", + "sourceGroupIndex" : 1 + }, + { + "backtrace" : 1, + "path" : "Parser.h", + "sourceGroupIndex" : 0 } ], "type" : "EXECUTABLE" diff --git a/code/out/build/x64-Debug/.ninja_deps b/code/out/build/x64-Debug/.ninja_deps index 6255070..d5d1cc5 100644 Binary files a/code/out/build/x64-Debug/.ninja_deps and b/code/out/build/x64-Debug/.ninja_deps differ diff --git a/code/out/build/x64-Debug/.ninja_log b/code/out/build/x64-Debug/.ninja_log index ee7e206..2495166 100644 --- a/code/out/build/x64-Debug/.ninja_log +++ b/code/out/build/x64-Debug/.ninja_log @@ -1,44 +1,73 @@ # ninja log v5 -25 210 7431084809957532 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 -43 214 7431084810063657 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda -24 172 7431116982257120 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -33 206 7431084809956682 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 -50 278 7431084810642954 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -175 495 7431116984802094 Compiler.exe 50ec252a81c8dc23 -20 55 0 clean 3807ae1e948da024 -18 997 7431354851821209 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -1001 1425 7431354855261025 Compiler.exe 50ec252a81c8dc23 -20 460 7431362339984697 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -30 464 7431362340011333 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -465 816 7431362342838171 Compiler.exe 50ec252a81c8dc23 -17 189 7431363530619303 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -192 549 7431363533626195 Compiler.exe 50ec252a81c8dc23 -23 460 7431371929499085 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -34 472 7431371929596360 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -473 858 7431371932632478 Compiler.exe 50ec252a81c8dc23 -23 1140 7431382286194721 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -33 1148 7431382286301666 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -17 166 7431383066730494 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -17 160 7431384349290787 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -164 513 7431384351998107 Compiler.exe 50ec252a81c8dc23 -16 161 7431386389030470 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -164 520 7431386391945228 Compiler.exe 50ec252a81c8dc23 -20 194 7431386535737730 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -197 552 7431386538668654 Compiler.exe 50ec252a81c8dc23 -15 48 0 clean 3807ae1e948da024 -15 168 7431388256798351 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 -28 182 7431388256952780 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda -22 193 7431388257062844 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 -34 195 7431388257042794 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -43 223 7431388257395555 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -224 618 7431388260376350 Compiler.exe 50ec252a81c8dc23 -23 800 7431398797180332 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -33 806 7431398797226099 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -807 1356 7431398802176962 Compiler.exe 50ec252a81c8dc23 -18 60 0 clean 3807ae1e948da024 -27 215 7431401764307221 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 -20 221 7431401764366150 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 -49 226 7431401764469284 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b -42 236 7431401764575903 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 -33 240 7431401764626713 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda -241 630 7431401767681309 Compiler.exe 50ec252a81c8dc23 +24 498 7440624591859307 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 +43 566 7440624592581290 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda +33 515 7440624592005470 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 +56 525 7440624592156954 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b +50 527 7440624592192741 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 +159 542 7437010150580298 Compiler.exe 50ec252a81c8dc23 +18 55 0 clean 3807ae1e948da024 +15 351 7440626044307785 build.ninja 10add4a6052b72f8 +15 182 7440626047063888 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +21 187 7440626047056670 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +189 576 7440626050029985 Compiler.exe 38da5d0f4370f39e +25 182 7440631440508714 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +19 170 7440632662970942 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +173 521 7440632665801060 Compiler.exe 38da5d0f4370f39e +23 170 7440634326067775 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +172 546 7440634329205049 Compiler.exe 38da5d0f4370f39e +23 181 7440636294965848 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +185 541 7440636297962130 Compiler.exe 38da5d0f4370f39e +16 53 0 clean 3807ae1e948da024 +39 228 7440636725359231 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda +30 242 7440636725403338 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 +47 249 7440636725587819 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 +21 270 7440636725776931 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 +63 298 7440636726059100 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +56 332 7440636726393452 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b +232 404 7440636727105202 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +408 820 7440636730359150 Compiler.exe 38da5d0f4370f39e +24 197 7440636981937639 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +202 591 7440636985077388 Compiler.exe 38da5d0f4370f39e +34 470 7440645643028233 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +16 47 0 clean 3807ae1e948da024 +14 198 7440646578666991 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 +20 207 7440646578564206 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 +45 221 7440646578813732 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +26 225 7440646578857534 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda +32 273 7440646579330680 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 +201 359 7440646580271166 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +24 171 7440653160558930 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +32 183 7440654114867267 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +14 40 0 clean 3807ae1e948da024 +17 205 7440654219477151 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 +24 218 7440654219520341 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 +29 234 7440654219758940 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda +50 236 7440654219757700 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +35 239 7440654219827560 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 +211 363 7440654221117339 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +21 165 7440654535136760 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +11 42 0 clean 3807ae1e948da024 +16 235 7440654611720512 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 +23 301 7440654611991915 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 +29 331 7440654612699807 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda +60 342 7440654612792284 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +34 349 7440654612914109 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 +239 433 7440654613810357 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +25 158 7440654846153569 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +27 193 7440655033073994 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +25 166 7440655836308505 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +24 155 7440656053752752 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +12 39 0 clean 3807ae1e948da024 +24 214 7440656239244279 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945 +16 225 7440656239464995 CMakeFiles/Compiler.dir/Compilers.c.obj 415acfa213439be1 +32 239 7440656239679536 CMakeFiles/Compiler.dir/MainReader.c.obj a8187c3450edeeda +38 302 7440656240364497 CMakeFiles/Compiler.dir/MainScanner.c.obj f70b8cd612a82135 +51 311 7440656240469832 CMakeFiles/Compiler.dir/MainParser.c.obj 7497f4a527769761 +217 422 7440656241596551 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +26 160 7440656939691275 CMakeFiles/Compiler.dir/Parser.c.obj d1d619ace1bae726 +19 173 7440656939811085 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b +174 582 7440656943013211 Compiler.exe 38da5d0f4370f39e +18 166 7440657231822817 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b +170 490 7440657234432389 Compiler.exe 38da5d0f4370f39e +23 204 7440657614983540 CMakeFiles/Compiler.dir/Scanner.c.obj e86ee7364d008e9b +207 602 7440657617834103 Compiler.exe 38da5d0f4370f39e diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Compilers.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Compilers.c.obj index e598f3a..2dfdbaf 100644 Binary files a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Compilers.c.obj and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Compilers.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainParser.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainParser.c.obj new file mode 100644 index 0000000..863b041 Binary files /dev/null and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainParser.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainReader.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainReader.c.obj index ab1e030..250b473 100644 Binary files a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainReader.c.obj and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainReader.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainScanner.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainScanner.c.obj index d57b39b..1198204 100644 Binary files a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainScanner.c.obj and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/MainScanner.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Parser.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Parser.c.obj new file mode 100644 index 0000000..ecc8793 Binary files /dev/null and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Parser.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Reader.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Reader.c.obj index be19422..d6fe370 100644 Binary files a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Reader.c.obj and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Reader.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Scanner.c.obj b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Scanner.c.obj index 982fba3..5dfcd25 100644 Binary files a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Scanner.c.obj and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Scanner.c.obj differ diff --git a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/vc140.pdb b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/vc140.pdb index 1391a1c..8e0cba9 100644 Binary files a/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/vc140.pdb and b/code/out/build/x64-Debug/CMakeFiles/Compiler.dir/vc140.pdb differ diff --git a/code/out/build/x64-Debug/Compiler.exe b/code/out/build/x64-Debug/Compiler.exe index 3503416..ae0d8e2 100644 Binary files a/code/out/build/x64-Debug/Compiler.exe and b/code/out/build/x64-Debug/Compiler.exe differ diff --git a/code/out/build/x64-Debug/Compiler.ilk b/code/out/build/x64-Debug/Compiler.ilk index bf38caa..fa65c07 100644 Binary files a/code/out/build/x64-Debug/Compiler.ilk and b/code/out/build/x64-Debug/Compiler.ilk differ diff --git a/code/out/build/x64-Debug/Compiler.pdb b/code/out/build/x64-Debug/Compiler.pdb index e1d5c81..264f96f 100644 Binary files a/code/out/build/x64-Debug/Compiler.pdb and b/code/out/build/x64-Debug/Compiler.pdb differ diff --git a/code/out/build/x64-Debug/Testing/Temporary/LastTest.log b/code/out/build/x64-Debug/Testing/Temporary/LastTest.log index c7f727a..68a2a83 100644 --- a/code/out/build/x64-Debug/Testing/Temporary/LastTest.log +++ b/code/out/build/x64-Debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Jul 19 19:26 Eastern Daylight Time +Start testing: Jul 30 13:04 Eastern Daylight Time ---------------------------------------------------------- -End testing: Jul 19 19:26 Eastern Daylight Time +End testing: Jul 30 13:04 Eastern Daylight Time diff --git a/code/out/build/x64-Debug/build.ninja b/code/out/build/x64-Debug/build.ninja index cd05aee..9beec0d 100644 --- a/code/out/build/x64-Debug/build.ninja +++ b/code/out/build/x64-Debug/build.ninja @@ -84,6 +84,20 @@ build CMakeFiles\Compiler.dir\Scanner.c.obj: C_COMPILER__Compiler_unscanned_Debu TARGET_COMPILE_PDB = CMakeFiles\Compiler.dir\ TARGET_PDB = Compiler.pdb +build CMakeFiles\Compiler.dir\MainParser.c.obj: C_COMPILER__Compiler_unscanned_Debug C$:\Mac\Home\Downloads\RuanScript\code\MainParser.c || cmake_object_order_depends_target_Compiler + FLAGS = /DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1 + OBJECT_DIR = CMakeFiles\Compiler.dir + OBJECT_FILE_DIR = CMakeFiles\Compiler.dir + TARGET_COMPILE_PDB = CMakeFiles\Compiler.dir\ + TARGET_PDB = Compiler.pdb + +build CMakeFiles\Compiler.dir\Parser.c.obj: C_COMPILER__Compiler_unscanned_Debug C$:\Mac\Home\Downloads\RuanScript\code\Parser.c || cmake_object_order_depends_target_Compiler + FLAGS = /DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1 + OBJECT_DIR = CMakeFiles\Compiler.dir + OBJECT_FILE_DIR = CMakeFiles\Compiler.dir + TARGET_COMPILE_PDB = CMakeFiles\Compiler.dir\ + TARGET_PDB = Compiler.pdb + # ============================================================================= # Link build statements for EXECUTABLE target Compiler @@ -92,7 +106,7 @@ build CMakeFiles\Compiler.dir\Scanner.c.obj: C_COMPILER__Compiler_unscanned_Debu ############################################# # Link the executable Compiler.exe -build Compiler.exe: C_EXECUTABLE_LINKER__Compiler_Debug CMakeFiles\Compiler.dir\Compilers.c.obj CMakeFiles\Compiler.dir\Reader.c.obj CMakeFiles\Compiler.dir\MainReader.c.obj CMakeFiles\Compiler.dir\MainScanner.c.obj CMakeFiles\Compiler.dir\Scanner.c.obj +build Compiler.exe: C_EXECUTABLE_LINKER__Compiler_Debug CMakeFiles\Compiler.dir\Compilers.c.obj CMakeFiles\Compiler.dir\Reader.c.obj CMakeFiles\Compiler.dir\MainReader.c.obj CMakeFiles\Compiler.dir\MainScanner.c.obj CMakeFiles\Compiler.dir\Scanner.c.obj CMakeFiles\Compiler.dir\MainParser.c.obj CMakeFiles\Compiler.dir\Parser.c.obj FLAGS = /DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1 LINK_FLAGS = /machine:x64 /debug /INCREMENTAL /subsystem:console LINK_LIBRARIES = kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib diff --git a/input/INPUT2_Volume.rs b/input/INPUT2_Volume.rs index 5a6c883..2ad7f4d 100644 --- a/input/INPUT2_Volume.rs +++ b/input/INPUT2_Volume.rs @@ -1,11 +1,13 @@ /* RuanScript Example: Volume of a sphere*/ //single line comment -main() { + +main(){ float PI = 3.14; float r = 0.0; float Vol = 0.0; - + r = input('Enter the radius:'); Vol = 4.0 / 3.0 * PI * (r * r * r); + print(Vol); } diff --git a/input/test.rs b/input/test.rs index 73c899a..e0f7c7f 100644 --- a/input/test.rs +++ b/input/test.rs @@ -1,3 +1,4 @@ This is one test to check if reader is -functional. \ No newline at end of file +functional. +