Formal S anskrit Syntax: A Specification for Programming Language (2020)

Abstract: The paper discusses the syntax of the primary statements of the Sanskritam, a programming language specification based on natural Sanskrit under a doctoral thesis. By a statement, we mean a syntactic unit regardless of its computational operations of variable declarations, program executions or evaluations of Boolean expressions etc. We have selected six common primary statements of declaration, assignment, inline initialization, if-then-else, for loop and while loop. The specification partly overlaps the ideas of natural language programming, Controlled Natural Language (Kunh, 2013), and Natural Language subset. The practice and application of structured natural language set in a discourse are deeply rooted in the theoretical text tradition of Sanskrit, like the sūtra-based disciplines and Navya-Nyāya (NN) formal language, etc. The effort is a kind of continuation and application of such traditions and their techniques in the modern field of Sanskrit NLP.

## introduction the paper is based on a non-english-based programming language, called sanskritam being developed under a doctoral thesis. instead of adopting the syntax of programming languages highly inspired by the symbolic language of logic and mathematics, we have adopted a natural language-based syntax like those of generic sanskrit used to write the aṣṭādhyāyī foot_0 (ad), a grammar of the natural sanskrit itself. we have selected 6 common primary statements that any general programming language may have. by a statement, we refer to a syntactic unit regardless of its computational operations of variable declarations, program executions or evaluations of boolean expressions etc. the program statements are translated to the two basic types of natural language sentences of assertive and imperative in the present tense, active voice. one of the core components in a program expression is the 'operator', which contributes to the semantic decision. different keywords and signs are used to indicate the operation of a statement in semantic analysis. in the whole paper, sanskritam refers to the language being specified while sanskrit means the very natural sanskrit. india has had one of the oldest traditions of linguistics, philosophy, logic, mathematics, and many other disciplines which were almost all written in sanskrit. the language of western symbolic logic is successfully adopted by a number of the modern field of studies, including mathematics, computer science, computer programming languages, formal language grammars, physical science and biology @xcite . the indic logic and other disciplines follow a linguistic model for their systems instead of a symbolic model. the technique or logic of such a linguistic model, be it sūtra foot_1 or nn (an indic philosophical school) language, had successfully gained popularity and share among other indic fields of studies also @xcite . they are widely accepted, used, and taught in school/universities, and there is a good number of active communities. the artificial formal language known as navya-nāya-sometimes it again means an individual sūtra many of which constitute the whole sūtra text. ## formal sanskrit in this section, we will discuss the syntax of six basic statements of sanskritam specification. we selected the primary statements of general programming languages, mostly inspired by java @xcite . we use the iast foot_6 , a latin alphabet-based transliteration for sanskrit texts. to represent the formal syntactic structure, we use the grammar notation of antlr metalanguage specification @xcite . the sanskritam grammar has its terminal symbols and tokens defined by its lexical grammar, representing program keywords, the nominal and verbal roots, indeclinable and other required word classes of the natural sanskrit. 𝑠𝑡𝑎𝑡𝑒𝑚𝑒𝑛𝑡 ∶ 𝑛𝑝 𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡 𝑐𝑜𝑝𝑢𝑙𝑎? ′ ; ′ | 𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡 𝑛𝑝 𝑐𝑜𝑝𝑢𝑙𝑎? ′ ; ′ ; the tokens in lower case not closed by single inverted commas represent non-terminals. the left-hand side of the colon represents a rule name which can have one or more alternate rules separated by bar (|) and terminated by a colon. a sanskritam statement is a simple copular sentence that constitutes the nps (of subject) and complement/s, an optionally omitted copula foot_7 , and finally terminates by a semicolon (;). the copula cannot be in a passive or impersonal foot_8 construction. since a complement represents a predefined term or data type, it allows the subject to occur before or after its complement expression. for instance: san: vṛddhih ād aic ; eng: "ād (vowel ā) aic (diphthongs āi and au) (are) vṛddhi." san: ad eṅ guṇaḥ ; eng: "ad (vowel a) eṅ (diphthongs e and o) (are) guṇa." the predicative expression vṛddhi precedes its subject ād (and) aic representing program variables in the first statement while the subject ad (and) eṅ precedes the complement in the second statement. the copula is omitted in both of the statements. ## conclusion and future work we have tried to describe the syntax of each selected sanskritam statements separately by giving the formal rules of each statement. the english translations of example source code may not match the exact syntax of sanskritam specification. a complete parser of the sanskritam specification based on a computational formal grammar starting from its start symbol will be discussed in future. later on, we will discuss its implementation in java environment.