Turn an ACL2 character into one or more Java characters for an ASCII Java identifier.
(atj-char-to-jchars-id char startp uscore flip-case-p) → jchars
This is used to translate ACL2 variable, function, and package names to Java identifiers in the shallow embedding approach. It is also used to map ACL2 characters and strings to parts of Java identifiers.
ACL2 symbol names may consist of arbitrary sequences of 8-bit characters, while Java identifiers may only contain certain Unicode characters; when Unicode is restricted to ASCII, Java identifiers are much more restricted than ACL2 symbols. They are also more restricted than ACL2 package names, although ACL2 package names have restrictions of their own compared to Java identifiers, notably the uppercase restriction.
If an ACL2 character (part of an ACL2 symbol name or package name)
is a letter,
we keep it unchanged in forming the Java identifier,
but we flip it from uppercase to lowercase or from lowercase to uppercase
if the
If the ACL2 character is a digit, we keep it unchanged
only if it is not at the start of the Java identifier:
this is indicated by the
If the ACL2 character is neither a letter or a digit,
by default we turn it into an ``escape'' of the form
However, if the
Definition:
(defconst *atj-char-to-jchars-id* '((#\Space . "$SPACE") (#\! . "$BANG") (#\" . "$DQUOTE") (#\# . "$HASH") (#\$ . "$DOLLAR") (#\% . "$PCENT") (#\& . "$AMPER") (#\' . "$SQUOTE") (#\( . "$OROUND") (#\) . "$CROUND") (#\* . "$STAR") (#\+ . "$PLUS") (#\, . "$COMMA") (#\- . "$DASH") (#\. . "$DOT") (#\/ . "$SLASH") (#\: . "$COLON") (#\; . "$SCOLON") (#\< . "$LT") (#\= . "$EQ") (#\> . "$GT") (#\? . "$QMARK") (#\@ . "$AT") (#\[ . "$OSQUARE") (#\\ . "$BSLASH") (#\] . "$CSQUARE") (#\^ . "$CARET") (#\_ . "$USCORE") (#\` . "$BQUOTE") (#\{ . "$OCURLY") (#\| . "$BAR") (#\} . "$CCURLY") (#\~ . "$TILDE") (#\0 . "$0$") (#\1 . "$1$") (#\2 . "$2$") (#\3 . "$3$") (#\4 . "$4$") (#\5 . "$5$") (#\6 . "$6$") (#\7 . "$7$") (#\8 . "$8$") (#\9 . "$9$")))
Function:
(defun atj-char-to-jchars-id (char startp uscore flip-case-p) (declare (xargs :guard (and (characterp char) (booleanp startp) (member-eq uscore '(nil :dash :space)) (booleanp flip-case-p)))) (let ((__function__ 'atj-char-to-jchars-id)) (declare (ignorable __function__)) (b* (((when (str::up-alpha-p char)) (if flip-case-p (list (str::downcase-char char)) (list char))) ((when (str::down-alpha-p char)) (if flip-case-p (list (str::upcase-char char)) (list char))) ((when (and (digit-char-p char) (not startp))) (list char)) ((when (or (and (eq uscore :dash) (eql char #\-)) (and (eq uscore :space) (eql char #\Space)))) (list #\_)) (pair? (assoc char *atj-char-to-jchars-id*)) ((when (consp pair?)) (explode (cdr pair?))) (code (char-code char)) ((mv hi-char lo-char) (ubyte8=>hexchars code))) (list #\$ #\x hi-char lo-char))))
Theorem:
(defthm character-listp-of-atj-char-to-jchars-id (implies (characterp char) (b* ((jchars (atj-char-to-jchars-id char startp uscore flip-case-p))) (character-listp jchars))) :rule-classes :rewrite)