Skip to content

Commit 34c81a6

Browse files
author
robertDurst
committed
Add some missing comments
1 parent 8a25bc5 commit 34c81a6

File tree

3 files changed

+22
-51
lines changed

3 files changed

+22
-51
lines changed

src/main/CommandLine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "../lexar/Lexar2.h"
99
#include "../parser/Parser.h"
1010
#include "../parser/Parser2.h"
11+
#include "../parser/display.h"
1112
#include "../semantics/SemanticAnalyzer.h"
1213
#include "../transpiler/Transpiler.h"
1314
#include <iostream>

src/parser/Parser2.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ Parser2::parseT()
757757
return makeNode(OP::PRIMARY, primary);
758758
}
759759

760+
/**
761+
* Primary := Bool | Integer | String | Identifier
762+
*/
760763
std::shared_ptr<LeafLexeme>
761764
Parser2::parsePrimary()
762765
{
@@ -782,12 +785,18 @@ Parser2::parsePrimary()
782785
}
783786
}
784787

788+
/**
789+
* Type := Identifier
790+
*/
785791
std::shared_ptr<LeafLexeme>
786792
Parser2::parseType()
787793
{
788794
return parseIdentifier();
789795
}
790796

797+
/**
798+
* Variable := Type Identifier
799+
*/
791800
std::shared_ptr<NodeLexeme>
792801
Parser2::parseVariable()
793802
{
@@ -801,6 +810,9 @@ Parser2::parseVariable()
801810
return makeNode(OP::VARIABLE, type, name);
802811
}
803812

813+
/**
814+
* Number := Integer | Float
815+
*/
804816
std::shared_ptr<LeafLexeme>
805817
Parser2::parseNumber()
806818
{
@@ -817,6 +829,9 @@ Parser2::parseNumber()
817829
return makeLeaf(LIT::FLOAT, v);
818830
}
819831

832+
/**
833+
* Identifier := lexvalue
834+
*/
820835
std::shared_ptr<LeafLexeme>
821836
Parser2::parseIdentifier()
822837
{
@@ -825,6 +840,9 @@ Parser2::parseIdentifier()
825840
return makeLeaf(LIT::IDENTIFIER, v);
826841
}
827842

843+
/**
844+
* Bool := lexvalue
845+
*/
828846
std::shared_ptr<LeafLexeme>
829847
Parser2::parseBoolean()
830848
{
@@ -833,6 +851,9 @@ Parser2::parseBoolean()
833851
return makeLeaf(LIT::IDENTIFIER, v);
834852
}
835853

854+
/**
855+
* String := lexvalue
856+
*/
836857
std::shared_ptr<LeafLexeme>
837858
Parser2::parseString()
838859
{

src/parser/Parser2.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -114,56 +114,5 @@ class Parser2
114114

115115
public:
116116
Parser2(const std::string& filename);
117-
118117
std::shared_ptr<NodeLexeme> parse();
119-
120-
void
121-
postorder(std::shared_ptr<NodeLexeme> p, int indent = 0)
122-
{
123-
if (p != NULL && p->op != OP::NULL_VAL)
124-
{
125-
if (indent)
126-
{
127-
std::cout << std::setw(indent) << ' ';
128-
}
129-
std::cout << disp(p->op) << "\n ";
130-
auto il = p->left.index();
131-
132-
if (il == 0)
133-
{
134-
auto w = std::get<std::shared_ptr<NodeLexeme>>(p->left);
135-
if (w)
136-
postorder(w, indent + 4);
137-
}
138-
else if (il == 1)
139-
{
140-
auto w = std::get<std::shared_ptr<LeafLexeme>>(p->left);
141-
if (w)
142-
postorder(w, indent + 4);
143-
}
144-
145-
auto ir = p->right.index();
146-
if (ir == 0)
147-
{
148-
auto w = std::get<std::shared_ptr<NodeLexeme>>(p->right);
149-
if (w)
150-
postorder(w, indent + 4);
151-
}
152-
else if (ir == 1)
153-
{
154-
auto w = std::get<std::shared_ptr<LeafLexeme>>(p->right);
155-
if (w)
156-
postorder(w, indent + 4);
157-
}
158-
}
159-
}
160-
void
161-
postorder(std::shared_ptr<LeafLexeme> p, int indent = 0)
162-
{
163-
if (indent)
164-
{
165-
std::cout << std::setw(indent) << ' ';
166-
}
167-
std::cout << disp(p->lit) << ": " << p->value << "\n ";
168-
}
169118
};

0 commit comments

Comments
 (0)