-
Notifications
You must be signed in to change notification settings - Fork 7
/
Prerequisites.g4
76 lines (60 loc) · 1.21 KB
/
Prerequisites.g4
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
65
66
67
68
69
70
71
72
73
74
75
76
grammar Prerequisites;
// This files defines the grammar expectedfrom the cleaned prerequisites section
// on a course details page on Oscar
// Parser rules
parse
: expression // an input can contain either a set (multiple clauses joined with operators)
| atom // or a single clause
| EOF
;
expression
: left=term ( OR right=term)*
;
term
: left=atom (AND right=atom)*
;
atom
: course
| test
| (OPARENS expression CPARENS)
;
course
: COURSE_PREFIX? subject=COURSE_SUBJECT number=COURSE_NUMBER (GRADE_PREFIX grade=GRADE_LETTER)?
;
test
// Re-use course number here to avoid parse ambiguity
: name=TEST_NAME score=COURSE_NUMBER
;
// Lexer rules
AND : 'and';
OR : 'or';
OPARENS : '(';
CPARENS : ')';
GRADE_LETTER
: 'A'..'D'
| 'T'
;
COURSE_PREFIX
: 'Undergraduate Semester level'
| 'Graduate Semester level'
;
GRADE_PREFIX
: 'Minimum Grade of'
;
TEST_NAME
: 'SAT Mathematics'
| 'MATH SECTION SCORE'
| 'ACT Math'
| 'Converted ACT Math'
| 'Math: Calculus AB'
| 'Math: Calculus BC'
;
COURSE_NUMBER
: [0-9X]+[A-Z]*
;
COURSE_SUBJECT
: [A-Z]+
;
SPACE
: [ \t\r\n] -> skip
;