Fix lexc compile errors: duplicate Multichar_Symbols and mredup typo - #24
Open
snomos wants to merge 1 commit into
Open
Fix lexc compile errors: duplicate Multichar_Symbols and mredup typo#24snomos wants to merge 1 commit into
snomos wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While building the copy of TRmorph pulled into giellalt/lang-tur-x-ext-trmorph (as a git subtree),
analyzer.cpp.lexcfailed to compile with both foma's and HFST's lexc parsers.Root cause
analyzer.lexcends up including the multi-char symbol declaration twice:#include "multi-char.lexc"#include "morph.cpp.lexc"— a pre-expanded copy ofmorph.lexc, which itself does#include "multi-char.lexc"Since
morph.cpp.lexcis already-expanded text (no more#includedirectives left by the time it's pasted in), the duplication can't be prevented from withinmulti-char.lexcalone unless the whole thing goes through a single preprocessor pass.Separately,
morph.lexc(LEXICON Nfamily, theALLOW_MREDUPbranch) 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 theMultichar_Symbolsdeclaration in a standard C-style include guard (the build already runs these files through cpp, so this works with the existingMakefile/makedepend.shsetup).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.lexccompiles cleanly afterwards with both the classic HFSThfst-lexc(3.17.3) andfoma -f analyzer.cpp.xfst, and that the duplicateMultichar_Symbolsblock and the typo are both gone from the generated output.