src/training/unicharset/validate_javanese.cpp
bool ValidateJavanese::ConsumeGraphemeIfValid() {
  switch (codes_[codes_used_].first) {
    case CharClass::kConsonant:
      return ConsumeConsonantHeadIfValid() && ConsumeConsonantTailIfValid();
    case CharClass::kVowel:
    case CharClass::kVedicMark:
      return ConsumeVowelIfValid();
    case CharClass::kZeroWidthJoiner:
    case CharClass::kZeroWidthNonJoiner:
      // Apart from within an aksara, joiners are silently dropped.
      if (report_errors_) {
        tprintf("Dropping isolated joiner: 0x%x\n", codes_[codes_used_].second);
      }
      ++codes_used_;
      return true;
    case CharClass::kOther:
      UseMultiCode(1);
      return true;
    default:
      if (report_errors_) {
        tprintf("Invalid start of grapheme sequence:%c=0x%x\n",
                static_cast<int>(codes_[codes_used_].first),
                codes_[codes_used_].second);
      }
      return false;
  }
}
// Returns whether codes matches the pattern for a Javanese Grapheme.
// Taken from unicode standard:
// http://www.unicode.org/charts/PDF/UA980.pdf
// http://www.unicode.org/versions/Unicode11.0.0/ch17.pdf
// The Consonant class here includes independent vowels.
// The order of components in an orthographic syllable as expressed in BNF is:
// {C F} C {{R}Y} {V{A}} {Z}
// Translated to the codes used by the CharClass enum:
// [(V|C[N])(H)] (V|C[N]) [[N]N] [M[D]] [v]
// Also see https://r12a.github.io/scripts/javanese/ for detailed notes.
// Validation rules copied from validate_indic.cpp and modified for Javanese.
// Indic - for reference
//  + vowel Grapheme:  V[D](v)*
//  + consonant Grapheme: (C[N](H|HZ|Hz|ZH)?)*C[N](H|Hz)?[M[P]][D](v)*
Returns whether codes matches the pattern for a Javanese Grapheme.
Returns whether codes matches the pattern for a Javanese Grapheme .
bool ValidateJavanese::ConsumeGraphemeIfValid() {
  switch (codes_[codes_used_].first) {
    case CharClass::kConsonant:
      return ConsumeConsonantHeadIfValid() && ConsumeConsonantTailIfValid();
    case CharClass::kVowel:
    case CharClass::kVedicMark:
      return ConsumeVowelIfValid();
    case CharClass::kZeroWidthJoiner:
    case CharClass::kZeroWidthNonJoiner:
      if (report_errors_) {
        tprintf("Dropping isolated joiner: 0x%x\n", codes_[codes_used_].second);
      }
      ++codes_used_;
      return true;
    case CharClass::kOther:
      UseMultiCode(1);
      return true;
    default:
      if (report_errors_) {
        tprintf("Invalid start of grapheme sequence:%c=0x%x\n",
                static_cast<int>(codes_[codes_used_].first),
                codes_[codes_used_].second);
      }
      return false;
  }
}
bool ValidateJavanese :: ConsumeGraphemeIfValid ( ) { switch ( codes_ [ codes_used_ ] . first ) { case CharClass :: kConsonant : return ConsumeConsonantHeadIfValid ( ) && ConsumeConsonantTailIfValid ( ) ; case CharClass :: kVowel : case CharClass :: kVedicMark : return ConsumeVowelIfValid ( ) ; case CharClass :: kZeroWidthJoiner : case CharClass :: kZeroWidthNonJoiner : if ( report_errors_ ) { tprintf ( " \n " , codes_ [ codes_used_ ] . second ) ; } ++ codes_used_ ; return true ; case CharClass :: kOther : UseMultiCode ( 1 ) ; return true ; default : if ( report_errors_ ) { tprintf ( " \n " , static_cast < int > ( codes_ [ codes_used_ ] . first ) , codes_ [ codes_used_ ] . second ) ; } return false ; } }
Returns whether codes matches the pattern for a Javanese Grapheme.
Returns whether codes matches the pattern for a Javanese Grapheme .
// Apart from within an aksara, joiners are silently dropped.