Giter VIP home page Giter VIP logo

Comments (4)

Alexey-T avatar Alexey-T commented on August 16, 2024

попробовал это поправить так

              case regparse^ of // r.e.extensions
                'd':
                  begin
                    //EmitRangeStr('0123456789');
                    if bInverse then
                      EmitNode(OP_NOTDIGIT)
                    else
                      EmitNode(OP_ANYDIGIT);
                  end;

где выше делается

        bInverse := regparse^ = '^';
        if bInverse then
        begin // Complement of range.
          if (fCompModifiers and MaskModI) <> 0 then
            ret := EmitRange(OP_ANYBUTCI)
          else
            ret := EmitRange(OP_ANYBUT);
          Inc(regparse);
        end
        else if (fCompModifiers and MaskModI) <> 0 then
          ret := EmitRange(OP_ANYOFCI)
        else
          ret := EmitRange(OP_ANYOF);

но это не помогло. Test11 все равно сбоит.
тогда тут кривое место - это место парсинга внутри [ ] для \d \w \s и тд.
что делать? @andgineer

from tregexpr.

Alexey-T avatar Alexey-T commented on August 16, 2024

судя по обработке опкода для [ ]

    OP_ANYOF:
      while (Result < TheMax) and (StrScan(opnd, scan^) <> nil) do
      begin
        Inc(Result);
        Inc(scan);
      end;
    OP_ANYBUT:
      while (Result < TheMax) and (StrScan(opnd, scan^) = nil) do
      begin
        Inc(Result);
        Inc(scan);
      end;
    OP_ANYOFCI:
      while (Result < TheMax) and (StrScanCI(opnd, scan^) <> nil) do
      begin
        Inc(Result);
        Inc(scan);
      end;
    OP_ANYBUTCI:
      while (Result < TheMax) and (StrScanCI(opnd, scan^) = nil) do
      begin
        Inc(Result);
        Inc(scan);
      end;

опкод всегда сканируется от OP_.... до нуля и никакие вложенные опкоды типа ANYLETTER ANYDIGIT ANYSPACE не разрешены. это нехорошо так сделали.

from tregexpr.

Alexey-T avatar Alexey-T commented on August 16, 2024

предлагаю сделать так.
для опкода внутри [ ] сейчас пишется поток символов и в конце 0.
сделать так.
писать поток ПАР символов. (kind, char). тогда при сканировании опкода можно смотреть на пары и если например

  • kind=1, то char это "просто символ",
  • kind=0, то это конец [ ]
  • kind=2, то это место \w
  • kind=3, это место \W

так мы поддержим вообще все штуки \w \W \d \D \s \S \v \V \h \H внутри [ ] !!

from tregexpr.

andgineer avatar andgineer commented on August 16, 2024

компактнее будет иметь опкоды для всех фиксированных подмножеств и для конца []
причем можно использовать те же опкоды что и снаружи []

а наборы сиволов писать парой - опкод "набор символов" и его длина, дальше сами символы

вообще вроде где-то еще использовался тот факт что [] это именно перечень символов, так что фиксированные множества в него не вставить - как минимум оптимизация которая определяет с какого символа может начинаться искомый текст если в начале регулярного выражения []

но надеюсь это выявят тесты

from tregexpr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.