Sha256: a8b3a714f05060ee24f412e3016547eeb5918a7ac0535640f031e90d14141ac8

Contents?: true

Size: 1.72 KB

Versions: 26

Compression:

Stored size: 1.72 KB

Contents

/* IMPORTANT: must compile with JFlex 1.4, JFlex 1.4.3 seems buggy with look-ahead */

package org.embulk.spi.time.lexer;

import org.embulk.spi.time.StrptimeToken;

%%
%public
%class StrptimeLexer
//%debug
%unicode
%type org.embulk.spi.time.StrptimeToken
%{
    StringBuilder stringBuf = new StringBuilder();

    public StrptimeToken rawString() {
        String str = stringBuf.toString();
        stringBuf.setLength(0);
        return StrptimeToken.str(str);
    }

    public StrptimeToken directive(char c) {
        StrptimeToken token;
        if (c == 'z') {
            int colons = yylength()-1; // can only be colons except the 'z'
            return StrptimeToken.zoneOffsetColons(colons);
        } else if ((token = StrptimeToken.format(c)) != null) {
            return token;
        } else {
            return StrptimeToken.special(c);
        }
    }
%}

Flags = [-_0#\^]+
Width = [1-9][0-9]*

// See RubyDateFormatter.main to generate this
// Chars are sorted by | ruby -e 'p STDIN.each_char.sort{|a,b|a.casecmp(b).tap{|c|break a<=>b if c==0}}.join'
Conversion = [\+AaBbCcDdeFGgHhIjkLlMmNnPpQRrSsTtUuVvWwXxYyZz] | {IgnoredModifier} | {Zone}
// From MRI strftime.c
IgnoredModifier = E[CcXxYy] | O[deHIMmSUuVWwy]
Zone = :{1,3} z

SimpleDirective = "%"
LiteralPercent = "%%"
Unknown = .|\n

%xstate CONVERSION

%%

<YYINITIAL> {
  {LiteralPercent}                  { return StrptimeToken.str("%"); }
  {SimpleDirective}  / {Conversion} { yybegin(CONVERSION); }
}

<CONVERSION> {Conversion}           { yybegin(YYINITIAL); return directive(yycharat(yylength()-1)); }

/* fallback */
{Unknown} / [^%]                    { stringBuf.append(yycharat(0)); }
{Unknown}                           { stringBuf.append(yycharat(0)); return rawString(); }

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.39-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.38 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.38-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.37 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.37-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.36 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.36-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.35 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.35-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.34 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.34-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.33 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.33-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.32 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.32-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.31 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.31-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.30 embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex
embulk-0.8.30-java embulk-jruby-strptime/src/main/java/org/embulk/spi/time/lexer/StrptimeLexer.flex