Skip to content

Commit

Permalink
export to c fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van der Heijden committed Oct 29, 2018
1 parent ddaa4e1 commit af75430
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2018.10.29, Version 1.3.2 (Stable)

* Replace / with _ in function name.

2018.10.25, Version 1.3.1 (Stable)

* Fixed exporting `Repeat` element to C. (issue #9)
Expand Down
2 changes: 1 addition & 1 deletion pyleri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
__author__ = 'Jeroen van der Heijden'
__maintainer__ = 'Jeroen van der Heijden'
__email__ = '[email protected]'
__version__ = '1.3.1'
__version__ = '1.3.2'
8 changes: 6 additions & 2 deletions pyleri/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class {name}(Grammar):
#define CLERI_FIRST_MATCH 0
#define CLERI_MOST_GREEDY 1
cleri_grammar_t * compile_{target}(void)
cleri_grammar_t * compile_{fun}(void)
{{
{language}
Expand All @@ -258,7 +258,7 @@ class {name}(Grammar):
#include <cleri/cleri.h>
cleri_grammar_t * compile_{target}(void);
cleri_grammar_t * compile_{fun}(void);
enum cleri_grammar_ids {{
CLERI_NONE, // used for objects with no name
Expand Down Expand Up @@ -489,10 +489,13 @@ def export_c(self, target=C_TARGET, c_indent=C_INDENTATION, headerf=None):

header_file = '"{}.h"'.format(target) if headerf is None else headerf

fun = target.strip('/').replace('/', '_')

return (self.__class__.C_TEMPLATE_C.format(
name=self.__class__.__name__,
target=target,
header_file=header_file,
fun=fun,
indent=c_indent,
datetime=time.strftime(
'%Y-%m-%d %H:%M:%S',
Expand All @@ -502,6 +505,7 @@ def export_c(self, target=C_TARGET, c_indent=C_INDENTATION, headerf=None):
self.__class__.C_TEMPLATE_H.format(
name=self.__class__.__name__,
target=target,
fun=fun,
guard=target.upper().replace('/', '_').replace('\\', '_'),
datetime=time.strftime(
'%Y-%m-%d %H:%M:%S',
Expand Down

0 comments on commit af75430

Please sign in to comment.