Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establishing generic parselets and functions #105

Merged
merged 111 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
53b86f1
Use IndexMap for constants and signature
phorward Feb 18, 2023
6b297f1
Unify naming for constants and signature
phorward Feb 18, 2023
ae9a4b7
Some renamings
phorward Feb 18, 2023
34e738e
Merge branch 'main' into generic-parselets
phorward Feb 22, 2023
06d12fa
Merge branch 'main' into generic-parselets
phorward Mar 4, 2023
2483e83
temporarily disabling prelude
phorward Mar 5, 2023
3482a3d
Merge branch 'main' into generic-parselets
phorward Mar 6, 2023
43353b8
ImlValue::ParseletInstance?
phorward Mar 11, 2023
fe9a1bb
Let's use ImlValue::Parselet for instances as well
phorward Mar 13, 2023
2b2d89d
Check for invalid parselet instances
phorward Mar 19, 2023
19c8b1c
Merge ImlTarget into ImlValue
phorward Mar 19, 2023
6f0d981
Renaming iml-modules into appropriate filenames
phorward Mar 19, 2023
9e4bb42
Rename ImlValue::value() to ImlValue::into_refvalue()
phorward Mar 19, 2023
50a5df8
First traversal of value_generic/genarg
phorward Mar 20, 2023
4eff813
Substitute Option<ImlValue> by ImlValue::Void
phorward Mar 20, 2023
0010a84
ImlValue::Generic & ImlParselet clean-up
phorward Mar 22, 2023
d4ee396
wip: get clarification for data model
phorward Apr 4, 2023
c12f1fc
wip: ImlValue::Shared
phorward Apr 16, 2023
bef35e8
.
phorward Apr 16, 2023
77e247f
wip: Rename Linker into ImlProgram
phorward Apr 17, 2023
45a1570
wip: Change signature of ImlOp::compile
phorward Apr 17, 2023
19acfce
wip: Move finalization entirely into ImlProgram
phorward Apr 17, 2023
de8932e
wip: Separated self-contained ImlProgram::finalize()
phorward Apr 18, 2023
6566246
ImlProgram::finalize() improvements
phorward Apr 18, 2023
5946136
ImlValue::compile_load() & ImlValue::compile_call()
phorward Apr 19, 2023
a5c658f
ImlOp::compile_to_vec()
phorward Apr 19, 2023
0c14cd9
Merge branch 'main' into generic-parselets
phorward Apr 19, 2023
089b122
Merge branch 'main' into generic-parselets
phorward Apr 20, 2023
a48e340
Improving debug / ImlSharedParselet
phorward Apr 21, 2023
24cdce6
wip: Improving code
phorward Apr 24, 2023
952f0dc
wip: Clean-up, annotations and refactor
phorward Apr 25, 2023
a78a2e2
wip: ImlValue::compile() and ImlValue::Parselet
phorward Apr 25, 2023
31c4a4a
wip: Implement ImlValue::Instance resolving
phorward Apr 26, 2023
e470038
wip: ImlParseletModel
phorward Apr 28, 2023
0e57b4c
Improved error handling
phorward Apr 29, 2023
4628298
Remove warnings
phorward Apr 29, 2023
e952bb6
Correctly handle static value calls
phorward May 2, 2023
706b3a9
ImlValue::Op() and unique parselet instances
phorward May 2, 2023
8851694
Merge branch 'main' into generic-parselets
phorward May 18, 2023
39fe57d
Use compiler statics' for atomics
phorward May 21, 2023
48210d4
Drafting Repeat<P> and improvements
phorward Jun 1, 2023
7f2f893
Clarification of the `repeat` keyword
phorward Jun 5, 2023
68fc8b6
`Self` and `self`, first draft of `List`
phorward Jun 6, 2023
d966e2a
Implemented `Self` usage from todo in `tokay.tok`
phorward Jun 7, 2023
bf0ca03
*-deref (don't call) operator + prelude Expect
phorward Jun 11, 2023
305fa23
Implement `reset`-keyword, `Not<P>`, `Peek<P>`
phorward Jun 16, 2023
b37d399
Some improvements on ImlValue::Instance
phorward Jun 20, 2023
d401e13
Re-introduce unresolved ImlValue::Generic
phorward Jun 22, 2023
42f2360
Merge branch 'main' into generic-parselets
phorward Jul 5, 2023
8b8571a
Merge branch 'threads' into generic-parselets-test
phorward Jul 10, 2023
7eda05d
Merge branch 'main' into generic-parselets
phorward Jul 20, 2023
64aa87b
Merge branch 'main' into generic-parselets
phorward Jul 22, 2023
b40affa
Merge branch 'main' into generic-parselets
phorward Jul 23, 2023
35861fc
Broken attempt to derive during finalization
phorward Jul 26, 2023
a5d6f50
Adding generics test examples
phorward Jul 26, 2023
acac3e8
ImlParselet::is_resolved()
phorward Jul 28, 2023
3d021e2
Merge branch 'main' into generic-parselets
phorward Jul 30, 2023
b25c621
Refactor finalization, part I
phorward Aug 5, 2023
733b63c
Refactor finalization, part II
phorward Aug 5, 2023
3412a7e
Improve Peek<P>
phorward Aug 5, 2023
e233491
`prelude.tok` with `Pos<P>, `Kle<P>` and `Opt<P>`
phorward Aug 5, 2023
adcaec6
Bugfix for unresolved instances
phorward Aug 11, 2023
27dce47
Improving derivation stuff and handle Self-values
phorward Aug 12, 2023
90a2ba4
Docstrings
phorward Aug 14, 2023
551d6ef
Renamings
phorward Aug 14, 2023
a0cf9f9
Some internal revisions
phorward Aug 22, 2023
863e9ab
Redefinition of Accept::Return
phorward Aug 23, 2023
949b11c
First attempt of `tokay.tok` using `Expect<P>`
phorward Aug 23, 2023
62b4723
Fixed whitespace issue in tokay.tok and parser.rs
phorward Aug 24, 2023
ea09f24
Built-in prelude using ast2rust (similar to parser)
phorward Aug 24, 2023
861c583
Some code maintenance for Compiler
phorward Aug 24, 2023
fa23154
Improving Expect<P> to respect EOF as well
phorward Aug 25, 2023
b72ceb7
New parser.rs from tokay.tok, eliminating `expect`, `not` and `peek`
phorward Aug 27, 2023
5a592d8
Add 'restrict'-mode to Compiler, improved reserved identifier detection
phorward Sep 4, 2023
a4e6242
Merge branch 'main' into generic-parselets
phorward Sep 16, 2023
afdec9b
Improving implementation of Repeat
phorward Sep 20, 2023
84e476d
Accept `void` as primitive for value!()-macro calls
phorward Sep 20, 2023
9e9be3d
Fixing preluded Kle
phorward Sep 21, 2023
718936a
First version that uses generics for Pos/Kle/Opt
phorward Sep 21, 2023
43ff0aa
ImlValue::Instance with optional severity
phorward Sep 21, 2023
d6731d5
Re-enable Char-modifier-optimization
phorward Sep 22, 2023
e7bb163
Further improving on preluded Kle
phorward Sep 23, 2023
a5d4b3d
Context::collect() should ignore severity 0 values (#118)
phorward Sep 23, 2023
7db1984
Redefine severity
phorward Sep 26, 2023
926b69a
Removed obsolete comment
phorward Sep 26, 2023
473659e
Merge branch 'redefine-severity' into generic-parselets
phorward Sep 26, 2023
d4a8069
Merge branch 'main' into generic-parselets
phorward Sep 26, 2023
460dfa3
Handle line breaks within generic definitions
phorward Sep 27, 2023
f7e0b5d
Fix ImlOp's consuming state and improve Op::Reset*
phorward Sep 27, 2023
62cde51
Redefined ImlOp::is_consuming()
phorward Sep 28, 2023
cda5cd6
Updating prelude, with "blur"-feature for compatiblity
phorward Sep 28, 2023
e464d45
Merge remote-tracking branch 'phorward/generic-parselets-fixes' into …
phorward Sep 28, 2023
92d9f59
Fix preluded' Repeat to use `list_push()` instead of `+=`
phorward Sep 28, 2023
216a222
Merge remote-tracking branch 'phorward/generic-parselets-fixes' into …
phorward Sep 28, 2023
b5a16c5
Modifiers with assumed severity
phorward Sep 30, 2023
dc8e24b
Improving context debug
phorward Sep 30, 2023
cf5ed31
Fixing left-recursion detection, improving debug
phorward Oct 3, 2023
c708a59
Modifying parselet_leftrec.tok to fulfill current capabilities on lef…
phorward Oct 4, 2023
d4ac089
Removal of ImlOp::Repeat
phorward Oct 5, 2023
307c7fc
Store name with compile-time local and global
phorward Oct 8, 2023
5b165ce
Several improvmenents on semantic error detection
phorward Oct 12, 2023
387dada
Fixing generic argument requirement error reporting
phorward Oct 15, 2023
ff60c5f
Replace ImlValue::Void by ImlValue::Unset
phorward Oct 19, 2023
6db705e
Renamed ImlValue::Shared into ImlValue::Unresolved
phorward Oct 19, 2023
5633b2c
Removal of dead error reporting
phorward Oct 20, 2023
4857a96
Merge ImlValue::Local/Global into ImlValue::Variable
phorward Oct 20, 2023
6bba5d2
Some renamings and docstring fixes
phorward Oct 21, 2023
755aaed
Renamings and restructuring
phorward Oct 21, 2023
d438840
Updating docstrings and adding tests
phorward Oct 21, 2023
d4ba713
Fixing `Expect` to report correct offset
phorward Oct 22, 2023
03bdb0e
Documentation for prelude.tok and fixing bug #123
phorward Oct 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

Current main branch.

- Implementation of generic parselets
- Syntax changes
- Handle parselet instances
- Handle generic values in intermediate structures
- System-defined parselets in prelude
- `Repeat<P, min: 1, max: void>`
- Implement `Pos<P>`, `Opt<P>`, `Kle<P>`
- Compile `P+` into `Pos<P>`, `P?` into `Opt<P>`, `P*` into `Kle<P>`
- `List<P, Sep: (',' _), empty: true>`
- `Peek<P>`, replaced `peek P` by `Peek<P>`
- `Not<P>`, replaced `not P` by `Not<P>`
- `Expect<P> msg=void`, replaced `expect P` by `Expect<P>`
- v0.6.4:
- Main parselet operates on multiple inputs (Readers) now
- Restructuring parts of VM, `Runtime` renamed into `Thread`
Expand Down
3 changes: 2 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ This document describes upcoming changes to achieve with a specific version.
## 0.7

- [x] Implement iterators and `for...in`-syntax (#101)
- [ ] Implement generic parselets (#10, #105)
- [x] Implement generic parselets (#10, #105)
- [ ] Implement embedded parselets (#120)
- [ ] New list syntax `[...]`, redefining sequence/`dict` syntax (#100)
- The character-class token syntax was replaced by a `Char`-builtin
- List definition `list = []`
Expand Down
15 changes: 15 additions & 0 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ all:
@echo ""
@echo " make builtins update src/_builtins.rs from src/"
@echo " make parser update src/compiler/parse.rs from src/compiler/tokay.tok"
@echo " make prelude update src/compiler/prelude.rs from src/prelude.tok"
@echo ""

# builtins --------------------------------------------------------------------
Expand Down Expand Up @@ -36,3 +37,17 @@ show-parser:

reset-parser:
git checkout $(PARSER)

# prelude ----------------------------------------------------------------------
PRELUDE=../src/compiler/prelude.rs

prelude: $(PRELUDE)

$(PRELUDE): .FORCE
$(ETARENEG) $@ >[email protected] && mv [email protected] $@

show-prelude:
$(ETARENEG) $(PRELUDE) 2>/dev/null

reset-prelude:
git checkout $(PRELUDE)
11 changes: 11 additions & 0 deletions examples/minicalc.tok
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

Main : @{
Expect<Expr> print("= " + $1)
}

Expr : @{
Expr '+' Int $1 + $3
Int
}

Main
6 changes: 5 additions & 1 deletion src/_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use crate::builtin::Builtin;

/*GENERATE cargo run -- _builtins.tok -- `find . -name "*.rs"` */
pub static BUILTINS: [Builtin; 63] = [
pub static BUILTINS: [Builtin; 64] = [
Builtin {
name: "Float",
func: crate::value::token::tokay_token_float,
Expand Down Expand Up @@ -87,6 +87,10 @@ pub static BUILTINS: [Builtin; 63] = [
name: "dict_set_item",
func: crate::value::dict::Dict::tokay_method_dict_set_item,
},
Builtin {
name: "eof",
func: crate::builtin::tokay_function_eof,
},
Builtin {
name: "error",
func: crate::error::tokay_function_error,
Expand Down
8 changes: 7 additions & 1 deletion src/builtin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ tokay_function!("type : @value", value!(value.name()).into());
tokay_function!("debug : @level", {
if let Ok(level) = level.to_usize() {
if level < u8::MAX as usize {
context.unwrap().thread.debug = level as u8;
let context = context.unwrap();
context.debug = level as u8;
//context.thread.debug = level as u8;
return Ok(Accept::Next);
}
}
Expand Down Expand Up @@ -210,3 +212,7 @@ tokay_function!("offset : @", {
])
.into()
});

tokay_function!("eof : @", {
value!(context.unwrap().thread.reader.eof()).into()
});
Loading
Loading