Skip to content

Commit

Permalink
Merge branch 'indentationRefactor' into 'master'
Browse files Browse the repository at this point in the history
Indentation refactor

See merge request btj12/Interpreter!86
  • Loading branch information
AdamKBeck committed May 1, 2018
2 parents 220af83 + b3a371c commit 11544e5
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 214 deletions.
9 changes: 6 additions & 3 deletions expression-ops.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#lang racket
(provide (all-defined-out))

; Checks if an expression is a a valid expression
(define G-expr?
(lambda (arglist)
(cond
Expand All @@ -15,6 +16,7 @@

(define get-op-from-expr car)

; Checks to see if a math expression is encountered
(define math-expr?
(lambda (op)
(cond
Expand All @@ -25,6 +27,7 @@
((eq? op '%) #t)
(else #f))))

; Checks to see if a boolean expression is encountered
(define boolean-expr?
(lambda (op)
(cond
Expand All @@ -33,6 +36,7 @@
((eq? op '!) #t)
(else #f))))

; Checks to see if a comparing expression is encountered
(define compare-expr?
(lambda (op)
(cond
Expand All @@ -44,8 +48,6 @@
((eq? op '>=) #t)
(else #f))))



; Determines whether a boolean in java boolean notation was encountered
(define java-boolean?
(lambda (value)
Expand All @@ -54,7 +56,7 @@
((eq? value 'false) #t)
(else #f))))


; Converted a java boolean name to a scheme boolean name (e.g. true in java is #t in scheme)
(define java-bool-to-scheme-bool
(lambda (value)
(cond
Expand Down Expand Up @@ -103,6 +105,7 @@
(or arg1 arg2)))
(else (error "unsupported boolean expression")))))

; Determines what type of operator we have
(define compare-operator-to-function-multi
(lambda (op)
(cond
Expand Down
4 changes: 2 additions & 2 deletions interpreter.scm
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
(with-handlers ([exn:fail? error->handler])
(show-parse-tree-output (evaluate-parse-tree->retval_state (get-main-code classname staticstate)
staticstate))))))
; Used as a debugging helper for testing our code.
(define debug-call
(lambda (filename classname)
(let* ([staticstate (G-parsed-file-to-state->state (parser filename) initstate)])
`(evaluate-parse-tree->retval_state ,(get-main-code classname staticstate) ,staticstate))))

; display the value from the parse tree output
(define show-parse-tree-output
(lambda (parse-tree-output)
Expand All @@ -41,8 +43,6 @@
; gets the code portion of a function closure (arglist + code)
(define get-code-from-function-closure cadr)



(define append-main
(lambda (program)
(append program '((return (funcall main))))))
Expand Down
Loading

0 comments on commit 11544e5

Please sign in to comment.