# PCASTL

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/PCASTL
> Markdown URL: https://mediated.wiki/source/PCASTL.md
> Source: https://en.wikipedia.org/wiki/PCASTL
> Source revision: 1345498684
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

High-level programming language

PCASTL Paradigm imperative, reflective Designed by Philippe Choquette Developer Philippe Choquette First appeared 2008; 18 years ago (2008) Stable release 3.5 / March 31, 2018; 8 years ago (2018-03-31) OS Cross-platform License GNU Lesser General Public License Website www.pcosmos.ca/pcastl/ Influenced by C, R

The **PCASTL** (an acronym for *by Parent and Childset Accessible Syntax Tree Language*) is an interpreted [high-level programming language](/source/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](/source/Self-modifying_code). The language has [reserved words](/source/Reserved_word) **parent** and **childset** to access the nodes of the [syntax tree](/source/Abstract_syntax_tree) of the currently written code.[2]

## Hello world

The "[Hello world program](/source/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](/source/Programming_languages) [C](/source/C_(programming_language)) and [R](/source/R_(programming_language)). The source of [R](/source/R_(programming_language)) version 2.5.1 has been studied to write the [grammar](/source/Formal_grammar) and the [lexer](/source/Lexical_analyzer) used in the PCASTL interpreter.

### Influences

Like in [R](/source/R_(programming_language)), statements can, but do not have to, be separated by [semicolons](/source/Semicolon).[3] Like in [R](/source/R_(programming_language)), a [variable](/source/Variable_(programming)) can change type in a [session](/source/Session_(computer_science)). Like in [C](/source/C_(programming_language)) and [R](/source/R_(programming_language)), PCASTL uses balanced [brackets](/source/Bracket) (**{** and **}**) to make [blocks](/source/Block_(programming)).

[Operators](/source/Operator_(programming)) found in PCASTL have the same [precedence](/source/Order_of_operations) and [associativity](/source/Operator_associativity) as their counterparts in [C](/source/C_(programming_language)).[2][4] **for** loops are defined like in [C](/source/C_(programming_language)). ++ and -- [operators](/source/Operator_(programming)) are used like in [C](/source/C_(programming_language)) to increment or decrement a variable before or after it is used in its expression.

An example of PCASTL using the **for** [reserved word](/source/Reserved_word) and the ++ [operator](/source/Operator_(programming)):

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

[Functions](/source/Subroutine) and [comments](/source/Comment_(computing)) in PCASTL are defined like in [R](/source/R_(programming_language)):

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

# function call
a()

### parent and childset reserved words

Those [reserved words](/source/Reserved_word) can only be written lowercase and will not be recognized otherwise. The **parent** reserved word gives a [reference](/source/Reference_(computer_science)) to the parent node in the [syntax tree](/source/Abstract_syntax_tree) of the code where the word is placed. In the following code, the parent node is the [operator](/source/Operator_(programming)) =.

a = parent

The [variable](/source/Variable_(programming)) "a" will hold a [reference](/source/Reference_(computer_science)) to the = node. The following code shows how to get [references](/source/Reference_(computer_science)) to the two child nodes of the [operator](/source/Operator_(programming)) = with the **childset** [reserved word](/source/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

- [Free and open-source software portal](https://en.wikipedia.org/wiki/Portal:Free_and_open-source_software)

- [Abstract syntax tree](/source/Abstract_syntax_tree)

- [Self-modifying code](/source/Self-modifying_code)

## References

1. **[^](#cite_ref-1)** ["pcosmos.ca"](http://www.pcosmos.ca/). Philippe Choquette. Retrieved 2008-06-14.

1. ^ [***a***](#cite_ref-PCASTLmain_2-0) [***b***](#cite_ref-PCASTLmain_2-1) ["PCASTL: by Parent and Childset Accessible Syntax Tree Language"](http://www.pcosmos.ca/pcastl/). Philippe Choquette. Retrieved 2008-06-14.

1. **[^](#cite_ref-3)** ["An Introduction to R"](https://cran.r-project.org/doc/manuals/R-intro.html). R Development Core Team. Retrieved 2008-06-14.

1. **[^](#cite_ref-4)** Hanly, Jeri R.; Elliot B. Koffman (1999). [*Problem Solving & Program Design in C, Third Edition*](https://archive.org/details/problemsolvingpr00hanl_1). [Addison-Wesley](/source/Addison-Wesley). [ISBN](/source/ISBN_(identifier)) [0-201-35748-8](https://en.wikipedia.org/wiki/Special:BookSources/0-201-35748-8).

## External links

- [PCASTL: by Parent and Childset Accessible Syntax Tree Language](http://www.pcosmos.ca/pcastl/)

v t e Free and open-source software General Alternative terms for free software Comparison of open-source and closed-source software Comparison of source-code-hosting facilities Free software Free software project directories Long-term support Open-source software Open-source software development Outline Timeline Software packages Audio Bioinformatics Codecs Configuration management Drivers Graphics Wireless Health Mathematics Office suites Operating systems Routing Television Video games Web applications E-commerce Android apps iOS apps Commercial Formerly proprietary Formerly open-source Community Free software movement History Open-source-software movement Events Advocacy Organisations Free Software Movement of India Free Software Foundation Licenses AFL Apache APSL Artistic Beerware BSD Creative Commons CDDL EPL Free Software Foundation GNU GPL GNU AGPL GNU LGPL ISC MIT MPL Python Python Software Foundation License Shared Source Initiative Sleepycat Unlicense WTFPL zlib Types and standards Comparison of licenses Contributor License Agreement Copyleft Debian Free Software Guidelines Definition of Free Cultural Works Free license The Free Software Definition The Open Source Definition Open-source license Permissive software license Public domain Challenges Digital rights management License proliferation Mozilla software rebranding Proprietary device drivers Proprietary firmware Proprietary software SCO/Linux controversies Software patents Software security Tivoization Trusted Computing Related topics Forking GNU Manifesto Microsoft Open Specification Promise Open-core model Open-source hardware Shared Source Initiative Source-available software The Cathedral and the Bazaar Revolution OS Portal Category

---
Adapted from the Wikipedia article [PCASTL](https://en.wikipedia.org/wiki/PCASTL) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/PCASTL?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
