CS 330 Lecture 7 – Finishing SLOWGO, a first Makefile, and a calculator

Agenda smart compilation with Make add drawing in to SLOWGO Code makefile ANTLRWORKS = $(HOME)/bin/antlrworks-1.4.3.jar SLOWGOInterpreter.class: SLOWGOInterpreter.java SLOWGOLexer.class SLOWGOParser.class javac -cp $(ANTLRWORKS):. SLOWGOInterpreter.java SLOWGOLexer.class: SLOWGOLexer.java javac -cp $(ANTLRWORKS) SLOWGOLexer.java SLOWGOParser.class: SLOWGOParser.java javac -cp $(ANTLRWORKS) SLOWGOParser.java SLOWGOLexer.java SLOWGOParser.java: SLOWGO.g java -cp $(ANTLRWORKS) org.antlr.Tool SLOWGO.g clean: rm -f *.class SLOWGO.g grammar SLOWGO; @members { private int x […]

CS 145 Lecture 4 – String problems and our first method

Agenda extracting names: “LASTNAME, FIRSTNAME MIDDLENAME …” lock the web: does a URL end in .edu? separate a comma-separated list turn “1,234,567” into 1234567 abstraction: hiding details abstracting SVG Code NameFixerUpper.java package preexam1; public class NameFixerUpper { public static void main(String[] args) { String name = “STEINMEYER, JOEL EDWARD”; // names in bad order! // […]

CS 330 Lecture 6 – Lexing, parsing, and translating

Agenda lexing recursive descent parsing writing interpreter glue adding state to ANTLR adding actions in ANTLR Code SLOWGO.g grammar SLOWGO; @members { private int x = 0; private int y = 0; private int theta = 0; private boolean isDrawing = false; } program @init { System.out.println(“axis equal”); System.out.println(“hold on”); } : command+ ; command […]

CS 145 Lecture 3 – Algorithms

Agenda algorithm pseudocode program this an early algorithm, a la Euclid primitives have operators objects have methods API String methods Program this You are indecisive. So are your friends. One quiet Monday night, you all decide one night to come up with a list of restaurants, each accompanied by a probability of how often you […]

CS 330 Lecture 5 – Our first language

Agenda your Logo their Logo our Logo hi, ANTLR recursive descent parsing Your Logo Design with a partner a little language that lets you move around in 2-D and draw things. Write down: your instructions an example program Their Logo From Papert’s NSF grant: The word constructionism is a mnemonic for two aspects of the […]