|
1 | | -<div align='center'> |
2 | | -<img src='Assets/PipeScript.png' /> |
3 | | -</div> |
| 1 | +This directory and it's subdirectories contain additional language keywords within PipeScript. |
4 | 2 |
|
5 | | -# What Is PipeScript? |
| 3 | +Most keywords will be implemented as a Transpiler that tranforms a CommandAST. |
6 | 4 |
|
7 | | -> PipeScript is a transpiled scripting language built atop of PowerShell. |
8 | 5 |
|
9 | | -> PipeScript can be run interactively |
| 6 | +|DisplayName |Synopsis | |
| 7 | +|------------------|----------------------------| |
| 8 | +|[New](New.psx.ps1)|['new' keyword](New.psx.ps1)| |
10 | 9 |
|
11 | | -> PipeScript can embedded within many languages to dynamically generate source code |
12 | 10 |
|
13 | | -## What's a Transpiler? |
14 | 11 |
|
15 | | -A transpiler takes source code written in one language and transforms or translates it. |
16 | 12 |
|
17 | | -Transpilers can be used to extend a given language. |
18 | | -For example, TypeScript adds strongly typed features to JavaScript, a weakly typed language. |
| 13 | +## New Example 1 |
19 | 14 |
|
20 | | -Transpilers can also be used to convert from one language to another. |
21 | | -For example, most PowerShell ```Select-Object``` statements could be translated to SQL. |
22 | 15 |
|
23 | | -Transpilers can also be used to optimize or reconfigure source code. |
24 | | -For example, any minifier or code stylization tool is a transpiler. |
| 16 | +~~~PowerShell |
| 17 | + .> { new DateTime } |
| 18 | +~~~ |
25 | 19 |
|
26 | | -## What makes PipeScript unique? |
| 20 | +## New Example 2 |
27 | 21 |
|
28 | | -PipeScript is unique because PowerShell is unique. |
29 | 22 |
|
30 | | -There are a few facets of PowerShell's uniqueness that make PipeScript possible: |
| 23 | +~~~PowerShell |
| 24 | + .> { new byte 1 } |
| 25 | +~~~ |
31 | 26 |
|
32 | | -### Incredibly Flexible Syntax |
| 27 | +## New Example 3 |
33 | 28 |
|
34 | | -One of PowerShell's strengths is it's consistent syntax. Most PowerShell you encounter will be cleanly organized into Verbs and Nouns. |
35 | | -For example, ```Get-Process```. |
36 | 29 |
|
37 | | -However, like JavaScript, what is valid syntax goes far beyond what PowerShell uses. Commands can be named almost anything. Attributes and Types need not exist to be valid. This gives us many places we can extend PowerShell as a language. |
| 30 | +~~~PowerShell |
| 31 | + .> { new int[] 5 } |
| 32 | +~~~ |
38 | 33 |
|
39 | | -Additionally, the core language features of PowerShell are a superset of most programming languages. This means that PowerShell should be able to be transpiled into any language. |
| 34 | +## New Example 4 |
40 | 35 |
|
41 | | -### The Abstract Syntax Tree |
42 | 36 |
|
43 | | -PowerShell also has an Abstract Syntax Tree. This is used to represent scripts before they run. As the name implies, this is hierarchical representation of syntax, which lets us walk thru step-by-step, not just token-by-token. |
| 37 | +~~~PowerShell |
| 38 | + .> { new datetime 12/31/1999 } |
| 39 | +~~~ |
44 | 40 |
|
45 | | -Because the Abstract Syntax Tree of PowerShell is so well-defined, it lets us be incredibly flexible. Not only can we transform certain parts of the syntax, we can do so differently based off of the surrounding context. This makes transforming PowerShell much more potent than a simple find and replace. |
| 41 | +## New Example 5 |
46 | 42 |
|
47 | | -### Rich RegEx Support |
48 | 43 |
|
49 | | -PowerShell comes with Rich RegEx Support. |
50 | | -The ```-match```, ```-replace```, and ```-split``` operators help slice and dice text, and the .NET ```[RegEx]``` class allows for even more advanced operations. This lets us flexibly parse text and turn it into objects. |
| 44 | +~~~PowerShell |
| 45 | + .> { new @{RandomNumber = Get-Random; A ='b'}} |
| 46 | +~~~ |
51 | 47 |
|
52 | | -### The Object Pipeline |
| 48 | +## New Example 6 |
53 | 49 |
|
54 | | -The Object Pipeline is the backbone of PowerShell and PipeScript. |
55 | 50 |
|
56 | | -It allows you to pipe structured data, not text, from one step to the next. |
| 51 | +~~~PowerShell |
| 52 | + .> { new Diagnostics.ProcessStartInfo @{FileName='f'} } |
| 53 | +~~~ |
57 | 54 |
|
58 | | -By using the object pipeline, you loosely couple each step and allow steps to easily take input from structured files or APIs. |
59 | | - |
60 | | -PipeScript allows you to transpile using an Object Pipeline. |
0 commit comments