summaryrefslogtreecommitdiff
path: root/Homework/cs5300/project-three/data
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
commit6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch)
treeed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs5300/project-three/data
downloadmisc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.tar.gz
misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.zip
Diffstat (limited to 'Homework/cs5300/project-three/data')
-rw-r--r--Homework/cs5300/project-three/data/Expr.cfg25
-rw-r--r--Homework/cs5300/project-three/data/ExprLexer.tokens39
-rw-r--r--Homework/cs5300/project-three/data/Paren.cfg17
-rw-r--r--Homework/cs5300/project-three/data/ParenLexer.tokens19
-rw-r--r--Homework/cs5300/project-three/data/Simple.cfg13
-rw-r--r--Homework/cs5300/project-three/data/SimpleLexer.tokens15
-rw-r--r--Homework/cs5300/project-three/data/Tiny copy.cfg63
-rw-r--r--Homework/cs5300/project-three/data/Tiny.cfg63
-rw-r--r--Homework/cs5300/project-three/data/TinyLexer.tokens41
-rw-r--r--Homework/cs5300/project-three/data/expr1.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr2.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr3.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr4.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr5.dat1
-rw-r--r--Homework/cs5300/project-three/data/expr6.dat1
-rw-r--r--Homework/cs5300/project-three/data/paren0.dat1
-rw-r--r--Homework/cs5300/project-three/data/paren1.dat3
-rw-r--r--Homework/cs5300/project-three/data/paren2.dat3
-rw-r--r--Homework/cs5300/project-three/data/paren3.dat1
-rw-r--r--Homework/cs5300/project-three/data/paren4.dat1
-rw-r--r--Homework/cs5300/project-three/data/tiny1.dat3
-rw-r--r--Homework/cs5300/project-three/data/tiny2.dat7
-rw-r--r--Homework/cs5300/project-three/data/tiny3.dat4
-rw-r--r--Homework/cs5300/project-three/data/tiny4.dat4
-rw-r--r--Homework/cs5300/project-three/data/tinyGrammar.pdfbin0 -> 83316 bytes
25 files changed, 328 insertions, 0 deletions
diff --git a/Homework/cs5300/project-three/data/Expr.cfg b/Homework/cs5300/project-three/data/Expr.cfg
new file mode 100644
index 0000000..7493e3e
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Expr.cfg
@@ -0,0 +1,25 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ExprLexer.tokens.
+
+grammar Expr;
+
+goal: expr;
+
+expr: expr PLUS term
+ | expr MINUS term
+ | term
+ ;
+
+term : term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN expr CPAREN
+ | INT
+ | FLOAT
+ | IDENTIFIER
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/ExprLexer.tokens b/Homework/cs5300/project-three/data/ExprLexer.tokens
new file mode 100644
index 0000000..ccb798a
--- /dev/null
+++ b/Homework/cs5300/project-three/data/ExprLexer.tokens
@@ -0,0 +1,39 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Expr.cfg.
+
+lexer grammar ExprLexer;
+
+PLUS: '+' ;
+MINUS: '-' ;
+MULTIPLY: '*' ;
+DIVIDE: '/' ;
+OPAREN: '(' ;
+CPAREN: ')' ;
+
+FLOAT
+ : DIGIT+ '.' DIGIT+
+ ;
+
+INT
+ : DIGIT+
+ ;
+
+IDENTIFIER
+ : LETTER (LETTER | DIGIT)*
+ ;
+
+COMMENT
+ : ( '//' ~[\r\n]* '\r'? '\n'
+ | '/*' .*? '*/'
+ ) -> skip
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
+
+fragment LETTER : ('a'..'z' | 'A'..'Z');
+fragment DIGIT : ('0'..'9'); \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/Paren.cfg b/Homework/cs5300/project-three/data/Paren.cfg
new file mode 100644
index 0000000..184b11c
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Paren.cfg
@@ -0,0 +1,17 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ParenLexer.tokens.
+
+grammar Paren;
+
+goal: list;
+
+list: list pair
+ | pair
+ ;
+
+pair: OPAREN list CPAREN
+ | OPAREN CPAREN
+ ;
diff --git a/Homework/cs5300/project-three/data/ParenLexer.tokens b/Homework/cs5300/project-three/data/ParenLexer.tokens
new file mode 100644
index 0000000..51e5258
--- /dev/null
+++ b/Homework/cs5300/project-three/data/ParenLexer.tokens
@@ -0,0 +1,19 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Paren.cfg.
+
+lexer grammar ParenLexer;
+
+OPAREN
+ : '('
+ ;
+
+CPAREN
+ : ')'
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
diff --git a/Homework/cs5300/project-three/data/Simple.cfg b/Homework/cs5300/project-three/data/Simple.cfg
new file mode 100644
index 0000000..80c1e18
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Simple.cfg
@@ -0,0 +1,13 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file contains an expression grammar that uses tokens described in
+// ParenLexer.tokens.
+
+grammar Simple;
+
+G: N;
+
+N: N X
+ | X
+ ;
diff --git a/Homework/cs5300/project-three/data/SimpleLexer.tokens b/Homework/cs5300/project-three/data/SimpleLexer.tokens
new file mode 100644
index 0000000..64ec3c1
--- /dev/null
+++ b/Homework/cs5300/project-three/data/SimpleLexer.tokens
@@ -0,0 +1,15 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Simple.cfg.
+
+lexer grammar SimpleLexer;
+
+X
+ : 'x'
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
diff --git a/Homework/cs5300/project-three/data/Tiny copy.cfg b/Homework/cs5300/project-three/data/Tiny copy.cfg
new file mode 100644
index 0000000..71fb8d9
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Tiny copy.cfg
@@ -0,0 +1,63 @@
+//
+// WRITE A CORRECT GRAMMAR FOR THE TINY LANGUAGE IN THIS FILE.
+//
+// The grammar is described in data/tinyGrammar.pdf. Do not use dashes
+// in your non-terminal names. I recommend you use mixed case naming for your
+// non-terminals instead (e.g. stmtSeq).
+//
+// Do not put any string literals in this grammar (e.g. "="). Use only token
+// names given in TinyLexer.tokens.
+//
+// This file contains an expression grammar that uses tokens described in
+// TinyLexer.tokens.
+//
+// NOTE ONE ERROR in the pdf: the second production rule should read:
+// stmt-seq -> stmt-seq stmt | stmt
+
+grammar Tiny;
+
+goal: program;
+
+program: stmtseq;
+
+stmtseq: stmtseq stmt
+ | stmt;
+
+stmt: ifstmt
+ | repeatstmt
+ | assignstmt
+ | readstmt
+ | writestmt
+ ;
+
+ifstmt: IF exp THEN stmtseq END
+ | IF exp THEN stmtseq ELSE stmtseq END
+ ;
+
+repeatstmt: REPEAT stmtseq UNTIL exp;
+
+assignstmt: ID EQUAL exp;
+
+readstmt: READ ID;
+
+writestmt: WRITE exp;
+
+exp: simpleexp LT simpleexp
+ | simpleexp EQUAL simpleexp
+ | simpleexp
+ ;
+
+simpleexp: simpleexp PLUS term
+ | simpleexp MINUS term
+ | term
+ ;
+
+term: term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN exp CPAREN
+ | NUM
+ | ID
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/Tiny.cfg b/Homework/cs5300/project-three/data/Tiny.cfg
new file mode 100644
index 0000000..71fb8d9
--- /dev/null
+++ b/Homework/cs5300/project-three/data/Tiny.cfg
@@ -0,0 +1,63 @@
+//
+// WRITE A CORRECT GRAMMAR FOR THE TINY LANGUAGE IN THIS FILE.
+//
+// The grammar is described in data/tinyGrammar.pdf. Do not use dashes
+// in your non-terminal names. I recommend you use mixed case naming for your
+// non-terminals instead (e.g. stmtSeq).
+//
+// Do not put any string literals in this grammar (e.g. "="). Use only token
+// names given in TinyLexer.tokens.
+//
+// This file contains an expression grammar that uses tokens described in
+// TinyLexer.tokens.
+//
+// NOTE ONE ERROR in the pdf: the second production rule should read:
+// stmt-seq -> stmt-seq stmt | stmt
+
+grammar Tiny;
+
+goal: program;
+
+program: stmtseq;
+
+stmtseq: stmtseq stmt
+ | stmt;
+
+stmt: ifstmt
+ | repeatstmt
+ | assignstmt
+ | readstmt
+ | writestmt
+ ;
+
+ifstmt: IF exp THEN stmtseq END
+ | IF exp THEN stmtseq ELSE stmtseq END
+ ;
+
+repeatstmt: REPEAT stmtseq UNTIL exp;
+
+assignstmt: ID EQUAL exp;
+
+readstmt: READ ID;
+
+writestmt: WRITE exp;
+
+exp: simpleexp LT simpleexp
+ | simpleexp EQUAL simpleexp
+ | simpleexp
+ ;
+
+simpleexp: simpleexp PLUS term
+ | simpleexp MINUS term
+ | term
+ ;
+
+term: term MULTIPLY factor
+ | term DIVIDE factor
+ | factor
+ ;
+
+factor: OPAREN exp CPAREN
+ | NUM
+ | ID
+ ; \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/TinyLexer.tokens b/Homework/cs5300/project-three/data/TinyLexer.tokens
new file mode 100644
index 0000000..ad6b2a7
--- /dev/null
+++ b/Homework/cs5300/project-three/data/TinyLexer.tokens
@@ -0,0 +1,41 @@
+//
+// DO NOT MODIFY THIS FILE.
+//
+// This file describes the tokens that will be available to the parser
+// that uses the grammar described in Tiny.cfg.
+
+lexer grammar TinyLexer;
+
+IF : 'if' ;
+THEN : 'then' ;
+ELSE : 'else' ;
+END : 'end' ;
+REPEAT : 'repeat' ;
+UNTIL : 'until' ;
+READ : 'read' ;
+WRITE : 'write' ;
+OPAREN : '(' ;
+CPAREN : ')' ;
+
+PLUS: '+' ;
+MINUS: '-' ;
+MULTIPLY: '*' ;
+DIVIDE: '/' ;
+LT: '<' ;
+EQUAL: '=' ;
+
+NUM : DIGIT+ ;
+ID : LETTER+ ;
+
+COMMENT
+ : ( '//' ~[\r\n]* '\r'? '\n'
+ | '/*' .*? '*/'
+ ) -> skip
+ ;
+
+WS
+ : (' ' | '\t' | '\n' | '\r' | '\f')+ -> skip
+ ;
+
+fragment LETTER : ('a'..'z' | 'A'..'Z');
+fragment DIGIT : ('0'..'9'); \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr1.dat b/Homework/cs5300/project-three/data/expr1.dat
new file mode 100644
index 0000000..846e7d3
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr1.dat
@@ -0,0 +1 @@
+3 + 4 * 5 / 8 \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr2.dat b/Homework/cs5300/project-three/data/expr2.dat
new file mode 100644
index 0000000..8e0c0b7
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr2.dat
@@ -0,0 +1 @@
+3 + + 42 * 34 \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr3.dat b/Homework/cs5300/project-three/data/expr3.dat
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr3.dat
@@ -0,0 +1 @@
+3
diff --git a/Homework/cs5300/project-three/data/expr4.dat b/Homework/cs5300/project-three/data/expr4.dat
new file mode 100644
index 0000000..84a357a
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr4.dat
@@ -0,0 +1 @@
+(a + b) * ((c-def)/43) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/expr5.dat b/Homework/cs5300/project-three/data/expr5.dat
new file mode 100644
index 0000000..c2c433b
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr5.dat
@@ -0,0 +1 @@
+(a + b) * ((c-d)/43
diff --git a/Homework/cs5300/project-three/data/expr6.dat b/Homework/cs5300/project-three/data/expr6.dat
new file mode 100644
index 0000000..f46d387
--- /dev/null
+++ b/Homework/cs5300/project-three/data/expr6.dat
@@ -0,0 +1 @@
+( \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren0.dat b/Homework/cs5300/project-three/data/paren0.dat
new file mode 100644
index 0000000..dd626a0
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren0.dat
@@ -0,0 +1 @@
+() \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren1.dat b/Homework/cs5300/project-three/data/paren1.dat
new file mode 100644
index 0000000..f7e9493
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren1.dat
@@ -0,0 +1,3 @@
+((
+))(
+)(((()))()(())) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren2.dat b/Homework/cs5300/project-three/data/paren2.dat
new file mode 100644
index 0000000..4f879eb
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren2.dat
@@ -0,0 +1,3 @@
+(
+))(
+) \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/paren3.dat b/Homework/cs5300/project-three/data/paren3.dat
new file mode 100644
index 0000000..e4a2fe8
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren3.dat
@@ -0,0 +1 @@
+)()(
diff --git a/Homework/cs5300/project-three/data/paren4.dat b/Homework/cs5300/project-three/data/paren4.dat
new file mode 100644
index 0000000..3077d74
--- /dev/null
+++ b/Homework/cs5300/project-three/data/paren4.dat
@@ -0,0 +1 @@
+()()(()())
diff --git a/Homework/cs5300/project-three/data/tiny1.dat b/Homework/cs5300/project-three/data/tiny1.dat
new file mode 100644
index 0000000..7f9078f
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny1.dat
@@ -0,0 +1,3 @@
+a = 3
+b = 4
+c = a + b
diff --git a/Homework/cs5300/project-three/data/tiny2.dat b/Homework/cs5300/project-three/data/tiny2.dat
new file mode 100644
index 0000000..09195b8
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny2.dat
@@ -0,0 +1,7 @@
+a = 3
+b = 4
+if a = b then
+ write (a + b * (c - d))
+else
+ write a
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/tiny3.dat b/Homework/cs5300/project-three/data/tiny3.dat
new file mode 100644
index 0000000..768addd
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny3.dat
@@ -0,0 +1,4 @@
+a = 3
+if a = then
+ write a
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/tiny4.dat b/Homework/cs5300/project-three/data/tiny4.dat
new file mode 100644
index 0000000..1d66283
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tiny4.dat
@@ -0,0 +1,4 @@
+a = 3
+if (a = b) then
+ write a = 3)
+end \ No newline at end of file
diff --git a/Homework/cs5300/project-three/data/tinyGrammar.pdf b/Homework/cs5300/project-three/data/tinyGrammar.pdf
new file mode 100644
index 0000000..855d45b
--- /dev/null
+++ b/Homework/cs5300/project-three/data/tinyGrammar.pdf
Binary files differ