To Get Started With Writing Code In Pencode You First Have To Start Off With Configuring The
pencode.py file
And Telling It The Filename And Path Of Your New File (It Is Strongly Recomended That You First Learn Python Before
Learning Pencode). Go To Line Number 7 and redefine the filename variable.
1  from lexer import Lexer
2  from parsers import Parserd
3  from evaluator import Evaluator
4  def main():
5   filename = 'hello.pencde'
6   file = open(filename, 'r')
7   filename = 'pen1.pencde'
8   file = open(filename, 'r')
9   lexer = Lexer(file)
10   parser = Parserd(lexer.tokens)
11   lexer.tokenizer()
12   # print( "TOKENS:" )
13   print( lexer.tokens, "\n" )
14   parser.build_AST()
15   # print( "AST:" )
16   # print( parser.AST, "\n" )
17   evaluator = Evaluator(parser.AST)
18   print("OUTPUT:")
19   evaluator.run(parser.AST)
20  if __name__ == "__main__":
21   main()
And Now We Can Have Some Fun With Pencode!
start: MethodNow that you Have Put Your Filename and Filepath In The pencode.py file, you can
start coding in pencode. The start: method (or function but a function in pencode is a method) is the
main part of any pencode file. The start: method tells pencode (and python) that the code has begun.
Anything you type after that runs first. lets declare the start: method in your own new file. this is
how you will do it:
1   start:
There we go, We Have a Main Method In Our Program!
penOut commandEverything in pencode is done by a pen and so do all the commands. When you want to get output in
pencode, you have to tell the pen to get output and you do that using the penOut command. Anything typed
after this
in double quotes (") is printed out to the screen. let's print some text then:
1 start:
2   penOut "Hello World!"
Now To Run our sweet little code we typed, we have to save our file and run the pencode.py
file and just look at the text under the OUTPUT: text. We just printed 'Hello World!' to the screen!
Note: Pencode Doesnt Care About Indentation:
1 start:
is same as:
2   penOut "blah blah blah..."
1 start:
2 penOut "blah blah blah..."