Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoft-UK committed Oct 9, 2024
1 parent f819f27 commit adea761
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 19 deletions.
Binary file modified examples/test.hpprgm
Binary file not shown.
22 changes: 21 additions & 1 deletion examples/test.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,33 @@

#define COPYWRITE "Copyright (c) 2023-2024 Insoft. All rights reserved."

// Synthetic Class
#define this MyClass


var _a;
var MyClass.b;

MyClass::method()
begin
_a = this.b = 0;
end;

#undef this


using namespace MyClass;
b = 0;
method();
remove namespace MyClass;

#if __VERSION >= 204
var text = {"This is some text... ... ...", "If I see you", "It means it's working."};
#else
var text {"I never want to see you.", "If I do, we have a BUG!"}
#endif

fn1:Function1()
fn2:Function1()
begin
var auto:copywriteText = COPYWRITE;
end;
Expand Down
4 changes: 2 additions & 2 deletions p+.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
1384DE7B2B6D70DE0090E24D /* switch.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = switch.cpp; sourceTree = "<group>"; };
1384DE7C2B6D70DE0090E24D /* switch.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = switch.hpp; sourceTree = "<group>"; };
1389CFEA2CA73BA6008FDBEB /* timer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = timer.hpp; sourceTree = "<group>"; };
138F54D22C976F10009357F9 /* LICENCE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENCE.txt; sourceTree = "<group>"; };
138F54D22C976F10009357F9 /* LICENSE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
138F54DC2C9E12EF009357F9 /* for_next.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = for_next.cpp; sourceTree = "<group>"; };
138F54DD2C9E12EF009357F9 /* for_next.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = for_next.hpp; sourceTree = "<group>"; };
138F54DF2C9E16E7009357F9 /* do_loop.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = do_loop.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,7 +101,7 @@
137FB27C2A03B06500AEFDF2 = {
isa = PBXGroup;
children = (
138F54D22C976F10009357F9 /* LICENCE.txt */,
138F54D22C976F10009357F9 /* LICENSE.txt */,
1351CC552BFC0E180073FEDF /* README.md */,
137FB2942A046E8E00AEFDF2 /* p+.entitlements */,
13166E852BA12E5E00D1E6F0 /* examples */,
Expand Down
8 changes: 4 additions & 4 deletions src/alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void parseAlias(const std::string& str, Aliases::TIdentity& identity) {
1 name
2 alias
*/
re = R"(((?:[^\x00-\x7F]|\w)+):([a-zA-Z][\w.]*((?:::)?[a-zA-Z][\w.]*)*))";
re = R"(((?:[^\x00-\x7F]|\w)+):([A-Za-z_][\w.]*((?:::)?[A-Za-z_][\w.]*)*))";

if (regex_search(str, matches, re)) {
identity.real = matches[1].str();
Expand All @@ -53,7 +53,7 @@ static void parseAlias(const std::string& str, Aliases::TIdentity& identity) {
}

static void parseAliases(const std::string& str, Aliases::TIdentity& identity) {
std::regex re(R"((?:[^\x00-\x7F]|\w)+\w*:[a-zA-Z][\w.]*((?:::)?[a-zA-Z][\w.]*)*)");
std::regex re(R"((?:[^\x00-\x7F]|\w)+\w*:[A-Za-z_][\w.]*((?:::)?[A-Za-z_][\w.]*)*)");

for(std::sregex_iterator it = std::sregex_iterator(str.begin(), str.end(), re); it != std::sregex_iterator(); ++it) {
parseAlias(it->str(), identity);
Expand Down Expand Up @@ -96,7 +96,7 @@ bool Alias::parse(std::string& str) {
1 name:alias
2 p1, p2:alias, auto:alias
*/
re = R"((?:export )?((?:(?:[^\x00-\x7F]|\w)+:)?(?:(?:[a-zA-Z_]\w*::)*?)[a-zA-Z][\w.]*)\((.*)\))";
re = R"((?:export )?((?:(?:[^\x00-\x7F]|\w)+:)?(?:(?:[A-Za-z_]\w*::)*?)[A-Za-z_][\w.]*)\((.*)\))";

if (regex_search(str, matches, re)) {
parseFunctionName(matches[1].str());
Expand All @@ -116,7 +116,7 @@ bool Alias::parse(std::string& str) {
}

if (!parsed) return false;
str = regex_replace(str, std::regex(R"(:[a-zA-Z][\w.]*((?:::)?[a-zA-Z][\w.]*)*)"), "");
str = regex_replace(str, std::regex(R"(:[A-Za-z_][\w.]*((?:::)?[A-Za-z_][\w.]*)*)"), "");

return true;
}
10 changes: 3 additions & 7 deletions src/aliases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,12 @@ bool Aliases::append(const TIdentity& idty) {
identity.scope = singleton->scope == Singleton::Scope::Global ? Aliases::Scope::Global : Aliases::Scope::Local;
}

if ('_' == identity.identifier.at(0) && '_' != identity.identifier.at(1)) {
identity.identifier = identity.identifier.substr(1, identity.identifier.length() - 1);
identity.type = Type::Property;
}

if (exists(identity) == true) {
for (const auto &it : _identities) {
if (it.identifier == identity.identifier) {
std::cout
<< MessageType::Warning
<< "redefinition of: \e[1;97m" << identity.identifier << "\e[0;m, ";
<< "redefinition of: " << ANSI::Bold << identity.identifier << ANSI::Default << ", ";
if (basename(Singleton::shared()->currentPathname()) == basename(it.pathname)) {
std::cout << "previous definition on line " << it.line << "\n";
}
Expand Down Expand Up @@ -191,7 +186,7 @@ std::string Aliases::resolveAllAliasesInText(const std::string& str) {
}
namespaces += *it;
}
namespaces += ")::)";
namespaces += ")(?:::|.))";

for (auto it = _identities.begin(); it != _identities.end(); ++it) {
if ('`' == it->identifier.at(0) && '`' == it->identifier.at(it->identifier.length() - 1)) {
Expand Down Expand Up @@ -305,6 +300,7 @@ Aliases::TIdentity Aliases::getIdentity(const std::string& identifier) {
//MARK: - namespace

void Aliases::addNamespace(const std::string& name) {
// We check to see if namespace allready exists, if it dose we just return.
for (auto it = _namespaces.begin(); it != _namespaces.end(); ++it) {
if (name == *it) return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ static std::string base10ToBase32(unsigned int num) {
static bool isValidPPLName(const std::string name) {
std::regex re;

if (name.at(0) == '_') return false;

re = R"(^[A-Za-z]\w*(?:(::)|\.))";
if (std::regex_search(name, re)) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/build.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define BUILD_NUMBER 205001
#define CURRENT_DATE "2024 October 07"
#define BUILD_DATE 20241007
#define BUILD_NUMBER 205030
#define CURRENT_DATE "2024 October 09"
#define BUILD_DATE 20241009
2 changes: 1 addition & 1 deletion src/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
205001
205030
2 changes: 1 addition & 1 deletion src/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool Preprocessor::parse(std::string& str) {
Group 0 #undef NAME
1 NAME
*/
re = R"(^ *#undef +([A-Za-z_][\w.:]*) *$)";
re = R"(^ *#undef +([A-Za-z_][\w]*) *$)";
if (std::regex_search(str, match, re)) {
_singleton->aliases.remove(match[1].str());
if (verbose) std::cout << MessageType::Verbose << "#undef: " << *it << '\n';
Expand Down

0 comments on commit adea761

Please sign in to comment.