This page shows all the different incantations, inputs and outputs of the current version of C'Dent compiling the hello-world example.
C'Dent Version
> cdent --version
The C'Dent portable module programming language. Copyright (c) 2010, Ingy dot Net Version 0.5
Inputs
C'Dent can currently parse the C'Dent subsets of Python, JavaScript and Perl 6.
These examples deal with equivalent versions of a World module. The module has a World class, which has a greet method, which has a println() command statement.
world.cd.py
This is the module written in C'Dent Python.
"""\ This is World class :) """ class World(): def greet(self): print "Hello, world"
World.cd.js
This is the module written in C'Dent JavaScript.
/** * This is World class :) */ (this.World = function() {}).prototype = { greet: function() { print("Hello, world"); } };
World.cd.pm6
This is the module written in C'Dent Perl 6.
### # This is World class :) ### class World { method greet { say "Hello, world"; } }
World.cd.yaml
This is the module in pure C'Dent "abstract tree" form, serialized as YAML.
%TAG ! tag:cdent.org,2010: --- !AST has: - !Module name: World has: - !Comment type: doc val: "This is World class :)\n" - !Comment type: blank val: "\n" - !Class name: World has: - !Method name: greet has: - !Println args: - !String val: Hello, world
Outputs
C'Dent can take any of the above inputs, and generate the following outputs: Perl, Python, PHP, Ruby, JavaScript, Scala, Java, ActionScript, Perl 6, Python 3000, Go, PIR, NQP or C'Dent.
Perl
> cdent --compile --in=world.cd.py --to=pm
# *** DO NOT EDIT *** This is a C'Dent generated Perl module. ### # This is World class :) ### package World; use CDent::Class; sub greet { my $self = shift; print "Hello, world", "\n"; } 1;
Python
> cdent --compile --in=world.cd.py --to=py
# *** DO NOT EDIT *** This is a C'Dent generated Python module. """\ This is World class :) """ class World(): def greet(self): print "Hello, world"
PHP
> cdent --compile --in=world.cd.py --to=php
// *** DO NOT EDIT *** This is a C'Dent generated PHP module. <?php /** * This is World class :) */ class World { public function greet() { print("Hello, world", "\n"); } } ?>
Ruby
> cdent --compile --in=world.cd.py --to=rb
# *** DO NOT EDIT *** This is a C'Dent generated Ruby module. ### # This is World class :) ### class World def greet puts("Hello, world") end end
JavaScript
> cdent --compile --in=world.cd.py --to=js
// *** DO NOT EDIT *** This is a C'Dent generated JavaScript module. /* * This is World class :) */ (this.World = function() {}).prototype = { greet: function() { print("Hello, world"); } }
Scala
> cdent --compile --in=world.cd.py --to=scala
// *** DO NOT EDIT *** This is a C'Dent generated Scala module. /** * This is World class :) */ class World { def greet() { println("Hello, world") } }
Java
> cdent --compile --in=world.cd.py --to=java
// *** DO NOT EDIT *** This is a C'Dent generated Java module. /** * This is World class :) */ public class World { public void greet() { System.out.println("Hello, world"); } }
ActionScript
> cdent --compile --in=world.cd.py --to=as
// *** DO NOT EDIT *** This is a C'Dent generated ActionScript module. package { /** * This is World class :) */ public class World { public function greet():void { trace("Hello, world" + "\n"); } } }
Perl 6
> cdent --compile --in=world.cd.py --to=pm6
# *** DO NOT EDIT *** This is a C'Dent generated Perl 6 module. ### # This is World class :) ### class World { method greet { say "Hello, world"; } }
Python 3000
> cdent --compile --in=world.cd.py --to=py3
# *** DO NOT EDIT *** This is a C'Dent generated Python 3 module. """\ This is World class :) """ class World(): def greet(self): print("Hello, world")
Go
> cdent --compile --in=world.cd.py --to=go
// *** DO NOT EDIT *** This is a C'Dent generated Go module. /* * This is World class :) */ package World import fmt "fmt" func greet() { fmt.Println("Hello, world") }
PIR
> cdent --compile --in=world.cd.py --to=pir
# *** DO NOT EDIT *** This is a C'Dent generated PIR module. ### # This is World class :) ### .namespace ["World"] .sub greet :method say "Hello, world" .end
NQP (Not Quite Perl)
> cdent --compile --in=world.cd.py --to=nqp
# *** DO NOT EDIT *** This is a C'Dent generated NQP (Not Quite Perl) module. ### # This is World class :) ### class World { method greet() { say("Hello, world"); } }
C'Dent
> cdent --compile --in=world.cd.py --to=cd.yaml
%TAG ! tag:cdent.org,2010: --- !AST has: - !Module has: - !Comment line: 1 type: doc val: 'This is World class :) ' - !Comment line: 4 type: blank val: ' ' - !Class has: - !Method has: - !Println args: - !String val: Hello, world line: 7 line: 6 name: greet line: 5 name: World line: 1 name: Module