Skip to content

Sorts.sdf3

pdmosses/sdf/org.metaborg.meta.lang.template/syntax/sorts/Sorts.sdf3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module 

imports kernel/Kernel
symbols/Symbols
basic/Basic
regular/Regular

lexical syntax
  //head:[A-Z] -> Sort {cons("one-char")}
  .OneChar = [A-Z]
  //head:[A-Z] middle:[A-Za-z0-9\_\-]* last:[A-Za-z0-9] -> Sort {cons("more-chars")}
  .MoreChars = [A-Z] [A-Za-z0-9\_\-]* [A-Za-z0-9]

context-free syntax
.Sort = <<Sort>>
.ParameterizedSort = <<Sort> [[<parameters:{Symbol ", "}+>]]>
.SortDef = <<Sort>> {prefer}
.Cf      = <<SymbolDef>-CF> {prefer}
.Lex     = <<SymbolDef>-LEX> {prefer}
.Var     = <<SymbolDef>-VAR> {prefer}

DeclSort.DeclSort    = <<Sort>>     // context-free
DeclSort.DeclSortCf  = <<Sort>-CF>  // desugared to DeclSort
DeclSort.DeclSortLex = <<Sort>-LEX>
DeclSort.DeclSortVar = <<Sort>-VAR>


Grammar.Sorts = <
  sorts <DeclSort*>

    >
Grammar.LexSorts = /* desugared */ <
  lexical sorts <Sort*>

    >
Grammar.CfSorts = /* desugared */ <
  context-free sorts <Sort*>

    >
Grammar.VarSorts = /* desugared */ <
  variable sorts <Sort*>

    >

lexical restrictions
    Sort -/- [A-Za-z0-9\_]

context-free priorities

{ SymbolDef.Cf SymbolDef.Lex SymbolDef.Var Symbol.Cf Symbol.Lex Symbol.Varsym} > Symbol.Alt