Skip to content

Commit

Permalink
Masplund/update reflex (#299)
Browse files Browse the repository at this point in the history
* Update reflex
  • Loading branch information
mwasplund authored Feb 16, 2025
1 parent 8c50d76 commit 39ea1c7
Show file tree
Hide file tree
Showing 13 changed files with 8,175 additions and 7,896 deletions.
2 changes: 1 addition & 1 deletion code/bench-tests/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/client/cli/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
}
Wren: {
Expand Down
15,943 changes: 8,102 additions & 7,841 deletions code/client/core/source/sml/SMLParser.cpp

Large diffs are not rendered by default.

93 changes: 48 additions & 45 deletions code/client/core/source/sml/SMLParser.l
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public:

bool TryParse()
{
std::unordered_map<std::string, SMLValue> table;
SequenceMap<std::string, SMLValue> table;
if (TryParseTableContents(table))
{
// Verify we are at the end of the content
Expand Down Expand Up @@ -240,52 +240,55 @@ private:

bool TryParsePackageReference(PackageReference& packageReference)
{
// Verify match assign
// Check for optional language name
MoveNext();
if (_currentToken != SMLToken::ExtendedKeyLiteral &&
_currentToken != SMLToken::KeyLiteral)
std::optional<std::string> languageName = std::nullopt;
if (_currentToken == SMLToken::OpenParenthesis)
{
// Verify match package name
MoveNext();
if (_currentToken != SMLToken::AlphaLiteral &&
_currentToken != SMLToken::AlphaExt3Literal)
return false;

// Key token already matched
languageName = str();

// Check end of content
MoveNext();
if (_currentToken != SMLToken::CloseParenthesis)
return false;

// Move beyond
MoveNext();
}

// Verify match user name
if (_currentToken != SMLToken::AlphaLiteral &&
_currentToken != SMLToken::AlphaExt1Literal)
return false;

// Key token already matched
auto key1 = str();

std::optional<std::string> userName;
std::string packageName;
auto userName = str();

// Check separator for user or package name
// Check separator
MoveNext();
switch (_currentToken)
{
case SMLToken::Pipe:
{
// Saw user name
userName = std::move(key1);

// Get the package name
MoveNext();
if (_currentToken != SMLToken::KeyLiteral)
return false;
if (_currentToken != SMLToken::Pipe)
return false;

packageName = str();
// Verify match package name
MoveNext();
if (_currentToken != SMLToken::AlphaLiteral &&
_currentToken != SMLToken::AlphaExt2Literal)
return false;

// Verify the at sign
MoveNext();
if (_currentToken != SMLToken::AtSign)
return false;
// Key token already matched
auto packageName = str();

break;
}
case SMLToken::AtSign:
{
// Saw package name
packageName = std::move(key1);
break;
}
default:
{
return false;
}
}
// Verify the separator
MoveNext();
if (_currentToken != SMLToken::AtSign)
return false;

// Check version type
SemanticVersion version;
Expand Down Expand Up @@ -316,7 +319,7 @@ private:
return false;

packageReference = PackageReference(
std::nullopt,
std::move(languageName),
std::move(userName),
std::move(packageName),
version);
Expand All @@ -326,7 +329,7 @@ private:

bool TryParseTable(SMLTable& table)
{
std::unordered_map<std::string, SMLValue> tableValues;
SequenceMap<std::string, SMLValue> tableValues;
if (TryParseTableContents(tableValues))
{
// Verify we are at the end of the content
Expand All @@ -342,7 +345,7 @@ private:
}
}

bool TryParseTableContents(std::unordered_map<std::string, SMLValue>& tableValues)
bool TryParseTableContents(SequenceMap<std::string, SMLValue>& tableValues)
{
// Odd move next to allow for optional extra delimiter checks at end
MoveNext();
Expand All @@ -363,7 +366,7 @@ private:
if (!tableValue.has_value())
return true;

tableValues.emplace(std::move(key), std::move(tableValue.value()));
tableValues.Insert(std::move(key), std::move(tableValue.value()));

// Check for zero or more optional values
while (true)
Expand All @@ -389,7 +392,7 @@ private:
return true;
}

tableValues.emplace(std::move(key), std::move(tableValue.value()));
tableValues.Insert(std::move(key), std::move(tableValue.value()));
}
}

Expand All @@ -401,7 +404,7 @@ private:
{
case SMLToken::Integer:
// Integer is a special case of Key and should be allowed
case SMLToken::KeyLiteral:
case SMLToken::AlphaLiteral:
{
// Key token already matched
key = str();
Expand Down Expand Up @@ -565,7 +568,7 @@ private:
}
case SMLToken::LessThan:
{
SMLPackageReference packageReference;
PackageReference packageReference;
if (!TryParsePackageReference(packageReference))
return false;

Expand Down
2 changes: 1 addition & 1 deletion code/client/tools/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Closures: {
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|json11': { Version: 1.1.3, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/generate-test/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/generate/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/tools/print-graph/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
printgraph: { Version: './', Build: 'Build0', Tool: 'Tool0' }
}
Expand Down
2 changes: 1 addition & 1 deletion code/tools/print-results/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
printresults: { Version: './', Build: 'Build0', Tool: 'Tool0' }
}
Expand Down
2 changes: 1 addition & 1 deletion code/tools/print-valuetable/PackageLock.sml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Closures: {
'mwasplund|Detours': { Version: 4.0.12, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Opal': { Version: 0.11.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|Soup.Test.Assert': { Version: 0.4.2, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|reflex': { Version: 5.2.1, Build: 'Build0', Tool: 'Tool0' }
'mwasplund|wren': { Version: 1.0.5, Build: 'Build0', Tool: 'Tool0' }
printvaluetable: { Version: './', Build: 'Build0', Tool: 'Tool0' }
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/linux/build-tools
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ eval soup restore $TOOLS_DIR

# Build tools
echo soup build $TOOLS_DIR -flavor $FLAVOR
eval soup build $TOOLS_DIR -flavor $FLAVOR
eval soup build $TOOLS_DIR -flavor $FLAVOR
2 changes: 1 addition & 1 deletion scripts/linux/build-view
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rm -r -f $ROOT_DIR/out/msbuild/bin/SoupView/$FLAVOR/net9.0/linux-x64/publish/

# Build SWhere tool
echo dotnet publish $SWHERE_DIR -c $FLAVOR -r linux-x64 --self-contained
eval dotnet publish $SWHERE_DIR -c $FLAVOR -r linux-x64 --self-contained
eval dotnet publish $SWHERE_DIR -c $FLAVOR -r linux-x64 --self-contained
15 changes: 15 additions & 0 deletions scripts/linux/generate-sml-lexer
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
echo "Generate SML Lexer!"

# Stop on first error
set -e

FLAVOR="$1"
SCRIPTS_DIR=$(dirname "$0")
ROOT_DIR=$SCRIPTS_DIR/../..
CODE_DIR=$ROOT_DIR/code
CLIENT_CODE_DIR=$CODE_DIR/client/core/source
REFLEX=~/source/repos/RE-flex/bin/reflex

echo $REFLEX $CLIENT_CODE_DIR/sml/SMLParser.l -o $CLIENT_CODE_DIR/sml/SMLParser.cpp
eval $REFLEX $CLIENT_CODE_DIR/sml/SMLParser.l -o $CLIENT_CODE_DIR/sml/SMLParser.cpp

0 comments on commit 39ea1c7

Please sign in to comment.