Code Monkey home page Code Monkey logo

pnp's People

Stargazers

 avatar

Forkers

lopescode

pnp's Issues

Include the semantic of logical operations

I'm converting everything to Kotlin because I was having too many problems with Null Pointer Exception with Java. #1 is the current list of what has to be done for now.
While is everything being refactored, should be good to check the current behaviour of the relational operations in the semantic phase.

Relational Operations:

  • And
    • Allowed to boolean operands
    • The result is always a boolean value. If both operands are true, the result is true. Otherwise, the result is false.
  • Or
    • Allowed to boolean operands
    • The result is always a boolean value. If both operands are false, the result is false. Otherwise, the result is true.
  • Not
    • Allowed to a boolean operands
    • The result is always a boolean value. If the operand is true, the result is false. Otherwise, the result is true.
  • Xor
    • Allowed to a boolean operands
    • The result is always a boolean value. If the operands are different, the result is true, Otherwise, the result is false.

Implement semantic of the Do-While statement

Do-While is one of the control flow statements that consists in the repetition of a block of instruction while the given Boolean condition is false. The difference between it and the while statement is that while has a pre-condition and do-while has a pos-condition. That means that the do-while statement executes its block of instructions at least once.

This is the syntax of the do-while loop in the PNP language:

repita
    <block of instructions>
ate que <condition>;

The Java implementation that it's been refactored already have an implementation of the do-while statement. We have to refactor it to Kotlin too.

Implement semantic of the Switch statement

The switch is one of the control flow statements that which perform different computations depending on the value of the given variable.

This is the syntax of the switch statement in the PNP language:

caso <variable> seja
    <value-1>: <block of instructions when variable = value1>
    <value-2>: <block of instructions when variable = value2>
    <value-2>: <block of instructions when variable = value3>
    senao: <block of instructions default>
fim

The default branch can be omitted. A switch statement can have multiple branches. Each branch can only be computed if its respective condition value is true and all the other branches won't be computed. The computation of the switch statement is very similar to an if statement #11. The equivalent of the switch example in an if statement is as follows:

se (variable = value1) entao
    <block of instructions when variable = value1>
senao se (variable = value2) entao
    <block of instructions when variable = value2>
senao se (variable = value3) entao
    <block of instructions when variable = value3>
senao
    <block of instructions default>
fim

Create a PNP interpreter

The main purpose of this project is to implement a compiler to the language we created. The compiler is a translator: it gets the code written in a language and translates it to another language. The most known compilers usually translate a programming language to a machine language.
Our compiler is under construction and the first purpose is to translate code written in PNP to Web Assembly Text Format.

I was thinking that we should also implement an interpreter to PNP language. Different from the compiler, an interpreter executes the code directly. This way, the final user can write codes in PNP and effectively execute then. I could be able only to read files or could have a user interface too.

Implement semantic of the While statement

While is one of the control flow statements that consists in the repetition of a block of instruction while the given Boolean condition is true.

This is the syntax of the while loop in the PNP language:

enquanto <condition> faca
    <block of instructions>
fim

The Java implementation that it's been refactored already have an implementation of the while statement. We have to refactor it to Kotlin too.

Include the semantic of arithmetic operations

I'm converting everything to Kotlin because I was having too many problems with Null Pointer Exception with Java. #1 is the current list of what has to be done for now.
While is everything being refactored, should be good to check the current behaviour of the arithmetic operations in the semantic phase.

Arithmetic Operations:

  • Addition
    • Allowed to integer and rational operands
    • The result depends on the operands. If both are integers, the result is an integer. Otherwise, the result is rational.
  • Subtraction
    • Allowed to integer and rational operands
    • The result depends on the operands. If both are integers, the result is an integer. Otherwise, the result is rational.
  • Multiplication
    • Allowed to integer and rational operands
    • The result depends on the operands. If both are integers, the result is an integer. Otherwise, the result is rational.
  • Rational Division
    • Allowed to integer and rational operands
    • The result is always a rational value
  • Integer Division
    • Allowed to integer operands
    • The result is always an integer value
  • Modulo
    • Allowed to integer operands
    • The result is always an integer value

Implement semantic of if statement

If is one of the control flow statements that which perform different computations depending on the value of the given Boolean condition.

This is the syntax of the if statement in the PNP language:

se <condition> entao
    <block of instructions when the condition is true>
senao
    <block of instructions when the condition is false>
fim

The else branch can be omitted. An if statement can have multiple branches. Each branch can only be computed if its respective condition value is true and all the other branches won't be computed.

se <condition-1> entao
    <block of instructions when the condition-1 is true>
senao se <condition-2> entao
    <block of instructions when only the condition-2 is true>
senao se <condition-3> entao
    <block of instructions when only the condition-3 is true>
senao
    <block of instructions when all conditions are false>
fim

Implement semantic of the For statement

For is one of the control flow statements that consists in the repetition of a block of instruction a given number of times.

This is the syntax of the for loop in the PNP language:

para <control-variable> de <initial-value> ate <final-value> passo <increment-value> repita
    <block of instructions>
fim

Following that syntax, the for-loop iteration can start and end at any value since the values have both the same type. The step of increment can be omitted with the default value of 1.

para <control-variable> de <initial-value> ate <final-value> repita
    <block of instructions>
fim

Include the semantic of relational operations

I'm converting everything to Kotlin because I was having too many problems with Null Pointer Exception with Java. #1 is the current list of what has to be done for now.
While is everything being refactored, should be good to check the current behaviour of the relational operations in the semantic phase.

Relational Operations:

  • Equality
    • Allowed to integer, boolean and character operands, with both operands having the same type
    • The result is always a boolean value
  • Inequality
    • Allowed to integer, boolean and character operands, with both operands having the same type
    • The result is always a boolean value
  • Greater than
    • Allowed to integer, rational and character operands, with both operands having the same type
    • The result is always a boolean value
  • Greater than or equal
    • Allowed to integer and character operands, with both operands having the same type
    • The result is always a boolean value
  • Less than
    • Allowed to integer, rational and character operands, with both operands having the same type
    • The result is always a boolean value
  • Less than or equal
    • Allowed to integer and character operands, with both operands having the same type
    • The result is always a boolean value

Refactor semantics check list

  • Operations
    • Arithmetic Operations #5
    • Relational Operations #13
    • Logical Operations #6
  • Variable Declaration and Assignment
  • Statements
    • While Statement #14
    • Do While Statement #9
    • If Statement #11
      • If-only Statement
      • If-else Statement
      • If-else-if Statement
    • For Statement #10
    • Switch Statement #12
  • Procedures
  • Abstract Types
  • Scope
    • Global Scope
    • Procedure Scope
    • Statement Scope

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.