PCASTL

PCASTL
PCASTL
Paradigm(s) imperative, reflective
Appeared in 2008
Designed by Philippe Choquette
Developer Philippe Choquette
Stable release 1.9 (September 18, 2009; 2 years ago (2009-09-18))
Influenced by C, R
OS Cross-platform
License GNU General Public License
Website http://www.pcosmos.ca/pcastl/

The PCASTL (an acronym for by Parent and Childset Accessible Syntax Tree Language) is an interpreted high-level programming language. It was created in 2008 by Philippe Choquette[1]. The PCASTL is designed to ease the writing of self-modifying code. The language has reserved words parent and childset to access the nodes of the syntax tree of the currently written code[2].

Contents

Hello world

The "Hello world program" is quite simple:

"Hello, world!"

or

print("Hello, world!")

will do the same.

Syntax

The syntax of PCASTL is derived from programming languages C and R. The source of R version 2.5.1 has been studied to write the grammar and the lexer used in the PCASTL interpreter.

Influences

Like in R, statements can, but do not have to, be separated by semicolons[3]. Like in R, a variable can change type in a session. Like in C and R, PCASTL uses balanced brackets ({ and }) to make blocks.

Operators found in PCASTL have the same precedence and associativity as their counterparts in C[2][4]. for loops are defined like in C. ++ and -- operators are used like in C to increment or decrement a variable before or after it is used in its expression.

An example of PCASTL using the for reserved word and the ++ operator:

for (i = 1; i < 4; i++) print(i)

Functions and comments in PCASTL are defined like in R:

# function definition (comment)
a = function()
{
   print("Hello, world!")
}

# function call
a()

parent and childset reserved words

Those reserved words can only be written lowercase and will not be recognized otherwise. The parent reserved word gives a reference to the parent node in the syntax tree of the code where the word is placed. In the following code, the parent node is the operator =.

a = parent

The variable "a" will hold a reference to the = node. The following code shows how to get references to the two child nodes of the operator = with the childset reserved word.

a.childset[0]
a.childset[1]

To display the value of "a", some ways are given in this example:

a
a.childset[0].parent
a.childset[1].parent
a.childset[0].parent.childset[0].parent # and so on...

In the following code: we assign a code segment to the right child of the = node, we execute the = node a second time and we call the newly defined function.

a.childset[1] = `function() print("hello")'
execute(a)
a()

See also

Notes

  1. ^ "pcosmos.ca". Philippe Choquette. http://www.pcosmos.ca/. Retrieved 2008-06-14. 
  2. ^ a b "PCASTL: by Parent and Childset Accessible Syntax Tree Language". Philippe Choquette. http://www.pcosmos.ca/pcastl/. Retrieved 2008-06-14. 
  3. ^ "An Introduction to R". R Development Core Team. http://cran.r-project.org/doc/manuals/R-intro.html. Retrieved 2008-06-14. 
  4. ^ Hanly, Jeri R.; Elliot B. Koffman (1999). Problem Solving & Program Design in C, Third Edition. Addison-Wesley. ISBN 0-201-35748-8. 

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • List of programming languages by category — Programming language lists Alphabetical Categorical Chronological Generational This is a list of programming languages grouped by category. Some languages are listed in multiple categories. Contents …   Wikipedia

  • Generational list of programming languages — Here, a genealogy of programming languages is shown. Languages are categorized under the ancestor language with the strongest influence. Of course, any such categorization has a large arbitrary element, since programming languages often… …   Wikipedia

  • Self-modifying code — In computer science, self modifying code is code that alters its own instructions, intentionally or otherwise, while it is executing.Self modifying code is quite straightforward to write when using assembly language (taking into account the CPU… …   Wikipedia

  • Генеалогический список языков программирования — Списки языков программирования По категориям Хронологический Генеалогический Приведён генеалогический список языков программирования. Языки классифицируются в соответствии с предшествующими языками, которые оказали сильное влияние на формирование …   Википедия

  • List of programming languages — Programming language lists Alphabetical Categorical Chronological Generational The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and historical ones, in… …   Wikipedia

  • Liste des langages de programmation — Le but de cette Liste des langages de programmation est d inclure tous les langages de programmation existants, qu ils soient actuellement utilisés ou historiques, par ordre alphabétique. Ne sont pas listés ici les langages informatiques de… …   Wikipédia en Français

  • Список языков программирования — Списки языков программирования Алфавитный По категориям Хронологический Генеалогический Цель этого алфавитного списка языков программирования состоит в том, чтобы дать полный перечень всех существующих языков программирования, как используемых в… …   Википедия

  • Хронология языков программирования — Списки языков программирования По категориям Хронологический Генеалогический Хронология языков программирования  упорядоченный в хронологическом порядке список языков программирования. Содержание …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”