Skip to content

webdsl-regex.stx

pdmosses/webdsl-statix/webdslstatix/trans/static-semantics/webdsl-regex.stx

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
module static-semantics/webdsl-regex

imports
  static-semantics/types/built-ins

  static-semantics/webdsl

rules

  typeOfExp(s, RegexCall(_, f, args)) = UNTYPED() :- { argTypes }
    false | error $[Cannot resolve Regex Call [f]],
    argTypes == typesOfExps(s, args).

  typeOfExp(, RegexCall(_, "find", args)) = bool(s) :- { }
    ts == [string(s)],
    argTypes == typesOfExps(s, args),
    typesCompatible(argTypes, ts) == TRUE() | error $[Given argument types not compatible with page definition. Got [argTypes] but expected [ts]].

  typeOfExp(s, RegexCall(_, "match", args)) = bool() :- { }
    ts == [string(s)],
    argTypes == typesOfExps(s, args),
    typesCompatible(argTypes, ts) == TRUE() | error $[Given argument types not compatible with page definition. Got [argTypes] but expected [ts]].

  typeOfExp(, RegexCall(_, "split", args)) = LIST(string(s)) :- { }
    ts == [string(s)],
    argTypes == typesOfExps(s, args),
    typesCompatible(argTypes, ts) == TRUE() | error $[Given argument types not compatible with page definition. Got [argTypes] but expected [ts]].

  typeOfExp(, RegexCall(_, "replaceAll", args)) = string(s) :- { }
    ts == [string(s), string(s)],
    argTypes == typesOfExps(s, args),
    typesCompatible(argTypes, ts) == TRUE() | error $[Given argument types not compatible with page definition. Got [argTypes] but expected [ts]].

  typeOfExp(, RegexCall(_, "replaceFirst", args)) = string(s) :- { }
    ts == [string(s), string(s)],
    argTypes == typesOfExps(s, args),
    typesCompatible(argTypes, ts) == TRUE() | error $[Given argument types not compatible with page definition. Got [argTypes] but expected [ts]].