Skip to content

Instantly share code, notes, and snippets.

@nasser
Last active August 29, 2015 14:07
Show Gist options
  • Save nasser/f863ce3911c6049279be to your computer and use it in GitHub Desktop.
Save nasser/f863ce3911c6049279be to your computer and use it in GitHub Desktop.
SFPC Grammar Homework 1
<meta charset="utf-8">
<script src="js/jquery.js"></script>
<script src="js/jqconsole.js"></script>
<script src="js/sugar.js"></script>
<script src="js/peg.js"></script>
<script src="js/plt.js"></script>
<script type="text/javascript">
// uncomment next line to enable refresh
// PLT.refresh = true
// write helper functions and semantics here
</script>
<title>Language</title>
<grammar>
start = [0-9]+
</grammar>
<h3>Numbers</h3>
<p>These should parse into JavaScript numbers.
Use <a href="http://www.w3schools.com/jsref/jsref_parseint.asp">parseInt</a>
and <a href="http://www.w3schools.com/jsref/jsref_parsefloat.asp">parseFloat</a> as needed.</p>
<code>45</code>
<code>83.2</code>
<code>-7</code>
<code>-92.8</code>
<h3>Text</h3>
<p>These should parse into JavaScript strings.
Use <a href="http://www.w3schools.com/jsref/jsref_join.asp">join</a> as needed.</p>
<code>"Hello"</code>
<code>"Hello World"</code>
<h3>Booleans</h3>
<p>These should parse into JavaScript booleans, true or false</p>
<code>true</code>
<code>false</code>
<code>yes</code>
<code>no</code>
<code>on</code>
<code>off</code>
<h3>Extra – Operators</h3>
<code>+ 5 6</code>
<code>* 5 6</code>
<code>- 5 6</code>
<h3>Extra – Nesting</h3>
<code>(+ 7 (- 10 9))</code>
<code>(+ (+ 20 5) (+ 7 2))</code>
<code>(+ (+ 20 5) (+ 7 (+ (+ 20 5) (+ 7 (+ (+ 20 5) (+ 7 (+ (+ 20 5) (+ 7 2))))))))</code>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment