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

The OR operator (|) in the regex module #19926

Closed
1 of 2 tasks
werdl opened this issue Nov 18, 2023 · 2 comments
Closed
1 of 2 tasks

The OR operator (|) in the regex module #19926

werdl opened this issue Nov 18, 2023 · 2 comments
Labels
Feature Request This issue is made to request a feature.

Comments

@werdl
Copy link

werdl commented Nov 18, 2023

Describe the feature

To make the regex module PCRE compliant, or alternatively make the pcre module the default regex module.

Use Case

I am frustrated at the fact that, for example, int|float does not match int or float, rather it would match infloat, which seems to make little sense. I cannot see why this is useful, and a PCRE compliant regex module would be much more useful than having a special one for V.

Proposed Solution

Make the regex module PCRE compliant. This could be as simple as making the pcre module the default regex engine, by simply renaming it.

Other Information

If this isn't ideal, you could at least make it so that the OR operator works as it does in PCRE.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V full version: V 0.4.3 a2dabdd.fbb43f5

Environment details (OS name and version, etc.)

V full version: V 0.4.3 a2dabdd.fbb43f5
OS: linux, Debian GNU/Linux 12 (bookworm)
Processor: 12 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i5-11400F @ 2.60GHz

getwd: /home/werdl/coding/vcc
vexe: /home/werdl/coding/vcss/v/v
vexe mtime: 2023-11-12 16:16:21

vroot: OK, value: /home/werdl/coding/vcss/v
VMODULES: OK, value: /home/werdl/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.39.2
Git vroot status: weekly.2023.44-117-gfbb43f5a (58 commit(s) behind V master)
.git/config present: true

CC version: cc (Debian 12.2.0-14) 12.2.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@werdl werdl added the Feature Request This issue is made to request a feature. label Nov 18, 2023
@werdl werdl changed the title The regex module The OR operator (|) in the regex module Nov 18, 2023
@Delta456
Copy link
Member

We have a pcre regex module in V.

@penguindark
Copy link
Member

V regex module was build to be a didactial very small regex.
Some design choices were done to achieve speed and simple code, other for simplify the code writing.
The regex OR was chosen different for two reason:

  • have more simple regex expressions, use always the same "base" for regex (the symbol) instead of change base of expression in every operation is more coherent and understandable.
  • The V regex OR implementation has not computational cost, the PCREs one is heavy.

Anyway, every contribute on the regex code is warmly welcomed.

P.S. regex: int|float => (int)|(float)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

3 participants