Giter Site home page Giter Site logo

hilden's Introduction

HILDEN

Hilden is a new language which implements blocked scoping written in C++.

Check out test/ for examples

Run

  1. Run make from the root of this repository
  2. Run an example ./hilden test/fact.hl

Language Design and Implementation

Lexer

lex/lexer.cpp

The lexer converts the text code into a list of tokens. Uses state machines to output token type.

The output of the lexer is passed to the Parser

Parser

parse/op_parse.cpp

The parser takes the ordered token list from the lexer and uses it to generate an Abstract Syntax Tree.

The parser works recursively. Everytime an open block is encountered, the parser is called recursively, which returns a abstract syntax tree node.

When the parser encounters a binary expression, it passes on the parsing to a parse_binary which mutually recurses with the main parse function (since a binary expression may have an expression within it). The binary parser uses the Shunting Yard Algorithm for parsing.

The generated AST is passed to the Semantic Analyser

Semantic Analysis

semantics/environment.cpp

The semantic analyser handles environments. Scoped declarations are local to the scope. Any declaration outside the scope is accessible inside but not vice versa.

The SA also evaluates the AST. Uses a modification of depth first tree traversal, looks at the node type, does typechecking and evaluates accrodingly.

Pass the --tree flag while executing Hilden code to print out the generated AST Pass the --lex flag while executing Hilden code to print out the token list Pass the --all flag while executing Hilden code to print out both the token list and the AST generated

For lexing:

from the root directory run the following commands

lex lex/lexer.l g++ lex.yy.c lex/scanner.cpp main.cpp ./a.out <a .hl file>

it should print out the correct token list

hilden's People

Contributors

delta7-138 avatar gr455 avatar vigneshbondugula avatar raddi1972 avatar abhinav-kamath avatar

Stargazers

Rishi Vakharia avatar Santhosh J S avatar Vyaas Shenoy avatar Temperatureblock avatar Parth Kulkarni avatar Vijay Jaisankar avatar  avatar

Watchers

 avatar

hilden's Issues

Port to Bison

Porting the parsing to Bison. A thread for the workflow.

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.