-
Notifications
You must be signed in to change notification settings - Fork 1
/
Grammar notes.txt
64 lines (51 loc) · 3.96 KB
/
Grammar notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Configuration file grammar:
//regex which replace literal values used are represented by the following:
deck_list: deck list:
card_name: [^;\]]+ //include CONDITION_CARD_END
scenarios: scenarios:
scenario_name: [^=>]+ //include CONDITION_SCENARIO_END
display: display
Upper case: not, and, or, xor
Lower case: true, false
single symbol are exactly the same. Text version is just for https://smlweb.cpsc.ucalgary.ca.
id: "[^;=\n" + SENTINEL_START + SENTINEL_END + CONDITION_CARD_START + CONDITION_CARD_END +
CONDITION_SCENARIO_START + CONDITION_SCENARIO_END + CONDITION_EXPR_START + CONDITION_EXPR_END + "]+"
//lower case for literal, capital for production rule.
//Note grammar does not have the unification resulting in ID, though is coded with that change.
START -> DECK PROBABILITY .
DECK -> DECK_START SENTINEL_START DECK_LIST SENTINEL_END.
DECK_START -> deck list: .
DECK_LIST -> CARD MORE_CARDS .
MORE_CARDS -> CARD MORE_CARDS | .
CARD -> CARD_NAME SEMI_COLON .
CARD_NAME -> id .
PROBABILITY -> PROBABILITY_START SENTINEL_START SCENARIO_LIST SENTINEL_END .
PROBABILITY_START -> scenarios: .
SCENARIO_LIST -> SCENARIO MORE_SCENARIOS .
MORE_SCENARIOS -> SCENARIO MORE_SCENARIOS | .
SCENARIO -> SCENARIO_NAME ASSIGN SENTINEL_START TREE DISPLAY SENTINEL_END .
SCENARIO_NAME -> id .
TREE -> TREE_START ASSIGN SENTINEL_START EXPR SENTINEL_END SEMI_COLON .
TREE_START -> scenario .
EXPR -> UNARY_EXPR BINARY_EXPR .
UNARY_EXPR -> UNARY_OPERATOR UNARY_EXPR | PRIMARY_EXPR .
UNARY_OPERATOR -> not .
PRIMARY_EXPR -> CONDITION_CARD_START CARD_NAME CONDITION_CARD_END
|CONDITION_SCENARIO_START SCENARIO_NAME CONDITION_SCENARIO_END
|CONDITION_EXPR_START EXPR CONDITION_EXPR_END .
CONDITION_CARD_START -> [ .
CONDITION_CARD_END -> ] .
CONDITION_SCENARIO_START -> < .
CONDITION_SCENARIO_END -> > .
CONDITION_EXPR_START -> ( .
CONDITION_EXPR_END -> ) .
BINARY_EXPR -> BINARY_OPERATOR UNARY_EXPR BINARY_EXPR | .
BINARY_OPERATOR -> and | or | xor .
DISPLAY -> DISPLAY_START ASSIGN DISPLAY_VALUE SEMI_COLON | .
DISPLAY_START -> display .
DISPLAY_VALUE -> true | false .
SENTINEL_START -> open_brace .
SENTINEL_END -> close_brace .
ASSIGN -> assign .
SEMI_COLON -> ;.
https://smlweb.cpsc.ucalgary.ca/vital-stats.php?grammar=START+-%3E+DECK+PROBABILITY+.%0D%0A%0D%0ADECK+-%3E+DECK_START+SENTINEL_START+DECK_LIST+SENTINEL_END.%0D%0ADECK_START+-%3E+deck+list%3A+.%0D%0ADECK_LIST+-%3E+CARD+MORE_CARDS+.%0D%0AMORE_CARDS+-%3E+CARD+MORE_CARDS+%7C+.%0D%0ACARD+-%3E+CARD_NAME+SEMI_COLON+.%0D%0ACARD_NAME+-%3E+id+.%0D%0A%0D%0APROBABILITY+-%3E+PROBABILITY_START+SENTINEL_START+SCENARIO_LIST+SENTINEL_END+.%0D%0APROBABILITY_START+-%3E+scenarios%3A+.%0D%0A%0D%0ASCENARIO_LIST+-%3E+SCENARIO+MORE_SCENARIOS+.%0D%0AMORE_SCENARIOS+-%3E+SCENARIO+MORE_SCENARIOS+%7C+.%0D%0A%0D%0ASCENARIO+-%3E+SCENARIO_NAME+ASSIGN+SENTINEL_START+TREE+DISPLAY+SENTINEL_END+.%0D%0ASCENARIO_NAME+-%3E+id+.%0D%0A%0D%0ATREE+-%3E+TREE_START+ASSIGN+SENTINEL_START+EXPR+SENTINEL_END+SEMI_COLON+.%0D%0ATREE_START+-%3E+scenario+.%0D%0A%0D%0AEXPR+-%3E+UNARY_EXPR+BINARY_EXPR+.%0D%0A%0D%0AUNARY_EXPR+-%3E+UNARY_OPERATOR+UNARY_EXPR+%7C+PRIMARY_EXPR+.%0D%0AUNARY_OPERATOR+-%3E+not+.%0D%0A%0D%0APRIMARY_EXPR+-%3E+CONDITION_CARD_START+CARD_NAME+CONDITION_CARD_END+%7C+CONDITION_SCENARIO_START+SCENARIO_NAME+CONDITION_SCENARIO_END+%7C+CONDITION_EXPR_START+EXPR+CONDITION_EXPR_END+.%0D%0A%0D%0ACONDITION_CARD_START+-%3E+open_bracket+.%0D%0ACONDITION_CARD_END+-%3E+close_bracket+.%0D%0ACONDITION_SCENARIO_START+-%3E+less_then+.%0D%0ACONDITION_SCENARIO_END+-%3E+greater_then+.%0D%0ACONDITION_EXPR_START+-%3E+open_parenthesis+.%0D%0ACONDITION_EXPR_END+-%3E+close_parenthesis+.%0D%0A%0D%0ABINARY_EXPR+-%3E+BINARY_OPERATOR+UNARY_EXPR+BINARY_EXPR+%7C+.%0D%0ABINARY_OPERATOR+-%3E+and+%7C+or+%7C+xor+.%0D%0A%0D%0ADISPLAY+-%3E+DISPLAY_START+ASSIGN+DISPLAY_VALUE+SEMI_COLON+%7C+.%0D%0ADISPLAY_START+-%3E+display+.%0D%0ADISPLAY_VALUE+-%3E+true+%7C+false+.%0D%0A%0D%0ASENTINEL_START+-%3E+open_brace+.%0D%0ASENTINEL_END+-%3E+close_brace+.%0D%0AASSIGN+-%3E+assign+.%0D%0ASEMI_COLON+-%3E+%3B.