Skip to content

Commit

Permalink
Merge pull request #35 from tmr232/release-0.0.10
Browse files Browse the repository at this point in the history
Prep for release 0.0.10
  • Loading branch information
tmr232 authored Dec 1, 2024
2 parents 1aeddef + b431a48 commit d094ea6
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

## [0.0.10]

### Added

- Added JetBrains frontend for use in JetBrains IDE plugin
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Custom color schems are created via the [interactive demo](https://tmr232.github

- [Go](https://tmr232.github.io/function-graph-overview/?language=0)
- [C](https://tmr232.github.io/function-graph-overview/?language=1)
- [C++](https://tmr232.github.io/function-graph-overview/?language=3)
- [Python](https://tmr232.github.io/function-graph-overview/?language=2)

## Development
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"//": "START EXTENSION ATTRIBUTES",
"publisher": "tamir-bahar",
"name": "function-graph-overview",
"version": "0.0.9",
"version": "0.0.10",
"description": "Function Graph Overview",
"displayName": "Function Graph Overview",
"icon": "./media/icon.png",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeSegmentation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
}
</script>

{#await initialize() then}
{#await initialize() then _}
<pre>{@html renderWrapper(code, language, { simplify, trim })}</pre>
<button on:click={recolorNodes}>Recolor Nodes</button>
{/await}
Expand Down
24 changes: 13 additions & 11 deletions src/components/Demo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@
import ColorScheme from "./ColorSchemeEditor.svelte";
import { getSystemColorList, toggleTheme, isDark } from "./lightdark.ts";
import type { LanguageSupport } from "@codemirror/language";
import { evolve } from "../control-flow/evolve.ts";
// ADD-LANGUAGES-HERE
const defaultCodeSamples: { [language in Language]?: string } = {
Go: "func Example() {\n\tif x {\n\t\treturn\n\t}\n}",
C: "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}",
"C++": "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}",
Python: "def example():\n if x:\n return",
};
export let code: { [language in Language]?: string } = {};
const languageCode = evolve(defaultCodeSamples, code);
export let codeGo = "func Example() {\n\tif x {\n\t\treturn\n\t}\n}";
export let codeC = "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}";
export let codeCpp = "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}";
export let codePython = "def example():\n if x:\n return";
let offsetToHighlight: number | undefined = undefined;
let colorList = getSystemColorList();
// ADD-LANGUAGES-HERE
Expand All @@ -37,13 +46,6 @@
},
] as const;
const languageCode: { [language in Language]: string } = {
Go: codeGo,
C: codeC,
Python: codePython,
"C++": codeCpp,
};
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has("go")) {
languageCode.Go = LZString.decompressFromEncodedURIComponent(
Expand Down
12 changes: 11 additions & 1 deletion src/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@
import demoCodeGo from "./assets/demo.go?raw";
import demoCodeC from "./assets/demo.c?raw";
import demoCodePython from "./assets/demo.py?raw";
import demoCodeCpp from "./assets/demo.cpp?raw";
import { isDark } from "../../components/lightdark";
import { onDestroy } from "svelte";
import type { Language } from "../../control-flow/cfg.ts";
document.body.dataset.theme = isDark ? "dark" : "light";
const unsubscribe = isDark.subscribe((isDark) => {
document.body.dataset.theme = isDark ? "dark" : "light";
});
// ADD-LANGUAGES-HERE
const code: { [language in Language]?: string } = {
C: demoCodeC,
Python: demoCodePython,
Go: demoCodeGo,
"C++": demoCodeCpp,
};
onDestroy(unsubscribe);
</script>

<main>
<Demo codeGo={demoCodeGo} codeC={demoCodeC} codePython={demoCodePython} />
<Demo {code} />
</main>

<style>
Expand Down
63 changes: 63 additions & 0 deletions src/demo/src/assets/demo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Capturer::Capturer( StringRef macroName,
SourceLineInfo const& lineInfo,
ResultWas::OfType resultType,
StringRef names ):
m_resultCapture( getResultCapture() ) {
auto trimmed = [&] (size_t start, size_t end) {
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
++start;
}
while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) {
--end;
}
return names.substr(start, end - start + 1);
};
auto skipq = [&] (size_t start, char quote) {
for (auto i = start + 1; i < names.size() ; ++i) {
if (names[i] == quote)
return i;
if (names[i] == '\\')
++i;
}
CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote");
};

size_t start = 0;
std::stack<char> openings;
for (size_t pos = 0; pos < names.size(); ++pos) {
char c = names[pos];
switch (c) {
case '[':
case '{':
case '(':
// It is basically impossible to disambiguate between
// comparison and start of template args in this context
// case '<':
openings.push(c);
break;
case ']':
case '}':
case ')':
// case '>':
openings.pop();
break;
case '"':
case '\'':
pos = skipq(pos, c);
break;
case ',':
if (start != pos && openings.empty()) {
m_messages.emplace_back(macroName, lineInfo, resultType);
m_messages.back().message = static_cast<std::string>(trimmed(start, pos));
m_messages.back().message += " := ";
start = pos;
}
break;
default:; // noop
}
}
assert(openings.empty() && "Mismatched openings");
m_messages.emplace_back(macroName, lineInfo, resultType);
m_messages.back().message = static_cast<std::string>(trimmed(start, names.size() - 1));
m_messages.back().message += " := ";
}

0 comments on commit d094ea6

Please sign in to comment.