Basic functionality

This commit is contained in:
E Dunbar 2025-04-18 15:35:24 -05:00
parent a0e03ddd73
commit 8cd6c4e65d
14 changed files with 9100 additions and 3 deletions

21
test/corpus/basic.txt Normal file
View file

@ -0,0 +1,21 @@
=======
shebang
=======
#!/usr/bin/env hy
---
(source_file
(shebang))
=======
comment
=======
; this is a comment
---
(source_file
(comment))

View file

@ -0,0 +1,50 @@
=======
keyword
=======
:test
(f :foo 3)
---
(source_file
(keyword)
(expression
(symbol) (keyword) (integer)))
==================
dotted identifiers
==================
(foo.bar.baz)
(.foo.bar)
(..foo.bar)
.foo.bar
---
(source_file
(expression
(dotted_identifier))
(expression
(dotted_identifier))
(expression
(dotted_identifier))
(dotted_identifier))
======================
not dotted identifiers
======================
.
...
........
. .
---
(source_file
(symbol)
(symbol)
(symbol)
(symbol) (symbol))

268
test/corpus/numeric.txt Normal file
View file

@ -0,0 +1,268 @@
=======
integer
=======
7
---
(source_file
(integer))
============
integer long
============
2147483647
---
(source_file
(integer))
==================
integer super long
==================
79228162514264337593543950336
---
(source_file
(integer))
==================
integer zero start
==================
00000042
---
(source_file
(integer))
========================
integer should be symbol
========================
_1
---
(source_file
(symbol))
==============
integer signed
==============
-7
+7
---
(source_file
(integer) (integer))
==============
integer with _
==============
100_000_000__000
---
(source_file
(integer))
==============
integer with ,
==============
10,000,000,000
---
(source_file
(integer))
=============
integer octal
=============
0o177
---
(source_file
(integer))
==============
integer binary
==============
0b_1110_0101
---
(source_file
(integer))
===========
integer hex
===========
0xdeadbeef
---
(source_file
(integer))
=====
float
=====
3.14
---
(source_file
(float))
============
float signed
============
+2.17
-1.
---
(source_file
(float) (float))
=================
float no fraction
=================
10.
---
(source_file
(float))
===================
float only fraction
===================
.001
---
(source_file
(float))
============
float with _
============
3.14_15_93
---
(source_file
(float))
============================
float scientific no fraction
============================
1e100
---
(source_file
(float))
==============================
float scientific with fraction
==============================
3.14e-10
---
(source_file
(float))
=======================
float scientific zeroes
=======================
0e0
---
(source_file
(float))
==============
float literals
==============
NaN
Inf
-Inf
---
(source_file
(float) (float) (float))
=======
complex
=======
3+4j
---
(source_file
(complex))
==============
complex signed
==============
-3+4j
---
(source_file
(complex))
==============
complex harder
==============
0+3.14e-10j
---
(source_file
(complex))
===============
complex literal
===============
-Inf+NaNj
---
(source_file
(complex))

82
test/corpus/sequence.txt Normal file
View file

@ -0,0 +1,82 @@
==========
expression
==========
(test this)
---
(source_file
(expression
(symbol) (symbol)))
====
list
====
[me list]
[]
---
(source_file
(list
(symbol) (symbol))
(list))
=====
tuple
=====
#(first second)
#()
---
(source_file
(tuple
(symbol) (symbol))
(tuple))
===
set
===
#{look me}
#{}
---
(source_file
(set
(symbol) (symbol))
(set))
==========
dictionary
==========
{key value}
{}
---
(source_file
(dictionary
(symbol) (symbol))
(dictionary))
===================
function definition
===================
(defn my-fn []
(print "abcd"))
---
(source_file
(expression
(symbol) (symbol) (list)
(expression
(symbol) (string))))

35
test/corpus/string.txt Normal file
View file

@ -0,0 +1,35 @@
======
string
======
("i am a string")
("i am
also a string")
"me too!"
---
(source_file
(expression
(string))
(expression
(string))
(string))
==============
bracket string
==============
(#[[i am a bracket string]])
(#[[i am
also a bracket string]])
#[[me too!]]
---
(source_file
(expression
(bracket_string))
(expression
(bracket_string))
(bracket_string))