Dylan Baker
63d4d4b735
Evaluate lambda functions
vor 6 Jahren
Dylan Baker
369853af3e
Replace compiler with evaluator
This class exposes two functions. `evalNode` take an AST node and evaluates it down to simplest terms. `eval` takes an array of AST nodes and calls evalNode on each of them. I don’t think we’re quite ready to be producing HTML yet so let’s not get ahead of ourselves.
vor 6 Jahren
Dylan Baker
4d957c60a0
Core functions should return Oslo types, not JS types
vor 6 Jahren
Dylan Baker
f4f4f18106
Add comparison functions to core env
vor 6 Jahren
Dylan Baker
76c6eac9b5
Implement conditionals
Currently I'm relying on JavaScript's semantics
around truthiness. I think I'm going to retain
that ease of use (i.e. `(if list #t #f)` should
return true if the list has more than 0 elements,
etc) but I want to specify that behavior myself.
vor 6 Jahren
Dylan Baker
c833db2f94
LOL I forgot how Lisp works
vor 6 Jahren
Dylan Baker
3e5a873054
Prettier :/
vor 6 Jahren
Dylan Baker
b83126524d
Make all functions lambdas for now
vor 6 Jahren
Dylan Baker
06ab1b52d4
Compile function applications (named and lambda)
vor 6 Jahren
Dylan Baker
7a9b1a6727
Create simple compiler class
Just numbers and strings for now
vor 6 Jahren
Dylan Baker
0b4d63ee91
Make sure source gets passed in as a string
I noticed that if you passed in just a number, JS
would helpfully parse that and then
`source.length` was undefined, which broke the
lexer.
vor 6 Jahren
Dylan Baker
bffecce670
Add lambdas
vor 6 Jahren
Dylan Baker
90d84dbb6f
Prettier
vor 6 Jahren
Dylan Baker
67ca84857f
Prettier
vor 6 Jahren
Dylan Baker
4b3ce29206
Remove resolver and compiler, add define to parser
vor 6 Jahren
Dylan Baker
91730231df
Saving state
vor 6 Jahren
Dylan Baker
3b6525e29f
Prettier
vor 6 Jahren
Dylan Baker
497af0aa34
Implement test helper functions
vor 6 Jahren
Dylan Baker
296e94f25a
Add .DS_Store and .oslo files to gitignore
I keep test .oslo files around and I hate not
having a clean repo.
vor 6 Jahren
Dylan Baker
681a88a755
Clean up unused stuff
vor 6 Jahren
Dylan Baker
a3e6a6df66
Move list of selfclosing tags into its own module
vor 6 Jahren
Dylan Baker
60c6d9a24a
Don't include ="" for attributes with empty string
vor 6 Jahren
Dylan Baker
20ab139ca7
Add doctype to list of self closing tags
I added upper and lowercase because that seemed
preferable to always casting every html function
name to lowercase.
vor 6 Jahren
Dylan Baker
f77ad26a69
Allow empty strings
vor 6 Jahren
Dylan Baker
581c99f794
Rewrite AST and compiler to be more normal
vor 6 Jahren
Dylan Baker
c7c40f7df7
Implement number and boolean types
vor 6 Jahren
Dylan Baker
64e2ab8eb0
Implement some very basic error handling
It's a little hacky and not very clean but it's
working for now.
vor 6 Jahren
Dylan Baker
802884b135
Runn prettier
vor 6 Jahren
Dylan Baker
31f584d688
Allow for self-closing tags
vor 6 Jahren
Dylan Baker
ebae8a3536
Rework main parser logic
The way that we were doing it before was going to
make it very difficult to implement any sort of
error handling or extension to the language.
vor 6 Jahren
Dylan Baker
d82d4ed612
Don't wrap eaches in an empty function call node
Because I was assuming that every expression
started with a literal, calls to `each` were
getting wrapped by a functionCall node with no
functionName, which was subsequently ignored by
the compiler. This removes all of that uselessness
vor 6 Jahren
Dylan Baker
ebc21f694d
Redo map as each, still playing with the syntax
vor 6 Jahren
Dylan Baker
db64e79472
Implement mapping
vor 6 Jahren
Dylan Baker
c9c2e34940
Check for blank cli arguments
vor 6 Jahren
Dylan Baker
d46f25c589
Run prettier
vor 6 Jahren
Dylan Baker
d60e736fec
Allow using special characters in literals
vor 6 Jahren
Dylan Baker
4ae6bd884b
Implement CLI
vor 6 Jahren
Dylan Baker
69dc0975d0
Manage the whitespace produced by the compiler
vor 6 Jahren
Dylan Baker
564b4808e9
Allow using variables as attribute values
vor 6 Jahren
Dylan Baker
ef0845237f
Allow whitespace while between quotes
What was happening was that spaces were allowed in
all literals to account for quoted strings, but
this meant that two identifiers in a row would get
parsed as a single literal. This commit sets a
flag to allow whitespace in literals when a quote
is encountered and then unsets that flag at the
next quote.
vor 6 Jahren
Dylan Baker
709986560e
First try at the compiler
No variables or conditionals or anything yet, just
the basic ability to turn s-expressions into HTML.
vor 6 Jahren
Dylan Baker
f7d7e9f46f
Fix up some stuff and add a test for parser
vor 7 Jahren
Dylan Baker
a6b691807d
Handle nested expressions
vor 7 Jahren
Dylan Baker
0bd9afe74b
Fix broken lexer test
vor 7 Jahren
Dylan Baker
d746573773
Fix lexer
vor 7 Jahren
Dylan Baker
bdf7527409
WIP Parser
vor 7 Jahren
Dylan Baker
5c8194cc44
Package lock
vor 7 Jahren
Dylan Baker
fdee6a6367
Use classes after all
vor 7 Jahren
Dylan Baker
22512cf334
Somehow I wasn't initializing variables?
vor 7 Jahren
Dylan Baker
cd6eccabb1
Update prettier config
vor 7 Jahren