swh:1:snp:e3b0b9991945262e7cc28768373af4560caf7afa
Raw File
Tip revision: ad0c16675d221938530269610308cd5a2c142687 authored by Software Heritage on 17 October 2018, 13:20:37 UTC
hal: Deposit 205 in collection hal
Tip revision: ad0c166
nesting.ml
(**************************************************************************)
(*  -*- tuareg -*-                                                        *)
(*                                                                        *)
(*  Copyright (C) 2017,2018 Yann RĂ©gis-Gianas, Nicolas Jeannerod,         *)
(*  Ralf Treinen.                                                         *)
(*                                                                        *)
(*  This is free software: you can redistribute it and/or modify it       *)
(*  under the terms of the GNU General Public License, version 3.         *)
(*                                                                        *)
(*  Additional terms apply, due to the reproduction of portions of        *)
(*  the POSIX standard. Please refer to the file COPYING for details.     *)
(**************************************************************************)

type t =
  | Backquotes of char * int
  | Parentheses
  | Braces
  | DQuotes
  | HereDocument of bool * string

let to_string = function
  | Backquotes (c, level) ->
     Printf.sprintf "@%c[%d]" c level
  | Parentheses ->
     "("
  | Braces ->
     "{"
  | DQuotes ->
     "\""
  | HereDocument (dashed, delimiter) ->
     Printf.sprintf "HereDoc[%B, %s]" dashed delimiter

let string_of_level l = String.concat " : " (List.map to_string l)

let rec under_backquoted_style_command_substitution = function
  | [] -> false
  | Backquotes ('`', _) :: _ -> true
  | Backquotes ('(', _) :: _ -> false
  | _ :: level -> under_backquoted_style_command_substitution level
back to top