Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stratego Song Zhou *Include slides from language.org/Stratego/SlidesForSoftwareGeneration2001http://www.stratego- language.org/Stratego/SlidesForSoftwareGeneration2001.

Similar presentations


Presentation on theme: "Stratego Song Zhou *Include slides from language.org/Stratego/SlidesForSoftwareGeneration2001http://www.stratego- language.org/Stratego/SlidesForSoftwareGeneration2001."— Presentation transcript:

1 Stratego Song Zhou *Include slides from http://www.stratego- language.org/Stratego/SlidesForSoftwareGeneration2001http://www.stratego- language.org/Stratego/SlidesForSoftwareGeneration2001

2 Introduction  Stratego is “ a language for the specification of transformation systems based on the paradigm of program rewriting strategies ”.  Basic components: Rules: basic transformation steps Strategies: control application of rules

3 Stratego/XT  Stratego is only a term-rewriting language. “ Term in, Term out. ” XT can combine Stratego with other tools to create a transformation system.  Front End: SGLR: a generic parser creating syntax tree  Back End: GPP: a generic pretty-printer to emit the syntax tree out  Communication Language Aterm: a term exchange format

4 Transformation Rules

5 Outline

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28 Transformation Strategies

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44 Traversal

45

46

47

48

49

50

51

52

53

54

55

56

57

58 First-Class Pattern Matching

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76 Scoped Dynamic Rewrite Rules

77

78

79

80

81

82

83

84

85

86

87

88 Concrete Object Syntax

89 What is wrong with Abstract Syntax  Problems Easy for computer to process Difficult for human being to read and write Maybe to verbose to be specified  Solution Directly employ the concrete object syntax to specify the rewriting rules in Stratego

90 Mix an Object Language With a Meta Language  Object Language inside Meta Language: Extending Meta Language with a quotation operator that lets the meta-programmer indicate object language fragments.  Meta Language inside Object Language: Antiquotation allows the use of meta-programming language constructs in these object language fragments to splice meta-computed object code into a fragment.  If Meta Language equals Object Language then the syntax extension is easy by just adding quote and antiquote operators to Meta Language.

91 Example  EvalPlus : |[ i + j ]| -> |[ k ]| where (i, j) => k  TraceProcedure : |[ function ~f(~* xs) = ~e ]| -> |[ function ~f(~* xs) = (print(~String( (f," entry\\n"))); ~e; print(~String( (f,"exit\\n"))))]|

92 Syntax Definition Formalism  Both the Stratego syntax and the object language syntax is specified using the Syntax Definition Formalism (SDF)  An SDF production sym 1... sym n -> sym declares that an expression of sort sym can be constructed by the concatenation of expressions of sorts sym 1 to sym n.  SDF supports regular expression operators such as {Exp ";"}*, which denotes a list of Expressions separated by ; semicolons.  SDF integrates the definition of lexical and context-free syntax in one formalism.  The formalism is modular the syntax definition of a language can be divided into smaller (reusable) modules syntax definitions for separate languages can easily be combined.

93 Stratego Syntax Definition in SDF

94 Tiger Syntax Definition in SDF

95 Corresponding Abstract Syntax Signature

96 Syntax Combination  The object language syntax definition can be imported into Stratego syntax definition  We also need define an additional combinationial syntax definiton, to specify the glues (quotation mark and antiquotaion mark)

97 Example of Combinational Syntax Definition

98 Theoretical Problems  Only full class of CFG have closure property. LL, LR and other subclasses of CFG are not closed under composition.  SDF2 supports scannerless generalized-LR parsing

99 Meta-Explode  Convert concrete object syntax term into Stratego syntax term

100 Generic Definition of Meta-explode

101 Summarize  Rules rewriting  Transformation strategy  First-Class Pattern Matching  Scoped Dynamic Rewrite Rules  Concrete Object Syntax


Download ppt "Stratego Song Zhou *Include slides from language.org/Stratego/SlidesForSoftwareGeneration2001http://www.stratego- language.org/Stratego/SlidesForSoftwareGeneration2001."

Similar presentations


Ads by Google