<commit_before>/* $Id: gramar.y,v 1.23 2012/04/27 14:18:30 demon Exp $ */
/*
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, dATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

%{
#include <sys/queue.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>

extern int yylineno;
extern FILE *yyin;
int yylex(void);
int yyparse(void);
void yyerror(const char *, ...);
void push(int, char *);
void popop(int);
void popall(void);
void popallr(void);
void addref(char *);

#if YYDEBUG
extern int yydebug;
#endif

struct pair {
	unsigned short val;
	int lineno;
	char *label;
} *stack, *ref;

static int sp = 0;
static int rp = 0;
static int pc = 0;
static int haserrors = 0;

unsigned short *buffer;
struct label {
	char *label;
	int lineno;
} *label;

%}

%union {
	int ival;
	char *sval;
};

%token A B C X Y Z I J

%token PUSH POP PEEK PICK SP PC EX

%token SET ADD SUB MUL MLI DIV DVI MOD MDI AND BOR XOR SHR ASR SHL
%token IFB IFC IFE IFN IFG IFA IFL IFU ADX SBX STI STD
%token NOP BRK DAT ORG
%token JSR HCF INT IAG IAS RFI IAQ HWN HWQ HWI
%token LBR RBR LBRACE RBRACE LPAR RPAR
%token COMMA DP
%token PLUS MINUS EMUL EDIV EMOD ENOT EXOR EAND EOR SHIFTL SHIFTR
%token DOT HASH MACRO INCLUDE
%token <ival> NUMBER
%token <sval> STRING QSTRING

%type <ival> register opcode operand expr extended noarg

%left EOR
%left EXOR
%left EAND
%left SHIFTL SHIFTR
%left PLUS MINUS
%left EMUL EDIV EMOD
%left ENOT NEG

%%

prog	
	: /* empty */
	| prog statement
	;

statement
	: opcode operand COMMA operand
	{
				popop(($4 << 10) | ($2 << 5) | $1);
				popallr();
	}
	| extended operand
	{
				popop(($2 << 10) | ($1 << 5));
				popallr();
	}
	| noarg			{ popop($1 << 5); }
	| DP STRING		{ addref($2); }
	| DAT data		{ popall(); }
	| ORG expr		{ pc = $2; }
	| error
	;

data
	: /* empty */
	| data block
	| data COMMA block
	;

block
	: QSTRING
	{
				char *s = $1;
				while (*s)
					push(*s++, NULL);
	}
	| STRING		{ push(0, $1); }
	| expr			{ push($1, NULL); }
	;
<commit_msg>rename<commit_after>/* $Id: gramar.y,v 1.24 2012/04/27 14:21:08 demon Exp $ */
/*
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, dATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

%{
#include <sys/queue.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>

extern int yylineno;
extern FILE *yyin;
int yylex(void);
int yyparse(void);
void yyerror(const char *, ...);
void push(int, char *);
void popop(int);
void popall(void);
void popallr(void);
void addref(char *);

#if YYDEBUG
extern int yydebug;
#endif

struct pair {
	unsigned short val;
	int lineno;
	char *label;
} *stack, *ref;

static int sp = 0;
static int rp = 0;
static int pc = 0;
static int haserrors = 0;

unsigned short *buffer;
struct label {
	char *label;
	int lineno;
} *label;

%}

%union {
	int ival;
	char *sval;
};

%token A B C X Y Z I J

%token PUSH POP PEEK PICK SP PC EX

%token SET ADD SUB MUL MLI DIV DVI MOD MDI AND BOR XOR SHR ASR SHL
%token IFB IFC IFE IFN IFG IFA IFL IFU ADX SBX STI STD
%token NOP BRK DAT ORG
%token JSR HCF INT IAG IAS RFI IAQ HWN HWQ HWI
%token LBR RBR LBRACE RBRACE LPAR RPAR
%token COMMA DP
%token PLUS MINUS EMUL EDIV EMOD ENOT EXOR EAND EOR SHIFTL SHIFTR
%token DOT HASH MACRO INCLUDE
%token <ival> NUMBER
%token <sval> STRING QSTRING

%type <ival> register opcode operand expr extended noarg

%left EOR
%left EXOR
%left EAND
%left SHIFTL SHIFTR
%left PLUS MINUS
%left EMUL EDIV EMOD
%left ENOT NEG

%%

prog	
	: /* empty */
	| prog statement
	;

statement
	: opcode operand COMMA operand
	{
				popop(($4 << 10) | ($2 << 5) | $1);
				popallr();
	}
	| extended operand
	{
				popop(($2 << 10) | ($1 << 5));
				popallr();
	}
	| noarg			{ popop($1 << 5); }
	| DP STRING		{ addref($2); }
	| DAT data		{ popall(); }
	| ORG expr		{ pc = $2; }
	| error
	;

data
	: /* empty */
	| data entry
	| data COMMA entry
	;

entry
	: QSTRING
	{
				char *s = $1;
				while (*s)
					push(*s++, NULL);
	}
	| STRING		{ push(0, $1); }
	| expr			{ push($1, NULL); }
	;

{'fraction_non_alphanumeric': 0.11404989682986306, 'fraction_numerical': 0.016507221909585444, 'mean_word_length': 3.454469507101086, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4449439', 'n_tokens_mistral': 2165, 'n_tokens_neox': 1983, 'n_words': 774}