The MRRoboto LanguageThe MRRoboto LanguageJason KopylecJason KopylecHema KrishnanHema KrishnanAdam MarczykAdam MarczykProgramming LanguagesProgramming LanguagesSpring 2004Spring 2004The InspirationThe InspirationnnIn most operating systems, writing In most operating systems, writing programs that interact with other programs programs that interact with other programs is difficult.is difficult.nnGraphical user interfaces are designed for Graphical user interfaces are designed for humans, not programs.humans, not programs.nnThere are many conceivable situations for There are many conceivable situations for which it would be nice to be able to control which it would be nice to be able to control other programs programmatically.other programs programmatically.nnSolution: Control the keyboard and the Solution: Control the keyboard and the mouse through software.mouse through software.The ConceptThe ConceptnnThe Macro Record Robot Language The Macro Record Robot Language (MRRoboto for short) allows programmers (MRRoboto for short) allows programmers to automate control of the keyboard and the to automate control of the keyboard and the mouse through simple batch programs.mouse through simple batch programs.nnThe syntax is JavaThe syntax is Java--like, but simplified so like, but simplified so that scripts can be written quickly. that scripts can be written quickly. nnA good way to teach beginning A good way to teach beginning programmers basic concepts such as flow programmers basic concepts such as flow control and modularization.control and modularization.The ExecutionThe ExecutionnnThe ANTLR parser generator was used to The ANTLR parser generator was used to create a grammar file that translates create a grammar file that translates MRRoboto scripts into humanMRRoboto scripts into human--readable readable Java source code which can then be Java source code which can then be compiled and run.compiled and run.nnTranslation consists of three steps: lexical Translation consists of three steps: lexical analysis, syntax tree generation, and a treeanalysis, syntax tree generation, and a tree--walking algorithm that performs semantic walking algorithm that performs semantic analysis and generates the code.analysis and generates the code.Some ExamplesSome Examples** a simple hello world program** a simple hello world programmouseMove(10, 10)mouseMove(10, 10)click()click()mouseMove(50, 10)mouseMove(50, 10)click()click()type("notepad")type("notepad")press("|ENTER|")press("|ENTER|")type("Hello World")type("Hello World")More ExamplesMore Examples** delays and flow control** delays and flow controlint aint aa = 3a = 3wait(60000) **60 secondswait(60000) **60 secondsif(a < 10)if(a < 10)moveAndDoubleClick(20,20)moveAndDoubleClick(20,20)elseelsewhile(a < 5)while(a < 5)moveAndClick(50,50)moveAndClick(50,50)endendendendThe Main Block and ProceduresThe Main Block and Proceduresstring bstring bb = "foo"b = "foo"doType(b)doType(b)procedure doType(string msg)procedure doType(string msg)type(msg)type(msg)endendError Detection and RecoveryError Detection and RecoverynnCode that violates the grammar rules (bad Code that violates the grammar rules (bad token, incorrect syntax, etc.) will be token, incorrect syntax, etc.) will be detected by ANTLR during initial lexical detected by ANTLR during initial lexical analysis and parsing.analysis and parsing.nnCode that contains semantic errors Code that contains semantic errors (undefined symbol, type mismatch, missing (undefined symbol, type mismatch, missing return statement, etc.) will be detected by return statement, etc.) will be detected by the semantic analyzer during the final stage the semantic analyzer during the final stage of translation.of translation.Future Directions…Future Directions…nnWe had relatively little time to implement We had relatively little time to implement computercomputer--vision functionality, other than vision functionality, other than some simple pixel color detection, so the some simple pixel color detection, so the ability of MRRoboto programs to actually ability of MRRoboto programs to actually interact with the screen is fairly limited.interact with the screen is fairly limited.nnMore sophisticated means of interaction, More sophisticated means of interaction, perhaps including automatic detection of perhaps including automatic detection of systemsystem--native windowing components, native windowing components, seems to be a likely place for future seems to be a likely place for future
View Full Document