aboutsummaryrefslogtreecommitdiff
path: root/src/ellinika/yyrename
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-06-10 23:04:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-06-11 00:34:20 +0300
commita1a5b7ddd6c3c0532c37551b24fd573a554ac181 (patch)
treef86f3572c77dc986bb2dfb65619ac4bc35c83847 /src/ellinika/yyrename
parent2bae7da012e2125762855ce014e63345ecbbbb18 (diff)
downloadellinika-a1a5b7ddd6c3c0532c37551b24fd573a554ac181.tar.gz
ellinika-a1a5b7ddd6c3c0532c37551b24fd573a554ac181.tar.bz2
Fix syllabification.
* configure.ac: Add AC_PROG_YACC * src/ellinika/phoneme.y: New file. * src/ellinika/yyrename: New file. * src/ellinika/syllabificator.c: New file. * src/ellinika/.gitignore: Update. * src/ellinika/elchr.c (char_info_st): Move to header. (el_basic_ctype): (elchr_info): Remove static qualifier. Return a pointer to const. (elchr_letter,elchr_phoneme): New functions. (elchr_diphthong): Remove. * src/ellinika/elmorph.c (elstr)<phoneme,phoneme_count>: New members. (_elstr_syllabize): Rewrite. (invalidate_maps)" New static function. (_elstr_alloc): Initialize new fields, take function name as argument, for diagnostic purposes. (_elstr_print): Rewrite (deftab): Update. (elstr-syllable-prop,elstr-syllable) (_elstr_set_accent,_elstr_set_accent_on_char): Rewrite. (elstr-char-phoneme,elstr->phonetic-map): New functions. * src/ellinika/elmorph.h (CHF_DIPH1,CHF_DIPH2): Remove. (CHF_DIPHTHONG): New flag. (PHON_.*): New constants. (phoneme,syllable): New structures. (char_info_st)<letter,phoneme>: New members. (elchr_info,elchr_letter) (elchr_phoneme,phoneme_map) (syllable_map): New protos. (elchr_diphthong): Remove protos. * src/ellinika/elmorph.scm4: Move public definitions to elmorph-public.scm; include it here. * src/ellinika/xlat.scm (ellinika:sounds-like): Rewrite as a wrapper over elstr->soundslike. Describe Milesian numbers. * style.css (img.ellinika-img): New class. * xml/lingua.conf.in (IMAGE): New tag. * xml/pl/alfabhta.xml: Describe Milesian numbers. Various fixes. * data/dbverb.struct: fix a typo in flection. Use 'sub' theme for pas/sub/aor. * data/irregular-verbs.xml: Add more verbs. * scm/conjugator.scm: Various fixes. * scm/verbop.scm: Accept empty mood and voice declarations.
Diffstat (limited to 'src/ellinika/yyrename')
-rwxr-xr-xsrc/ellinika/yyrename97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/ellinika/yyrename b/src/ellinika/yyrename
new file mode 100755
index 0000000..996abf2
--- /dev/null
+++ b/src/ellinika/yyrename
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Rename yy.* identifiers to avoid name clashes. This file is part of Grecs.
+# Copyright (C) 2011 Sergey Poznyakoff
+#
+# Grecs 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, or (at your option)
+# any later version.
+#
+# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+# Usage: yyrename [-f "OUTFILE [OUTFILE...]"] COMMAND INFILE
+# Makefile.am:
+# LEXCOMPILE = yyrename -f $(LEX_OUTPUT_ROOT).c \
+# '$(LEX) $(LFLAGS) $(AM_LFLAGS)'
+# YACCCOMPILE = yyrename '$(YACC) $(YFLAGS) $(AM_YFLAGS)'
+#
+# This script runs COMMAND with INFILE as its argument and scans
+# OUTFILEs for identifiers starting with 'yy'. It then renames these
+# identifiers by replacing 'yy' with the selected prefix.
+#
+# The prefix is looked up in the file yytrans, located in the INFILE's
+# directory. If this file does not exist, the prefix is constructed
+# by concatenating the string 'grecs_' and the ``root name''. The root
+# name is built by removing '-lex.l' or '-gram.y' from the base name.
+# If the latter does not end in any of these, the root name
+# is constructed by removing the suffix from the base name.
+#
+# The yytrans file is a line-oriented lookup table. Empty lines are
+# ignored, usual UNIX comment lines are honored. The remaining lines
+# shall consist of two words separated by any amount of whitespace.
+# The first word is a look-up key, the second one provides a translation
+# (yy replacement) for that key.
+#
+# Two look-ups are tried: first the base name and then the root name.
+# If both result in a non-empty replacement, the former is preferred
+# over the latter.
+#
+# The -f option supplies a list of output file names generated by COMMAND.
+# If not supplied, the following defaults are used: y.tab.c and y.tab.h, if
+# INFILE ends in '.y', and yy.lex.c, if it ends in '.l'. If INFILE does not
+# end in any of these suffixes, error is reported.
+#
+# BUGS: Any occurrence of 'yy' is replaced, not only 'yy' prefixes.
+#
+case $1 in
+-f) files=$2
+ shift
+ shift
+esac
+
+if test $# -ne 2; then
+ echo >&2 "usage: yyrename [-f "OUTFILE [OUTFILE...]"] COMMAND INFILE"
+ exit 1
+fi
+
+base=`expr "$2" : '.*/\(.*\)\.[ly]'`
+dir=`dirname "$2"`
+case $2 in
+*.y) test -z "$files" && files="y.tab.c y.tab.h"
+ root=`expr "$2" : '.*/\(.*\)-gram\.y'`;;
+*.l) test -z "$files" && files=lex.yy.c
+ root=`expr "$2" : '.*/\(.*\)-lex\.l'`;;
+*) if test -z "$files"; then
+ echo >&2 "$0: suffix unknown, files must be given (use -f)"
+ exit 1
+ fi
+ root=$base
+esac
+
+if test -f $dir/yytrans; then
+ pfx=`awk '
+{ sub(/#.*$/,"") }
+NF == 2 && $1=="'$base'" { exact=$2 }
+NF == 2 && $1=="'$root'" { root=$2 }
+{ next }
+END { print exact ? exact : root ? root : "" }' $dir/yytrans`
+else
+ pfx=
+fi
+if test -z "$pfx"; then
+ pfx=ellinika_`echo $root | tr .- __`
+fi
+
+eval $* || exit $?
+
+for file in $files
+do
+ mv $file ${file}.tmp
+ sed "/^#line/b;/^# *[0-9]/b;s/yy/$pfx/g;s/YY/$pfx/g" ${file}.tmp > $file
+done

Return to:

Send suggestions and report system problems to the System administrator.