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

Regular Expressions do not work #3

Closed
dprog opened this issue Oct 2, 2013 · 1 comment
Closed

Regular Expressions do not work #3

dprog opened this issue Oct 2, 2013 · 1 comment

Comments

@dprog
Copy link

dprog commented Oct 2, 2013

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();

}

youxkei added a commit that referenced this issue Oct 8, 2013
@youxkei
Copy link
Owner

youxkei commented Oct 8, 2013

Fixed

@youxkei youxkei closed this as completed Oct 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants