Truly independent web browser
Go to file
Emanuel Sprung 55450055d8 LibRegex: Add a regular expression library
This commit is a mix of several commits, squashed into one because the
commits before 'Move regex to own Library and fix all the broken stuff'
were not fixable in any elegant way.
The commits are listed below for "historical" purposes:

- AK: Add options/flags and Errors for regular expressions

Flags can be provided for any possible flavour by adding a new scoped enum.
Handling of flags is done by templated Options class and the overloaded
'|' and '&' operators.

- AK: Add Lexer for regular expressions

The lexer parses the input and extracts tokens needed to parse a regular
expression.

- AK: Add regex Parser and PosixExtendedParser

This patchset adds a abstract parser class that can be derived to implement
different parsers. A parser produces bytecode to be executed within the
regex matcher.

- AK: Add regex matcher

This patchset adds an regex matcher based on the principles of the T-REX VM.
The bytecode pruduced by the respective Parser is put into the matcher and
the VM will recursively execute the bytecode according to the available OpCodes.
Possible improvement: the recursion could be replaced by multi threading capabilities.

To match a Regular expression, e.g. for the Posix standard regular expression matcher
use the following API:

```
Pattern<PosixExtendedParser> pattern("^.*$");
auto result = pattern.match("Well, hello friends!\nHello World!"); // Match whole needle

EXPECT(result.count == 1);
EXPECT(result.matches.at(0).view.starts_with("Well"));
EXPECT(result.matches.at(0).view.end() == "!");

result = pattern.match("Well, hello friends!\nHello World!", PosixFlags::Multiline); // Match line by line

EXPECT(result.count == 2);
EXPECT(result.matches.at(0).view == "Well, hello friends!");
EXPECT(result.matches.at(1).view == "Hello World!");

EXPECT(pattern.has_match("Well,....")); // Just check if match without a result, which saves some resources.
```

- AK: Rework regex to work with opcodes objects

This patchsets reworks the matcher to work on a more structured base.
For that an abstract OpCode class and derived classes for the specific
OpCodes have been added. The respective opcode logic is contained in
each respective execute() method.

- AK: Add benchmark for regex

- AK: Some optimization in regex for runtime and memory

- LibRegex: Move regex to own Library and fix all the broken stuff

Now regex works again and grep utility is also in place for testing.
This commit also fixes the use of regex.h in C by making `regex_t`
an opaque (-ish) type, which makes its behaviour consistent between
C and C++ compilers.
Previously, <regex.h> would've blown C compilers up, and even if it
didn't, would've caused a leak in C code, and not in C++ code (due to
the existence of `OwnPtr` inside the struct).

To make this whole ordeal easier to deal with (for now), this pulls the
definitions of `reg*()` into LibRegex.

pros:
- The circular dependency between LibC and LibRegex is broken
- Eaiser to test (without accidentally pulling in the host's libc!)

cons:
- Using any of the regex.h functions will require the user to link -lregex
- The symbols will be missing from libc, which will be a big surprise
  down the line (especially with shared libs).

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2020-11-27 21:32:41 +01:00
.github Meta: Enable CodeQL static analysis for Serenity 2020-11-26 09:48:21 +01:00
AK AK: Always inline RefPtr::operator bool() and RefPtr::is_null() 2020-11-25 21:26:58 +01:00
Applications Spreadsheet: Allow copying from one cell to many 2020-11-24 21:38:13 +01:00
Base Kernel: Add unveil('b') 2020-11-23 18:37:40 +01:00
Demos AK: Rename new_out to out and new_warn to warn. 2020-11-09 16:21:29 +01:00
DevTools Profiler: Fix assertion when all function samples hit one instruction 2020-11-24 22:02:34 +01:00
Documentation Documentation: Update required GCC version to >= 10 2020-11-07 18:22:18 +01:00
Games Breakout: Add simple menu and about dialog :^) 2020-11-10 14:32:45 +01:00
Kernel Kernel: Enable VMWareBackdoor immediately at boot 2020-11-26 10:00:01 +01:00
Libraries LibRegex: Add a regular expression library 2020-11-27 21:32:41 +01:00
MenuApplets MenuApplets: Added ability to remove entry from ClipboardHistory (#4143) 2020-11-24 21:37:04 +01:00
Meta LibRegex: Add a regular expression library 2020-11-27 21:32:41 +01:00
Ports Ports: Add GNU indent 2020-11-09 16:22:52 +01:00
Services LibWeb: Rename LayoutNode classes and move them into Layout namespace 2020-11-22 15:56:27 +01:00
Shell Shell: Remove unused private member and includes 2020-11-17 09:48:02 +01:00
Toolchain Toolchain: Trust cache blindly 2020-11-08 09:58:55 +01:00
Userland LibPthread: Fix broken EINVAL check in pthread_attr_setdetachstate() 2020-11-26 19:33:44 +01:00
.clang-format Meta: Update .clang-format to not indent nested namespaces 2020-03-14 10:10:21 +01:00
.gitattributes Meta: Add .gitattributes file 2020-07-30 17:07:40 +02:00
.gitignore Meta: Add .cache to .gitignore 2020-11-12 10:15:07 +01:00
.prettierignore Meta: Move prettier config files to the root of the repository 2020-08-24 18:21:33 +02:00
.prettierrc Meta: Move prettier config files to the root of the repository 2020-08-24 18:21:33 +02:00
CMakeLists.txt LibRegex: Add a regular expression library 2020-11-27 21:32:41 +01:00
CODE_OF_CONDUCT.md Meta: Move code of conduct (lol) to a separate file 2019-10-23 10:05:06 +02:00
CONTRIBUTING.md Meta: s/Travis/GitHub Actions/ in CONTRIBUTING.md 2020-11-12 10:16:45 +01:00
LICENSE Meta: Tweak license in celebration of 10'000 commits :^) 2020-05-28 19:07:31 +02:00
ReadMe.md Meta: Enable Github Actions 2020-11-08 09:58:55 +01:00

SerenityOS

Graphical Unix-like operating system for x86 computers.

Build status

About

SerenityOS is a love letter to '90s user interfaces with a custom Unix-like core. It flatters with sincerity by stealing beautiful ideas from various other systems.

Roughly speaking, the goal is a marriage between the aesthetic of late-1990s productivity software and the power-user accessibility of late-2000s *nix. This is a system by us, for us, based on the things we like.

I (Andreas) regularly post raw hacking sessions and demos on my YouTube channel.

Sometimes I write about the system on my github.io blog.

I'm also on Patreon and GitHub Sponsors if you would like to show some support that way.

Screenshot

Screenshot as of 8ea4375

Kernel features

  • x86 (32-bit) kernel with pre-emptive multi-threading
  • Hardware protections (SMEP, SMAP, UMIP, NX, WP, TSD, ...)
  • IPv4 stack with ARP, TCP, UDP and ICMP protocols
  • ext2 filesystem
  • POSIX signals
  • Purgeable memory
  • /proc filesystem
  • Pseudoterminals (with /dev/pts filesystem)
  • Filesystem notifications
  • CPU and memory profiling
  • SoundBlaster 16 driver
  • VMWare/QEMU mouse integration

System services

  • Launch/session daemon (SystemServer)
  • Compositing window server (WindowServer)
  • Text console manager (TTYServer)
  • DNS client (LookupServer)
  • Network protocols server (ProtocolServer)
  • Software-mixing sound daemon (AudioServer)
  • Desktop notifications (NotificationServer)
  • HTTP server (WebServer)
  • Telnet server (TelnetServer)
  • DHCP client (DHCPClient)

Libraries

  • C++ templates and containers (AK)
  • Event loop and utilities (LibCore)
  • 2D graphics library (LibGfx)
  • GUI toolkit (LibGUI)
  • Cross-process communication library (LibIPC)
  • HTML/CSS engine (LibWeb)
  • JavaScript engine (LibJS)
  • Markdown (LibMarkdown)
  • Audio (LibAudio)
  • PCI database (LibPCIDB)
  • Terminal emulation (LibVT)
  • Out-of-process network protocol I/O (LibProtocol)
  • Mathematical functions (LibM)
  • ELF file handling (LibELF)
  • POSIX threading (LibPthread)
  • Higher-level threading (LibThread)
  • Transport Layer Security (LibTLS)
  • HTTP and HTTPS (LibHTTP)

Userland features

  • Unix-like libc and userland
  • Shell with pipes and I/O redirection
  • On-line help system (both terminal and GUI variants)
  • Web browser (Browser)
  • C++ IDE (HackStudio)
  • IRC client
  • Desktop synthesizer (Piano)
  • Various desktop apps & games
  • Color themes

How do I read the documentation?

Man pages are browsable outside of SerenityOS under Base/usr/share/man.

When running SerenityOS you can use man for the terminal interface, or help for the GUI interface.

How do I build and run this?

See the SerenityOS build instructions

Before opening an issue

Please see the issue policy.

Communication hubs

The main hub is #serenityos on the Freenode IRC network.

We also have a project mailing list: serenityos-dev.

Author

Contributors

(And many more!) The people listed above have landed more than 100 commits in the project. :^)

License

SerenityOS is licensed under a 2-clause BSD license.