Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idl parser #90

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Idl parser #90

wants to merge 13 commits into from

Conversation

seriyps
Copy link
Member

@seriyps seriyps commented Jul 22, 2019

Some draft for idl parser. Should fix #68 at some point.

  • lexer
  • parser (almost done)
  • parser tests
  • avdl-avsc converter
  • avdl-avprconverter
  • avdl-loader (to load avdl to avro_schema_store; make avdl first-class citizen)
  • more tests

Just as a quick example of how does the parse tree looks:

> File = "test/data/protocol_with_typedefs.avdl",
> rp( (fun(F) -> {ok, B} = file:read_file(F), {ok, T, _} =  avro_idl_lexer:string(binary_to_list(B)), avro_idl_parser:parse(T) end)(File) ).
{ok,{annotated,{annotation,"namespace","org.erlang.www"},
               {protocol,"MyProto",
                         [{import,idl,"foo.avdl"},
                          {import,protocol,"bar.avpr"},
                          {import,schema,"baz.avsc"},
                          {enum,"MyEnum1",["VAR11","VAR12","VAR13"]},
                          {enum,"MyEnum2",["VAR21","VAR22","VAR23"]},
                          {fixed,"MyFix",10},
                          {record,"MyRec",
                                  [{field,"my_int",int,undefined},
                                   {field,"my_string",string,"wasd"},
                                   {field,"my_float",float,12.34},
                                   {field,"my_bool",boolean,false},
                                   {field,"my_custom",{custom,"MyFix"},undefined},                                                                           
                                   {field,"my_union",{union,[boolean,null]},null},                                                                           
                                   {field,"my_date",date,123456},
                                   {field,"my_decimal",{decimal,5,2},1222},
                                   {field,"my_int_array",{array,int},undefined},                                                                             
                                   {field,"my_int_array_def",{array,int},[1,2,3]},                                                                           
                                   {field,"my_str_array_def",
                                          {array,string},
                                          ["123","456","cdf"]},
                                   {field,"my_map",{map,float},#{"a" => 1.23,"b" => 45.67}}]},                                                               
                          {annotated,{annotation,"namespace","org.erlang.ftp"},                                                                              
                                     {record,"MyAnnotated",
                                             [{field,"error",
                                                     {custom,"org.erlang.www.MyError"},                                                                      
                                                     undefined}]}},
                          {error,"MyError",
                                 [{field,"code",{custom,"MyEnum2"},undefined},
                                  {field,"description",string,undefined}]},
                          {function,"mul",
                                    [{arg,"arg1",int,undefined},{arg,"arg2",float,1.0}],                                                                     
                                    float,undefined},
                          {function,"append",
                                    [{arg,"arg1",bytes,undefined},{arg,"arg2",string,"tail"}],                                                               
                                    {custom,"MyFix"},
                                    {throws,"MyError"}},
                          {function,"gen_server_cast",
                                    [{arg,"opts",{map,float},undefined}],
                                    void,oneway},
                          {function,"ping",[],{custom,"MyEnum1"},undefined}]}}} 

@coveralls
Copy link

coveralls commented Jul 22, 2019

Pull Request Test Coverage Report for Build 599

  • 75 of 77 (97.4%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-29.7%) to 70.257%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/avro_idl.erl 70 72 97.22%
Totals Coverage Status
Change from base Build 591: -29.7%
Covered Lines: 2870
Relevant Lines: 4085

💛 - Coveralls

src/avro_idl_lexer.xrl Outdated Show resolved Hide resolved
@CLAassistant
Copy link

CLAassistant commented Jan 21, 2021

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Would be nice to have support for Avro IDL schema format (.avdl)
3 participants