Skip to content

Commit 6725ed8

Browse files
Gabriel-T-HarrisGabriel T. Harris 4
andauthored
Parser (#2)
* Token Class Wrote class to represent tokens to be created by lexical analyzer. * Test Cases All test cases complete except for 5 card Poker. That one is incomplete. * Delete Files Added in this Commit * Removing TEST Files * Finished 5 Card Poker Test Finished writing out the remaining scenarios. * Corrected Error Accidentally duplicated an equals sign. * Started Tokenization Wrote representations of definitions. * Corrected Oversight in Equals Function Accidentally deferred to wrong equals function. * Most of the Tokenizer Wrote overall structure of tokenizer. As well as multiple subroutines for it. * Finished Tokenizer Added part to match keywords. * Added Entry Point There now exists a starting point for the project's execution. * Corrected Line Numbering Errors Added \n to list of restricted char. Corrected error in not counting \n in comments. * Added Program Argument Parsing Reworked all command line argument parsing to use new parser from external JAR. Also added said JAR. Added all expected command line arguments and corresponding code to parse them. Includes test file parsing. * Minor changes due to review. * Gardening (#3) * Clean Up Made none functional changes to correct/update a few things. * Added support for dot file output Changed Evaluable<T> from an Interface to Abstract Class. Added toString functions and support for breath first construction of dot file. * Message * Added Xor_test.java * Requested Changes Xor_test.java tests are failing. Which will be fixed in another branch. Co-authored-by: Gabriel T. Harris 4 <Gabriel T. Harris [email protected]>
1 parent ee57124 commit 6725ed8

37 files changed

+2190
-121
lines changed

Input/Default Configuration.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
deck list:
2+
{
3+
First;
4+
Second;
5+
Third;
6+
Forth;
7+
Fifth;
8+
6th;
9+
7th;
10+
Ash Blossom & Joyous Spring;
11+
First;
12+
}
13+
14+
scenarios:
15+
{
16+
Contains "First" Card =
17+
{
18+
scenario =
19+
{
20+
[First]
21+
};
22+
}
23+
Contains "Second" Card =
24+
{
25+
scenario =
26+
{
27+
[Second]
28+
};
29+
display = false;
30+
}
31+
Contains Ash Blossom & Joyous Spring =
32+
{
33+
scenario =
34+
{
35+
[Ash Blossom & Joyous Spring]
36+
};
37+
}
38+
39+
//should be the highest
40+
First | Ash =
41+
{
42+
scenario =
43+
{
44+
<Contains "First" Card> OR <Contains Ash Blossom & Joyous Spring>
45+
};
46+
}
47+
48+
//should be the lowest
49+
First & Ash =
50+
{
51+
scenario =
52+
{
53+
<Contains "First" Card> AND <Contains Ash Blossom & Joyous Spring>
54+
};
55+
}
56+
//should be the same as First & Ash
57+
First AND Ash =//legal name
58+
{
59+
scenario =
60+
{
61+
([First]) AND NOT NOT [Ash Blossom & Joyous Spring]
62+
};
63+
}
64+
}
65+
/*
66+
Other:
67+
Line Comment, yes
68+
Block Comment, yes
69+
Block Comment error, no
70+
71+
Deck List properties:
72+
Duplicate Card, yes
73+
Invalid Card, no
74+
No Deck Error, no
75+
76+
Scenario List Properties:
77+
No Scenario Defined Error, no
78+
Invalid Name, no
79+
Repeated Name Error, no
80+
Binary Operator, yes
81+
Binary Operand Missing, no
82+
Reference Scenario, yes
83+
Undefined Referenced Scenario Error, no
84+
Empty scenario, no
85+
Has Display, yes
86+
Invalid Display, no
87+
Unary Operator, yes
88+
Multiple Unary, yes
89+
Nesting of Expressions, yes
90+
*/

Notes.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Configuration File:
44
-throw away none main deck parts
55
-maybe read a ydk file instead of in same file.
66
-declare scenarios
7-
-state which to display at the end
7+
-state which to display at the end, which also states which should be evaluated on its on
88

99
Structure:
1010

@@ -14,20 +14,21 @@ Structure:
1414
-short circuit operator evaluation
1515
-node per operator
1616
-node per single match as leaf
17-
-TODO: figure out duplicates and overlap of sub-scenarios.
17+
-cards are used, thereby preventing a card from being matched by multiple conditions.
1818

1919
Parser:
2020

21-
-Like a compiler going over expressions.
22-
-Table driven?
21+
-Like a compiler going over expressions (context free grammar).
22+
-Table driven, LL(1)
2323

2424
Later Versions:
2525

2626
-add special ability to cards
2727
-example, when a hand includes a draw card, apply draw to look at more cards for evaluations
28+
-draw, example Pot of Greed
29+
-excavate, Pot of Duality
30+
-draw then discard, Graceful Charity
31+
-other such as Pot of Desires
2832

2933
-provide more options for writing configuration file?
3034
-allow some regex for stating cards?
31-
32-
-additional options for command line arguments?
33-
-maybe put in the planned (yet to be written) command line argument parser

Output/Default Configuration 2021-7-30_2319.outlexerrors

Whitespace-only changes.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[Lexeme TYPE: DECK_START, LEXEME: deck list:, line number: 1]
2+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 2]
3+
[Lexeme TYPE: ID, LEXEME: First, line number: 3][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 3]
4+
[Lexeme TYPE: ID, LEXEME: Second, line number: 4][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 4]
5+
[Lexeme TYPE: ID, LEXEME: Third, line number: 5][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 5]
6+
[Lexeme TYPE: ID, LEXEME: Forth, line number: 6][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 6]
7+
[Lexeme TYPE: ID, LEXEME: Fifth, line number: 7][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 7]
8+
[Lexeme TYPE: ID, LEXEME: 6th, line number: 8][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 8]
9+
[Lexeme TYPE: ID, LEXEME: 7th, line number: 9][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 9]
10+
[Lexeme TYPE: ID, LEXEME: Ash Blossom & Joyous Spring, line number: 10][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 10]
11+
[Lexeme TYPE: ID, LEXEME: First, line number: 11][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 11]
12+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 12]
13+
14+
[Lexeme TYPE: PROBABILITY_START, LEXEME: scenarios:, line number: 14]
15+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 15]
16+
[Lexeme TYPE: ID, LEXEME: Contains "First" Card, line number: 16][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 16]
17+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 17]
18+
[Lexeme TYPE: TREE_START, LEXEME: scenario, line number: 18][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 18]
19+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 19]
20+
[Lexeme TYPE: CONDITION_CARD_START, LEXEME: [, line number: 20][Lexeme TYPE: ID, LEXEME: First, line number: 20][Lexeme TYPE: CONDITION_CARD_END, LEXEME: ], line number: 20]
21+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 21][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 21]
22+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 22]
23+
[Lexeme TYPE: ID, LEXEME: Contains "Second" Card, line number: 23][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 23]
24+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 24]
25+
[Lexeme TYPE: TREE_START, LEXEME: scenario, line number: 25][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 25]
26+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 26]
27+
[Lexeme TYPE: CONDITION_CARD_START, LEXEME: [, line number: 27][Lexeme TYPE: ID, LEXEME: Second, line number: 27][Lexeme TYPE: CONDITION_CARD_END, LEXEME: ], line number: 27]
28+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 28][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 28]
29+
[Lexeme TYPE: DISPLAY_START, LEXEME: display, line number: 29][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 29] [Lexeme TYPE: ID, LEXEME: false, line number: 29][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 29]
30+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 30]
31+
[Lexeme TYPE: ID, LEXEME: Contains Ash Blossom & Joyous Spring, line number: 31][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 31]
32+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 32]
33+
[Lexeme TYPE: TREE_START, LEXEME: scenario, line number: 33][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 33]
34+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 34]
35+
[Lexeme TYPE: CONDITION_CARD_START, LEXEME: [, line number: 35][Lexeme TYPE: ID, LEXEME: Ash Blossom & Joyous Spring, line number: 35][Lexeme TYPE: CONDITION_CARD_END, LEXEME: ], line number: 35]
36+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 36][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 36]
37+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 37]
38+
39+
[Lexeme TYPE: LINE_COMMENT, LEXEME: //should be the highest, line number: 39]
40+
[Lexeme TYPE: ID, LEXEME: First | Ash, line number: 40][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 40]
41+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 41]
42+
[Lexeme TYPE: TREE_START, LEXEME: scenario, line number: 42][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 42]
43+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 43]
44+
[Lexeme TYPE: CONDITION_SCENARIO_START, LEXEME: <, line number: 44][Lexeme TYPE: ID, LEXEME: Contains "First" Card, line number: 44][Lexeme TYPE: CONDITION_SCENARIO_END, LEXEME: >, line number: 44] [Lexeme TYPE: OR, LEXEME: OR, line number: 44] [Lexeme TYPE: CONDITION_SCENARIO_START, LEXEME: <, line number: 44][Lexeme TYPE: ID, LEXEME: Contains Ash Blossom & Joyous Spring, line number: 44][Lexeme TYPE: CONDITION_SCENARIO_END, LEXEME: >, line number: 44]
45+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 45][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 45]
46+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 46]
47+
48+
[Lexeme TYPE: LINE_COMMENT, LEXEME: //should be the lowest, line number: 48]
49+
[Lexeme TYPE: ID, LEXEME: First & Ash, line number: 49][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 49]
50+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 50]
51+
[Lexeme TYPE: TREE_START, LEXEME: scenario, line number: 51][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 51]
52+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 52]
53+
[Lexeme TYPE: CONDITION_SCENARIO_START, LEXEME: <, line number: 53][Lexeme TYPE: ID, LEXEME: Contains "First" Card, line number: 53][Lexeme TYPE: CONDITION_SCENARIO_END, LEXEME: >, line number: 53] [Lexeme TYPE: AND, LEXEME: AND, line number: 53] [Lexeme TYPE: CONDITION_SCENARIO_START, LEXEME: <, line number: 53][Lexeme TYPE: ID, LEXEME: Contains Ash Blossom & Joyous Spring, line number: 53][Lexeme TYPE: CONDITION_SCENARIO_END, LEXEME: >, line number: 53]
54+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 54][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 54]
55+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 55]
56+
[Lexeme TYPE: LINE_COMMENT, LEXEME: //should be the same as First & Ash, line number: 56]
57+
[Lexeme TYPE: ID, LEXEME: First AND Ash, line number: 57][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 57][Lexeme TYPE: LINE_COMMENT, LEXEME: //legal name, line number: 57]
58+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 58]
59+
[Lexeme TYPE: TREE_START, LEXEME: scenario, line number: 59][Lexeme TYPE: ASSIGN, LEXEME: =, line number: 59]
60+
[Lexeme TYPE: SENTINEL_START, LEXEME: {, line number: 60]
61+
[Lexeme TYPE: CONDITION_EXPR_START, LEXEME: (, line number: 61][Lexeme TYPE: CONDITION_CARD_START, LEXEME: [, line number: 61][Lexeme TYPE: ID, LEXEME: First, line number: 61][Lexeme TYPE: CONDITION_CARD_END, LEXEME: ], line number: 61][Lexeme TYPE: CONDITION_EXPR_END, LEXEME: ), line number: 61] [Lexeme TYPE: AND, LEXEME: AND, line number: 61] [Lexeme TYPE: NOT, LEXEME: NOT, line number: 61] [Lexeme TYPE: NOT, LEXEME: NOT, line number: 61] [Lexeme TYPE: CONDITION_CARD_START, LEXEME: [, line number: 61][Lexeme TYPE: ID, LEXEME: Ash Blossom & Joyous Spring, line number: 61][Lexeme TYPE: CONDITION_CARD_END, LEXEME: ], line number: 61]
62+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 62][Lexeme TYPE: SEMI_COLON, LEXEME: ;, line number: 62]
63+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 63]
64+
[Lexeme TYPE: SENTINEL_END, LEXEME: }, line number: 64]
65+
[Lexeme TYPE: BLOCK_COMMENT, LEXEME: /*
66+
Other:
67+
Line Comment, yes
68+
Block Comment, yes
69+
Block Comment error, no
70+
71+
Deck List properties:
72+
Duplicate Card, yes
73+
Invalid Card, no
74+
No Deck Error, no
75+
76+
Scenario List Properties:
77+
No Scenario Defined Error, no
78+
Invalid Name, no
79+
Repeated Name Error, no
80+
Binary Operator, yes
81+
Binary Operand Missing, no
82+
Reference Scenario, yes
83+
Undefined Referenced Scenario Error, no
84+
Empty scenario, no
85+
Has Display, yes
86+
Invalid Display, no
87+
Unary Operator, yes
88+
Multiple Unary, yes
89+
Nesting of Expressions, yes
90+
*/, line number: 65]
25.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)