2023-07-14 00:24:37 +00:00
|
|
|
#pragma once
|
2023-07-12 23:37:55 +00:00
|
|
|
|
|
|
|
// A chunk is a reference to a piece of string
|
|
|
|
// from "start" relative to its start
|
|
|
|
// and goes on for len characters.
|
2023-07-12 19:22:54 +00:00
|
|
|
struct chunk
|
|
|
|
{
|
|
|
|
int start, len;
|
|
|
|
};
|
|
|
|
typedef struct chunk chunk;
|
|
|
|
|
2023-07-13 00:58:39 +00:00
|
|
|
// An error
|
|
|
|
struct sc_error
|
|
|
|
{
|
|
|
|
int position;
|
|
|
|
int code;
|
|
|
|
};
|
|
|
|
typedef struct sc_error sc_error;
|
|
|
|
|
2023-07-12 23:37:55 +00:00
|
|
|
// Describes a parsed shortcode
|
2023-07-12 19:22:54 +00:00
|
|
|
struct shortcode
|
|
|
|
{
|
2023-07-12 20:10:55 +00:00
|
|
|
chunk whole;
|
2023-07-12 19:22:54 +00:00
|
|
|
chunk name;
|
|
|
|
chunk data;
|
|
|
|
char matching;
|
|
|
|
chunk argnames[100];
|
|
|
|
chunk argvals[100];
|
|
|
|
int argcount;
|
|
|
|
};
|
|
|
|
typedef struct shortcode shortcode;
|
|
|
|
|
2023-07-13 00:58:39 +00:00
|
|
|
struct sc_result
|
|
|
|
{
|
|
|
|
shortcode sc[100];
|
|
|
|
sc_error errors[10];
|
|
|
|
int errcount;
|
|
|
|
};
|
|
|
|
typedef struct sc_result sc_result;
|
|
|
|
|
|
|
|
// Error codes
|
|
|
|
|
|
|
|
/* You are closing the wrong shortcode.
|
|
|
|
Example:
|
|
|
|
|
|
|
|
{{% foo %}} {{% /bar %}}
|
|
|
|
*/
|
2023-07-14 00:24:37 +00:00
|
|
|
#define ERR_MISMATCHED_CLOSING_TAG 1
|
|
|
|
#define ERR_MISMATCHED_BRACKET 2
|
2023-07-13 00:58:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
sc_result parse(char *);
|