Microsoft Oslo, ANTLR and STEPS

Posted April 26, 2009 by bengillis
Categories: Big Picture, Microsoft Oslo, Oslo Programming

Tags: , , , , , , , , , , ,

For those of you interested in what Microsoft Oslo is about, you should check out STEPS.   When you first get to the STEPS site, you might think, “what has this got to do with anything”?   For starters, check out the STEPS project 2007 Report.

The project is ‘DSL-focused’ (domain-specific languages).  For a quick glance, check out the TCP/IP section.  In summary, it’s about programming with DSLs rather than general-purpose languagse.

For example, here’s how a TCP/IP stack might look written in a DSL vs. a general-purpose language (mostly commonly, C/C++):

['{ svc = &->(svc? [self peek])
syn = &->(syn? [self peek]) . ->(out ack-syn -1 (+ sequenceNumber 1) (+ TCP_ACK TCP_SYN) 0)
req = &->(req? [self peek]) . ->(out ack-psh-fin 0 (+ sequenceNumber datalen (fin-len tcp))
(+ TCP_ACK TCP_PSH TCP_FIN)
(up destinationPort dev ip tcp
(tcp-payload tcp) datalen))
ack = &->(ack? [self peek]) . ->(out ack acknowledgementNumber
(+ sequenceNumber datalen (fin-len tcp))
TCP_ACK 0)
;
( svc (syn | req | ack | .) | . ->(out ack-rst acknowledgementNumber
(+ sequenceNumber 1)
(+ TCP_ACK TCP_RST) 0)
) *
} < [NetworkPseudoInterface tunnel: '"/dev/tun0" from: '"10.0.0.1" to: '"10.0.0.2"]]

There’s a DSL definition language used throughout, OMeta.  This is a very BNF-ish language borrowing some ANTLR concepts (symantic and syntactic predicates).  Some say Oslo’s M is very similar.  However, almost all the tools I see in use with grammar definition share some BNF-ish ideas.  Perhaps the science of grammar definition is settled on that approach; therefore, M would naturally look like that.

Check out the STEPS document, it talks about pipelining DSLs from one to the next, a multi-layer abstraction architecture.  The top layer would be something like the above, or whatever you want for a DSL, that’s input to yet-another-DSL layer, the bottom layer finally outputting machine language.  However, the STEPS document talks about hardware changes that would make this approach more feasible vs. today’s hardware/instruction sets.

I couldn’t help but think of the new Microsoft Phoenix compiler technology reading through this document.  Check out the ‘intermediate representation’ stuff.