JKML - Just K markup language
use JKML; decode_jkml(<<'...'); [ { # heh. input => "hoghoge", expected => "hogehoge", description => <<-EOF, This markup language is human writable. JKML supports following features: * heredoc * raw string. * comments EOF regexp => r" ^^ \s+ ", } ] ...
JKML is parser library for JKML. JKML is yet another markup language.
This module is alpha state. Any API will change without notice.
JKML extends following features:
These features are very useful for writing test data.
You MUST use UTF-8 for every JKML data.
JKML allows raw strings. Such as following:
raw_string = "r'" .*? "'" | 'r"' .*? '"' | 'r"""' .*? '"""' | "r'''" .*? "'''"
Every raw string literals does not care about non terminater characters.
r'hoge' r"hoge" r"""hoge""" r'''hoge'''
Perl5 style comemnt is allowed.
# comment
String literal is compatible with JSON.
string = sqstring | dqstring dqstring = '"' dqchar* '"' sqstring = "'" sqchar* "'" dqchar = unescaped | "'" | escaped sqchar = unescaped | '"' | escaped escaped = escape ( %x22 / ; " quotation mark U+0022 %x5C / ; \ reverse solidus U+005C %x2F / ; / solidus U+002F %x62 / ; b backspace U+0008 %x66 / ; f form feed U+000C %x6E / ; n line feed U+000A %x72 / ; r carriage return U+000D %x74 / ; t tab U+0009 %x75 4HEXDIG ) ; uXXXX U+XXXX escape = %x5C ; \ quotation-mark = %x22 ; " unescaped = [^"'\]
Number literal is compatible with JSON. See JSON RFC.
3 3.14 3e14
Map literal's grammar is:
pair = string "=>" value map = "{" "}" | "{" pair ( "," pair )* ","? "}"
You can omit quotes for keys, if you don't want to type it.
You can use trailing comma unlike JS.
Examples:
{ a => 3, "b" => 4, }
array = "[" "]" | "[" value ( "," value )* ","? "]"
[1,2,3] [1,2,3,]
Ruby style heredoc.
<<-TOC hoghoge TOC
value = map | array | string | raw_string | number | funcall
bool = "true" | "false"
null = "null"
Will decode to undef.
undef
funcall = ident "(" value ")" ident = [a-zA-Z_] [a-zA-Z0-9_]*
JKML supports some builtin functions.
Decode base64 string.
base64(string)
tokuhirom <tokuhirom@gmail.com>
Copyright (C) tokuhirom
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This library uses JSON::Tiny's code. JSON::Tiny's license term is following:
Copyright 2012-2013 David Oswald.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. See http://www.perlfoundation.org/artistic_license_2_0 for more information.
To install JKML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JKML
CPAN shell
perl -MCPAN -e shell install JKML
For more information on module installation, please visit the detailed CPAN module installation guide.