Skip to content

Commit

Permalink
wip on rain string
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Oct 30, 2024
1 parent 699d718 commit 77ffee4
Show file tree
Hide file tree
Showing 22 changed files with 24 additions and 568 deletions.
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 30bb7a
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
22 changes: 2 additions & 20 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 {LibParseChars} from "rain.string/lib/parse/LibParseChars.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
Loading

0 comments on commit 77ffee4

Please sign in to comment.