The proposed tools contemplate the source code keywords, comments and Collaboration between programmers.
Although each tool is designed to iterate over the elements of Bloom’s Taxonomy Cognitive Dimension (Bloom et al. 1956), they mainly intend to stimulate the Affective Dimension elements in students, through the inclusion of their existing linguistic knowledge in the problem-solving process.
5.1 Glotter: A Compiler-Level Natural-Language Neutrality Enabler
A Glotter is a Lexical Analysis tool that converts the source code Lexical Units (tokens) from a Source to a Target Natural-Language.
A Source Natural Language can be any existing Natural Language while the Target Natural-Language is a predefined Bridge Natural Language, a Lingua Franca, which will enable all other Source Natural Languages to be translated to and from it.
The name is derived from the Latin word glot, which means Language, and the English word enabler. Therefore, a Glotter is a Language Enabler.
The Glotter receives a list of tokens, a list of Language Dictionaries and a selected Natural-Language, which serves as the context for the translation.
Its integration to a compiler enables the possibility of different (translated) versions of the same keywords being compiled into a single version. This process ultimately serves the purpose of enabling a single PL to be used with various Natural Languages, while maintaining all the syntactic and semantic structure and rules.
Upon processing, if the keyword is present at the selected Language Dictionary its value is substituted by the matching value. Otherwise, it is left intact. Although it is possible to implement an error reporting functionality upon detection of a non-existent keyword version in the selected Language, this feature might exceed the responsibilities of a Lexical Analyzer. Furthermore, this error can be reported by the Syntax Analyzer.
Implementation Methods
Embedded.
By integrating the Glotter to the compiler, each token can be translated at a time. This approach is more flexible and does not add a performance impact on the normal working of the compiler. An Embedded Glotter requires modification to the compiler source code for an existing PL, what poses a disadvantage in case a seamless integration is expected (Fig. 4).
Standalone.
In this alternative method, the Glotter is separated from the Compiler. The complete source code (input) is parsed by the Glotter, in a process that involves a Lexical Analysis (Tokenization) of the given code. Therefore, the source code is Tokenized twice. This process requires no modification of an existing compiler’s source code, a fact that constitutes an advantage to enabling NLN in already existing PLs (Fig. 5).
Note:
It is assumed that the List of Lexical Units comprises of a list of objects with at least type and value properties and upon not finding an entry or entry-value in a dictionary null is returned.
5.2 Glotation: Natural-Language Annotated Comments
A Glotation is a special kind of comment that includes a source Natural Language attribute and the comment message.
The name is derived from the Latin word Glot, which means Language, and the English word Annotation, metadata attached to text (in this case, attached to source code).
The source language attribute can later be used to translate the comment message to a different Natural Language.
Syntax.
Example:
The example above creates Glotations in English, Portuguese and French with the equivalents of “This is a Glotation”. Each time a user will access the source code, an option to translate the Glotations, Glotate, can allow the translations to occur, provided the user specifies to Environment (target) Language. Therefore, although the comments can be written in different languages, a user can choose to visualize all comments in his/hers context-Natural-Language.
The @ symbol is desirable since its usage is not common among the most used PLs. Therefore, it is possible to avoid confusion between a general comment and a Glotation.
A Glotation translation can be achieved using a Third Party translation service, which might require an internet connection.
To implement Glotations, the rules of the Syntax Analyzer (Parser) should be modified. The rules should detect a Glotation by the symbol @ and build an Abstract SyntaxFootnote 3 node with the following properties:
Therefore, the rules for a well-formed Glotation can be deduced as:
-
1.
Starts with the @ symbol
-
2.
Has no space between the symbol and the following text
-
3.
The text immediately following the @ symbol consists of a two-character string
-
4.
Immediately following the two character string, there is a whitespace
-
5.
After the whitespace follows the comment message with alphanumeric and special characters, including whitespace.
A message should only be translated if the Glotation language is different from the Language currently being used in the Development Environment by the user. Therefore, there should be a mechanism to obtain the Development Environment language.
5.3 Natural-Language Neutrality Collaborative Model for Programming Languages
Making usage of the Glotter and Glotations, a collaborative model can be implemented to allow dissimilar Natural-Languages to be used in a programming environment. Such model should employ a mechanism to allow a user to write a program with keywords and comments in his/hers Natural-Language granted that this same program can be understood by a user with a different Natural-Language.
Translation of keywords and comments can be achieved by the Glotter and Glotations, respectively, but the key factor lies in the data format being used when storing and exchanging the program among the users (Fig. 6).
Upon creation, the source code to be exchanged should desirably possess only Glotations, instead of only comments or a mix. Such process can be automated on the Source code editor by automatically replacing general comments with Glotations, granted that the user has already permitted the functionality and chosen the environment Natural-Language. Similarly, the source code should always be stored with the keywords in the target Natural-language.
Such source code file, with Glotations and keywords in the target Natural-Language, will serve as the intermediate file format, the essence of the collaborative model.
When a different user receives this same source code, the process of contextualization can be performed by applying the Glotter and Glotation functionalities, joint or separately.
Therefore, the inverse process can take place by the second author editing the source code file, storing it in the intermediate file format and sending it back to the first author.