Skip to content

Commit 5248f1e

Browse files
authored
Merge pull request #7 from codinuum/develop
Develop
2 parents d4de60f + 6cd32c8 commit 5248f1e

File tree

6 files changed

+47
-14
lines changed

6 files changed

+47
-14
lines changed

src/ast/analyzing/common/edit_base.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,8 @@ class ['node_t, 'tree_t] seq_base options = object (self : 'edits)
13631363
let n2 = Info.get_node info2 in
13641364
n1#data#is_named_orig && n2#data#is_named_orig ||
13651365
(not n1#data#is_named && n2#data#is_named || n1#data#is_named && not n2#data#is_named) ||
1366-
n1#data#more_anonymized_label <> n2#data#more_anonymized_label
1366+
(not (n1#data#is_compatible_with n2#data) &&
1367+
n1#data#more_anonymized_label <> n2#data#more_anonymized_label)
13671368
in
13681369
if ok then begin
13691370
let loc1 = Info.get_loc info1 in

src/ast/analyzing/langs/common/astloc.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ let merge loc0 loc1 =
227227
loc
228228
end
229229

230-
let collapse_forward
230+
let collapse_forward ?(len=1)
231231
{ filename = fn0;
232232
start_offset = so0;
233233
end_offset = eo0;
@@ -239,14 +239,14 @@ let collapse_forward
239239
=
240240
{ filename = fn0;
241241
start_offset = so0;
242-
end_offset = so0;
242+
end_offset = so0+len-1;
243243
start_line = sl0;
244244
start_char = sc0;
245245
end_line = sl0;
246-
end_char = sc0;
246+
end_char = sc0+len-1;
247247
}
248248

249-
let collapse_backward
249+
let collapse_backward ?(len=1)
250250
{ filename = fn0;
251251
start_offset = so0;
252252
end_offset = eo0;
@@ -257,10 +257,10 @@ let collapse_backward
257257
}
258258
=
259259
{ filename = fn0;
260-
start_offset = eo0;
260+
start_offset = eo0-len+1;
261261
end_offset = eo0;
262262
start_line = el0;
263-
start_char = ec0;
263+
start_char = ec0-len+1;
264264
end_line = el0;
265265
end_char = ec0;
266266
}

src/ast/analyzing/langs/common/astloc.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ val start_to_string : ?show_ext:bool -> ?short:bool -> ?prefix:string -> ?suffix
4242
val end_to_string : ?show_ext:bool -> ?short:bool -> ?prefix:string -> ?suffix:string -> t -> string
4343
val normalize_fname : string -> string
4444
val merge : t -> t -> t
45-
val collapse_forward : t -> t
46-
val collapse_backward : t -> t
45+
val collapse_forward : ?len:int -> t -> t
46+
val collapse_backward : ?len:int -> t -> t
4747
val widen : t -> int -> t
4848
val is_contained : t -> t -> bool
4949
val to_offsets : t -> (int * int)

src/ast/analyzing/langs/fortran/parsing/src/tokenbuffer.ml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ module F (Stat : Aux.STATE_T) = struct
400400
else
401401
raise Not_found
402402

403+
let toxxx_pat = Str.regexp "to\\([0-9]+\\)$"
403404

404405
let hack_token (tokensrc : Tokensource.c) ((_tok, _loc) as _qtoken) =
405406
let loc = ref _loc in
@@ -1120,8 +1121,27 @@ module F (Stat : Aux.STATE_T) = struct
11201121
end
11211122
else begin (* not env#in_format_context *)
11221123
if is_head_of_stmt_ then begin
1123-
DEBUG_MSG "<identifier> --> <pp-identifier>";
1124-
tok := PP_IDENTIFIER s0
1124+
if
1125+
env#current_source#lang_config#is_fixed_source_form &&
1126+
String.lowercase_ascii s0 = "go" &&
1127+
Str.string_match toxxx_pat (String.lowercase_ascii s0') 0
1128+
then begin
1129+
DEBUG_MSG "GO TO<x> --> GO_TO <x>";
1130+
let _, l0 = discard() in
1131+
let l' = Loc.collapse_backward ~len:2 l0 in
1132+
tokensrc#prepend (INT_LITERAL (Str.matched_group 1 s0'), l');
1133+
let s_ =
1134+
s0^
1135+
(String.make (l0.Loc.start_offset-(!loc).Loc.end_offset-1) ' ')^
1136+
(String.sub s0' 0 2)
1137+
in
1138+
tok := GO_TO s_;
1139+
loc := merge_locs !loc (Loc.collapse_forward ~len:2 l0)
1140+
end
1141+
else begin
1142+
DEBUG_MSG "<identifier> --> <pp-identifier>";
1143+
tok := PP_IDENTIFIER s0
1144+
end
11251145
end
11261146
else begin
11271147
let is_kind_size =

src/ast/analyzing/langs/java/java_label.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,9 @@ let is_compatible lab1 lab2 =
24502450
| Primary p1, Primary p2 -> Primary.is_compatible p1 p2
24512451
| Method(n1, _), Method(n2, _) -> n1 = n2
24522452
| Constructor(n1, _), Constructor(n2, _) -> n1 = n2
2453+
| ClassBody _, InterfaceBody _ | InterfaceBody _, ClassBody _ -> true
2454+
| ClassBody _, EnumBody _ | EnumBody _, ClassBody _ -> true
2455+
| EnumBody _, InterfaceBody _ | InterfaceBody _, EnumBody _ -> true
24532456
| _ -> false
24542457

24552458
let quasi_eq lab1 lab2 =
@@ -2611,6 +2614,7 @@ let is_named = function
26112614
| ClassBody _
26122615
| EnumBody _
26132616
| Interface _
2617+
| Specifier _
26142618
| AnnotationType _
26152619
| AnnotationTypeBody _
26162620
| InterfaceBody _
@@ -2646,7 +2650,8 @@ let is_named_orig = function
26462650
| Class _
26472651
| Enum _
26482652
| EnumConstant _
2649-
| Interface _
2653+
| Interface _
2654+
| Specifier _
26502655
| AnnotationType _
26512656
| ElementDeclaration _
26522657
| PackageDeclaration _

src/ast/analyzing/langs/java/parsing/src/ulexer.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,16 @@ module F (Stat : Parser_aux.STATE_T) = struct
315315
raise EOF_reached
316316

317317
| _ ->
318-
lexing_error lexbuf (Printf.sprintf "invalid symbol(%s)" (Ulexing.utf8_lexeme lexbuf))
319-
318+
let s = Ulexing.utf8_lexeme lexbuf in
319+
if env#keep_going_flag then begin
320+
let loc = offsets_to_loc (Ulexing.lexeme_start lexbuf) (Ulexing.lexeme_end lexbuf) in
321+
Common.warning_loc loc "invalid symbol(%s)" s;
322+
token lexbuf
323+
end
324+
else
325+
lexing_error lexbuf (Printf.sprintf "invalid symbol(%s)" s)
320326

327+
321328

322329
and traditional_comment st = lexer
323330
| "*/" -> env#comment_regions#add (env#current_pos_mgr#offsets_to_loc st (Ulexing.lexeme_end lexbuf))

0 commit comments

Comments
 (0)