Skip to content

Commit 648d249

Browse files
committed
Added handling of 's in identifiers
1 parent 399629f commit 648d249

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

performance/Sort.lama

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
fun compare (x, y) {
2-
x - y
3-
}
4-
51
fun bubbleSort (l) {
62
fun inner (l) {
73
case l of
84
x : z@(y : tl) ->
9-
if compare (x, y) > 0
5+
if x > y
106
then [true, y : inner (x : tl) [1]]
117
else case inner (z) of [f, z] -> [f, x : z] esac
128
fi
@@ -28,4 +24,4 @@ fun generate (n) {
2824
if n then n : generate (n-1) else {} fi
2925
}
3026

31-
bubbleSort (generate (1000))
27+
bubbleSort (generate (10000))

src/Language.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ module Expr =
582582
eval conf Skip (schedule_list [e; Intrinsic (fun conf -> branch conf bs)])
583583

584584
(* Expression parser. You can use the following terminals:
585-
LIDENT --- a non-empty identifier a-z[a-zA-Z0-9_]* as a string
586-
UIDENT --- a non-empty identifier A-Z[a-zA-Z0-9_]* as a string
585+
LIDENT --- a non-empty identifier a-z[a-zA-Z0-9_']* as a string
586+
UIDENT --- a non-empty identifier A-Z[a-zA-Z0-9_']* as a string
587587
DECIMAL --- a decimal constant [0-9]+ as a string
588588
*)
589589

@@ -604,7 +604,7 @@ module Expr =
604604
match s with
605605
| ":" -> Sexp ("cons", [x; y])
606606
| ":=" -> Assign (x, y)
607-
| "=" -> Binop ("==", Call (Var ("compare"), [x; y]), Const (0))
607+
| "=" -> Binop ("==", Call (Var ("compare"), [x; y]), Const (0))
608608
| _ -> Binop (s, x, y)
609609
in
610610
match x with
@@ -1289,13 +1289,16 @@ let run_parser cmd =
12891289
inherit Util.Lexers.string s
12901290
inherit Util.Lexers.char s
12911291
inherit Util.Lexers.infix s
1292-
inherit Util.Lexers.lident kws s
1292+
inherit Util.Lexers.lident kws s as lident
12931293
inherit Util.Lexers.uident kws s
12941294
inherit Util.Lexers.skip [
12951295
Matcher.Skip.whitespaces " \t\n\r";
12961296
Matcher.Skip.lineComment "--";
12971297
Matcher.Skip.nestedComment "(*" "*)"
12981298
] s
1299+
1300+
method getLIDENT : 'b. (String.t -> 'self -> ('self, 'b, Reason.t) Types.result) -> ('self, 'b, Reason.t) Types.result =
1301+
fun k -> lident#getIdent (fun s self -> k (String.map (function '\'' -> '$' | c -> c) s) self)
12991302
end
13001303
)
13011304
(if cmd#is_workaround then ostap (p:!(constparse cmd) -EOF) else ostap (p:!(parse cmd) -EOF))

0 commit comments

Comments
 (0)