Giter Site home page Giter Site logo

practical / practical-sa Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 689 KB

The Practical Programming Language - Semantic Analyzer

License: Boost Software License 1.0

Makefile 0.54% M4 4.48% C++ 94.98%
programming-language compiler runtime-library practical-programming-language semantic-analyzer-library programming-language-development

practical-sa's People

Contributors

shachar avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

practical-sa's Issues

Unify expression and statement parsing

The parser syntax should be able to start processing a block of code, and only then decide whether it is an expression returning value or a statement.

This is crucial for efficient nested compound statements support.

Should operators on literals delay range check?

def var : S8 = 0 - 128;

Should it not compile, because 128 is not a valid number for the expected type S8? In which case, the code needs to be written as:
def var : S8 = expect!S16(0 - 128);

Or should the check for range be delayed? How about:

def var : S8 = 128 - 256;?

Dummy run changes context

Determining an unconstrained expression by code-generating it using a dummy code-gen might introduce variables into the context (especially if it's variables defined in a parent context).

Consider necessity of IdentifierId

The code generation currently communicates an IdentifierId that identifies functions. It seems that it is never used, never even stored, and adds nothing to the code.

Should consider removing it.

Implicit cast compilation error is misleading.

When compiling the following code:
{
def var1: s32 = 5;
def var2: u32 = var1;
//Do something.
}

I get a compilation error along the lines of:
"s32 cast to u32 is not allowed"

This error is misleading as an explicit cast is allowed, it is just not allowed implicitly.

Conditional expression must be either alone or inside parenthesis

As currently implemented, conditional expressions must either come alone (i.e. - not interact with any other operator), or surrounded by parenthesis. So, this is legal:

def chain( number : U64 ) -> U64 {
  if( numer%2 == 0 ) {
    number/2
  } else {
    number*3 + 1
  }
}

And this is also legal:

def chain( number: U64 ) -> U64 {
  ( if(number>12) {number} else {12} ) + 5
}

But this isn't:

def chain( number: U64 ) -> U64 {
  if(number>12) {number} else {12} + 5
}

Currently, this is a limitation of the parser, but we need a debate on whether that's actually a good restriction on conditional expressions.

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.