Follow up with yesterday:
you can get my Scala syntax gem extension here, and read below for the instructions on how to install it.
First here is the result:
class Auction(seller: Actor, minBid: Int, closing: Date) extends Actor {
val StringForFun = "hello"
val timeToShutdown = 36000000 val bidIncrement = 10
def act() {
var maxBid = minBid - bidIncrement
var maxBidder: Actor = null
var running = true
while (running) {
receiveWithin ((closing.getTime() - new Date().getTime())) {
case Offer(bid, client) =>
if (bid >= maxBid + bidIncrement) {
if (maxBid >= minBid) maxBidder ! BeatenOffer(bid)
maxBid = bid; maxBidder = client; client ! BestOffer
} else {
client ! BeatenOffer(maxBid)
}
case Inquire(client) =>
client ! Status(maxBid, closing)
case TIMEOUT =>
if (maxBid >= minBid) {
val reply = AuctionConcluded(seller, maxBidder)
maxBidder ! reply; seller ! reply
} else {
seller ! AuctionFailed
}
receiveWithin(timeToShutdown) {
case Offer(_, client) => client ! AuctionOver
case TIMEOUT => running = false
}
}
}
}
}
You will need to add those CSS elements to display things correctly:
pre {
background: #000000 repeat-x;
color: #00FF00;
font-family: arial, 'lucida console', sans-serif;
line-height: 160%;
font-size: 120%;
}
code {
color: #00EE00;
font-style: bold;
font-family: arial, 'lucida console', sans-serif;
}
.comment { color: #333; font-style: italic; }
.keyword { color: #eff; font-weight: bold; }
.punct { color: #444; font-weight: bold; }
.symbol { color: #0bb; }
.string { color: #6b4; }
.ident { color: #00b; }
.constant { color: #66f; }
.regex { color: #a82; }
.number { color: #a33; }
.expr { color: #227; }
Then on your machine, you will need ruby and rubygems installed, and install redcloth and syntax:
gem install syntax
gem install redcloth
Put your sample into a text file in the same folder as run.rb, then run:
ruby run.rb myscala.txt > output.html
That’s about it. It’d be great to develop the same things for Java and CSS. In the mean time, enjoy!