Skip to content

Commit

Permalink
add function macros to rust dast
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Nov 28, 2023
1 parent dc07334 commit 2d0a6ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion packages/doenetml-worker-rust/doenetml-core/src/dast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ enum DastElementContent {
Element(DastElement),
Text(DastText),
Macro(DastMacro),
FunctionMacro(DastFunctionMacro),
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
enum DastTextMacroContent {
Text(DastText),
Macro(DastMacro),
FunctionMacro(DastFunctionMacro),
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -82,6 +84,18 @@ struct DastMacro {
position: Option<Position>,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type")]
#[serde(rename = "function")]
struct DastFunctionMacro {
#[serde(rename = "macro")]
function_macro: DastMacro,
input: Option<Vec<Vec<DastElementContent>>>,

#[serde(skip_serializing_if = "Option::is_none")]
position: Option<Position>,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type")]
#[serde(rename = "pathPart")]
Expand All @@ -97,7 +111,7 @@ struct PathPart {
#[serde(tag = "type")]
#[serde(rename = "index")]
struct DastIndex {
value: DastTextMacroContent,
value: Vec<DastTextMacroContent>,

#[serde(skip_serializing_if = "Option::is_none")]
position: Option<Position>,
Expand Down
3 changes: 2 additions & 1 deletion packages/test-viewer/src/test/testViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from "react";
// @ts-ignore
import { DoenetML } from "@doenet/doenetml";
// import { DoenetML } from "@doenet/doenetml";
import { DoenetML } from "@doenet/doenetml-prototype";
// @ts-ignore
import doenetMLstring from "./testCode.doenet?raw";
import { Button } from "@doenet/ui-components";
Expand Down

0 comments on commit 2d0a6ff

Please sign in to comment.