Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14EcoSLEcoSLLalit K KantetiLalit K KantetiSomenathSomenathSrinivasSrinivasEconomical Spreadsheet LanguageFeeling like this??Feeling like this??Image from: www.spreadsheet-factory.com/presentation.htmlWe have EcoSL for you!!We have EcoSL for you!!Image from: www.spreadsheet-factory.com/presentation.htmlWhat’s this Language?What’s this Language?A language which allows users to manipulate on sets of data A language which allows users to manipulate on sets of data in a spreadsheet like mannerin a spreadsheet like mannerKey features of Spreadsheets: Data InterpretationsKey features of Spreadsheets: Data InterpretationsSoftware should be more than Scientific CalSoftware should be more than Scientific CalMathematical Computations on dataMathematical Computations on dataGraphical representationsGraphical representationsNo need to know too much of Programming conceptsNo need to know too much of Programming conceptsEcoSL was motivated and had started with above goalsEcoSL was motivated and had started with above goalsEcoSL is not a compiler. It’s an InterpreterEcoSL is not a compiler. It’s an InterpreterTired of hello world? Let’s have some different fodder for the Tired of hello world? Let’s have some different fodder for the newbie!newbie!{{ /*/* * A Sample program* A Sample program */ */ func max(a,b){func max(a,b){ if (a>=b)if (a>=b) return a;return a; else else return b;return b;} } [1:2] = 2;[1:2] = 2;[3:5] = 6;[3:5] = 6;max(5,99);max(5,99);c = max(5,99);c = max(5,99); println(c);println(c); print(max([1:2],[3:5]));print(max([1:2],[3:5]));} } The adjacent sample program The adjacent sample program prints the following outputprints the following output 9999 66Does the previous code look cool. Guess why???Does the previous code look cool. Guess why???•EcoSL is characterized by a simple syntax. EcoSL is characterized by a simple syntax. •[x:y] defines a basic unit of computation in a spreadsheet [x:y] defines a basic unit of computation in a spreadsheet called a cellcalled a cell•Not to annoy the seasoned programmer we also support the Not to annoy the seasoned programmer we also support the traditional identifiers. traditional identifiers. •Built in functions of Sigma, Avg, Print, PrintlnBuilt in functions of Sigma, Avg, Print, Println•In addition the user can easily define any functionIn addition the user can easily define any function of his choiceof his choiceObserveObserveNo declarations for identifiersNo declarations for identifiersNo return type defined for functionsNo return type defined for functionsBuilt-in functions synonymous to mathematical operationsBuilt-in functions synonymous to mathematical operationsConverts stream of program input to tokensConverts stream of program input to tokensAn example comment matching ruleAn example comment matching rule COMMENT: "/*" ( COMMENT: "/*" ( options { generateAmbigWarnings = options { generateAmbigWarnings = false; }: { LA(2) != '/' }? '*'false; }: { LA(2) != '/' }? '*'| "\r\n"{ newline(); }| "\r\n"{ newline(); }| ( '\r' | '\n' ){ newline(); }| ( '\r' | '\n' ){ newline(); }| ~( '*'| '\r' | '\n' )| ~( '*'| '\r' | '\n' ))* "*/"{ $setType(Token.SKIP); })* "*/"{ $setType(Token.SKIP); };;EcoSL-LexerEcoSL-LexerEcosl ParserEcosl Parser Our entry point into the parser is Our entry point into the parser is shown belowshown belowprogram: LBRACE! (statement)+ program: LBRACE! (statement)+ RBRACE! { RBRACE! { #program = #([PROGRAM, #program = #([PROGRAM, "program"], program);"program"], program); } ;} ;Some key parser productionsSome key parser productionsStatement : ……Statement : …… | (LBRACE! (statement)+ | (LBRACE! (statement)+ RBRACE!) {RBRACE!) { #statement = #([STMT_BLOCK, #statement = #([STMT_BLOCK, "stmt_block"], statement); "stmt_block"], statement); }) }) Contd…Contd…func_decl : func_decl : "func"! ID LPAREN! (formal_args)* "func"! ID LPAREN! (formal_args)* RPAREN! LBRACE! (statement)* RPAREN! LBRACE! (statement)* RBRACE! {RBRACE! { #func_decl = #([FUNC_DECL, #func_decl = #([FUNC_DECL, "func_decl"], func_decl);"func_decl"], func_decl); } ;} ;coordinate : coordinate : LBRAC! (expr) COLON! (expr) RBRAC!LBRAC! (expr) COLON! (expr) RBRAC!{ { #coordinate = #([COORDINATE, #coordinate = #([COORDINATE, "coordinate"] , coordinate); "coordinate"] , coordinate); }}Walker – Ecosl runs!!!Walker – Ecosl runs!!!program program returnsreturns [Program prog] [Program prog] { prog={ prog=nullnull;Stmt s = ;Stmt s = nullnull; }; } : #(PROGRAM { prog = : #(PROGRAM { prog = newnew Program();} Program();} (s = statement (s = statement {{ prog.addStmt(s); prog.addStmt(s); }} )*)* ););#(FUNC_DECL ID (args=formal_args)?#(FUNC_DECL ID (args=formal_args)?{{ s1 = s1 = newnew StmtBlock(); StmtBlock();} } (s2=statement (s2=statement { ((StmtBlock)s1).addStmt(s{ ((StmtBlock)s1).addStmt(s2); }2); } )*)* {{ s = s = newnew FunctionDecl (#ID.getText(), args, s1); FunctionDecl (#ID.getText(), args, s1); }}formal_args formal_args returnsreturns [java.util.Vector [java.util.Vector formalArgs]formalArgs]{formalArgs = {formalArgs = nullnull; }; } : #(FORMAL_ARGS : #(FORMAL_ARGS { formalArgs = { formalArgs = newnew java.util.Vector(); } java.util.Vector(); } (ID { formalArgs.add ((ID { formalArgs.add (newnew Variable(#ID.getText())); })*);Variable(#ID.getText())); })*);#(COORDINATE a=expr b=expr {#(COORDINATE a=expr b=expr { e = e = newnew Coordinate(a, b); Coordinate(a, b); } } ) )ProgramStatementsExpr StatementWhile For BreakIfContinuePlus Minus Mod Func Call Variable IntConstant....................Looking for the same old features?? It is there in EcoSL!!Looking for the same old features?? It is there in EcoSL!!User defined functionsUser defined functionsBuilt-in functionsBuilt-in functionsIterations (while, for)Iterations (while, for)CommentsCommentsConditional statements (if else)Conditional statements (if else)ScopeScopeData types (Integer, float)Data types (Integer, float)Basic arithmetic operationsBasic arithmetic operationsBreak,continueBreak,continueLooking for the something new?? It is there in
View Full Document