code:
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects

scriptversion=2013-05-30.07; # UTC

# Copyright (C) 1999-2013 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.

case $1 in
  '')
    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
    exit 1;
    ;;
  -h | --h*)
    cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]

Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.

Environment variables:
  depmode     Dependency tracking mode.
  source      Source file read by 'PROGRAMS ARGS'.
  object      Object file output by 'PROGRAMS ARGS'.
  DEPDIR      directory where to store dependencies.
  depfile     Dependency file to output.
  tmpdepfile  Temporary file to use when outputting dependencies.
  libtool     Whether libtool is used (yes/no).

Report bugs to <bug-automake@gnu.org>.
EOF
    exit $?
    ;;
  -v | --v*)
    echo "depcomp $scriptversion"
    exit $?
    ;;
esac

# Get the directory component of the given path, and save it in the
# global variables '$dir'.  Note that this directory component will
# be either empty or ending with a '/' character.  This is deliberate.
set_dir_from ()
{
  case $1 in
    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
      *) dir=;;
  esac
}

# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}

# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
  echo "#dummy" > "$depfile"
}

# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
  # If the compiler actually managed to produce a dependency file,
  # post-process it.
  if test -f "$tmpdepfile"; then
    # Each line is of the form 'foo.o: dependency.h'.
    # Do two passes, one to just change these to
    #   $object: dependency.h
    # and one to simply output
    #   dependency.h:
    # which is needed to avoid the deleted-header problem.
    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
    } > "$depfile"
    rm -f "$tmpdepfile"
  else
    make_dummy_depfile
  fi
}

# A tabulation character.
tab='	'
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}

if test -z "$depmode" || test -z "$source" || test -z "$object"; then
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
  exit 1
fi

# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}

rm -f "$tmpdepfile"

# Avoid interferences from the environment.
gccflag= dashmflag=

# Some modes work just like other modes, but use different flags.  We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write.  Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
  # HP compiler uses -M and no extra arg.
  gccflag=-M
  depmode=gcc
fi

if test "$depmode" = dashXmstdout; then
  # This is just like dashmstdout with a different argument.
  dashmflag=-xM
  depmode=dashmstdout
fi

cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
  # This is just like msvisualcpp but w/o cygpath translation.
  # Just convert the backslash-escaped backslashes to single forward
  # slashes to satisfy depend.m4
  cygpath_u='sed s,\\\\,/,g'
  depmode=msvisualcpp
fi

if test "$depmode" = msvc7msys; then
  # This is just like msvc7 but w/o cygpath translation.
  # Just convert the backslash-escaped backslashes to single forward
  # slashes to satisfy depend.m4
  cygpath_u='sed s,\\\\,/,g'
  depmode=msvc7
fi

if test "$depmode" = xlc; then
  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
  gccflag=-qmakedep=gcc,-MF
  depmode=gcc
fi

case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff.  Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am.  Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
  for arg
  do
    case $arg in
    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
    *)  set fnord "$@" "$arg" ;;
    esac
    shift # fnord
    shift # $arg
  done
  "$@"
  stat=$?
  if test $stat -ne 0; then
    rm -f "$tmpdepfile"
    exit $stat
  fi
  mv "$tmpdepfile" "$depfile"
  ;;

gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc.  Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
##   up in a subdir.  Having to rename by hand is ugly.
##   (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
##   -MM, not -M (despite what the docs say).  Also, it might not be
##   supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
##   than renaming).
  if test -z "$gccflag"; then
    gccflag=-MD,
  fi
  "$@" -Wp,"$gccflag$tmpdepfile"
  stat=$?
  if test $stat -ne 0; then
    rm -f "$tmpdepfile"
    exit $stat
  fi
  rm -f "$depfile"
  echo "$object : \\" > "$depfile"
  # The second -e expression handles DOS-style file names with drive
  # letters.
  sed -e 's/^[^:]*: / /' \
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header).  We avoid this by adding
## dummy dependencies for each header file.  Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'.  On the theory
## that the space means something, we add a space to the output as
## well.  hp depmode also adds that space, but also prefixes the VPATH
## to the object.  Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly.  Breaking it into two sed invocations is a workaround.
  tr ' ' "$nl" < "$tmpdepfile" \
    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
    | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

hp)
  # This case exists only to let depend.m4 do its work.  It works by
  # looking at the text of this script.  This case will never be run,
  # since it is checked for above.
  exit 1
  ;;

xlc)
  # This case exists only to let depend.m4 do its work.  It works by
  # looking at the text of this script.  This case will never be run,
  # since it is checked for above.
  exit 1
  ;;

aix)
  # The C for AIX Compiler uses -M and outputs the dependencies
  # in a .u file.  In older versions, this file always lives in the
  # current directory.  Also, the AIX compiler puts '$object:' at the
  # start of each line; $object doesn't have directory information.
  # Version 6 uses the directory in both cases.
  set_dir_from "$object"
  set_base_from "$object"
  if test "$libtool" = yes; then
    tmpdepfile1=$dir$base.u
    tmpdepfile2=$base.u
    tmpdepfile3=$dir.libs/$base.u
    "$@" -Wc,-M
  else
    tmpdepfile1=$dir$base.u
    tmpdepfile2=$dir$base.u
    tmpdepfile3=$dir$base.u
    "$@" -M
  fi
  stat=$?
  if test $stat -ne 0; then
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
    exit $stat
  fi

  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
  do
    test -f "$tmpdepfile" && break
  done
  aix_post_process_depfile
  ;;

tcc)
  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
  # FIXME: That version still under development at the moment of writing.
  #        Make that this statement remains true also for stable, released
  #        versions.
  # It will wrap lines (doesn't matter whether long or short) with a
  # trailing '\', as in:
  #
  #   foo.o : \
  #    foo.c \
  #    foo.h \
  #
  # It will put a trailing '\' even on the last line, and will use leading
  # spaces rather than leading tabs (at least since its commit 0394caf7
  # "Emit spaces for -MD").
  "$@" -MD -MF "$tmpdepfile"
  stat=$?
  if test $stat -ne 0; then
    rm -f "$tmpdepfile"
    exit $stat
  fi
  rm -f "$depfile"
  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
  # We have to change lines of the first kind to '$object: \'.
  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
  # And for each line of the second kind, we have to emit a 'dep.h:'
  # dummy dependency, to avoid the deleted-header problem.
  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file.  A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
  # Portland's C compiler understands '-MD'.
  # Will always output deps to 'file.d' where file is the root name of the
  # source file under compilation, even if file resides in a subdirectory.
  # The object file name does not affect the name of the '.d' file.
  # pgcc 10.2 will output
  #    foo.o: sub/foo.c sub/foo.h
  # and will wrap long lines using '\' :
  #    foo.o: sub/foo.c ... \
  #     sub/foo.h ... \
  #     ...
  set_dir_from "$object"
  # Use the source, not the object, to determine the base name, since
  # that's sadly what pgcc will do too.
  set_base_from "$source"
  tmpdepfile=$base.d

  # For projects that build the same source file twice into different object
  # files, the pgcc approach of using the *source* file root name can cause
  # problems in parallel builds.  Use a locking strategy to avoid stomping on
  # the same $tmpdepfile.
  lockdir=$base.d-lock
  trap "
    echo '$0: caught signal, cleaning up...' >&2
    rmdir '$lockdir'
    exit 1
  " 1 2 13 15
  numtries=100
  i=$numtries
  while test $i -gt 0; do
    # mkdir is a portable test-and-set.
    if mkdir "$lockdir" 2>/dev/null; then
      # This process acquired the lock.
      "$@" -MD
      stat=$?
      # Release the lock.
      rmdir "$lockdir"
      break
    else
      # If the lock is being held by a different process, wait
      # until the winning process is done or we timeout.
      while test -d "$lockdir" && test $i -gt 0; do
        sleep 1
        i=`expr $i - 1`
      done
    fi
    i=`expr $i - 1`
  done
  trap - 1 2 13 15
  if test $i -le 0; then
    echo "$0: failed to acquire lock after $numtries attempts" >&2
    echo "$0: check lockdir '$lockdir'" >&2
    exit 1
  fi

  if test $stat -ne 0; then
    rm -f "$tmpdepfile"
    exit $stat
  fi
  rm -f "$depfile"
  # Each line is of the form `foo.o: dependent.h',
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
  # Do two passes, one to just change these to
  # `$object: dependent.h' and one to simply `dependent.h:'.
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
  # Some versions of the HPUX 10.20 sed can't process this invocation
  # correctly.  Breaking it into two sed invocations is a workaround.
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
    | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

hp2)
  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
  # compilers, which have integrated preprocessors.  The correct option
  # to use with these is +Maked; it writes dependencies to a file named
  # 'foo.d', which lands next to the object file, wherever that
  # happens to be.
  # Much of this is similar to the tru64 case; see comments there.
  set_dir_from  "$object"
  set_base_from "$object"
  if test "$libtool" = yes; then
    tmpdepfile1=$dir$base.d
    tmpdepfile2=$dir.libs/$base.d
    "$@" -Wc,+Maked
  else
    tmpdepfile1=$dir$base.d
    tmpdepfile2=$dir$base.d
    "$@" +Maked
  fi
  stat=$?
  if test $stat -ne 0; then
     rm -f "$tmpdepfile1" "$tmpdepfile2"
     exit $stat
  fi

  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
  do
    test -f "$tmpdepfile" && break
  done
  if test -f "$tmpdepfile"; then
    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
    # Add 'dependent.h:' lines.
    sed -ne '2,${
               s/^ *//
               s/ \\*$//
               s/$/:/
               p
             }' "$tmpdepfile" >> "$depfile"
  else
    make_dummy_depfile
  fi
  rm -f "$tmpdepfile" "$tmpdepfile2"
  ;;

tru64)
  # The Tru64 compiler uses -MD to generate dependencies as a side
  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
  # dependencies in 'foo.d' instead, so we check for that too.
  # Subdirectories are respected.
  set_dir_from  "$object"
  set_base_from "$object"

  if test "$libtool" = yes; then
    # Libtool generates 2 separate objects for the 2 libraries.  These
    # two compilations output dependencies in $dir.libs/$base.o.d and
    # in $dir$base.o.d.  We have to check for both files, because
    # one of the two compilations can be disabled.  We should prefer
    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
    # automatically cleaned when .libs/ is deleted, while ignoring
    # the former would cause a distcleancheck panic.
    tmpdepfile1=$dir$base.o.d          # libtool 1.5
    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
    "$@" -Wc,-MD
  else
    tmpdepfile1=$dir$base.d
    tmpdepfile2=$dir$base.d
    tmpdepfile3=$dir$base.d
    "$@" -MD
  fi

  stat=$?
  if test $stat -ne 0; then
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
    exit $stat
  fi

  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
  do
    test -f "$tmpdepfile" && break
  done
  # Same post-processing that is required for AIX mode.
  aix_post_process_depfile
  ;;

msvc7)
  if test "$libtool" = yes; then
    showIncludes=-Wc,-showIncludes
  else
    showIncludes=-showIncludes
  fi
  "$@" $showIncludes > "$tmpdepfile"
  stat=$?
  grep -v '^Note: including file: ' "$tmpdepfile"
  if test $stat -ne 0; then
    rm -f "$tmpdepfile"
    exit $stat
  fi
  rm -f "$depfile"
  echo "$object : \\" > "$depfile"
  # The first sed program below extracts the file names and escapes
  # backslashes for cygpath.  The second sed program outputs the file
  # name when reading, but also accumulates all include files in the
  # hold buffer in order to output them again at the end.  This only
  # works with sed implementations that can handle large buffers.
  sed < "$tmpdepfile" -n '
/^Note: including file:  *\(.*\)/ {
  s//\1/
  s/\\/\\\\/g
  p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
  s/.*/'"$tab"'/
  G
  p
}' >> "$depfile"
  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
  rm -f "$tmpdepfile"
  ;;

msvc7msys)
  # This case exists only to let depend.m4 do its work.  It works by
  # looking at the text of this script.  This case will never be run,
  # since it is checked for above.
  exit 1
  ;;

#nosideeffect)
  # This comment above is used by automake to tell side-effect
  # dependency tracking mechanisms from slower ones.

dashmstdout)
  # Important note: in order to support this mode, a compiler *must*
  # always write the preprocessed file to stdout, regardless of -o.
  "$@" || exit $?

  # Remove the call to Libtool.
  if test "$libtool" = yes; then
    while test "X$1" != 'X--mode=compile'; do
      shift
    done
    shift
  fi

  # Remove '-o $object'.
  IFS=" "
  for arg
  do
    case $arg in
    -o)
      shift
      ;;
    $object)
      shift
      ;;
    *)
      set fnord "$@" "$arg"
      shift # fnord
      shift # $arg
      ;;
    esac
  done

  test -z "$dashmflag" && dashmflag=-M
  # Require at least two characters before searching for ':'
  # in the target name.  This is to cope with DOS-style filenames:
  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
  "$@" $dashmflag |
    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
  rm -f "$depfile"
  cat < "$tmpdepfile" > "$depfile"
  # Some versions of the HPUX 10.20 sed can't process this sed invocation
  # correctly.  Breaking it into two sed invocations is a workaround.
  tr ' ' "$nl" < "$tmpdepfile" \
    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
    | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

dashXmstdout)
  # This case only exists to satisfy depend.m4.  It is never actually
  # run, as this mode is specially recognized in the preamble.
  exit 1
  ;;

makedepend)
  "$@" || exit $?
  # Remove any Libtool call
  if test "$libtool" = yes; then
    while test "X$1" != 'X--mode=compile'; do
      shift
    done
    shift
  fi
  # X makedepend
  shift
  cleared=no eat=no
  for arg
  do
    case $cleared in
    no)
      set ""; shift
      cleared=yes ;;
    esac
    if test $eat = yes; then
      eat=no
      continue
    fi
    case "$arg" in
    -D*|-I*)
      set fnord "$@" "$arg"; shift ;;
    # Strip any option that makedepend may not understand.  Remove
    # the object too, otherwise makedepend will parse it as a source file.
    -arch)
      eat=yes ;;
    -*|$object)
      ;;
    *)
      set fnord "$@" "$arg"; shift ;;
    esac
  done
  obj_suffix=`echo "$object" | sed 's/^.*\././'`
  touch "$tmpdepfile"
  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
  rm -f "$depfile"
  # makedepend may prepend the VPATH from the source file name to the object.
  # No need to regex-escape $object, excess matching of '.' is harmless.
  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
  # Some versions of the HPUX 10.20 sed can't process the last invocation
  # correctly.  Breaking it into two sed invocations is a workaround.
  sed '1,2d' "$tmpdepfile" \
    | tr ' ' "$nl" \
    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
    | sed -e 's/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile" "$tmpdepfile".bak
  ;;

cpp)
  # Important note: in order to support this mode, a compiler *must*
  # always write the preprocessed file to stdout.
  "$@" || exit $?

  # Remove the call to Libtool.
  if test "$libtool" = yes; then
    while test "X$1" != 'X--mode=compile'; do
      shift
    done
    shift
  fi

  # Remove '-o $object'.
  IFS=" "
  for arg
  do
    case $arg in
    -o)
      shift
      ;;
    $object)
      shift
      ;;
    *)
      set fnord "$@" "$arg"
      shift # fnord
      shift # $arg
      ;;
    esac
  done

  "$@" -E \
    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
    | sed '$ s: \\$::' > "$tmpdepfile"
  rm -f "$depfile"
  echo "$object : \\" > "$depfile"
  cat < "$tmpdepfile" >> "$depfile"
  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

msvisualcpp)
  # Important note: in order to support this mode, a compiler *must*
  # always write the preprocessed file to stdout.
  "$@" || exit $?

  # Remove the call to Libtool.
  if test "$libtool" = yes; then
    while test "X$1" != 'X--mode=compile'; do
      shift
    done
    shift
  fi

  IFS=" "
  for arg
  do
    case "$arg" in
    -o)
      shift
      ;;
    $object)
      shift
      ;;
    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
        set fnord "$@"
        shift
        shift
        ;;
    *)
        set fnord "$@" "$arg"
        shift
        shift
        ;;
    esac
  done
  "$@" -E 2>/dev/null |
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
  rm -f "$depfile"
  echo "$object : \\" > "$depfile"
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
  echo "$tab" >> "$depfile"
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
  rm -f "$tmpdepfile"
  ;;

msvcmsys)
  # This case exists only to let depend.m4 do its work.  It works by
  # looking at the text of this script.  This case will never be run,
  # since it is checked for above.
  exit 1
  ;;

none)
  exec "$@"
  ;;

*)
  echo "Unknown depmode $depmode" 1>&2
  exit 1
  ;;
esac

exit 0

# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

path: tp/parsetexi/depcomp


code:
/* Copyright 2010, 2011, 2012, 2013, 2014, 2015
   Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <stdlib.h>
#include <stdio.h>

#include "parser.h"
#include "input.h"
#include "text.h"
#include "labels.h"
#include "indices.h"
#include "api.h"

#define element_type_name(e) element_type_names[(e)->type]

#define TREE_ROOT_VAR "$TREE"

static int indent = 0;

/* A dump to fill in references from one part of the tree to another. */
static TEXT fixup_dump;

/* A dump for information about the indices. */
static TEXT indices_dump;

/* A dump to fill in references from the parse tree to the indices
   information.  */
static TEXT tree_to_indices_dump;

void dump_contents (ELEMENT *, TEXT *);
void dump_element (ELEMENT *, TEXT *);
void dump_args (ELEMENT *, TEXT *);

/* Output INDENT spaces. */
static void
dump_indent (TEXT *text)
{
  int i;

  for (i = 0; i < indent; i++)
    text_append_n (text, " ", 1);
}

/* Ouput S escaping single quotes and backslashes, so that
   Perl can read it in when it is surrounded by single quotes.  */
void
dump_string (char *s, TEXT *text)
{
 while (*s)
   {
     if (*s == '\''
       || *s == '\\')
       text_append_n (text, "\\", 1);
     text_append_n (text, s++, 1);
   }
}

void
dump_args (ELEMENT *e, TEXT *text)
{
  int i;
  int not_in_tree = 0;

  /* Don't set routing information if not dumping from a route
     directly from the root, that is via an extra value. */
  if (e->parent_type == route_not_in_tree
      || (e->parent_type == route_uninitialized && e->parent))
    not_in_tree = 1;
  text_append_n (text, "[\n", 2);
  indent += 2;

  for (i = 0; i < e->args.number; i++)
    {
      if (!not_in_tree)
        {
          e->args.list[i]->parent_type = route_args;
          e->args.list[i]->index_in_parent = i;
        }

      dump_indent (text);
      dump_element (e->args.list[i], text);
      text_append_n (text, ",\n", 2);
    }

  indent -= 2;
  dump_indent (text);
  text_append_n (text, "],\n", 3);
}

void
dump_contents (ELEMENT *e, TEXT *text)
{
  int i;
  int not_in_tree = 0;

  /* Don't set routing information if not dumping from a route
     directly from the root, that is via an extra value. */
  if (e->parent_type == route_not_in_tree
      || (e->parent_type == route_uninitialized && e->parent))
    not_in_tree = 1;

  text_append_n (text, "[\n", 2);
  indent += 2;

  for (i = 0; i < e->contents.number; i++)
    {
      if (!not_in_tree)
        {
          e->contents.list[i]->parent_type = route_contents;
          e->contents.list[i]->index_in_parent = i;
        }

      dump_indent (text);
      dump_element (e->contents.list[i], text);
      text_append_n (text, ",\n", 2);
    }

  indent -= 2;
  dump_indent (text);
  text_append_n (text, "],\n", 3);
}

/* Recursively go up to the root of the tree.  On the way back print the path
   to the element into DUMP. */
void
dump_route_to_element (ELEMENT *e, TEXT *dump)
{
  if (e->parent)
    dump_route_to_element (e->parent, dump);

  switch (e->parent_type)
    {
    case route_args:
      text_append (dump, "{'args'}");
      text_printf (dump, "[%d]", e->index_in_parent);
      break;
    case route_contents:
      text_append (dump, "{'contents'}");
      text_printf (dump, "[%d]", e->index_in_parent);
      break;
    case route_uninitialized:
      if (e->parent)
        abort ();
      text_append (dump, TREE_ROOT_VAR "->");
      break;
    default:
      abort ();
    }
}

/* Append to FIXUP_DUMP a line assigning the I'th 'extra' key of E. */
void
dump_fixup_line (ELEMENT *e, int i)
{
  dump_route_to_element (e, &fixup_dump);
  text_printf (&fixup_dump, "{'extra'}{'%s'}", e->extra[i].key);

  text_append (&fixup_dump, " = ");
  dump_route_to_element (e->extra[i].value, &fixup_dump);

  switch (e->extra[i].type)
    {
    case extra_element:
      break;
    case extra_element_contents:
      text_append (&fixup_dump, "->{'contents'}");
      break;
    case extra_element_text:
      text_append (&fixup_dump, "->{'text'}");
      break;
    default:
      abort ();
    }
  text_append (&fixup_dump, ";\n");
}

static void
dump_node_spec (NODE_SPEC_EXTRA *value, TEXT *text)
{
  text_append_n (text, "{\n", 2);
  indent += 2;
  if (value->manual_content)
    {
      dump_indent (text);
      text_append (text, "'manual_content' => ");
      dump_contents (value->manual_content, text);
    }
  if (value->node_content)
    {
      dump_indent (text);
      text_append (text, "'node_content' => ");
      dump_contents (value->node_content, text);
    }
  indent -= 2;
  dump_indent (text);
  text_append_n (text, "},\n", 3);
}

/* Dump a skeleton for the 'extra' key.  For each key, if the referenced
   element has been dumped yet and we know its, append a line filling in the
   value of the key to FIXUP_DUMP.  Otherwise, record the reference in the
   'pending_references' field.  Look through the pending references in E itself
   for references to this element from elsewhere. */
void
dump_extra (ELEMENT *e, TEXT *text)
{
  int i;

  text_append_n (text, "{\n", 2);
  indent += 2;

  if (e->extra_number > 0)
    {
      for (i = 0; i < e->extra_number; i++)
        {
          if (e->extra[i].type == extra_deleted)
            continue;
          if (e->extra[i].type == extra_index_entry)
            {
              /* A "index_entry" extra key on a command defining an index
                 entry.  Unlike the other keys, the value is not in the
                 main parse tree, but in the indices_information.  It would
                 be much nicer if we could get rid of the need for this key. */

              INDEX_ENTRY_REF *ire = (INDEX_ENTRY_REF *) e->extra[i].value;
              INDEX_ENTRY *value = &ire->index->index_entries[ire->entry];

              dump_route_to_element (e, &tree_to_indices_dump);
              text_printf (&tree_to_indices_dump, "{'extra'}{'%s'} = ",
                           e->extra[i].key);
              text_printf (&tree_to_indices_dump,
                           "$INDEX_NAMES->{'%s'}{'index_entries'}[%d];\n",
                           value->index_name, value->number - 1);
              /* value->number is 1-based so we needed to subtract 1. */

              continue;
            }

          dump_indent (text);

          if (e->extra[i].type == extra_misc_args)
            {
              int j;
              /* A "misc_args" value is just an array of strings. */
              text_append_n (text, "'", 1);
              text_append (text, e->extra[i].key);
              text_append (text, "' => [");
              for (j = 0; j < e->extra[i].value->contents.number; j++)
                {
                  if (e->extra[i].value->contents.list[j]->text.end > 0)
                    {
                      text_append_n (text, "'", 1);
                      dump_string(e->extra[i].value->contents.list[j]
                                    ->text.text, text);
                      text_append_n (text, "',", 2);
                    }
                  /* else an error? */
                }
              text_append_n (text, "],\n", 3);
            }
          else if (e->extra[i].type == extra_node_spec)
            {
              NODE_SPEC_EXTRA *value = (NODE_SPEC_EXTRA *) e->extra[i].value;

              text_printf (text, "'%s' => ", e->extra[i].key);
              dump_node_spec (value, text);
            }
          else if (e->extra[i].type == extra_node_spec_array)
            {
              NODE_SPEC_EXTRA **array = (NODE_SPEC_EXTRA **) e->extra[i].value;

              text_append_n (text, "'", 1);
              text_append (text, e->extra[i].key);
              text_append (text, "' => [\n");
              while (*array)
                {
                  dump_indent (text);
                  dump_node_spec (*array, text);
                  array++;
                }
              dump_indent (text);
              text_append_n (text, "],\n", 3);
            }
          else if (e->extra[i].type == extra_string)
            {
              char *value = (char *) e->extra[i].value;

              text_append_n (text, "'", 1);
              text_append (text, e->extra[i].key);
              text_append (text, "' => '");
              dump_string (value, text);
              text_append_n (text, "',\n", 3);
            }
          else if (e->extra[i].type == extra_def_args)
            {
              DEF_ARGS_EXTRA *value = (DEF_ARGS_EXTRA *) e->extra[i].value;
              int j;
              char *label;

              text_append_n (text, "'", 1);
              text_append (text, e->extra[i].key);
              text_append (text, "' => [\n");

              for (j = 0; j < value->nelements; j++)
                {
                  label = value->labels[j];
                  dump_indent (text);
                  text_append_n (text, "['", 2);
                  text_append (text, label);
                  text_append_n (text, "', ", 3);

                  dump_element (value->elements[j], text);
                  text_append_n (text, "],\n", 3);
                }
              dump_indent (text);
              text_append_n (text, "],\n", 3);
              /* TODO: Also output a "def_parsed_hash". */
            }
          else if (e->extra[i].value->parent_type == route_not_in_tree)
            {
              switch (e->extra[i].type)
                {
                  int j;
                case extra_element:
                  dump_element (e->extra[i].value, text);
                  break;
                case extra_element_contents:
                  text_append_n (text, "'", 1);
                  text_append (text, e->extra[i].key);
                  text_append (text, "' => ");
                  dump_contents (e->extra[i].value, text);
                  break;
                case extra_element_contents_array:
                  /* Like extra_element_contents, but this time output an array
                     of arrays (instead of an array). */
                  text_append_n (text, "'", 1);
                  text_append (text, e->extra[i].key);
                  text_append (text, "' => [\n");
                  indent += 2;
                  for (j = 0; j < e->extra[i].value->contents.number; j++)
                    {
                      dump_indent (text);
                      dump_contents (e->extra[i].value->contents.list[j],
                                     text);
                    }
                  indent -= 2;
                  dump_indent (text);
                  text_append (text, "],\n");
                  break;
                default:
                  abort ();
                }
            }
          else
            {
              if (e->extra[i].type != extra_element)
                abort ();

              text_append_n (text, "'", 1);
              text_append (text, e->extra[i].key);
              text_append (text, "' => {},\n");

              if (e->extra[i].value->parent_type != route_uninitialized)
                {
                  dump_fixup_line (e, i);
                }
              else /* Add a pending reference to this element. */
                {
                  ELEMENT *e2;

                  e2 = e->extra[i].value;

                  if (e2->pending_number == e2->pending_space)
                    {
                      e2->pending_references = realloc (e2->pending_references,
                        (e2->pending_space += 2) * sizeof (PENDING_REFERENCE));
                      if (!e2->pending_references)
                        abort ();
                    }

                  e2->pending_references[e2->pending_number].element = e;
                  e2->pending_references[e2->pending_number++].extra_index = i;
                }
            }
        }
    }

  if (e->pending_number > 0)
    {
      for (i = 0; i < e->pending_number; i++)
        {
          ELEMENT *referring;
          int index;

          referring = e->pending_references[i].element;
          index = e->pending_references[i].extra_index;
          dump_fixup_line (referring, index);
        }
    }

  indent -= 2;
  dump_indent (text);
  text_append_n (text, "},\n", 3);
}

void
dump_line_nr (LINE_NR *line_nr, TEXT *text)
{
  text_append_n (text, "{\n", 2);
  indent += 2;

  dump_indent (text);
  text_printf (text, "'file_name' => '%s',\n",
               line_nr->file_name ?
               line_nr->file_name : "");

  if (line_nr->line_nr)
    {
      dump_indent (text);
      text_append (text, "'line_nr' => ");
      text_printf (text, "%d", line_nr->line_nr);
      text_append (text, ",\n");
    }

  /* TODO: macro. */
  if (line_nr->macro)
    {
      dump_indent (text);
      text_append (text, "'macro' => ");
      text_printf (text, "'%s'", line_nr->macro);
      text_append (text, ",\n");
    }
  else
    {
      dump_indent (text);
      text_append (text, "'macro' => ''\n");
    }

  indent -= 2;
  dump_indent (text);
  text_append_n (text, "},\n", 3);
}

void
dump_element (ELEMENT *e, TEXT *text)
{
  text_append_n (text, "{\n", 2);
  indent += 2;

  if (e->type)
    {
      dump_indent (text);
      if (e->cmd != CM_verb)
        text_printf (text, "'type' => '%s',\n", element_type_name(e));
      else
        {
          char c = (char) e->type;
          text_printf (text, "'type' => '");
          if (c == '\'' || c == '\\') /* Escaping for Perl. */
            text_append_n (text, "\\", 1);
          text_append_n (text, &c, 1);
          text_printf (text, "',\n");
        }
    }

  if (e->cmd)
    {
      dump_indent (text);
      text_append (text, "'cmdname' => '");
      dump_string (command_data(e->cmd).cmdname, text);
      text_append_n (text, "',\n", 3);
    }

  if (e->line_nr.line_nr)
    {
      dump_indent (text);
      text_append (text, "'line_nr' => ");
      dump_line_nr (&e->line_nr, text);
    }

  if (e->text.text)
    {
      dump_indent (text);
      text_append (text, "'text' => '");
      dump_string (e->text.text, text);
      text_append_n (text, "',\n", 3);
    }

  if (e->args.number > 0)
    {
      dump_indent (text);
      text_append (text, "'args' => ");
      dump_args (e, text);
    }

  if (e->extra_number > 0)
    {
      dump_indent (text);
      text_append (text, "'extra' => ");
      dump_extra (e, text);
    }

  if (e->contents.number > 0)
    {
      dump_indent (text);
      text_append (text, "'contents' => ");
      dump_contents (e, text);
    }

  indent -= 2;
  dump_indent (text);
  text_append_n (text, "}", 1);
}

/* Append to FIXUP_DUMP information about the labels. */
static void
dump_labels_information (void)
{
  int i;

  text_append (&fixup_dump, "\n$TARGETS = [\n");

  for (i = 0; i < labels_number; i++)
    {
      dump_route_to_element (labels_list[i].target, &fixup_dump);
      text_append (&fixup_dump, ",\n");
    }

  text_append (&fixup_dump, "];\n");
}

static void
dump_entries_of_index (INDEX *idx)
{
  int i;
  INDEX_ENTRY *e;

  if (idx->index_number == 0)
    return;
  text_printf (&indices_dump, "\n'index_entries' => [");
  for (i = 0; i < idx->index_number; i++)
    {
      e = &idx->index_entries[i];
      text_printf (&indices_dump, "\n{");
      text_printf (&indices_dump, "'index_name' => '%s',", e->index_name);
      text_printf (&indices_dump, "'index_prefix' => '%s',", e->index_prefix);

      text_printf (&indices_dump, "\n");
      text_printf (&indices_dump, "'index_at_command' => '%s',",
                  command_data(e->index_at_command).cmdname);
      text_printf (&indices_dump, "'index_type_command' => '%s',\n",
                   command_data(e->index_type_command).cmdname);

      text_printf (&indices_dump, "'command' => ");
      dump_route_to_element (e->command, &indices_dump);
      text_printf (&indices_dump, ",\n");

      text_printf (&indices_dump, "'number' => %d,", e->number);

      if (e->content)
        {
          text_printf (&indices_dump, "'content' => ");
          if (e->content->parent_type != route_not_in_tree)
            dump_route_to_element (e->content, &indices_dump);
          else
            dump_element (e->content, &indices_dump);
          text_printf (&indices_dump, "{'contents'}");
          text_printf (&indices_dump, ",\n");
        }

      if (e->node)
        {
          text_printf (&indices_dump, "'node' => ");
          dump_route_to_element (e->node, &indices_dump);
          text_printf (&indices_dump, ",\n");
        }

      text_printf (&indices_dump, "},");
    }
  text_printf (&indices_dump, "],\n");
}

/* Append to INDICES_DUMP information about the indices. */
static void
dump_indices_information (void)
{
  INDEX **i, *idx;

  text_append (&indices_dump, "\n$INDEX_NAMES = {\n");
  for (i = index_names; (idx = *i); i++)
    {
      text_printf (&indices_dump, "'%s' => {", idx->name);
      text_printf (&indices_dump, "'name' => '%s',", idx->name);
      text_printf (&indices_dump, "'in_code' => 0,");

      /* TODO: This is a list of recognized prefixes for the index. */
      text_printf (&indices_dump, "'prefix' => ['%c', '%s'],",
                   *idx->name, idx->name);

      /* TODO: Handle index merging. */
      text_printf (&indices_dump, "'contained_indices' => {'%s'=>1},",
                   idx->name);

      dump_entries_of_index (idx);

      text_printf (&indices_dump, "},\n");
    }

  text_append (&indices_dump, "};\n");
}

void
dump_tree_to_perl (ELEMENT *root)
{
  TEXT output;

  text_init (&output);
  text_init (&fixup_dump);
  text_init (&tree_to_indices_dump);

  text_append (&output, TREE_ROOT_VAR " = ");
  dump_element (root, &output);
  text_append_n (&output, ";\n", 2);

  /* All the elements in the tree have routing information now. */

  if (output.end > 0)
    printf ("%s", output.text);

  //dump_labels_information ();

  //dump_indices_information ();

  if (fixup_dump.end > 0)
    printf ("%s", fixup_dump.text);

  if (indices_dump.end > 0)
    printf ("%s", indices_dump.text);

  /* This must be output at the end so that both the tree and the indices
     will exist by the time this is read. */
  if (tree_to_indices_dump.end > 0)
    printf ("%s", tree_to_indices_dump.text);

  free (output.text);
}

/************************************************************/
/* Following are functions each returning Perl code to be
   eval'd.  When done in the right order the data will be
   transferred into the Perl program. */

char *
dump_root_element_1 (void)
{
  ELEMENT *e = Root;
  TEXT textb;
  TEXT *text;

  text = &textb;
  text_init (text);

  text_append (text, TREE_ROOT_VAR " = ");
  text_append_n (text, "{\n", 2);
  indent += 2;

  if (e->type)
    {
      dump_indent (text);
      text_printf (text, "'type' => '%s',\n", element_type_name(e));
    }

  if (e->cmd)
    {
      dump_indent (text);
      text_append (text, "'cmdname' => '");
      dump_string (command_data(e->cmd).cmdname, text);
      text_append_n (text, "',\n", 3);
    }

  if (e->line_nr.line_nr)
    {
      dump_indent (text);
      text_append (text, "'line_nr' => ");
      dump_line_nr (&e->line_nr, text);
    }

  if (e->text.text)
    {
      dump_indent (text);
      text_append (text, "'text' => '");
      dump_string (e->text.text, text);
      text_append_n (text, "',\n", 3);
    }

  if (e->args.number > 0)
    {
      dump_indent (text);
      text_append (text, "'args' => ");
      dump_args (e, text);
    }

  if (e->extra_number > 0)
    {
      dump_indent (text);
      text_append (text, "'extra' => ");
      dump_extra (e, text);
    }
  text_append_n (text, "};\n", 3);
  return textb.text;
}

char *
dump_root_element_2 (void)
{
  static int i = 0;
  TEXT text;
  ELEMENT *e = Root;

  if (i == e->contents.number)
    {
      i++;
      return 0;
    }

  text_init (&text);
  text_printf (&text, TREE_ROOT_VAR "->{'contents'}[%d] = ", i);

  e->contents.list[i]->parent_type = route_contents;
  e->contents.list[i]->index_in_parent = i;
  dump_element (e->contents.list[i], &text);
  text_append (&text, ";");

  i++;
  return text.text;
}

char *
dump_tree_to_string_1 (void)
{
  text_init (&fixup_dump);
  text_init (&indices_dump);
  text_init (&tree_to_indices_dump);

  return "";
}

char *
dump_tree_to_string_2 (void)
{
  dump_labels_information ();

  if (fixup_dump.end > 0)
     return fixup_dump.text;
  return "";
}

char *
dump_tree_to_string_25 (void)
{
  dump_indices_information ();

  if (indices_dump.end > 0)
     return indices_dump.text;
  return "";
}

char *
dump_tree_to_string_3 (void)
{
  /* This must be output at the end so that both the tree and the indices
     will exist by the time this is read. */
  if (tree_to_indices_dump.end > 0)
     return tree_to_indices_dump.text;
  return "";
}

repo_name: mthl/texinfo

license: mit


code:
void dump_tree_to_perl (ELEMENT *root);
void dump_string (char *s, TEXT *text);
void dump_line_nr (LINE_NR *line_nr, TEXT *text);


code:
# Copyright 2014, 2015 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

BEGIN {
  print "/* This file automatically generated by element_types.awk */"
  print "enum element_type {"
  print "ET_NONE,"
}

!/^$/ && !/^#/ {
    print "ET_" $1 ","
    array = array "\"" $1 "\",\n"
}

END {
  print "};"
  print
  print "extern char *element_type_names[];"
  print "char *element_type_names[] = {" > "element_types.c"
  print "0," > "element_types.c"
  print array > "element_types.c"
  print "};" > "element_types.c"
}

function output_array (string)
{
    print string > "element_types.c"
}


code:
char *element_type_names[] = {
0,
"command_as_argument",
"index_entry_command",
"following_arg",
"space_command_arg",
"definfoenclose_command",
"empty_line",
"raw",
"last_raw_newline",
"empty_line_after_command",
"empty_spaces_after_command",
"spaces_at_end",
"empty_space_at_end_def_bracketed",
"space_at_end_block_command",
"empty_spaces_before_argument",
"empty_spaces_after_close_brace",
"empty_spaces_before_paragraph",
"preamble_text",
"space_at_end_menu_node",
"after_description_line",
"spaces",
"text_root",
"document_root",
"root_line",
"preamble",
"preamble_before_setfilename",
"paragraph",
"preformatted",
"rawpreformatted",
"brace_command_arg",
"brace_command_context",
"block_line_arg",
"misc_line_arg",
"misc_arg",
"menu_entry",
"menu_entry_leading_text",
"menu_entry_name",
"menu_entry_separator",
"menu_entry_node",
"menu_entry_description",
"menu_comment",
"menu_star",
"macro_name",
"macro_arg",
"before_item",
"table_entry",
"table_term",
"table_item",
"inter_item",
"def_line",
"def_item",
"inter_def_item",
"multitable_head",
"multitable_body",
"row",
"bracketed",
"bracketed_def_content",
"bracketed_multitable_prototype",
"row_prototype",
"elided",
"elided_block",
"delimiter",
"untranslated",

};


code:
/* This file automatically generated by element_types.awk */
enum element_type {
ET_NONE,
ET_command_as_argument,
ET_index_entry_command,
ET_following_arg,
ET_space_command_arg,
ET_definfoenclose_command,
ET_empty_line,
ET_raw,
ET_last_raw_newline,
ET_empty_line_after_command,
ET_empty_spaces_after_command,
ET_spaces_at_end,
ET_empty_space_at_end_def_bracketed,
ET_space_at_end_block_command,
ET_empty_spaces_before_argument,
ET_empty_spaces_after_close_brace,
ET_empty_spaces_before_paragraph,
ET_preamble_text,
ET_space_at_end_menu_node,
ET_after_description_line,
ET_spaces,
ET_text_root,
ET_document_root,
ET_root_line,
ET_preamble,
ET_preamble_before_setfilename,
ET_paragraph,
ET_preformatted,
ET_rawpreformatted,
ET_brace_command_arg,
ET_brace_command_context,
ET_block_line_arg,
ET_misc_line_arg,
ET_misc_arg,
ET_menu_entry,
ET_menu_entry_leading_text,
ET_menu_entry_name,
ET_menu_entry_separator,
ET_menu_entry_node,
ET_menu_entry_description,
ET_menu_comment,
ET_menu_star,
ET_macro_name,
ET_macro_arg,
ET_before_item,
ET_table_entry,
ET_table_term,
ET_table_item,
ET_inter_item,
ET_def_line,
ET_def_item,
ET_inter_def_item,
ET_multitable_head,
ET_multitable_body,
ET_row,
ET_bracketed,
ET_bracketed_def_content,
ET_bracketed_multitable_prototype,
ET_row_prototype,
ET_elided,
ET_elided_block,
ET_delimiter,
ET_untranslated,
};

extern char *element_type_names[];


code:
# Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016
# Free Software Foundation, Inc.
#
# This file is part of GNU Texinfo.
#
# GNU Texinfo is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Types for @-commands
#def_line # duplicated below
command_as_argument
index_entry_command
following_arg
space_command_arg
definfoenclose_command

# For text elements
empty_line
raw
last_raw_newline
empty_line_after_command
empty_spaces_after_command
spaces_at_end
empty_space_at_end_def_bracketed
space_at_end_block_command
empty_spaces_before_argument
empty_spaces_after_close_brace
empty_spaces_before_paragraph
preamble_text
space_at_end_menu_node
after_description_line
spaces

# Other special types
text_root
document_root
root_line
preamble
preamble_before_setfilename
paragraph
preformatted
rawpreformatted
brace_command_arg
brace_command_context
block_line_arg
misc_line_arg
misc_arg

menu_entry
menu_entry_leading_text
menu_entry_name
menu_entry_separator
menu_entry_node
menu_entry_description
menu_comment
# Used internally
menu_star

macro_name
macro_arg
before_item
table_entry
table_term
table_item
inter_item
def_line
def_item
inter_def_item
multitable_head
multitable_body
row
bracketed
bracketed_def_content
bracketed_multitable_prototype
row_prototype

# for unexpanded parts of conditionals
elided
elided_block

# for def commands
delimiter

# for inserted text in def commands
untranslated