Move grammar-related stuff into package jw-grammar

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-11-12 16:08:26 +01:00
commit c2c409ed4b
8 changed files with 0 additions and 2004 deletions

View file

@ -1,14 +0,0 @@
TOPDIR = ../..
-include local.mk
EXE_ARGS ?= grammartest.code
PREREQ_BUILD += ytools
FB_NAME = grammartest
NAMESPACE_IN_GENERATED = gt
GENERATE_CONFIG_FILE = generate.conf
IRRELEVANT_SYMBOLS ?= white_space
include $(TOPDIR)/make/proj.mk
include $(TOPDIR)/make/generate-flex-bison.mk
include $(MODDIR)/make/exe.mk

View file

@ -1,20 +0,0 @@
[symbols]
[white_space[
type = token
lex_extra_action = "if memchr(yytext, '\n', yyleng) context->line++;"
regex = "[ \n\t\r]+"
]
[all_characters[
type = non-terminal
regex = "[[:print:]]"
#lex_as = yytext[0]
]
[test[
type = token
dings = bums
regex = "bumsdings"
]

View file

@ -1,6 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import jwutils
jwutils.run_sub_commands('generate Test parser files', modules = ['jwutils.grammar'])

View file

@ -1,16 +0,0 @@
(* a simple program syntax in EBNF Wikipedia *)
program = 'PROGRAM', white space, identifier, white space,
'BEGIN', white space,
{ assignment, ";", white space },
'END.', [ white space ];
identifier = alphabetic character, { alphabetic character | digit } ;
number = [ "-" ], digit, { digit } ;
string = '"' , { all characters }, '"' ;
assignment = identifier , ":=" , ( number | identifier | string ) ;
alphabetic character = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
white space = ? white space characters ? ;
all characters = ? all visible characters ? ;

View file

@ -1,9 +0,0 @@
PROGRAM DEMO1
BEGIN
A:=3;
B:=45;
H:=-100023;
C:=A;
D123:=B34A;
BABOON:=GIRAFFE;
END.

View file

@ -1,30 +0,0 @@
#include <string>
#include <slog.h>
#include <YMisc.h>
#include "include/grammartest.h"
using namespace std;
int main(int argc, const char *argv[])
{
if (argc < 2) {
fprintf(stderr, "usage: %s input-file\n", filenotdir(argv[0]));
return 1;
}
const char *path = argv[1];
string content;
if (YMisc::suck_in_file(path, content)<0) {
slog(PRI_ERR, "failed to read [%s] (%s)", path, err());
return 1;
}
if (FB_SYM(create_ast)(content.c_str())<0) {
slog(PRI_ERR, "failed to create AST from [%s] (%s)", path, err());
return 1;
}
return 0;
}