Last active
March 29, 2016 03:50
-
-
Save zkessin/5063b9334cb783e06dc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Definitions. | |
D = [0-9] | |
L = [A-Za-z] | |
WS = ([\000-\s]|%.*) | |
C = (\:\-|\-\>) | |
WC = [A-Za-z0-9] | |
Rules. | |
{WS} : skip_token. | |
\. : skip_token. | |
{WC}+ : {token, {path_symbol, TokenLine, TokenChars}}. | |
{C} : {token, {path_divider, TokenLine}}. | |
Erlang code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%-*- Erlang -*- | |
Terminals path_symbol path_divider. | |
Nonterminals Path Rule . | |
Rootsymbol Rule. | |
%% rules -> | |
%% rule rules. | |
%% rules -> | |
%% rule. | |
Rule -> | |
Path path_divider Path : {map, '$1','$3'}. | |
Path -> | |
path_symbol Path : ['$1' | '$2']. | |
Path -> | |
path_symbol : ['$1']. | |
Erlang code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(wm@draco)11> {ok, L, _} = map:string( "product image small string -> product image label"). | |
{ok,[{object,1,{path_symbol,"product"}}, | |
{object,1,{path_symbol,"image"}}, | |
{object,1,{path_symbol,"small"}}, | |
{object,1,{path_symbol,"string"}}, | |
{object,1,path_divider}, | |
{object,1,{path_symbol,"product"}}, | |
{object,1,{path_symbol,"image"}}, | |
{object,1,{path_symbol,"label"}}], | |
1} | |
(wm@draco)12> map_g:parse(L). | |
{error,{1,map_g, | |
["syntax error before: ", | |
[[123,["path_symbol",44,"\"product\""],125]]]}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment