I thought as a bit of fun we could
extend what we've done already. You don't
have to watch the videos [but] you might want
to go back and watch the previous videos,
later on. We, certainly, here in Western
Europe, when we utter a sentence tend to
be happy with subject-verb-object order:
"The man goes to town". It's really quite
common across a lot of languages. What
we've done is put together a vocabulary
with lots of silly things in it like "the dog", 
"the man", "the robot", for the Subject,
"bit", "kicked", stroked for the Verb and the
Object of course is the thing that
these actions are done on. So, you can
have "the robot kicked the dog", whatever you
like.  But then we got to thinking: "Subject 
Verb Object.
Is this favored by all beings in the universe?"
Are there some beings out there
that, regardless of the actual details of
language and the words -  be it Finnish, English,
French, Spanish - don't like
subject-verb-object orderings?" 
They'd like to do it a weird way around.
How about Object-Subject-Verb? So, instead
of saying "the man goes to town" as we
would say [we get]: "to town the man goes" ? 
Sounded to me, 20 years ago I first stumbled on
this, very much like Yoda the Jedi Master.
For those of you coming into this cold
and direct - because you saw the word
"Yoda" and grep-ped  over the entire universe
for what this could possibly mean - you
landed back here in Nottingham. And
you're finding that we've done a Yoda
syntax transformer. We started off by
doing the 'furry'grammar and being able
to make up sentences like "the robot
stroked two furry dice". But we didn't do
anything with it. All we did in those
early ones - but there are details there -
you might find it interesting to say: "How
is it decided that 'the robot stroked two furry dice'
is, in some sense, legal and OK?"
Because that's what we've done.
We're basically saying: "It's OK. Use rule 4;
use rule 3; use rule 6". So, we were
sitting there struggling.
What would be ... what you typically do in a compiler?
We've analyzed what's wanted [and] in
a compiler you [then] generate code. So, what's
our "code generation" because we're not doing
anything at the moment! 
Our code generation is gonna be so simple: it's
going to be: 'take the subject-verb-object
parse tree, as it's called, for the input
sentence. Swap around the object to the
front, leave the subject in the middle,
and the verb at the end. So, it's quite a
good exercise on how to hang your
'actions' off what's called a 'yacc' grammar
that implements this. And I think you
might actually enjoy that. So just for a
bit of fun, in this limited vocabulary of
words we've got, what we're going to do is:
analyze the input and say 'have you
really put this in in subject-verb-
object (boring?!)  order. And if you have done
that correctly, then as the action of our
parser we will Yoda-ise it. We will turn
it into Yoda order and put it out that way.
I just wish we had a speech
synthesizer in here! Sean, bring one with
you next time so that we could speak it [i.e. the 
yoda-ised version] But, let's see, I have got a compiled-up
program to do all of this. It is called
'yoda'. It's waiting for input. The standard
sentence, the one we like best of all in
this silly grammar we've put together, is:
"the robot stroked two furry dice". So that
shall be our first test-piece. 
[mutters, looking at screen; furry ... dice] 
Oh look at that! Not only has it analyzed for me
which rules in the grammar were used to
analyze our subject-verb-object sentence
and to be happy that it is in SVO order -
that's a necessary starting point - but
then the transformation, the action, of
our brilliant 'yoda compiler', if you like,
is: "Yoda says:  two furry dice the robot stroked"
So, in other words, we have picked
out from the input sentence what the
object bit was, at the end, we've
promoted that to the front. Then we've
left the subject, the next piece after that, 
and the verb
comes in last: "two furry dice the robot stroked".
>> DFB: Go on, ask me another one Sean, let's see if it works!
>> Sean: Well, let's go for a very clear
simple one : "the dog bit the man" 
>> DFB: the dog bit the man
[It's] happy with the analysis look!
Slightly different to last time but it
is still subject-verb-object Yoda
would say: "the man the dog bit" 
I think that works, don't you Sean?, You do ... you've
always got to say: "Well even in that
re-ordering is it clear who's getting
bitten?!" Yeah?. We're very clear that that
is a subject, that it is the dog biting
the man still? Yes?! Because this grammar
has this one cute phrase of " ... stroked two furry dice"
I'm afraid I have called the
whole grammar 'furry'. But this is Yoda-ised
furry-speak now. 
>> Sean: Maybe we need
people to contribute to this and expand
its vocabulary
>> DFB: We'll be putting out a .zip
file full of all of the 'lex' and 'yacc'
files that make this up. Some of you
could try out and re-run the whole thing
if you've got Linux systems. 
Basically, even for those of you that haven't, I'm
also including the intermediate and
complete C program file (for 'yoda') that those 
pre-processors generate. So you could always
come in, in the middle. Try compiling the
C file, it will probably be ok. Don't get
frustrated by missing libraries - if
you're on UNIX or Linux you should be OK,
if you follow the instructions. For those
of you brave souls running C on either
Windows or Macintosh, I've been out on
the Web, and looked up, and you can get it
to work. But what happens is people translate 
the tools [e.g. 'lex' and 'yacc'] but forget about the
libraries. But never mind, let's see where
we get to.  And I hope you all have a lot
of fun with this. I've even included the
binaries for 64-bit Intel[x86]- based Linux.
Some of you may even be able to just
execute those? I don't know. 
But many of you might want to recompile the
C and hopefully if the libraries are there,
you know, you may be able to get the
whole thing working again. Once you've
succeeding in getting the basic thing
going, you may want to have a lot of fun
making Yoda's vocabulary much more Star
Wars related. I've come off the 'furry'
grammar that I was already doing, just as
a bit of a silly very elementary exercise.
But no you could  ... you could fill
up your vocab. strings with "Jedi"
"Light sabre", "Death Star" all this kind of stuff. 
Sean has just pointed out to me
they're not called "robots" in Star Wars
they're called "droids". Is that right? So you
can translate the word "robot" into "droid"
Or you could even come backwards, you know,
"If yoda-speak you give, we
want it back as SVO, subject-verb-object.
Yeah! so back from Yoda ordering back
into English ordering will be another
thing to do
>> Sean: translator 
>> DFB: [another] translator, yeah
