Skip to content

Regular Expressions do not work #3

@dprog

Description

@dprog

I am trying the following. I have used regular expression [a-zA-Z]+. While it seems to match lower letters, it does not match the upper case letters.

import ctpg;
import std.array: join;
import std.conv: to;
import std.stdio;
import std.algorithm;

mixin(genParsers(
q{
@_setSkip(skip)

// root parser string root = addExp $; // addition and subtraction string addExp = mulExp !"+" addExp >> (lhs, rhs){ return lhs ~ "+" ~ rhs; } / mulExp !"-" addExp >> (lhs, rhs){ return lhs ~ "-" ~ rhs; } / mulExp; // multiplication and division string mulExp = primary !"*" mulExp >> (lhs, rhs){ return lhs ~ "*" ~ rhs; } / primary !"/" mulExp >> (lhs, rhs){ return lhs ~ "/" ~ rhs; } / primary; string primary = !"(" addExp !")" / [a-zA-Z]+ >> to!string; 

}));

void main()
{
static bool test()
{
pragma(msg, parse!root("a * b + c * d").value);
pragma(msg, parse!root("A * B + C * D").value);
return true;
};

test(); 

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions