build_wtname.sh 1.9 KB

1234567891011
  1. # Prepend an L (ell) to turn to a wide literal constant from a string one. Warrantied assumption is made that only single byte characters will form the values of yytname that is dealt with here.
  2. # We say "warrantied" backed/layed on the fact that this array is created from hardcoded values from our own grammar, meaning that the values are authored by our hands, and we know to be only valid English characters,
  3. # and because the C standard (ISO/IEC) settles a prerequisite that the plattform shall support a character set at least as comprehensive as those of the tokens used in the grammar that give rise to yytname.
  4. # Not that will it in use, however in theory any character of LC_LOCALE can be supported on the plattform where Notehaus is compiled. Because it's about a baremetal source-to-source transcription,
  5. # the characters of token types in the parser generated C source file are just well for the Translation Environment to map them in the first phase of source-to-object translation.
  6. # Again, the following source-to-source transcription, plus the L prepended, should make effective wide strings literal not limited to ASCII characters, making languages with internationalized keywords.
  7. # Mainly led by the above reasoning, the decision is to build wtname in a source generation phase fashion, rather than computing it at runtime from yytname.
  8. # The trick, under the assumption the theory's correct, is that the multibyte characters in the C source, with the prefix L, interpreted by the translation environment, as defined by the standard, give rise to the wide characters in the running program. This means plattform independency to an extent compared with as wide characters are to multibyte characters.
  9. echo "$(sed '/yytname\s*\[\s*\]\s*=/!d; s/yytname/wtname/; s/char/wchar_t/; :x /^};$/M!{N;bx}; s/"\([^"\]\|\(\\\\\)*\\"\)*"/L&/g; q;' java7.tab.c)" > wtname.h
  10. echo "$(sed '/yytoknum\s*\[\s*\]\s*=/!d; s/yytoknum/mytoknum/; :x /^};$/M!{N;bx}; q;' java7.tab.c)" >> wtname.h