Skip to content

Commit

Permalink
Fix to work on julia v0.4
Browse files Browse the repository at this point in the history
The relevant change to Regex was made in JuliaLang/julia#11447
  • Loading branch information
garrison committed Jun 14, 2015
1 parent eb6efce commit e924b29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/TOML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module TOML
VERSION = v"0.1.2"


if Base.VERSION >= v"0.4.0-dev+5050"
anchored_regex(r) = Regex(r, Base.PCRE.ANCHORED, 0)
else
anchored_regex(r) = Regex(r, Base.PCRE.ANCHORED)
end


include("datetime.jl")


Expand Down Expand Up @@ -65,7 +72,7 @@ function parse(subject::Union(String, Array{Uint8, 1}))
end


const table_pattern = Regex("[ \t]*([^ \t\r\n][^\]\r\n]*)\]", Base.PCRE.ANCHORED)
const table_pattern = anchored_regex("[ \t]*([^ \t\r\n][^\]\r\n]*)\]")

function table (state::ParserState)
m = match(table_pattern, state.subject, state.index)
Expand Down Expand Up @@ -103,7 +110,7 @@ function table (state::ParserState)
end


const table_array_pattern = Regex("[ \t]*([^ \t\r\n]?[^\]\r\n]*)\]\]", Base.PCRE.ANCHORED)
const table_array_pattern = anchored_regex("[ \t]*([^ \t\r\n]?[^\]\r\n]*)\]\]")

function table_array (state::ParserState)
m = match(table_array_pattern, state.subject, state.index)
Expand Down Expand Up @@ -152,7 +159,7 @@ function table_array (state::ParserState)
end


const key_pattern = Regex("([^\n\r=]*)([\n\r=])", Base.PCRE.ANCHORED)
const key_pattern = anchored_regex("([^\n\r=]*)([\n\r=])")

function key (state)
m = match(key_pattern, state.subject, state.index)
Expand Down
2 changes: 1 addition & 1 deletion src/datetime.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# waiting for official Timestamp support in Julia. Calendar.jl is too slow to load.
const date_pattern = Regex("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})Z", Base.PCRE.ANCHORED)
const date_pattern = anchored_regex("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})Z")

immutable DateTime
year::Int
Expand Down

0 comments on commit e924b29

Please sign in to comment.