mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
Move grammar-related stuff into package jw-grammar
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
930efae39f
commit
c2c409ed4b
8 changed files with 0 additions and 2004 deletions
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
]
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import jwutils
|
||||
|
||||
jwutils.run_sub_commands('generate Test parser files', modules = ['jwutils.grammar'])
|
||||
|
|
@ -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 ? ;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
PROGRAM DEMO1
|
||||
BEGIN
|
||||
A:=3;
|
||||
B:=45;
|
||||
H:=-100023;
|
||||
C:=A;
|
||||
D123:=B34A;
|
||||
BABOON:=GIRAFFE;
|
||||
END.
|
||||
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue