fbpx
Wikipedia

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]

PCASTL
Paradigmimperative, reflective
Designed byPhilippe Choquette
DeveloperPhilippe Choquette
First appeared2008; 15 years ago (2008)
Stable release
3.5 / March 31, 2018; 5 years ago (2018-03-31)
OSCross-platform
LicenseGNU Lesser General Public License
Websitewww.pcosmos.ca/pcastl/
Influenced by
C, R

Hello world edit

The "Hello world program" is quite simple:

"Hello, world!" 

or

print("Hello, world!") 

will do the same.

Syntax edit

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 edit

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 edit

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 edit

References edit

  1. ^ "pcosmos.ca". Philippe Choquette. Retrieved 2008-06-14.
  2. ^ a b "PCASTL: by Parent and Childset Accessible Syntax Tree Language". Philippe Choquette. Retrieved 2008-06-14.
  3. ^ "An Introduction to R". R Development Core Team. 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 edit

  • PCASTL: by Parent and Childset Accessible Syntax Tree Language

pcastl, acronym, parent, childset, accessible, syntax, tree, language, interpreted, high, level, programming, language, created, 2008, philippe, choquette, designed, ease, writing, self, modifying, code, language, reserved, words, parent, childset, access, nod. 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 PCASTLParadigmimperative reflectiveDesigned byPhilippe ChoquetteDeveloperPhilippe ChoquetteFirst appeared2008 15 years ago 2008 Stable release3 5 March 31 2018 5 years ago 2018 03 31 OSCross platformLicenseGNU Lesser General Public LicenseWebsitewww wbr pcosmos wbr ca wbr pcastl wbr Influenced byC R Contents 1 Hello world 2 Syntax 2 1 Influences 2 2 parent and childset reserved words 3 See also 4 References 5 External linksHello world editThe Hello world program is quite simple Hello world or print Hello world will do the same Syntax editThe 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 edit 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 lt 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 edit 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 edit nbsp Free and open source software portalAbstract syntax tree Self modifying codeReferences edit pcosmos ca Philippe Choquette Retrieved 2008 06 14 a b PCASTL by Parent and Childset Accessible Syntax Tree Language Philippe Choquette Retrieved 2008 06 14 An Introduction to R R Development Core Team Retrieved 2008 06 14 Hanly Jeri R Elliot B Koffman 1999 Problem Solving amp Program Design in C Third Edition Addison Wesley ISBN 0 201 35748 8 External links editPCASTL by Parent and Childset Accessible Syntax Tree Language Retrieved from https en wikipedia org w index php title PCASTL amp oldid 1163281954, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.