Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:transceptor-technology/libcleri
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van der Heijden committed Oct 22, 2019
2 parents 9a4a004 + 9c3d416 commit 060afed
Show file tree
Hide file tree
Showing 54 changed files with 774 additions and 251 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ debian/libcleri-dev/
debian/libcleri0.debhelper.log
debian/libcleri0.substvars
debian/libcleri0/
debian/tmp/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ git commit -am 'some work that has been done'

Create archive from code
```
git archive -o ../libcleri_0.10.0.orig.tar.gz master
git archive -o ../libcleri_0.10.1.orig.tar.gz master
```

Build deb package
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ Example:
```c
// In case a translation function returns an empty string, no text is used
const char * translate(cleri_t * o) {
return ""; // a possible result might be: `error at position x`
return ""; // a possible result might be: `error at line 0, position x`
}
// Text may be returned based on gid
const char * translate(cleri_t * o) {
switch (o->gid) {
case 1: return "A"; // error at position x, expecting: A
case 1: return "A"; // error at line 0, position x, expecting: A
case 2: return ""; // gid 2 will be ignored
}
return NULL; // normal parsing for everything else
Expand Down
7 changes: 0 additions & 7 deletions Release/makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
Expand All @@ -31,8 +26,6 @@ INSTALL_PATH := /usr
SO_NAME := soname
endif

# Add inputs and outputs from these tool invocations to the build variables

# All Target
all: libcleri

Expand Down
4 changes: 0 additions & 4 deletions Release/objects.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

USER_OBJS :=

LIBS := -lpcre2-8
21 changes: 8 additions & 13 deletions Release/sources.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
OBJ_SRCS :=
ASM_SRCS :=
C_SRCS :=
O_SRCS :=
S_UPPER_SRCS :=
EXECUTABLES :=
OBJS :=
C_DEPS :=

OBJ_SRCS :=
ASM_SRCS :=
C_SRCS :=
O_SRCS :=
S_UPPER_SRCS :=
EXECUTABLES :=
OBJS :=
C_DEPS :=

# Every subdirectory with source files must be described here
SUBDIRS := \
src \

18 changes: 7 additions & 11 deletions Release/src/subdir.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/children.c \
../src/choice.c \
Expand All @@ -25,7 +20,9 @@ C_SRCS += \
../src/sequence.c \
../src/this.c \
../src/token.c \
../src/tokens.c
../src/tokens.c \
../src/version.c


OBJS += \
./src/children.o \
Expand All @@ -49,7 +46,8 @@ OBJS += \
./src/sequence.o \
./src/this.o \
./src/token.o \
./src/tokens.o
./src/tokens.o \
./src/version.o

C_DEPS += \
./src/children.d \
Expand All @@ -73,14 +71,12 @@ C_DEPS += \
./src/sequence.d \
./src/this.d \
./src/token.d \
./src/tokens.d
./src/tokens.d \
./src/version.d

# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross GCC Compiler'
gcc -DNDEBUG -I../inc -O3 -Wall $(CPPFLAGS) $(CFLAGS) -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '


8 changes: 0 additions & 8 deletions Release/subdir.mk

This file was deleted.

24 changes: 24 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
libcleri (0.11.0-0~tt1) unstable; urgency=medium

* Added cleri_parse2() which accepts an additional `flags` argument
* Improved syntax error handling
* Set correct position when nested error in syntax is found

-- Jeroen van der Heijden <joente@xjoente> Tue, 22 Oct 2019 10:59:14 +0200

libcleri (0.10.1-0~alpha1-tt1) unstable; urgency=medium

* Added option to disable generating expecting info

-- Jeroen van der Heijden <jeroen@transceptor.technology> Mon, 12 Nov 2018 14:34:16 +0100

libcleri (0.10.1-0~alpha0-tt1) unstable; urgency=medium

* Added `void *data` to node type for public usage
* Children will only be added to a node when necessary
(Be carefull that accessing the first child therefore
must be checked for NULL whereas in previous versions,
one could immediately check the `children->node` pointer)

-- Jeroen van der Heijden <jeroen@transceptor.technology> Wed, 31 Oct 2018 22:22:05 +0100

libcleri (0.10.0-0~tt1) unstable; urgency=medium

* Update deb test
Expand Down
4 changes: 2 additions & 2 deletions debian/libcleri0.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ libcleri.so.0 libcleri0 #MINVER#
CLERI_THIS@Base 0.9.3
cleri__children_add@Base 0.9.3
cleri__children_free@Base 0.9.3
cleri__children_new@Base 0.9.3
cleri__expecting_combine@Base 0.9.3
cleri__expecting_free@Base 0.9.3
cleri__expecting_new@Base 0.9.3
Expand Down Expand Up @@ -35,7 +34,7 @@ libcleri.so.0 libcleri0 #MINVER#
cleri_list@Base 0.9.3
cleri_new@Base 0.9.3
cleri_optional@Base 0.9.3
cleri_parse@Base 0.9.3
cleri_parse2@Base 0.10.1~
cleri_parse_expect_start@Base 0.9.3
cleri_parse_free@Base 0.9.3
cleri_parse_strn@Base 0.10.0~
Expand All @@ -47,3 +46,4 @@ libcleri.so.0 libcleri0 #MINVER#
cleri_sequence@Base 0.9.3
cleri_token@Base 0.9.3
cleri_tokens@Base 0.9.3
cleri_version@Base 0.10.1~
3 changes: 1 addition & 2 deletions inc/cleri/children.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ typedef struct cleri_node_s cleri_node_t;
typedef struct cleri_children_s cleri_children_t;

/* private functions */
cleri_children_t * cleri__children_new(void);
void cleri__children_free(cleri_children_t * children);
int cleri__children_add(cleri_children_t * children, cleri_node_t * node);
int cleri__children_add(cleri_children_t ** children, cleri_node_t * node);

/* structs */
struct cleri_children_s
Expand Down
7 changes: 7 additions & 0 deletions inc/cleri/cleri.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#define cleri__malloc(__t) (malloc(sizeof(__t)))
#endif

#ifdef __cplusplus
#define cleri__mallocn(__n, __t) ((__t*)malloc(__n * sizeof(__t)))
#else
#define cleri__mallocn(__n, __t) (malloc(__n * sizeof(__t)))
#endif

#include <cleri/expecting.h>
#include <cleri/keyword.h>
#include <cleri/sequence.h>
Expand All @@ -28,6 +34,7 @@
#include <cleri/rule.h>
#include <cleri/this.h>
#include <cleri/ref.h>
#include <cleri/version.h>

/* typedefs */
typedef struct cleri_s cleri_t;
Expand Down
2 changes: 1 addition & 1 deletion inc/cleri/expecting.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef struct cleri_exp_modes_s cleri_exp_modes_t;
typedef struct cleri_expecting_s cleri_expecting_t;

/* private functions */
cleri_expecting_t * cleri__expecting_new(const char * str);
cleri_expecting_t * cleri__expecting_new(const char * str, int flags);
int cleri__expecting_update(
cleri_expecting_t * expecting,
cleri_t * cl_obj,
Expand Down
18 changes: 9 additions & 9 deletions inc/cleri/kwcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@

/* typedefs */
typedef struct cleri_parse_s cleri_parse_t;
typedef struct cleri_kwcache_s cleri_kwcache_t;

/* private functions */
cleri_kwcache_t * cleri__kwcache_new(void);
uint8_t * cleri__kwcache_new(const char * str);
ssize_t cleri__kwcache_match(cleri_parse_t * pr, const char * str);
void cleri__kwcache_free(cleri_kwcache_t * kwcache);
static inline void cleri__kwcache_free(uint8_t * kwcache);

/* structs */
struct cleri_kwcache_s

/*
* Destroy kwcache. (parsing NULL is allowed)
*/
static inline void cleri__kwcache_free(uint8_t * kwcache)
{
size_t len;
const char * str;
cleri_kwcache_t * next;
};
free(kwcache);
}

#endif /* CLERI_KWCACHE_H_ */

5 changes: 3 additions & 2 deletions inc/cleri/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ struct cleri_node_s
size_t len;
cleri_t * cl_obj;
cleri_children_t * children;
void * data; /* free to use by the user */

/* private */
uint_fast8_t ref;
int64_t result;
size_t ref;
int64_t result; /* DEPRECATED */
};

#endif /* CLERI_NODE_H_ */
1 change: 1 addition & 0 deletions inc/cleri/olist.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int cleri__olist_append_nref(cleri_olist_t * olist, cleri_t * cl_object);
void cleri__olist_free(cleri_olist_t * olist);
void cleri__olist_empty(cleri_olist_t * olist);
void cleri__olist_cancel(cleri_olist_t * olist);
void cleri__olist_unique(cleri_olist_t * olist);

/* structs */
struct cleri_olist_s
Expand Down
31 changes: 26 additions & 5 deletions inc/cleri/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@
#include <cleri/rule.h>

#ifndef MAX_RECURSION_DEPTH
#define MAX_RECURSION_DEPTH 50
#define MAX_RECURSION_DEPTH 500
#endif

enum
{
CLERI_FLAG_EXPECTING_DISABLED =1<<0,
CLERI_FLAG_EXCLUDE_OPTIONAL =1<<1,
CLERI_FLAG_EXCLUDE_FM_CHOICE =1<<2,
CLERI_FLAG_EXCLUDE_RULE_THIS =1<<3,
};

/* typedefs */
typedef struct cleri_s cleri_t;
typedef struct cleri_grammar_s cleri_grammar_t;
typedef struct cleri_node_s cleri_node_t;
typedef struct cleri_expecting_s cleri_expecting_t;
typedef struct cleri_kwcache_s cleri_kwcache_t;
typedef struct cleri_rule_store_s cleri_rule_store_t;
typedef struct cleri_parse_s cleri_parse_t;
typedef const char * (cleri_translate_t)(cleri_t *);
Expand All @@ -32,7 +39,13 @@ typedef const char * (cleri_translate_t)(cleri_t *);
extern "C" {
#endif

cleri_parse_t * cleri_parse(cleri_grammar_t * grammar, const char * str);
static inline cleri_parse_t * cleri_parse(
cleri_grammar_t * grammar,
const char * str);
cleri_parse_t * cleri_parse2(
cleri_grammar_t * grammar,
const char * str,
int flags);
void cleri_parse_free(cleri_parse_t * pr);
void cleri_parse_expect_start(cleri_parse_t * pr);
int cleri_parse_strn(
Expand All @@ -57,14 +70,22 @@ cleri_node_t * cleri__parse_walk(
struct cleri_parse_s
{
int is_valid;
int flags;
size_t pos;
const char * str;
cleri_node_t * tree;
const cleri_olist_t * expect;
cleri_expecting_t * expecting;
pcre2_code * re_keywords;
pcre2_match_data * match_data;
cleri_kwcache_t * kwcache;
uint8_t * kwcache;
};

#endif /* CLERI_PARSE_H_ */
static inline cleri_parse_t * cleri_parse(
cleri_grammar_t * grammar,
const char * str)
{
return cleri_parse2(grammar, str, 0);
}

#endif /* CLERI_PARSE_H_ */
2 changes: 1 addition & 1 deletion inc/cleri/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef CLERI_VERSION_H_
#define CLERI_VERSION_H_

#define LIBCLERI_VERSION "0.10.0"
#define LIBCLERI_VERSION "0.11.0"

/* public funtion */
#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion makefile.init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAJOR := 0
MINOR := 10
PATCH := 0
PATCH := 1
VERSION := $(MAJOR).$(MINOR).$(PATCH)
Loading

0 comments on commit 060afed

Please sign in to comment.