Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit bb6b690edfdf29d871bf11f5ea877a48134f8336 Devin Torres committed Feb 25, 2011
Showing with 1,254 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +7 −0 Makefile
  3. +29 −0 README.md
  4. +24 −0 UNLICENSE
  5. +7 −0 ebin/zucchini.app
  6. BIN rebar
  7. +15 −0 src/zucchini.erl
  8. +745 −0 src/zucchini_lexer.erl
  9. +45 −0 src/zucchini_lexer.xrl
  10. +359 −0 src/zucchini_parser.erl
  11. +21 −0 src/zucchini_parser.yrl
@@ -0,0 +1,2 @@
+.DS_Store
+*.beam
@@ -0,0 +1,7 @@
+all: compile
+
+compile:
+ @./rebar compile
+
+clean:
+ @./rebar clean
@@ -0,0 +1,29 @@
+Zucchini - An Erlang INI parser
+===============================
+
+## Example
+
+ $ erl -pa ebin
+ 1> zucchini:parse_string("
+ 1> [pumpkin]
+ 1> variety = winter
+ 1> name = Pumpkin ; mmm, pumpkin pie
+ 1> fortune = \"Pumpkin carving = Awesome\"
+ 1> weight = 3.3
+ 1> amount = 2
+ 1>
+ 1> [yellow] ; It's just called Yellow!
+ 1> variety = summer
+ 1> name = Yellow Squash
+ 1> weight = 0.3
+ 1> amount = 3
+ 1> ").
+ {ok,[{pumpkin,[{variety,winter},
+ {name,"Pumpkin"},
+ {fortune,"Pumpkin carving = Awesome"},
+ {weight,3.3},
+ {amount,2}]},
+ {yellow,[{variety,summer},
+ {name,"Yellow Squash"},
+ {weight,0.3},
+ {amount,3}]}]}
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,7 @@
+{application, zucchini, [
+ {description, "An Erlang INI parser"},
+ {vsn, "0.1"},
+ {applications, [kernel, stdlib]},
+ {modules, [zucchini, zucchini_lexer, zucchini_parser]},
+ {registered, []}
+]}.
BIN rebar
Binary file not shown.
@@ -0,0 +1,15 @@
+-module(zucchini).
+
+-export([parse_string/1, parse_file/1]).
+
+parse_string(String) when is_binary(String) ->
+ parse_string(binary_to_list(String));
+parse_string(String) ->
+ {ok, Tokens, _} = zucchini_lexer:string(String),
+ zucchini_parser:parse(Tokens).
+
+parse_file(Filename) ->
+ case file:read_file(Filename) of
+ {ok, Binary} -> parse_string(Binary);
+ Error -> Error
+ end.
Oops, something went wrong.

0 comments on commit bb6b690

Please sign in to comment.