<commit_before>{
/*
 * fMBT, free Model Based Testing tool
 * Copyright (c) 2011, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include <vector>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include "aalang.hh"
#include "aalang_cpp.hh"
#include "aalang_java.hh"
#include "aalang_py.hh"

std::string result("");
aalang* obj=NULL;

typedef struct _node {
  std::string* str;
} node;
#define D_ParseNode_User node
std::vector<std::string> aname;

int count=1;

char *ops;
void *ops_cache=&count;

#include "d.h"

int bstr_scan(char *ops, void *ops_cache, d_loc_t *loc,
              unsigned char *op_assoc, int *op_priority)
{
    int count=1;
    int pos=0;
    while (count) {
        switch (loc->s[pos]) {
        case '{':
            count++;
            pos++;
            break;
        case '}':
            count--;
            if (count) pos++;
            break;
        default:
            pos++;
        }
    }

    loc->s+=pos;

    return 1;
}
}

aal: aal_start header+ ( act | tag | itag | comment )* '}' ;

aal_start: 'aal' string '{' language {
            obj->set_namestr($1.str);
        } ;

header: variables | istate | push | pop | comment;

comment: '#' "[^\n]*" {} ;

act: 'action' astr '{' comment* guard comment* body comment* adapter comment* '}' {
            obj->next_action();
        };

astr:   string          {
            obj->set_name($0.str);
        } |
        astr ',' string {
            obj->set_name($2.str);
        } ;

tag: 'tag' tstr '{' comment* guard  comment* '}' { obj->next_tag(); };

itag: 'new_tag' tstr '{' implicit_guard '}' { obj->next_tag(); };

tstr:   string          {
            obj->set_tagname($0.str);
        } |
        tstr ',' string {
            obj->set_tagname($2.str);
        } ;

push: 'push' '{' bstr '}' { 
            obj->set_push($2.str); 
        } ;

pop:  'pop' '{' bstr '}' { obj->set_pop ($2.str); } ;

language: 'language:' cpp    { obj=new aalang_cpp  ; } starter ';'? |
          'language:' java   { obj=new aalang_java ; } starter ';'? |
          'language:' python { obj=new aalang_py   ; } starter ';'? ;

cpp: 'C++' | 'cpp' | 'c++';

java: 'oak' | 'green' | 'java';

starter: |
        '{' bstr '}' { obj->set_starter($1.str); };

python: 'Python' | 'python' | 'py';

namestr: unquoted_string {
            $$.str=$0.str; // I'm too lazy to figure out why this can't be returned in $0
        };

variables: 'variables' '{' bstr '}' { obj->set_variables($2.str); };

istate: 'initial_state' '{' bstr '}' { obj->set_istate($2.str); } ;

guard: 'guard' '()' '{' bstr '}' { obj->set_guard($3.str); }
    | { obj->empty_guard(); } ;

implicit_guard: bstr { obj->set_guard($0.str); };
<commit_msg>experimental "new_tag" dropped, tags need to be extensible<commit_after>{
/*
 * fMBT, free Model Based Testing tool
 * Copyright (c) 2011, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include <vector>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include "aalang.hh"
#include "aalang_cpp.hh"
#include "aalang_java.hh"
#include "aalang_py.hh"

std::string result("");
aalang* obj=NULL;

typedef struct _node {
  std::string* str;
} node;
#define D_ParseNode_User node
std::vector<std::string> aname;

int count=1;

char *ops;
void *ops_cache=&count;

#include "d.h"

int bstr_scan(char *ops, void *ops_cache, d_loc_t *loc,
              unsigned char *op_assoc, int *op_priority)
{
    int count=1;
    int pos=0;
    while (count) {
        switch (loc->s[pos]) {
        case '{':
            count++;
            pos++;
            break;
        case '}':
            count--;
            if (count) pos++;
            break;
        default:
            pos++;
        }
    }

    loc->s+=pos;

    return 1;
}
}

aal: aal_start header+ ( act | tag | comment )* '}' ;

aal_start: 'aal' string '{' language {
            obj->set_namestr($1.str);
        } ;

header: variables | istate | push | pop | comment;

comment: '#' "[^\n]*" {} ;

act: 'action' astr '{' comment* guard comment* body comment* adapter comment* '}' {
            obj->next_action();
        };

astr:   string          {
            obj->set_name($0.str);
        } |
        astr ',' string {
            obj->set_name($2.str);
        } ;

tag: 'tag' tstr '{' comment* guard  comment* '}' { obj->next_tag(); };

tstr:   string          {
            obj->set_tagname($0.str);
        } |
        tstr ',' string {
            obj->set_tagname($2.str);
        } ;

push: 'push' '{' bstr '}' { 
            obj->set_push($2.str); 
        } ;

pop:  'pop' '{' bstr '}' { obj->set_pop ($2.str); } ;

language: 'language:' cpp    { obj=new aalang_cpp  ; } starter ';'? |
          'language:' java   { obj=new aalang_java ; } starter ';'? |
          'language:' python { obj=new aalang_py   ; } starter ';'? ;

cpp: 'C++' | 'cpp' | 'c++';

java: 'oak' | 'green' | 'java';

starter: |
        '{' bstr '}' { obj->set_starter($1.str); };

python: 'Python' | 'python' | 'py';

namestr: unquoted_string {
            $$.str=$0.str; // I'm too lazy to figure out why this can't be returned in $0
        };

variables: 'variables' '{' bstr '}' { obj->set_variables($2.str); };

istate: 'initial_state' '{' bstr '}' { obj->set_istate($2.str); } ;

guard: 'guard' '()' '{' bstr '}' { obj->set_guard($3.str); }
    | { obj->empty_guard(); } ;

{'fraction_non_alphanumeric': 0.16286742651469707, 'fraction_numerical': 0.010347930413917216, 'mean_word_length': 2.489795918367347, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4897223', 'n_tokens_mistral': 2290, 'n_tokens_neox': 2246, 'n_words': 636}