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

2024 10 30 rain string #298

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/rainix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- run: nix develop --command rainix-sol-prelude
- run: nix develop --command rainix-rs-prelude
- run: nix develop --command i9r-prelude
- run: nix develop -c rainix-sol-prelude
- run: nix develop -c rainix-rs-prelude
- run: nix develop -c i9r-prelude
- name: Run ${{ matrix.task }}
env:
ETH_RPC_URL: ${{ secrets.CI_DEPLOY_SEPOLIA_RPC_URL || vars.CI_DEPLOY_SEPOLIA_RPC_URL }}
Expand All @@ -47,4 +47,4 @@ jobs:
CI_FORK_SEPOLIA_BLOCK_NUMBER: ${{ vars.CI_FORK_SEPOLIA_BLOCK_NUMBER }}
CI_FORK_SEPOLIA_DEPLOYER_ADDRESS: ${{ vars.CI_FORK_SEPOLIA_DEPLOYER_ADDRESS }}
CI_DEPLOY_SEPOLIA_RPC_URL: ${{ secrets.CI_DEPLOY_SEPOLIA_RPC_URL || vars.CI_DEPLOY_SEPOLIA_RPC_URL }}
run: nix develop --command ${{ matrix.task }}
run: nix develop -c ${{ matrix.task }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "lib/rain.math.float"]
path = lib/rain.math.float
url = https://github.com/rainlanguage/rain.math.float
[submodule "lib/rain.string"]
path = lib/rain.string
url = https://github.com/rainlanguage/rain.string
1 change: 1 addition & 0 deletions lib/rain.string
Submodule rain.string added at ad06da
2 changes: 1 addition & 1 deletion src/abstract/BaseRainterpreterSubParserNPE2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {LibBytes, Pointer} from "rain.solmem/lib/LibBytes.sol";
import {ISubParserV3, AuthoringMetaV2} from "rain.interpreter.interface/interface/ISubParserV3.sol";
import {IncompatibleSubParser} from "../error/ErrSubParse.sol";
import {LibSubParse, ParseState, CURRENT_COMPATIBILITY} from "../lib/parse/LibSubParse.sol";
import {CMASK_RHS_WORD_TAIL} from "../lib/parse/LibParseCMask.sol";
import {CMASK_RHS_WORD_TAIL} from "rain.string/lib/parse/LibParseCMask.sol";
import {LibParse, Operand} from "../lib/parse/LibParse.sol";
import {LibParseMeta} from "rain.interpreter.interface/lib/parse/LibParseMeta.sol";
import {LibParseOperand} from "../lib/parse/LibParseOperand.sol";
Expand Down
28 changes: 5 additions & 23 deletions src/lib/parse/LibParse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
COMMENT_START_SEQUENCE,
COMMENT_END_SEQUENCE,
CMASK_IDENTIFIER_HEAD
} from "./LibParseCMask.sol";
} from "rain.string/lib/parse/LibParseCMask.sol";
import {LibParseChar} from "rain.string/lib/parse/LibParseChar.sol";
import {LibCtPop} from "rain.math.binary/lib/LibCtPop.sol";
import {LibParseMeta} from "rain.interpreter.interface/lib/parse/LibParseMeta.sol";
import {LibParseLiteral} from "./literal/LibParseLiteral.sol";
Expand Down Expand Up @@ -121,25 +122,6 @@ library LibParse {
}
}

/// Skip an unlimited number of chars until we find one that is not in the
/// mask.
function skipMask(uint256 cursor, uint256 end, uint256 mask) internal pure returns (uint256) {
assembly ("memory-safe") {
//slither-disable-next-line incorrect-shift
for {} and(lt(cursor, end), gt(and(shl(byte(0, mload(cursor)), 1), mask), 0)) { cursor := add(cursor, 1) } {}
}
return cursor;
}

/// Checks if the cursor points at a char of the given mask, and is in range
/// of end.
function isMask(uint256 cursor, uint256 end, uint256 mask) internal pure returns (uint256 result) {
assembly ("memory-safe") {
//slither-disable-next-line incorrect-shift
result := and(lt(cursor, end), iszero(iszero(and(shl(byte(0, mload(cursor)), 1), mask))))
}
}

function parseLHS(ParseState memory state, uint256 cursor, uint256 end) internal pure returns (uint256) {
unchecked {
while (cursor < end) {
Expand Down Expand Up @@ -169,7 +151,7 @@ library LibParse {
}
// Anon stack item.
else {
cursor = skipMask(cursor + 1, end, CMASK_LHS_STACK_TAIL);
cursor = LibParseChar.skipMask(cursor + 1, end, CMASK_LHS_STACK_TAIL);
}
// Bump the index regardless of whether the stack
// item is named or not.
Expand All @@ -179,7 +161,7 @@ library LibParse {
// Set yang as we are now building a stack item.
state.fsm |= FSM_YANG_MASK | FSM_ACTIVE_SOURCE_MASK;
} else if (char & CMASK_WHITESPACE != 0) {
cursor = skipMask(cursor + 1, end, CMASK_WHITESPACE);
cursor = LibParseChar.skipMask(cursor + 1, end, CMASK_WHITESPACE);
// Set ying as we now open to possibilities.
state.fsm &= ~FSM_YANG_MASK;
} else if (char & CMASK_LHS_RHS_DELIMITER != 0) {
Expand Down Expand Up @@ -374,7 +356,7 @@ library LibParse {
state.highwater();
cursor++;
} else if (char & CMASK_WHITESPACE > 0) {
cursor = skipMask(cursor + 1, end, CMASK_WHITESPACE);
cursor = LibParseChar.skipMask(cursor + 1, end, CMASK_WHITESPACE);
// Set yin as we now open to possibilities.
state.fsm &= ~FSM_YANG_MASK;
}
Expand Down
Loading