Skip to content

Fix lexc compile errors: duplicate Multichar_Symbols and mredup typo - #24

Open
snomos wants to merge 1 commit into
coltekin:masterfrom
snomos:fix-lexc-double-multichar-and-mredup-typo
Open

Fix lexc compile errors: duplicate Multichar_Symbols and mredup typo#24
snomos wants to merge 1 commit into
coltekin:masterfrom
snomos:fix-lexc-double-multichar-and-mredup-typo

Conversation

@snomos

@snomos snomos commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

While building the copy of TRmorph pulled into giellalt/lang-tur-x-ext-trmorph (as a git subtree), analyzer.cpp.lexc failed to compile with both foma's and HFST's lexc parsers.

Root cause

analyzer.lexc ends up including the multi-char symbol declaration twice:

  • once directly, via its own #include "multi-char.lexc"
  • once more via #include "morph.cpp.lexc" — a pre-expanded copy of morph.lexc, which itself does #include "multi-char.lexc"

Since morph.cpp.lexc is already-expanded text (no more #include directives left by the time it's pasted in), the duplication can't be prevented from within multi-char.lexc alone unless the whole thing goes through a single preprocessor pass.

Separately, morph.lexc (LEXICON Nfamily, the ALLOW_MREDUP branch) has a typo: %<N%::mredup%> has an extra, unescaped colon, giving the entry two upper:lower separators instead of one. Every other occurrence of this tag elsewhere in the file uses %<...%:mredup%> (single colon).

Fix

  • multi-char.lexc: wrap the Multichar_Symbols declaration in a standard C-style include guard (the build already runs these files through cpp, so this works with the existing Makefile/makedepend.sh setup).
  • analyzer.lexc: #include "morph.lexc" (raw source) instead of #include "morph.cpp.lexc" (pre-expanded), so the file is composed in one cpp pass and the include guard actually takes effect.
  • morph.lexc: fix the <N:mredup> typo to match the tag used everywhere else.

Verified analyzer.cpp.lexc compiles cleanly afterwards with both the classic HFST hfst-lexc (3.17.3) and foma -f analyzer.cpp.xfst, and that the duplicate Multichar_Symbols block and the typo are both gone from the generated output.

analyzer.lexc pulls in morph.lexc's content twice: once directly via
its own #include "multi-char.lexc", and once more via #include
"morph.cpp.lexc" (a pre-expanded copy of morph.lexc, which itself
includes multi-char.lexc). The result is that the final
analyzer.cpp.lexc ends up with two separate Multichar_Symbols
declarations, which both foma's and HFST's lexc parsers reject as a
syntax error.

- multi-char.lexc: wrap the Multichar_Symbols declaration in a
  standard C-style include guard, since the whole system is already
  built by running these lexc files through the C preprocessor.
- analyzer.lexc: include the raw morph.lexc instead of the
  already-preprocessed morph.cpp.lexc, so the file is composed in a
  single cpp pass and the include guard above actually takes effect.
- morph.lexc: fix a typo in the <N:mredup> tag under LEXICON
  Nfamily's ALLOW_MREDUP branch. It had an extra, unescaped colon
  (%<N%::mredup%>), giving the entry two upper:lower separators
  instead of one; every other occurrence of this tag uses
  %<...%:mredup%>.

Found and fixed while trying to build the TRmorph subtree pulled into
https://github.com/giellalt/lang-tur-x-ext-trmorph.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant