tested grammar for reading entries (parsing quite slow)

This commit is contained in:
Trilarion 2020-09-02 14:45:25 +02:00
parent a1ce1809f3
commit 60fd9ed93e
21 changed files with 118 additions and 50 deletions

View File

@ -1,15 +1,21 @@
start: title description property+ _E note? _E? building start: title description property+ (_E note)? _E building
title: "#" /(?! ).+(?<! )/ "\n" _E // not starting or ending with a space title: "#" /(?! ).+(?<! )/ "\n" _E // not starting or ending with a space
description: "_" /(?! ).+(?<![ _])/ "_\n" _E // single line not ending with underscore description: "_" /(?! ).+(?<![ _])/ "_\n" _E // single line not ending with underscore
property: "- " _key ": " _value "\n" // a property on a single line "- key: value"
_key: /(?! ).+?(?=:)/ // key: everything until next ":"
_value: /.+(?<! )/ // everything until the end of the line
building: "## Building\n" _E property+ _E? note // the "building" section
note: /(?![\-#]).*\n/* // Unstructured text, not starting with - or # note: /(?![\-#]).*\n/* // Unstructured text, not starting with - or #
building: "## Building\n" (_E property+)? (_E note)? // the "building" section
property: "-" _key ":" _values "\n"? // a property on a single line "- key: value"
_key: /(?! ).+?(?=:)(?<! )/ // key: everything until next ":", not beginning or ending with a space
_values: [_value ("," _value)*] // a comma separated list
_value: quoted_value | unquoted_value // quoted or unquoted values
quoted_value: /\".+?\"/ // with quotation marks, can contain commas
unquoted_value: /(?![ \"])[^,\n]+(?<![ ])/ // cannot contain commas, cannot start or end with quotation mark
_E: /^$\n/m // empty new line _E: /^$\n/m // empty new line
%import common.WS
%ignore WS

View File

@ -28,11 +28,12 @@ if __name__ == "__main__":
print('{} inspirations in the inspirations database'.format(len(inspirations))) print('{} inspirations in the inspirations database'.format(len(inspirations)))
osg.write_inspirations_info(inspirations) # write again just to check integrity osg.write_inspirations_info(inspirations) # write again just to check integrity
osg_ui.run_simple_button_app('Maintenance inspirations', (('Duplicate check', duplicate_check),)) #osg_ui.run_simple_button_app('Maintenance inspirations', (('Duplicate check', duplicate_check),))
# assemble info # assemble info
entries = osg.read_entries()
entries = osg.assemble_infos() entries = osg.assemble_infos()
# assemble inspirations info from entries # assemble inspirations info from entries

View File

@ -58,11 +58,19 @@ class ListingTransformer(lark.Transformer):
# transformer # transformer
class EntryTransformer(lark.Transformer): class EntryTransformer(lark.Transformer):
def start(self, x): def unquoted_value(self, x):
d = {} return x[0].value
for key, value in x:
d[key] = value def quoted_value(self, x):
return d return x[0].value[1:-1] # remove quotation marks
def property(self, x):
"""
The key of a property will be converted to lower case and the value part is the second part
:param x:
:return:
"""
return x[0].lower(), x[1:]
def title(self, x): def title(self, x):
return 'title', x[0].value return 'title', x[0].value
@ -70,18 +78,32 @@ class EntryTransformer(lark.Transformer):
def description(self, x): def description(self, x):
return 'description', x[0].value return 'description', x[0].value
def property(self, x):
return str.casefold(x[0].value), x[1].value
def note(self, x): def note(self, x):
"""
Optional
:param x:
:return:
"""
if not x:
raise lark.Discard
return 'note', x[0].value return 'note', x[0].value
def building(self, x): def building(self, x):
d = {} d = {}
for key, value in x: for key, value in x:
if key in d:
raise RuntimeError('Key in entry appears twice')
d[key] = value d[key] = value
return 'building', d return 'building', d
def start(self, x):
d = {}
for key, value in x:
if key in d:
raise RuntimeError('Key in entry appears twice')
d[key] = value
return d
regex_sanitize_name = re.compile(r"[^A-Za-z 0-9-+]+") regex_sanitize_name = re.compile(r"[^A-Za-z 0-9-+]+")
regex_sanitize_name_space_eater = re.compile(r" +") regex_sanitize_name_space_eater = re.compile(r" +")
@ -535,6 +557,44 @@ def write_inspirations_info(inspirations):
utils.write_text(inspirations_file, content) utils.write_text(inspirations_file, content)
def read_entries():
"""
Parses all entries and assembles interesting infos about them.
"""
# setup parser
grammar_file = os.path.join(code_path, 'grammar_entries.lark')
grammar = utils.read_text(grammar_file)
parser = lark.Lark(grammar, debug=False)
# setup transformer
transformer = EntryTransformer()
# a database of all important infos about the entries
entries = []
# iterate over all entries
for file, _, content in entry_iterator():
print(file)
# parse and transform entry content
try:
tree = parser.parse(content)
entry = transformer.transform(tree)
except Exception as e:
print(e)
continue
# add file information
entry['file'] = file
# add to list
entries.append(entry)
return entries
def compare_entries_developers(entries, developers): def compare_entries_developers(entries, developers):
""" """
Cross checks the game entries lists and the developers lists. Cross checks the game entries lists and the developers lists.

View File

@ -13,4 +13,3 @@ _Space browsergame framework._
- Developer: Jan-Otto Kröpke, Ozan Kurt, Hilarious001 - Developer: Jan-Otto Kröpke, Ozan Kurt, Hilarious001
## Building ## Building

View File

@ -18,7 +18,7 @@ _Boost provides free peer-reviewed portable C++ source libraries._
Uses its own Build process Uses its own Build process
2017-11 (1.65.1) 2017-11 (1.65.1)
- Much is header only, but some parts require building Much is header only, but some parts require building
- Follow [Getting started on Windows](https://www.boost.org/doc/libs/1_65_1/more/getting_started/windows.html) or [Getting started on Unix variants](https://www.boost.org/doc/libs/1_65_1/more/getting_started/unix-variants.html) Follow [Getting started on Windows](https://www.boost.org/doc/libs/1_65_1/more/getting_started/windows.html) or [Getting started on Unix variants](https://www.boost.org/doc/libs/1_65_1/more/getting_started/unix-variants.html)
- Building on Windows with MSVC 2017 requires a workaround (see [issue #13197](https://svn.boost.org/trac10/ticket/13197)) Building on Windows with MSVC 2017 requires a workaround (see [issue #13197](https://svn.boost.org/trac10/ticket/13197))
- With MSVC 2015 run "bootstrap vc14" followed by "b2 toolset=msvc-14.0 stage" With MSVC 2015 run "bootstrap vc14" followed by "b2 toolset=msvc-14.0 stage"

View File

@ -1,6 +1,6 @@
# C-evo # C-evo
_C-evo is a freeware empire building game for Windows._ _Empire building game._
- Home: http://www.c-evo.org/ - Home: http://www.c-evo.org/
- Media: https://en.wikipedia.org/wiki/C-evo - Media: https://en.wikipedia.org/wiki/C-evo

View File

@ -5,7 +5,7 @@ _Remake of Commander Keen Series._
- Home: http://clonekeenplus.sourceforge.net/, https://sourceforge.net/projects/clonekeenplus/ - Home: http://clonekeenplus.sourceforge.net/, https://sourceforge.net/projects/clonekeenplus/
- State: mature - State: mature
- Download: http://clonekeenplus.sourceforge.net/download.php - Download: http://clonekeenplus.sourceforge.net/download.php
. Platform: Windows, Linux, Android - Platform: Windows, Linux, Android
- Keywords: action, inspired by Commander Keen Series, remake - Keywords: action, inspired by Commander Keen Series, remake
- Code repository: https://gitlab.com/Dringgstein/Commander-Genius.git, https://github.com/albertz/commandergenius.git (+), https://github.com/pelya/commandergenius.git (+), https://github.com/gerstrong/Commander-Genius.git (+) - Code repository: https://gitlab.com/Dringgstein/Commander-Genius.git, https://github.com/albertz/commandergenius.git (+), https://github.com/pelya/commandergenius.git (+), https://github.com/gerstrong/Commander-Genius.git (+)
- Code language: C, C++ - Code language: C, C++

View File

@ -4,7 +4,7 @@ _Remake of Space Invaders and other small arcade games._
- Home: https://github.com/Hopson97/Hopson-Arcade - Home: https://github.com/Hopson97/Hopson-Arcade
- State: mature - State: mature
- Platform. Linux - Platform: Linux
- Keywords: arcade, inspired by Space Invaders, open content, remake - Keywords: arcade, inspired by Space Invaders, open content, remake
- Code repository: https://github.com/Hopson97/Hopson-Arcade.git - Code repository: https://github.com/Hopson97/Hopson-Arcade.git
- Code language: C++ - Code language: C++

View File

@ -16,5 +16,5 @@ _libpng is the official PNG reference library._
## Building ## Building
2017-12 2017-12
- On Windows CMake fails with "No CMAKE_ASM_COMPILER could be found." on "project(.. ASM)" with MSVC 2015 as generator On Windows CMake fails with "No CMAKE_ASM_COMPILER could be found." on "project(.. ASM)" with MSVC 2015 as generator

View File

@ -1,6 +1,6 @@
# Micropolis # Micropolis
_Micropolis is the open source version of SimCity Classic from Maxis._ _Remake of SimCity._
- Home: https://micropolisonline.com/ - Home: https://micropolisonline.com/
- Media: <https://en.wikipedia.org/wiki/SimCity_(1989_video_game)#Micropolis> - Media: <https://en.wikipedia.org/wiki/SimCity_(1989_video_game)#Micropolis>
@ -14,4 +14,5 @@ _Micropolis is the open source version of SimCity Classic from Maxis._
## Building ## Building
- Build system: setup.py - Build system: setup.py
Many various parts Many various parts

View File

@ -1,6 +1,6 @@
# Open Legend RPG # Open Legend RPG
_A tabletop roleplaying game (or RPG) in which the players play the part of mighty heroes and wicked villains in order to tell stories of epic proportion._ _The players play mighty heroes and wicked villains in order to tell stories of epic proportion._
- Home: https://openlegendrpg.com - Home: https://openlegendrpg.com
- State: mature - State: mature
@ -9,4 +9,4 @@ _A tabletop roleplaying game (or RPG) in which the players play the part of migh
- Code language: None - Code language: None
- Code license: Custom (Open Legend Community License: https://github.com/openlegend/core-rules/blob/master/LICENSE.md) - Code license: Custom (Open Legend Community License: https://github.com/openlegend/core-rules/blob/master/LICENSE.md)
## Building

View File

@ -11,5 +11,3 @@ _Simple game about matching a pathogen molecular structure on a hexagonal grid._
- Developer: Jetro Lauha - Developer: Jetro Lauha
## Building ## Building
Build system:

View File

@ -12,4 +12,7 @@ _Shooting game which uses a 3d engine but allows 2d gameplay._
- Code dependencies: SDL - Code dependencies: SDL
- Developer: Matthew Sarnoff (Game Creation Society), Chris DeLeon (Game Creation Society), John Nesky (Game Creation Society), Gregory Peng (Game Creation Society), Jeff Thoene (Game Creation Society), Tuscan Knox (music, Game Creation Society), Michael Weber (Game Creation Society) - Developer: Matthew Sarnoff (Game Creation Society), Chris DeLeon (Game Creation Society), John Nesky (Game Creation Society), Gregory Peng (Game Creation Society), Jeff Thoene (Game Creation Society), Tuscan Knox (music, Game Creation Society), Michael Weber (Game Creation Society)
## Building system: VisualStudio ## Building
- Build system: VisualStudio

View File

@ -20,5 +20,4 @@ Does not contain tests.
Includes precompiled libraries for various compilers in source folder _extlibs_. Includes precompiled libraries for various compilers in source folder _extlibs_.
2017-12 2017-12
- Windows, CMake, MSVC 2015 builds Windows, CMake, MSVC 2015 builds

View File

@ -20,7 +20,7 @@ _Simple DirectMedia Layer is a cross-platform development library designed to pr
2017-11 (2.0.7) 2017-11 (2.0.7)
+ SDL 2.0.7 with MSVC 2015 via CMake 3.9 works + SDL 2.0.7 with MSVC 2015 via CMake 3.9 works
## Projects Projects
+ [SDL_ttf 2.0](https://www.libsdl.org/projects/SDL_ttf/) + [SDL_ttf 2.0](https://www.libsdl.org/projects/SDL_ttf/)
+ [SDL_net 2.0](https://www.libsdl.org/projects/SDL_net/) + [SDL_net 2.0](https://www.libsdl.org/projects/SDL_net/)

View File

@ -13,11 +13,10 @@ _A community developed, multiplayer round-based role playing game, where players
Uses the [Byond engine]() which is closed source! Uses the [Byond engine]() which is closed source!
Open source versions: Open source versions:
- https://tgstation13.org/ https://github.com/tgstation/tgstation + https://tgstation13.org/ https://github.com/tgstation/tgstation
- https://baystation12.net/ https://github.com/Baystation12/Baystation12/ + https://baystation12.net/ https://github.com/Baystation12/Baystation12/
- https://www.paradisestation.org/forum/ https://github.com/ParadiseSS13/Paradise + https://www.paradisestation.org/forum/ https://github.com/ParadiseSS13/Paradise
- https://github.com/ss13remake/ss13remake + https://github.com/ss13remake/ss13remake
- https://github.com/griefly/griefly (not using Byond?) + https://github.com/griefly/griefly (not using Byond?)
## Building ## Building

View File

@ -11,3 +11,4 @@ _Multiplayer realtime team-based 2D combat._
- Code language: Java - Code language: Java
- Code license: MIT - Code license: MIT
## Building

View File

@ -1,6 +1,6 @@
# Wargamer # Wargamer
_Open source development of the game Wargamer:Napoleon 1813 originally developed by Steven Green/Greenius, and published in 1999 by Empire Interactive._ _Remake of Wargamer:Napoleon 1813._
- Home: https://sourceforge.net/projects/wargamer/, http://wargamer.sourceforge.net/ - Home: https://sourceforge.net/projects/wargamer/, http://wargamer.sourceforge.net/
- State: mature, inactive since 2003 - State: mature, inactive since 2003
@ -11,5 +11,6 @@ _Open source development of the game Wargamer:Napoleon 1813 originally developed
- Code license: GPL-2.0 - Code license: GPL-2.0
May require original files? May require original files?
Wargamer: Napoleon 1813 originally developed by Steven Green/Greenius, and published in 1999 by Empire Interactive.
## Building ## Building