Cedalion: A Language Oriented Programming Language

Transcription

Cedalion:A Language OrientedProgramming LanguageBoaz RosenanDept. of Computer ScienceThe Open University of IsraelJoint Work With:David H. Lorenz

LOP: Middle-Out n)(Application lementationImplementationConciseExpressiveReusable

LOP: Middle-Out n)(Application seDSL6ExpressiveReusable

LOP PlatformsFreedom in definingsyntax and semanticsEasy to implement Haskel Intentional ModelTalk Lisp RubyInternalDSLs MPS?ExternalDSLs(Language Workbench)

Language Design Perspective Haskel ModelTalk Lisp RubyInternalDSLs Intentional MPS

Language Design PerspectiveStaticAnalysis Haskel ModelTalk Lisp Cedalion Intentional MPS RubyInternalDSLsProjectionalEditing

Projectional EditingTraditionalText nProjectionEditingEditingASTModel

A Peek at CedalionDSL DefinitionDSL ImplementationDSL Code (Application Implementation)

Outline Introduction LOP Example Designing an LOP Language Demo Conclusion

Example: LOP with Internal DSLs Task: Implement a parser for a given BNF grammar Steps:SS:: :: aSbaSbSS:: :: 1.Translating the specification into a “parsable” formin our target language, while implicitly defining theDSL.2.Making the code executable by implementing theDSL constructs. We use Prolog as a host language.

Step 1: Formalizing the Spec We use Prolog's (meta) syntax to express thegrammar (our specifications).We define our DSL as we go.TerminalProduction Rules:: [a],s:: [a], s,s, [b].[b].s:: [].s:: [].ConcatenationEmpty String SS:: :: aSbaSbSS:: ::

Step 2: Making It ExecutableSyntactic definition of ':: ':- op(1100, xfx, ':: ').parse([], X, X).parse([T], [T L], L).parse((P1,P2), X, Y) :parse(P1, X, X1),parse(P2, X1, Y).parse(P, X, Y) :(P :: Q),parse(Q, X, Y).Empty StringTerminalConcatenationProduction Ruleparse(P, T, R): succeeds if a prefix of T is derivablefrom P, leaving residue R.

Limitations of Internal DSLs inProlog Syntactic Limitations When fusing several DSLs, operator collisions mayoccur.Semantic Limitations No conformance checking.Mistakenly writing s:: {a},s,{b}instead of s:: [a],s,[b]will result in a bug, not an error.

What is CedalionStaticAnalysisCedalion is iting

The Best of All LispCedalionInternalDSLsProjectionalEditing

Our onalEditingLanguageWorkbenches

Designing an LOP DSLsProjectionalEditing C/C C# Haskell Java Lisp Nemerle Prolog Ruby Smalltalk

Designing an LOP icHomoiconicInternalDSLsProjectionalEditing C/C C# Haskell Java Lisp Nemerle Prolog Ruby Smalltalk

Designing an LOP Editing C/C C# Haskell Java Lisp Nemerle Prolog Ruby Smalltalk

Designing an LOP rnalDSLsProjectionalEditing C/C C# Haskell Java Lisp Nemerle Prolog Ruby Smalltalk

Cedalion An LOP language Statically typed, using Hindley-Milner typeinference, implemented using validators.Uses projectional editing (cannot be edited as text)Based on logic programming Extensible, homoiconic, and dynamicAs its “Domain 0”Comes with a Language Workbench Provides pojectional editing for Cedalion

The Cedalion Workbench Based on Eclipse (3.5).Queries the Cedalion programfor information on how toproject language constructs.

Outline Introduction LOP Example Designing an LOP Language Demo Conclusion

Related Work Meta Programming System Developed by S. Dmitriev at Jetbrains, released2009.Intentional Domain Workbench A language workbench for external DSLs.A language workbench for external DSLs.Developed by C. Simonyi at Intentional Software,not released yet.ModelTalk/Ink A language workbench for XML-based internalDSLs. Used internally at Pontis.[A. Hen-Tov, D. H. Lorenz and L. Shachter,2009].

Conclusion Cedalion is a proof of concept Provides the ease of defining internal DSLs.Provides full control in defining syntax andsemantics.Future Work Making Cedalion ready for “prime time”.Case studies: Solve real-life problems withCedalion.Evaluating other base semantics.

Thank You Cedalion z Rosenan boaz@nansore.net oaz RosenanDavid H. Lorenz lorenz@openu.ac.il http://www.openu.ac.il/home/lorenz/

Related Work Meta Programming System A language workbench for external DSLs. Developed by S. Dmitriev at Jetbrains, released 2009. Intentional Domain Workbench A language workbench for external DSLs. Developed by C. Simonyi at Intentional Software, not released yet. ModelTalk/Ink A language workbench for XML-based internal DSLs. Used internally at Po