Git Product home page Git Product logo

swifttsinterpreter's Introduction

Swift-Barcelona: Swift Language Support for Source Academy

Swift-Barcelona is a subset of Swift 5. This repository is the Source-academy compatible implementation of Swift-Barcelona, conforming to the <language>-slang API.

Installation

To write Swift-Barcelona codes on Source Academy on your local machine,

Clone repository

  1. Clone the repository cs4215-project-2022-barcelona to your machine.

This repository contains the implementation of Swift-Barcelona.

  1. Clone the repository cs4215-project-2022-frontend-barcelona to the same folder on your machine.

This repository contains the Source Academy.

Build Swift-Barcelona

  1. Go to the repository folder cs4215-project-2022-barcelona in the terminal.

  2. Run the following command to install required dependencies:

$ yarn install
  1. Replace the file node_modules/@types/estree/index.d.ts with this file.

The reason for this step is that installing the dependencies in the previous step would overwrite the modified ESTree file, and the modified ESTree file is necessary for Swift-Barcelona.

  1. Generate the antlr4ts lexer and parser with the following command:
$ yarn run antlr4ts
  1. Delete line 9-11 of the file src/lang/CalcLexer.ts.
import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator";
import { NotNull } from "antlr4ts/Decorators"; // REMOVE
import { Override } from "antlr4ts/Decorators"; // REMOVE
import { RuleContext } from "antlr4ts/RuleContext"; // REMOVE
import { Vocabulary } from "antlr4ts/Vocabulary";

The reason for this step is that although NotNull, Override, RuleContext are auto-generated, they are never used in this file which will stop users from building the project.

  1. Delete line 7, 9, 13-14 of the file src/lang/CalcParser.ts.
import { FailedPredicateException } from "antlr4ts/FailedPredicateException";
import { NotNull } from "antlr4ts/Decorators"; // REMOVE
import { NoViableAltException } from "antlr4ts/NoViableAltException";
import { Override } from "antlr4ts/Decorators"; // REMOVE
import { Parser } from "antlr4ts/Parser";
import { ParserRuleContext } from "antlr4ts/ParserRuleContext";
import { ParserATNSimulator } from "antlr4ts/atn/ParserATNSimulator";
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; // REMOVE
import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; // REMOVE
import { RecognitionException } from "antlr4ts/RecognitionException";

The reason for this step is that although NotNull, Override, ParserTreeListener, ParserTreeVisitor are auto-generated, they are never used in this file which will stop users from building the project.

  1. Build the project with the following command:
$ yarn build
  1. Link the project:
$ yarn link

Link to, build and run Source Academy

  1. Go to the folder cs4215-project-2022-frontend-barcelona in the terminal.

  2. Link the frontend to the built implementation of Swift-Barcelona:

$ yarn link x-slang
  1. Delete line 49 of the file package.json
"flexboxgrid-helpers": "^1.1.3",
"x-slang": "^0.4.70", // REMOVE
"lodash": "^4.17.20",

The reason for this step is that we are using the x-slang of our own. Delete this line so that it will not try to find x-slang online when installing the dependencies in the next step. We will need to add it back after installing the dependencies.

  1. Install required dependencies:
$ yarn install
  1. Add "x-slang":"^0.4.70", back to the file package.json.
"flexboxgrid-helpers": "^1.1.3",
"x-slang": "^0.4.70", // ADD
"lodash": "^4.17.20",
  1. Start the Source Academy:
$ yarn run start
  1. When you see Compiled successfully! in the terminal, access Source Academy in your browser at localhost:8000.

Happy coding!

Test Case

The sample test code can be found in testcase.

swifttsinterpreter's People

Contributors

xiatg avatar bastianhoj avatar github-classroom[bot] avatar

Watchers

 avatar

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.