Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e8586fc authored by Casey Dahlin's avatar Casey Dahlin Committed by Gerrit Code Review
Browse files

Merge "Convert to C++ Bison output"

parents c71fdabd 96786829
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
#include "aidl_language.h"
#include "aidl_language_y.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string>
@@ -74,7 +75,7 @@ bool ParseState::OpenFileFromDisk() {
}

int ParseState::RunParser() {
  int ret = yyparse(this);
  int ret = yy::parser(this).parse();

  free((void *)g_currentPackage);
  g_currentPackage = NULL;
+19 −18
Original line number Diff line number Diff line
%{
#include "aidl_language.h"
#include "aidl_language_y.h"
#include "aidl_language_y.hpp"
#include "search_path.h"
#include <string.h>
#include <stdlib.h>
@@ -39,6 +39,7 @@ static void do_package_statement(const char* importText);
%option noyywrap
%option reentrant
%option bison-bridge
%option bison-locations

%x COPYING LONG_COMMENT

@@ -65,13 +66,13 @@ idvalue (0|[1-9][0-9]*)
<LONG_COMMENT>\**\/             { BEGIN(INITIAL); }

^{whitespace}?import{whitespace}[^ \t\r\n]+{whitespace}?;  {
                                                SET_BUFFER(IMPORT);
                                                return IMPORT;
                                                SET_BUFFER(yy::parser::token::IMPORT);
                                                return yy::parser::token::IMPORT;
                                            }
^{whitespace}?package{whitespace}[^ \t\r\n]+{whitespace}?;  {
                                                do_package_statement(yytext);
                                                SET_BUFFER(PACKAGE);
                                                return PACKAGE;
                                                SET_BUFFER(yy::parser::token::PACKAGE);
                                                return yy::parser::token::PACKAGE;
                                            }
<<EOF>>             { yyterminate(); }

@@ -90,25 +91,25 @@ idvalue (0|[1-9][0-9]*)
=               { SET_BUFFER('='); return '='; }

    /* keywords */
parcelable      { SET_BUFFER(PARCELABLE); return PARCELABLE; }
interface       { SET_BUFFER(INTERFACE); return INTERFACE; }
in              { SET_BUFFER(IN); return IN; }
out             { SET_BUFFER(OUT); return OUT; }
inout           { SET_BUFFER(INOUT); return INOUT; }
oneway          { SET_BUFFER(ONEWAY); return ONEWAY; }

{brackets}+     { SET_BUFFER(ARRAY); return ARRAY; }
{idvalue}       { SET_BUFFER(IDVALUE); return IDVALUE; }
{identifier}                                        { SET_BUFFER(IDENTIFIER); return IDENTIFIER; }
parcelable      { SET_BUFFER(yy::parser::token::PARCELABLE); return yy::parser::token::PARCELABLE; }
interface       { SET_BUFFER(yy::parser::token::INTERFACE); return yy::parser::token::INTERFACE; }
in              { SET_BUFFER(yy::parser::token::IN); return yy::parser::token::IN; }
out             { SET_BUFFER(yy::parser::token::OUT); return yy::parser::token::OUT; }
inout           { SET_BUFFER(yy::parser::token::INOUT); return yy::parser::token::INOUT; }
oneway          { SET_BUFFER(yy::parser::token::ONEWAY); return yy::parser::token::ONEWAY; }

{brackets}+     { SET_BUFFER(yy::parser::token::ARRAY); return yy::parser::token::ARRAY; }
{idvalue}       { SET_BUFFER(yy::parser::token::IDVALUE); return yy::parser::token::IDVALUE; }
{identifier}                                        { SET_BUFFER(yy::parser::token::IDENTIFIER); return yy::parser::token::IDENTIFIER; }
{identifier}\<{whitespace}*{identifier}({whitespace}*,{whitespace}*{identifier})*{whitespace}*\>    {
                                                      SET_BUFFER(GENERIC); return GENERIC; }
                                                      SET_BUFFER(yy::parser::token::GENERIC); return yy::parser::token::GENERIC; }

    /* syntax error! */
.               { printf("UNKNOWN(%s)", yytext);
                  yylval->buffer.lineno = yylineno;
                  yylval->buffer.token = IDENTIFIER;
                  yylval->buffer.token = yy::parser::token::IDENTIFIER;
                  yylval->buffer.data = strdup(yytext);
                  return IDENTIFIER;
                  return yy::parser::token::IDENTIFIER;
                }

%%
+10 −8
Original line number Diff line number Diff line
%{
#include "aidl_language.h"
#include "aidl_language_y.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int yyerror(ParseState* ps, char* errstr)
{
  ps->ReportError(errstr);
  return 1;
}

int yylex(lexer_type *, void *);
int yylex(lexer_type *, yy::parser::location_type *l, void *);

static int count_brackets(const char*);

#define YYLEX_PARAM ps->Scanner()
#define lex_scanner ps->Scanner()

%}

%parse-param { ParseState* ps }
%lex-param { void *lex_scanner }

%pure-parser
%skeleton "glr.cc"

%token IMPORT
%token PACKAGE
@@ -339,3 +336,8 @@ static int count_brackets(const char* s)
    }
    return n;
}

void yy::parser::error(const yy::parser::location_type& l, const std::string& errstr)
{
  ps->ReportError(errstr);
}