import React from 'react'; import Highlight, { defaultProps } from "prism-react-renderer"; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import useThemeContext from '@theme/hooks/useThemeContext'; import defaultTheme from 'prism-react-renderer/themes/palenight'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; const PASCALIGO_EXAMPLE = ` type storage is int type parameter is Increment of int | Decrement of int | Reset type return is list (operation) * storage // Two entrypoints function add (const store : storage; const delta : int) : storage is store + delta function sub (const store : storage; const delta : int) : storage is store - delta (* Main access point that dispatches to the entrypoints according to the smart contract parameter. *) function main (const action : parameter; const store : storage) : return is ((nil : list (operation)), // No operations case action of Increment (n) -> add (store, n) | Decrement (n) -> sub (store, n) | Reset -> 0 end) `; const CAMELIGO_EXAMPLE = ` type storage = int type parameter = Increment of int | Decrement of int | Reset type return = operation list * storage // Two entrypoints let add (store, delta : storage * int) : storage = store + delta let sub (store, delta : storage * int) : storage = store - delta (* Main access point that dispatches to the entrypoints according to the smart contract parameter. *) let main (action, store : parameter * storage) : return = ([] : operation list), // No operations (match action with Increment (n) -> add (store, n) | Decrement (n) -> sub (store, n) | Reset -> 0) `; const REASONLIGO_EXAMPLE = ` type storage = int; type parameter = Increment (int) | Decrement (int) | Reset; type return = (list (operation), storage); (* Two entrypoints *) let add = ((store, delta) : (storage, int)) : storage => store + delta; let sub = ((store, delta) : (storage, int)) : storage => store - delta; (* Main access point that dispatches to the entrypoints according to the smart contract parameter. *) let main = ((action, store) : (parameter, storage)) : return => { (([] : list (operation)), // No operations (switch (action) { | Increment (n) => add ((store, n)) | Decrement (n) => sub ((store, n)) | Reset => 0})) }; `; function CodeExamples (props) { const { siteConfig: { themeConfig: {prism = {}}, }, } = useDocusaurusContext(); const {isDarkTheme} = useThemeContext(); const lightModeTheme = prism.theme || defaultTheme; const darkModeTheme = prism.darkTheme || lightModeTheme; const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme; return ( {({ className, style, tokens, getLineProps, getTokenProps }) => (
                {tokens.map((line, i) => (
                  
{line.map((token, key) => ( ))}
))}
)}
{({ className, style, tokens, getLineProps, getTokenProps }) => (
                {tokens.map((line, i) => (
                  
{line.map((token, key) => ( ))}
))}
)}
{({ className, style, tokens, getLineProps, getTokenProps }) => (
                {tokens.map((line, i) => (
                  
{line.map((token, key) => ( ))}
))}
)}
); }; export default CodeExamples