Giter Site home page Giter Site logo

nathanuniversityexercisespl's Introduction

#Integrate your parser

Next, integrate your Scheem parser and Scheem interpreter.

First make a minor update to your parser so that it detects numbers. You want inputs like 5 to parse to the number 5 rather than the string 5.

Once you've got that done, you should be able to parse inputs like (+ 2 (* 3 4)) into a JavaScript form that is ready for passing along to your evalScheem.

#Downloading your parser code

Now in your local copy of simpletest.html add a line to load your parser. I organized the files as Scheem/parser.js and Scheem/test/simpletest.html so my extra line in Scheem/test/simpletest.html looks like this:

        <script src="../parser.js"></script>

#Unit testing the parser

Now we can start writing tests for the parser. Here are a couple examples:

      suite('parse', function() {
          test('a number', function() {
              assert.deepEqual(
                  SCHEEM.parse('42'),
                  42
              );
          });
          test('a variable', function() {
              assert.deepEqual(
                  SCHEEM.parse('x'),
                  'x'
              );
          });
      });
      evalScheemString

Now that you have your parser and interpreter working together, you can make a single function that does everything. Create a new function evalScheemString that takes a string and an environment and then parses and interprets the Scheem expression.

Integrate your parser into your browser test page. Write tests of all the features of your parser and make sure they pass. Add in the evalScheemString function. Write some tests for it, too.

nathanuniversityexercisespl's People

Contributors

crguezl avatar

Watchers

James Cloos avatar  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.