From eabb9e4597549d0b4ad6789a3946a99c9ea7d1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gr=C3=A4ter?= Date: Thu, 23 Feb 2012 20:13:03 +0100 Subject: [PATCH 01/97] Setting some library function definitions to "const char*" --- markdown_lib.c | 8 ++++---- markdown_lib.h | 6 +++--- markdown_output.c | 8 ++++---- markdown_peg.h | 4 ++-- utility_functions.c | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/markdown_lib.c b/markdown_lib.c index 8ff03ca7..867783c1 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -25,7 +25,7 @@ /* preformat_text - allocate and copy text buffer while * performing tab expansion. */ -static GString *preformat_text(char *text) { +static GString *preformat_text(const char *text) { GString *buf; char next_char; int charstotab; @@ -144,7 +144,7 @@ static element * process_raw_blocks(element *input, int extensions, element *ref /* markdown_to_gstring - convert markdown text to the output format specified. * Returns a GString, which must be freed after use using g_string_free(). */ -GString * markdown_to_g_string(char *text, int extensions, int output_format) { +GString * markdown_to_g_string(const char *text, int extensions, int output_format) { element *result; element *references; element *notes; @@ -181,7 +181,7 @@ GString * markdown_to_g_string(char *text, int extensions, int output_format) { /* markdown_to_string - convert markdown text to the output format specified. * Returns a null-terminated string, which must be freed after use. */ -char * markdown_to_string(char *text, int extensions, int output_format) { +char * markdown_to_string(const char *text, int extensions, int output_format) { GString *out; char *char_out; out = markdown_to_g_string(text, extensions, output_format); @@ -195,7 +195,7 @@ char * markdown_to_string(char *text, int extensions, int output_format) { /* extract_metadata_value - parse document and return value of specified metadata key (e.g. "LateX Mode")/ Returns a null-terminated string, which must be freed after use. */ -char * extract_metadata_value(char *text, int extensions, char *key) { +char * extract_metadata_value(const char *text, int extensions, const char *key) { char *value; element *result; GString *formatted_text; diff --git a/markdown_lib.h b/markdown_lib.h index 3c4cdaf8..a306d958 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -23,8 +23,8 @@ enum markdown_formats { ODF_BODY_FORMAT }; -GString * markdown_to_g_string(char *text, int extensions, int output_format); -char * markdown_to_string(char *text, int extensions, int output_format); -char * extract_metadata_value(char *text, int extensions, char *key); +GString * markdown_to_g_string(const char *text, int extensions, int output_format); +char * markdown_to_string(const char *text, int extensions, int output_format); +char * extract_metadata_value(const char *text, int extensions, const char *key); /* vim: set ts=4 sw=4 : */ diff --git a/markdown_output.c b/markdown_output.c index 3664df67..f5f73e85 100644 --- a/markdown_output.c +++ b/markdown_output.c @@ -82,8 +82,8 @@ element * print_html_headingsection(GString *out, element *list, bool obfuscate) static bool is_html_complete_doc(element *meta); static int find_latex_mode(int format, element *list); -element * metadata_for_key(char *key, element *list); -char * metavalue_for_key(char *key, element *list); +element * metadata_for_key(const char *key, element *list); +char * metavalue_for_key(const char *key, element *list); element * element_for_attribute(char *querystring, element *list); char * dimension_for_attribute(char *querystring, element *list); @@ -2501,7 +2501,7 @@ static int find_latex_mode(int format, element *list) { /* find specified metadata key, if present */ -element * metadata_for_key(char *key, element *list) { +element * metadata_for_key(const char *key, element *list) { element *step = NULL; step = list; char *label; @@ -2530,7 +2530,7 @@ element * metadata_for_key(char *key, element *list) { /* find specified metadata key, if present */ -char * metavalue_for_key(char *key, element *list) { +char * metavalue_for_key(const char *key, element *list) { element *step = NULL; step = list; char *label; diff --git a/markdown_peg.h b/markdown_peg.h index bed3faad..19b3d84f 100644 --- a/markdown_peg.h +++ b/markdown_peg.h @@ -135,8 +135,8 @@ void print_element_list(GString *out, element *elt, int format, int exts); element * parse_metadata_only(char *string, int extensions); -char * extract_metadata_value(char *text, int extensions, char *key); +char * extract_metadata_value(const char *text, int extensions, const char *key); -char * metavalue_for_key(char *key, element *list); +char * metavalue_for_key(const char *key, element *list); element * parse_markdown_for_opml(char *string, int extensions); diff --git a/utility_functions.c b/utility_functions.c index ec95c545..2befa0d6 100644 --- a/utility_functions.c +++ b/utility_functions.c @@ -3,7 +3,7 @@ extern int strcasecmp(const char *string1, const char *string2); -static char *label_from_string(char *str, bool obfuscate) ; +static char *label_from_string(const char *str, bool obfuscate) ; static void localize_typography(GString *out, int character, int language, int output); static void print_raw_element_list(GString *out, element *list); @@ -290,7 +290,7 @@ static char *label_from_element_list(element *list, bool obfuscate) { HTML id */ /* Returns a null-terminated string, which must be freed after use. */ -static char *label_from_string(char *str, bool obfuscate) { +static char *label_from_string(const char *str, bool obfuscate) { bool valid = FALSE; GString *out = g_string_new(""); char *label; From a84a81f78929b404dacfab6bc3715412d2f90dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gr=C3=A4ter?= Date: Thu, 23 Feb 2012 20:14:20 +0100 Subject: [PATCH 02/97] Fix some warnings --- GLibFacade.h | 9 +++++++-- markdown_output.c | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GLibFacade.h b/GLibFacade.h index 30651ac5..6b5928ab 100644 --- a/GLibFacade.h +++ b/GLibFacade.h @@ -21,8 +21,13 @@ typedef int gboolean; typedef char gchar; /* This style of bool is used in shared source code */ -#define FALSE false -#define TRUE true +#ifndef FALSE + #define FALSE false +#endif + +#ifndef TRUE + #define TRUE true +#endif /* WE implement minimal mirror implementations of GLib's GString and GSList * sufficient to cover the functionality required by MultiMarkdown. diff --git a/markdown_output.c b/markdown_output.c index f5f73e85..ae43ef52 100644 --- a/markdown_output.c +++ b/markdown_output.c @@ -36,7 +36,6 @@ static char cell_type = 'd'; static int language = ENGLISH; static bool html_footer = FALSE; static int odf_type = 0; -static bool in_list = FALSE; static bool no_latex_footnote = FALSE; static bool am_printing_html_footnote = FALSE; static int footnote_counter_to_print = 0; @@ -420,7 +419,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { /* if contents.str == 0, then print note; else ignore, since this * is a note block that has been incorporated into the notes list */ if (elt->contents.str == 0) { - if ( (elt->children->contents.str == 0) ){ + if ( elt->children->contents.str == 0 ){ /* The referenced note has not been used before */ add_endnote(elt->children); ++notenumber; @@ -2321,8 +2320,6 @@ void print_memoir_element_list(GString *out, element *list) { /* print_memoir_element - print an element as LaTeX for memoir class */ static void print_memoir_element(GString *out, element *elt) { - int lev; - char *label; switch (elt->key) { case VERBATIM: pad(out, 1); From c68bffa74bb81427b335a19400abbbe483fc9cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gr=C3=A4ter?= Date: Thu, 23 Feb 2012 20:14:37 +0100 Subject: [PATCH 03/97] Perform changes for Xcode 4.3 --- MultiMarkdown.xcodeproj/project.pbxproj | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 3851ba4c..a968a1cf 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXAggregateTarget section */ @@ -315,10 +315,10 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0410; + LastUpgradeCheck = 0430; }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MultiMarkdown" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( @@ -452,8 +452,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Debug; }; @@ -469,8 +468,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.4; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Release; }; @@ -520,8 +518,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.4; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = "Release10.6+"; }; @@ -541,7 +538,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = Peg; ZERO_LINK = NO; }; @@ -552,7 +548,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = "MultiMarkdown Tests"; ZERO_LINK = NO; }; @@ -573,7 +568,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = Peg; ZERO_LINK = NO; }; @@ -594,7 +588,6 @@ buildSettings = { COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = "MultiMarkdown Tests"; ZERO_LINK = NO; }; From e1e388909a259d93facf5892892e981dcbbd2792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gr=C3=A4ter?= Date: Thu, 23 Feb 2012 20:32:59 +0100 Subject: [PATCH 04/97] Factoring out AST handling to separate function --- MultiMarkdown.xcodeproj/project.pbxproj | 4 + markdown_lib.c | 72 +++++++++++++- markdown_parser_lib.h | 122 ++++++++++++++++++++++++ markdown_peg.h | 117 +---------------------- 4 files changed, 198 insertions(+), 117 deletions(-) create mode 100644 markdown_parser_lib.h diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index a968a1cf..4da4564f 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 4AFA467D13E3640600CFA132 /* markdown_output.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66313DF47CC00D0980C /* markdown_output.c */; }; 65F0B69E13DF47CC00D0980C /* markdown.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66713DF47CC00D0980C /* markdown.c */; }; 65F89EA713E37B9D006A34B8 /* libMultiMarkdown.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFA466213E3624F00CFA132 /* libMultiMarkdown.a */; }; + 79F800D114F6CAB1003AD4AA /* markdown_parser_lib.h in Headers */ = {isa = PBXBuildFile; fileRef = 79F800D014F6CAB1003AD4AA /* markdown_parser_lib.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -107,6 +108,7 @@ 65F89EB813E37BEF006A34B8 /* Common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Common.xcconfig; sourceTree = ""; }; 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 79F800D014F6CAB1003AD4AA /* markdown_parser_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = markdown_parser_lib.h; sourceTree = ""; }; 8DD76FB20486AB0100D96B5E /* multimarkdown */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = multimarkdown; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -154,6 +156,7 @@ 65F0B6C513DF485F00D0980C /* Makefile */, 65F0B66113DF47CC00D0980C /* markdown_lib.c */, 65F0B66213DF47CC00D0980C /* markdown_lib.h */, + 79F800D014F6CAB1003AD4AA /* markdown_parser_lib.h */, 65F0B66313DF47CC00D0980C /* markdown_output.c */, 65F0B66513DF47CC00D0980C /* markdown_parser.leg */, 65F0B66613DF47CC00D0980C /* markdown_peg.h */, @@ -248,6 +251,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 79F800D114F6CAB1003AD4AA /* markdown_parser_lib.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/markdown_lib.c b/markdown_lib.c index 867783c1..bf8e394d 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -144,7 +144,7 @@ static element * process_raw_blocks(element *input, int extensions, element *ref /* markdown_to_gstring - convert markdown text to the output format specified. * Returns a GString, which must be freed after use using g_string_free(). */ -GString * markdown_to_g_string(const char *text, int extensions, int output_format) { +GString * markdown_to_g_string_legacy(const char *text, int extensions, int output_format) { element *result; element *references; element *notes; @@ -179,6 +179,76 @@ GString * markdown_to_g_string(const char *text, int extensions, int output_form return out; } +/* markdown_to_opml_frontend - convert markdown text to OPML + */ +GString * markdown_to_g_string_opml_frontend(const char *text, int extensions) { + element *result; + GString *formatted_text; + GString *out = g_string_new(""); + + formatted_text = preformat_text(text); + + result = parse_markdown_for_opml(formatted_text->str, extensions); + + g_string_free(formatted_text, TRUE); + + print_element_list(out, result, OPML_FORMAT, extensions); + + markdown_free_ast(result); + + return out; +} + +/* markdown_to_gstring - convert markdown text to the output format specified. + * Returns a GString, which must be freed after use using g_string_free(). */ +GString * markdown_to_g_string(const char *text, int extensions, int output_format) { + element *ast = markdown_to_ast(text, extensions); + GString *out = g_string_new(""); + + print_element_list(out, ast, output_format, extensions); + + markdown_free_ast(ast); + + return out; +} + + +/* markdown_to_ast - convert markdown text and return the AST + */ +element *markdown_to_ast(const char *markdownString, int extensions) +{ + element *result; + element *references; + element *notes; + element *labels; + GString *formatted_text; + GString *out; + out = g_string_new(""); + + formatted_text = preformat_text(markdownString); + + references = parse_references(formatted_text->str, extensions); + notes = parse_notes(formatted_text->str, extensions, references); + labels = parse_labels(formatted_text->str, extensions, references, notes); + result = parse_markdown_with_metadata(formatted_text->str, extensions, references, notes, labels); + + result = process_raw_blocks(result, extensions, references, notes, labels); + + g_string_free(formatted_text, TRUE); + + free_element_list(references); + free_element_list(labels); + + return result; +} + +/* markdown_free_ast - Frees the AST after usage + */ +void markdown_free_ast(struct Element *ast) +{ + free_element_list(ast); +} + /* markdown_to_string - convert markdown text to the output format specified. * Returns a null-terminated string, which must be freed after use. */ char * markdown_to_string(const char *text, int extensions, int output_format) { diff --git a/markdown_parser_lib.h b/markdown_parser_lib.h new file mode 100644 index 00000000..7c130419 --- /dev/null +++ b/markdown_parser_lib.h @@ -0,0 +1,122 @@ +#ifndef MARKDOWN_PARSER_LIB_H +#define MARKDOWN_PARSER_LIB_H + +#include + +/* Information (label, URL and title) for a link. */ +struct Link { + struct Element *label; + char *url; + char *title; + struct Element *attr; + char *identifier; +}; + +/* Union for contents of an Element (string, list, or link). */ +union Contents { + char *str; + struct Link *link; +}; + +/* Types of semantic values returned by parsers. */ +enum keys { LIST, /* A generic list of values. For ordered and bullet lists, see below. */ + RAW, /* Raw markdown to be processed further */ + SPACE, + LINEBREAK, + ELLIPSIS, + EMDASH, + ENDASH, + APOSTROPHE, + SINGLEQUOTED, + DOUBLEQUOTED, + STR, + LINK, + IMAGE, + IMAGEBLOCK, + CODE, + HTML, + EMPH, + STRONG, + PLAIN, + PARA, + LISTITEM, + BULLETLIST, + ORDEREDLIST, + H1, H2, H3, H4, H5, H6, H7, /* Code assumes that these are in order. */ + BLOCKQUOTE, + VERBATIM, + HTMLBLOCK, + HRULE, + REFERENCE, + NOTE, + CITATION, + NOCITATION, + LOCATOR, + NOTELABEL, + DEFLIST, + TERM, + DEFINITION, + METAKEY, + METAVALUE, + METADATA, + FOOTER, + LABEL, + HEADINGSECTION, + ENDHTML, + TABLE, + TABLEHEAD, + TABLEBODY, + TABLEROW, + TABLECELL, + CELLSPAN, + TABLECAPTION, + TABLELABEL, + TABLESEPARATOR, + AUTOLABEL, + ATTRIBUTE, + ATTRKEY, + ATTRVALUE, + GLOSSARY, + GLOSSARYTERM, + GLOSSARYSORTKEY, + MATHSPAN +}; + +/* constants for managing Smart Typography */ +enum smartelements { + LSQUOTE, + RSQUOTE, + LDQUOTE, + RDQUOTE, + NDASH, + MDASH, + ELLIP, + APOS, +}; + +enum smartoutput { + HTMLOUT, + LATEXOUT, +}; + +enum language { + DUTCH, + ENGLISH, + FRENCH, + GERMAN, + SWEDISH, + GERMANGUILL, +}; + +/* Semantic value of a parsing action. */ +struct Element { + int key; + union Contents contents; + struct Element *children; + struct Element *next; +}; + +struct Element * markdown_to_ast(const char *text, int extensions); +void markdown_free_ast(struct Element *ast); + +#endif \ No newline at end of file diff --git a/markdown_peg.h b/markdown_peg.h index 19b3d84f..c0a54f3b 100644 --- a/markdown_peg.h +++ b/markdown_peg.h @@ -1,126 +1,11 @@ /* markdown_peg.h */ #include "markdown_lib.h" #include "glib.h" +#include "markdown_parser_lib.h" extern char *strdup(const char *string); -/* Information (label, URL and title) for a link. */ -struct Link { - struct Element *label; - char *url; - char *title; - struct Element *attr; - char *identifier; -}; - typedef struct Link link; - -/* Union for contents of an Element (string, list, or link). */ -union Contents { - char *str; - struct Link *link; -}; - -/* Types of semantic values returned by parsers. */ -enum keys { LIST, /* A generic list of values. For ordered and bullet lists, see below. */ - RAW, /* Raw markdown to be processed further */ - SPACE, - LINEBREAK, - ELLIPSIS, - EMDASH, - ENDASH, - APOSTROPHE, - SINGLEQUOTED, - DOUBLEQUOTED, - STR, - LINK, - IMAGE, - IMAGEBLOCK, - CODE, - HTML, - EMPH, - STRONG, - PLAIN, - PARA, - LISTITEM, - BULLETLIST, - ORDEREDLIST, - H1, H2, H3, H4, H5, H6, H7, /* Code assumes that these are in order. */ - BLOCKQUOTE, - VERBATIM, - HTMLBLOCK, - HRULE, - REFERENCE, - NOTE, - CITATION, - NOCITATION, - LOCATOR, - NOTELABEL, - DEFLIST, - TERM, - DEFINITION, - METAKEY, - METAVALUE, - METADATA, - FOOTER, - LABEL, - HEADINGSECTION, - ENDHTML, - TABLE, - TABLEHEAD, - TABLEBODY, - TABLEROW, - TABLECELL, - CELLSPAN, - TABLECAPTION, - TABLELABEL, - TABLESEPARATOR, - AUTOLABEL, - ATTRIBUTE, - ATTRKEY, - ATTRVALUE, - GLOSSARY, - GLOSSARYTERM, - GLOSSARYSORTKEY, - MATHSPAN - }; - -/* constants for managing Smart Typography */ -enum smartelements { - LSQUOTE, - RSQUOTE, - LDQUOTE, - RDQUOTE, - NDASH, - MDASH, - ELLIP, - APOS, -}; - -enum smartoutput { - HTMLOUT, - LATEXOUT, -}; - -enum language { - DUTCH, - ENGLISH, - FRENCH, - GERMAN, - SWEDISH, - GERMANGUILL, -}; - -/* Semantic value of a parsing action. */ -struct Element { - int key; - union Contents contents; - struct Element *children; - struct Element *next; -}; - - - typedef struct Element element; element * parse_references(char *string, int extensions); From 3ff5dbfee4163bd90280163dc4aca11afa1fc90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gr=C3=A4ter?= Date: Thu, 23 Feb 2012 23:45:33 +0100 Subject: [PATCH 05/97] Public debugging API --- markdown_lib.c | 2 +- markdown_parser_lib.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/markdown_lib.c b/markdown_lib.c index bf8e394d..7a61e6bb 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -55,7 +55,7 @@ static GString *preformat_text(const char *text) { } /* print_tree - print tree of elements, for debugging only. */ -static void print_tree(element * elt, int indent) { +void print_tree(element * elt, int indent) { int i; char * key; while (elt != NULL) { diff --git a/markdown_parser_lib.h b/markdown_parser_lib.h index 7c130419..2a7d791e 100644 --- a/markdown_parser_lib.h +++ b/markdown_parser_lib.h @@ -119,4 +119,6 @@ struct Element { struct Element * markdown_to_ast(const char *text, int extensions); void markdown_free_ast(struct Element *ast); +void print_tree(struct Element * elt, int indent); + #endif \ No newline at end of file From 131c9bcdbb4f6e2a52b3e575e70169cf5cfa2911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gr=C3=A4ter?= Date: Fri, 24 Feb 2012 13:56:10 +0100 Subject: [PATCH 06/97] Removing dead code --- markdown_lib.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/markdown_lib.c b/markdown_lib.c index 7a61e6bb..0f1dc42a 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -142,43 +142,6 @@ static element * process_raw_blocks(element *input, int extensions, element *ref return input; } -/* markdown_to_gstring - convert markdown text to the output format specified. - * Returns a GString, which must be freed after use using g_string_free(). */ -GString * markdown_to_g_string_legacy(const char *text, int extensions, int output_format) { - element *result; - element *references; - element *notes; - element *labels; - GString *formatted_text; - GString *out; - out = g_string_new(""); - - formatted_text = preformat_text(text); - - if (output_format == OPML_FORMAT) { - result = parse_markdown_for_opml(formatted_text->str, extensions); - } else { - references = parse_references(formatted_text->str, extensions); - notes = parse_notes(formatted_text->str, extensions, references); - labels = parse_labels(formatted_text->str, extensions, references, notes); - result = parse_markdown_with_metadata(formatted_text->str, extensions, references, notes, labels); - - result = process_raw_blocks(result, extensions, references, notes, labels); - } - - g_string_free(formatted_text, TRUE); - - print_element_list(out, result, output_format, extensions); - - free_element_list(result); - - if (output_format != OPML_FORMAT) { - free_element_list(references); - free_element_list(labels); - } - return out; -} - /* markdown_to_opml_frontend - convert markdown text to OPML */ GString * markdown_to_g_string_opml_frontend(const char *text, int extensions) { From 321170d0637a91292ba77e2f91edc2ea9f4eaa36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Mon, 14 May 2012 15:21:23 +0200 Subject: [PATCH 07/97] Disable passing of build settings to peg Makefile This prevents compiler issues in Xcode 4.4 --- MultiMarkdown.xcodeproj/project.pbxproj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 4da4564f..63401b81 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -269,7 +269,7 @@ dependencies = ( ); name = Peg; - passBuildSettingsInEnvironment = 1; + passBuildSettingsInEnvironment = 0; productName = Peg; }; /* End PBXLegacyTarget section */ @@ -319,7 +319,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0430; + LastUpgradeCheck = 0440; }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MultiMarkdown" */; compatibilityVersion = "Xcode 3.2"; @@ -451,6 +451,7 @@ ppc, x86_64, ); + COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -468,6 +469,7 @@ ppc, x86_64, ); + COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -518,6 +520,7 @@ ppc, x86_64, ); + COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; From 2947650f40f2422e2432910abb4ee0eb8b8466e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Mon, 14 May 2012 16:07:12 +0200 Subject: [PATCH 08/97] Ignore XCode-specific files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 8971846e..fb05b461 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ peg-0.1.4/leg *.pbxuser *.perspectivev3 + +MultiMarkdown.xcodeproj/project.xcworkspace/ +MultiMarkdown.xcodeproj/xcuserdata/ From d79db4c8d0348a1a3e3d2eb753082cf3efff8682 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Fri, 8 Jun 2012 23:13:56 +0200 Subject: [PATCH 09/97] Set missing install path. Signed-off-by: Max Seelemann --- MultiMarkdown.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 63401b81..b14560c3 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -421,7 +421,6 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; HEADER_SEARCH_PATHS = .; - INSTALL_PATH = /usr/local/bin; PRODUCT_NAME = multimarkdown; }; name = Debug; @@ -435,7 +434,6 @@ GCC_MODEL_TUNING = G5; GCC_PREFIX_HEADER = MarkdownMacPrefix.h; HEADER_SEARCH_PATHS = .; - INSTALL_PATH = /usr/local/bin; OTHER_CFLAGS = "-DSTANDALONE_MAC_VERSION=1"; PRODUCT_NAME = multimarkdown; SEPARATE_STRIP = YES; @@ -488,6 +486,7 @@ "$(inherited)", ); HEADER_SEARCH_PATHS = .; + INSTALL_PATH = "@rpath"; PRODUCT_NAME = MultiMarkdown; }; name = Debug; @@ -498,6 +497,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; HEADER_SEARCH_PATHS = .; + INSTALL_PATH = "@rpath"; PRODUCT_NAME = MultiMarkdown; }; name = Release; @@ -508,6 +508,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; HEADER_SEARCH_PATHS = .; + INSTALL_PATH = "@rpath"; PRODUCT_NAME = MultiMarkdown; }; name = "Release10.6+"; @@ -535,7 +536,6 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; HEADER_SEARCH_PATHS = .; - INSTALL_PATH = /usr/local/bin; PRODUCT_NAME = multimarkdown; }; name = "Release10.6+"; From 99d4e4c3851f3a54a2e61026e196b101a5463208 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Sat, 9 Jun 2012 22:30:53 +0200 Subject: [PATCH 10/97] Skipped library install. Signed-off-by: Max Seelemann --- MultiMarkdown.xcodeproj/project.pbxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 4da4564f..f73a67a1 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -487,6 +487,7 @@ ); HEADER_SEARCH_PATHS = .; PRODUCT_NAME = MultiMarkdown; + SKIP_INSTALL = YES; }; name = Debug; }; @@ -497,6 +498,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; HEADER_SEARCH_PATHS = .; PRODUCT_NAME = MultiMarkdown; + SKIP_INSTALL = YES; }; name = Release; }; @@ -507,6 +509,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; HEADER_SEARCH_PATHS = .; PRODUCT_NAME = MultiMarkdown; + SKIP_INSTALL = YES; }; name = "Release10.6+"; }; From 69001bc2d3c7545ac3e1e3d555e6d59545c2829b Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Tue, 19 Jun 2012 16:07:11 +0200 Subject: [PATCH 11/97] Updated project file. Signed-off-by: Max Seelemann --- MultiMarkdown.xcodeproj/project.pbxproj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 9c0480b4..1b7bba2b 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -481,12 +481,14 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = MultiMarkdown; SKIP_INSTALL = YES; }; @@ -497,8 +499,10 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = MultiMarkdown; SKIP_INSTALL = YES; }; @@ -509,8 +513,10 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = MultiMarkdown; SKIP_INSTALL = YES; }; @@ -546,8 +552,10 @@ 651A542A13E20D2400BCB02A /* Release10.6+ */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = Peg; ZERO_LINK = NO; }; @@ -566,9 +574,11 @@ 65F0B88913DF6C0D00D0980C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = Peg; }; name = Debug; @@ -576,8 +586,10 @@ 65F0B88A13DF6C0D00D0980C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = Peg; ZERO_LINK = NO; }; From 43c5cc57e628cd3fad0c71c95db1438626c4d262 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Wed, 27 Jun 2012 10:18:23 +0200 Subject: [PATCH 12/97] Fixed broken iOS target. Signed-off-by: Max Seelemann --- MultiMarkdown.xcodeproj/project.pbxproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 1b7bba2b..dc925770 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -481,7 +481,6 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -499,7 +498,6 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; MACOSX_DEPLOYMENT_TARGET = 10.6.8; @@ -513,7 +511,6 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; MACOSX_DEPLOYMENT_TARGET = 10.6.8; From 7cfeff208a9bdcd4d93305645b0c920f58f42720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Fri, 20 Jul 2012 17:05:35 +0200 Subject: [PATCH 13/97] Fixes warnings of static analyzer --- GLibFacade.c | 2 +- markdown_lib.c | 2 -- markdown_output.c | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/GLibFacade.c b/GLibFacade.c index f60c1443..b0e94c1a 100644 --- a/GLibFacade.c +++ b/GLibFacade.c @@ -59,7 +59,7 @@ GString* g_string_new(char *startingString) { GString* newString = malloc(sizeof(GString)); - if (startingString == NULL) startingString = ""; + if (startingString == NULL) startingString = "\0"; size_t startingBufferSize = kStringBufferStartingSize; size_t startingStringSize = strlen(startingString); diff --git a/markdown_lib.c b/markdown_lib.c index 0f1dc42a..1eced02d 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -185,8 +185,6 @@ element *markdown_to_ast(const char *markdownString, int extensions) element *notes; element *labels; GString *formatted_text; - GString *out; - out = g_string_new(""); formatted_text = preformat_text(markdownString); diff --git a/markdown_output.c b/markdown_output.c index ae43ef52..fbc78fbc 100644 --- a/markdown_output.c +++ b/markdown_output.c @@ -1726,7 +1726,7 @@ void print_odf_element(GString *out, element *elt) { char *label; char *height; char *width; - element *locator = NULL; + int old_type = 0; switch (elt->key) { case SPACE: @@ -2013,7 +2013,7 @@ void print_odf_element(GString *out, element *elt) { case NOCITATION: case CITATION: /* Get locator, if present */ - locator = locator_for_citation(elt); + locator_for_citation(elt); if (strncmp(elt->contents.str,"[#",2) == 0) { /* reference specified externally, so just display it */ @@ -2021,7 +2021,7 @@ void print_odf_element(GString *out, element *elt) { } else { /* reference specified within the MMD document, so will output as footnote */ - if (elt->children->contents.str == NULL) { + if (elt && elt->children && (elt->children->contents.str == NULL)) { /* First use of this citation */ ++notenumber; char buf[5]; From 26c8786b36424a5a7d6583e81c8c912e8db31048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Go=CC=88tz=20Fabian?= Date: Wed, 10 Oct 2012 15:14:25 +0200 Subject: [PATCH 14/97] Changed build architecture for iOS to armv7. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Götz Fabian --- MultiMarkdown.xcodeproj/project.pbxproj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index dc925770..d26dcca5 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -420,8 +420,11 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = armv7; HEADER_SEARCH_PATHS = .; + ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = multimarkdown; + "VALID_ARCHS[sdk=iphoneos*]" = armv7; }; name = Debug; }; @@ -430,6 +433,7 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = armv7; COPY_PHASE_STRIP = NO; GCC_MODEL_TUNING = G5; GCC_PREFIX_HEADER = MarkdownMacPrefix.h; @@ -438,6 +442,7 @@ PRODUCT_NAME = multimarkdown; SEPARATE_STRIP = YES; STRIP_INSTALLED_PRODUCT = YES; + "VALID_ARCHS[sdk=iphoneos*]" = armv7; }; name = Release; }; @@ -481,6 +486,7 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = armv7; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -490,6 +496,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = MultiMarkdown; SKIP_INSTALL = YES; + "VALID_ARCHS[sdk=iphoneos*]" = armv7; }; name = Debug; }; @@ -498,11 +505,13 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = armv7; HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = MultiMarkdown; SKIP_INSTALL = YES; + "VALID_ARCHS[sdk=iphoneos*]" = armv7; }; name = Release; }; @@ -511,11 +520,13 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = armv7; HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; MACOSX_DEPLOYMENT_TARGET = 10.6.8; PRODUCT_NAME = MultiMarkdown; SKIP_INSTALL = YES; + "VALID_ARCHS[sdk=iphoneos*]" = armv7; }; name = "Release10.6+"; }; @@ -541,8 +552,10 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = armv7; HEADER_SEARCH_PATHS = .; PRODUCT_NAME = multimarkdown; + "VALID_ARCHS[sdk=iphoneos*]" = armv7; }; name = "Release10.6+"; }; From 201d7eb348d27e870a0e13c62f393c504c12da10 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Tue, 13 Nov 2012 09:39:49 +0100 Subject: [PATCH 15/97] Upgraded project file for Xcode 4.6 Signed-off-by: Max Seelemann --- MultiMarkdown.xcodeproj/project.pbxproj | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index d26dcca5..5bcca0a7 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -319,7 +319,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0440; + LastUpgradeCheck = 0460; }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MultiMarkdown" */; compatibilityVersion = "Xcode 3.2"; @@ -454,7 +454,6 @@ ppc, x86_64, ); - COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -472,7 +471,6 @@ ppc, x86_64, ); - COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -538,7 +536,6 @@ ppc, x86_64, ); - COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; From a511886a861e5e6b80cbac90f07a1fd9af2d848b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 14:08:23 +0100 Subject: [PATCH 16/97] Fix OS X project file --- .gitignore | 3 + MultiMarkdown.xcodeproj/project.pbxproj | 73 ++++++++++++------------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 4bbdcc2e..6038f0f5 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ peg-0.1.4/leg MultiMarkdown.xcodeproj/project.xcworkspace/ MultiMarkdown.xcodeproj/xcuserdata/ + +/peg-0.1.9/peg +/peg-0.1.9/leg \ No newline at end of file diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 2391e525..81839a5f 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -29,6 +29,12 @@ 4AFA467D13E3640600CFA132 /* markdown_output.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66313DF47CC00D0980C /* markdown_output.c */; }; 65F0B69E13DF47CC00D0980C /* markdown.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66713DF47CC00D0980C /* markdown.c */; }; 65F89EA713E37B9D006A34B8 /* libMultiMarkdown.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFA466213E3624F00CFA132 /* libMultiMarkdown.a */; }; + 79C2C97F16E774B6002B79F3 /* markdown_parser_lib.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C2C97E16E774B6002B79F3 /* markdown_parser_lib.h */; }; + 79C2C98116E774BF002B79F3 /* markdown_parser_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 79C2C98016E774BF002B79F3 /* markdown_parser_lib.c */; }; + 79C2C98316E775D7002B79F3 /* parsing_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C2C98216E775D7002B79F3 /* parsing_functions.h */; }; + 79C2C98416E7766B002B79F3 /* utility_functions.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B69A13DF47CC00D0980C /* utility_functions.c */; }; + 79C2C98516E7766F002B79F3 /* parsing_functions.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66A13DF47CC00D0980C /* parsing_functions.c */; }; + 79C2C98616E7767F002B79F3 /* odf.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66813DF47CC00D0980C /* odf.c */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -85,19 +91,6 @@ 65F0B66813DF47CC00D0980C /* odf.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = odf.c; sourceTree = ""; }; 65F0B66913DF47CC00D0980C /* odf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = odf.h; sourceTree = ""; }; 65F0B66A13DF47CC00D0980C /* parsing_functions.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = parsing_functions.c; sourceTree = ""; }; - 65F0B66C13DF47CC00D0980C /* compile.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = compile.c; sourceTree = ""; }; - 65F0B68B13DF47CC00D0980C /* leg */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = leg; sourceTree = ""; }; - 65F0B68C13DF47CC00D0980C /* leg.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = leg.c; sourceTree = ""; }; - 65F0B68D13DF47CC00D0980C /* leg.leg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = leg.leg; sourceTree = ""; }; - 65F0B68F13DF47CC00D0980C /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - 65F0B69013DF47CC00D0980C /* peg */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = peg; sourceTree = ""; }; - 65F0B69113DF47CC00D0980C /* peg.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = peg.1; sourceTree = ""; }; - 65F0B69213DF47CC00D0980C /* peg.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = peg.c; sourceTree = ""; }; - 65F0B69413DF47CC00D0980C /* peg.peg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = peg.peg; sourceTree = ""; }; - 65F0B69513DF47CC00D0980C /* peg.peg-c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "peg.peg-c"; sourceTree = ""; }; - 65F0B69613DF47CC00D0980C /* tree.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tree.c; sourceTree = ""; }; - 65F0B69713DF47CC00D0980C /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = ""; }; - 65F0B69913DF47CC00D0980C /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = ""; }; 65F0B69A13DF47CC00D0980C /* utility_functions.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = utility_functions.c; sourceTree = ""; }; 65F0B6C513DF485F00D0980C /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; 65F0B6D713DF4C6B00D0980C /* MarkdownMacPrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkdownMacPrefix.h; sourceTree = ""; }; @@ -107,6 +100,10 @@ 65F89EB813E37BEF006A34B8 /* Common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Common.xcconfig; sourceTree = ""; }; 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 79C2C97C16E772E9002B79F3 /* peg-0.1.9 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "peg-0.1.9"; sourceTree = ""; }; + 79C2C97E16E774B6002B79F3 /* markdown_parser_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = markdown_parser_lib.h; sourceTree = ""; }; + 79C2C98016E774BF002B79F3 /* markdown_parser_lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = markdown_parser_lib.c; sourceTree = ""; }; + 79C2C98216E775D7002B79F3 /* parsing_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsing_functions.h; sourceTree = ""; }; 8DD76FB20486AB0100D96B5E /* multimarkdown */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = multimarkdown; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -134,6 +131,8 @@ isa = PBXGroup; children = ( 651A525B13E1BEFE00BCB02A /* TODO.txt */, + 79C2C97E16E774B6002B79F3 /* markdown_parser_lib.h */, + 79C2C98016E774BF002B79F3 /* markdown_parser_lib.c */, 651A528113E1C30100BCB02A /* GLibFacade.h */, 651A528213E1C30100BCB02A /* GLibFacade.c */, 65F0B6D713DF4C6B00D0980C /* MarkdownMacPrefix.h */, @@ -151,6 +150,7 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( + 79C2C97C16E772E9002B79F3 /* peg-0.1.9 */, 65F0B6C513DF485F00D0980C /* Makefile */, 65F0B66113DF47CC00D0980C /* markdown_lib.c */, 65F0B66213DF47CC00D0980C /* markdown_lib.h */, @@ -160,8 +160,8 @@ 65F0B66713DF47CC00D0980C /* markdown.c */, 65F0B66813DF47CC00D0980C /* odf.c */, 65F0B66913DF47CC00D0980C /* odf.h */, + 79C2C98216E775D7002B79F3 /* parsing_functions.h */, 65F0B66A13DF47CC00D0980C /* parsing_functions.c */, - 65F0B66B13DF47CC00D0980C /* peg-0.1.4 */, 65F0B69A13DF47CC00D0980C /* utility_functions.c */, ); name = Source; @@ -195,26 +195,6 @@ name = "Other Frameworks"; sourceTree = ""; }; - 65F0B66B13DF47CC00D0980C /* peg-0.1.4 */ = { - isa = PBXGroup; - children = ( - 65F0B66C13DF47CC00D0980C /* compile.c */, - 65F0B68B13DF47CC00D0980C /* leg */, - 65F0B68C13DF47CC00D0980C /* leg.c */, - 65F0B68D13DF47CC00D0980C /* leg.leg */, - 65F0B68F13DF47CC00D0980C /* Makefile */, - 65F0B69013DF47CC00D0980C /* peg */, - 65F0B69113DF47CC00D0980C /* peg.1 */, - 65F0B69213DF47CC00D0980C /* peg.c */, - 65F0B69413DF47CC00D0980C /* peg.peg */, - 65F0B69513DF47CC00D0980C /* peg.peg-c */, - 65F0B69613DF47CC00D0980C /* tree.c */, - 65F0B69713DF47CC00D0980C /* tree.h */, - 65F0B69913DF47CC00D0980C /* version.h */, - ); - path = "peg-0.1.4"; - sourceTree = ""; - }; 65F0B8B513DF6D4700D0980C /* Generated Sources */ = { isa = PBXGroup; children = ( @@ -248,6 +228,8 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 79C2C97F16E774B6002B79F3 /* markdown_parser_lib.h in Headers */, + 79C2C98316E775D7002B79F3 /* parsing_functions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -261,7 +243,7 @@ buildPhases = ( ); buildToolPath = /usr/bin/make; - buildWorkingDirectory = "./peg-0.1.4"; + buildWorkingDirectory = "./peg-0.1.9"; dependencies = ( ); name = Peg; @@ -352,7 +334,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "./peg/leg -o markdown_parser.c markdown_parser.leg"; + shellScript = "./peg-0.1.9/leg -o markdown_parser.c markdown_parser.leg"; }; 65F0B8E913DF714E00D0980C /* Run Tests */ = { isa = PBXShellScriptBuildPhase; @@ -379,6 +361,10 @@ 4AFA467613E362B500CFA132 /* markdown_parser.c in Sources */, 4AFA467A13E363FA00CFA132 /* markdown_lib.c in Sources */, 4AFA467D13E3640600CFA132 /* markdown_output.c in Sources */, + 79C2C98116E774BF002B79F3 /* markdown_parser_lib.c in Sources */, + 79C2C98416E7766B002B79F3 /* utility_functions.c in Sources */, + 79C2C98516E7766F002B79F3 /* parsing_functions.c in Sources */, + 79C2C98616E7767F002B79F3 /* odf.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -483,7 +469,10 @@ "DEBUG=1", "$(inherited)", ); - HEADER_SEARCH_PATHS = .; + HEADER_SEARCH_PATHS = ( + ., + "peg-0.1.9/", + ); PRODUCT_NAME = MultiMarkdown; }; name = Debug; @@ -493,7 +482,10 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - HEADER_SEARCH_PATHS = .; + HEADER_SEARCH_PATHS = ( + ., + "peg-0.1.9/", + ); PRODUCT_NAME = MultiMarkdown; }; name = Release; @@ -503,7 +495,10 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - HEADER_SEARCH_PATHS = .; + HEADER_SEARCH_PATHS = ( + ., + "peg-0.1.9/", + ); PRODUCT_NAME = MultiMarkdown; }; name = "Release10.6+"; From a898796b6ff8a9031d470a58116ea5ea2e178757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 14:08:34 +0100 Subject: [PATCH 17/97] Adpat interface to MarkdownKit --- markdown_lib.c | 6 +- markdown_parser_lib.c | 48 ++++++++++++++++ markdown_parser_lib.h | 124 +++++++++++++++++++++--------------------- markdown_peg.h | 117 +-------------------------------------- 4 files changed, 115 insertions(+), 180 deletions(-) create mode 100644 markdown_parser_lib.c diff --git a/markdown_lib.c b/markdown_lib.c index d83df744..a556d2a3 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -27,7 +27,7 @@ /* preformat_text - allocate and copy text buffer while * performing tab expansion. */ -static GString *preformat_text(char *text) { +GString *preformat_text(char *text) { GString *buf; char next_char; int charstotab; @@ -57,7 +57,7 @@ static GString *preformat_text(char *text) { } /* print_tree - print tree of elements, for debugging only. */ -static void print_tree(element * elt, int indent) { +void print_tree(element * elt, int indent) { int i; char * key; while (elt != NULL) { @@ -114,7 +114,7 @@ static void print_tree(element * elt, int indent) { /* process_raw_blocks - traverses an element list, replacing any RAW elements with * the result of parsing them as markdown text, and recursing into the children * of parent elements. The result should be a tree of elements without any RAWs. */ -static element * process_raw_blocks(element *input, int extensions, element *references, element *notes, element *labels) { +element * process_raw_blocks(element *input, int extensions, element *references, element *notes, element *labels) { element *current = NULL; element *last_child = NULL; char *contents; diff --git a/markdown_parser_lib.c b/markdown_parser_lib.c new file mode 100644 index 00000000..1ecd3631 --- /dev/null +++ b/markdown_parser_lib.c @@ -0,0 +1,48 @@ +// +// markdown_parser_lib.c +// MultiMarkdown +// +// Created by Friedrich Gräter on 06.03.13. +// +// + +#include "markdown_parser_lib.h" + +GString *preformat_text(char *text); +element * process_raw_blocks(element *input, int extensions, element *references, element *notes, element *labels); + +/* markdown_to_ast - convert markdown text and return the AST + */ +element *markdown_to_ast(const char *markdownString, int extensions) +{ + element *result; + element *references; + element *notes; + element *labels; + GString *formatted_text; + GString *out; + out = g_string_new(""); + + formatted_text = preformat_text((char*)markdownString); + + references = parse_references(formatted_text->str, extensions); + notes = parse_notes(formatted_text->str, extensions, references); + labels = parse_labels(formatted_text->str, extensions, references, notes); + result = parse_markdown_with_metadata(formatted_text->str, extensions, references, notes, labels); + + result = process_raw_blocks(result, extensions, references, notes, labels); + + g_string_free(formatted_text, TRUE); + + free_element_list(references); + free_element_list(labels); + + return result; +} + +/* markdown_free_ast - Frees the AST after usage + */ +void markdown_free_ast(struct Element *ast) +{ + free_element_list(ast); +} diff --git a/markdown_parser_lib.h b/markdown_parser_lib.h index 2a7d791e..8d697d96 100644 --- a/markdown_parser_lib.h +++ b/markdown_parser_lib.h @@ -18,68 +18,68 @@ union Contents { struct Link *link; }; -/* Types of semantic values returned by parsers. */ +/* Types of semantic values returned by parsers. */ enum keys { LIST, /* A generic list of values. For ordered and bullet lists, see below. */ - RAW, /* Raw markdown to be processed further */ - SPACE, - LINEBREAK, - ELLIPSIS, - EMDASH, - ENDASH, - APOSTROPHE, - SINGLEQUOTED, - DOUBLEQUOTED, - STR, - LINK, - IMAGE, - IMAGEBLOCK, - CODE, - HTML, - EMPH, - STRONG, - PLAIN, - PARA, - LISTITEM, - BULLETLIST, - ORDEREDLIST, - H1, H2, H3, H4, H5, H6, H7, /* Code assumes that these are in order. */ - BLOCKQUOTE, - VERBATIM, - HTMLBLOCK, - HRULE, - REFERENCE, - NOTE, - CITATION, - NOCITATION, - LOCATOR, - NOTELABEL, - DEFLIST, - TERM, - DEFINITION, - METAKEY, - METAVALUE, - METADATA, - FOOTER, - LABEL, - HEADINGSECTION, - ENDHTML, - TABLE, - TABLEHEAD, - TABLEBODY, - TABLEROW, - TABLECELL, - CELLSPAN, - TABLECAPTION, - TABLELABEL, - TABLESEPARATOR, - AUTOLABEL, - ATTRIBUTE, - ATTRKEY, - ATTRVALUE, - GLOSSARY, - GLOSSARYTERM, - GLOSSARYSORTKEY, - MATHSPAN + RAW, /* Raw markdown to be processed further */ + SPACE, + LINEBREAK, + ELLIPSIS, + EMDASH, + ENDASH, + APOSTROPHE, + SINGLEQUOTED, + DOUBLEQUOTED, + STR, + LINK, + IMAGE, + IMAGEBLOCK, + CODE, + HTML, + EMPH, + STRONG, + PLAIN, + PARA, + LISTITEM, + BULLETLIST, + ORDEREDLIST, + H1, H2, H3, H4, H5, H6, H7, /* Code assumes that these are in order. */ + BLOCKQUOTE, + VERBATIM, + HTMLBLOCK, + HRULE, + REFERENCE, + NOTE, + CITATION, + NOCITATION, + LOCATOR, + NOTELABEL, + DEFLIST, + TERM, + DEFINITION, + METAKEY, + METAVALUE, + METADATA, + FOOTER, + LABEL, + HEADINGSECTION, + ENDHTML, + TABLE, + TABLEHEAD, + TABLEBODY, + TABLEROW, + TABLECELL, + CELLSPAN, + TABLECAPTION, + TABLELABEL, + TABLESEPARATOR, + AUTOLABEL, + ATTRIBUTE, + ATTRKEY, + ATTRVALUE, + GLOSSARY, + GLOSSARYTERM, + GLOSSARYSORTKEY, + MATHSPAN }; /* constants for managing Smart Typography */ @@ -121,4 +121,4 @@ void markdown_free_ast(struct Element *ast); void print_tree(struct Element * elt, int indent); -#endif \ No newline at end of file +#endif diff --git a/markdown_peg.h b/markdown_peg.h index fdea31e7..4a228d15 100644 --- a/markdown_peg.h +++ b/markdown_peg.h @@ -5,125 +5,12 @@ #include "markdown_lib.h" #include "glib.h" -/* Information (label, URL and title) for a link. */ -struct Link { - struct Element *label; - char *url; - char *title; - struct Element *attr; - char *identifier; -}; +#include "markdown_parser_lib.h" typedef struct Link link; - -/* Union for contents of an Element (string, list, or link). */ -union Contents { - char *str; - struct Link *link; -}; - -/* Types of semantic values returned by parsers. */ -enum keys { LIST, /* A generic list of values. For ordered and bullet lists, see below. */ - RAW, /* Raw markdown to be processed further */ - SPACE, - LINEBREAK, - ELLIPSIS, - EMDASH, - ENDASH, - APOSTROPHE, - SINGLEQUOTED, - DOUBLEQUOTED, - STR, - LINK, - IMAGE, - IMAGEBLOCK, - CODE, - HTML, - EMPH, - STRONG, - PLAIN, - PARA, - LISTITEM, - BULLETLIST, - ORDEREDLIST, - H1, H2, H3, H4, H5, H6, H7, /* Code assumes that these are in order. */ - BLOCKQUOTE, - VERBATIM, - HTMLBLOCK, - HRULE, - REFERENCE, - NOTE, - CITATION, - NOCITATION, - LOCATOR, - NOTELABEL, - DEFLIST, - TERM, - DEFINITION, - METAKEY, - METAVALUE, - METADATA, - FOOTER, - LABEL, - HEADINGSECTION, - ENDHTML, - TABLE, - TABLEHEAD, - TABLEBODY, - TABLEROW, - TABLECELL, - CELLSPAN, - TABLECAPTION, - TABLELABEL, - TABLESEPARATOR, - AUTOLABEL, - ATTRIBUTE, - ATTRKEY, - ATTRVALUE, - GLOSSARY, - GLOSSARYTERM, - GLOSSARYSORTKEY, - MATHSPAN - }; - -/* constants for managing Smart Typography */ -enum smartelements { - LSQUOTE, - RSQUOTE, - LDQUOTE, - RDQUOTE, - NDASH, - MDASH, - ELLIP, - APOS, -}; - -enum smartoutput { - HTMLOUT, - LATEXOUT, -}; - -enum language { - DUTCH, - ENGLISH, - FRENCH, - GERMAN, - SWEDISH, - GERMANGUILL, -}; - -/* Semantic value of a parsing action. */ -struct Element { - int key; - union Contents contents; - struct Element *children; - struct Element *next; -}; - - - typedef struct Element element; + element * parse_references(char *string, int extensions); element * parse_notes(char *string, int extensions, element *reference_list); element * parse_labels(char *string, int extensions, element *reference_list, element *note_list); From 5d7ebbe0b6037b456568be2ee48978d23bd750f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 14:36:40 +0100 Subject: [PATCH 18/97] Enabling re-entrant parsing mode for libMMD --- MultiMarkdown.xcodeproj/project.pbxproj | 9 ++-- parsing_functions.c | 61 ++++++++++++++++--------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 81839a5f..6f48ea47 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -24,7 +24,6 @@ /* Begin PBXBuildFile section */ 4AFA467413E3625F00CFA132 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFA466913E3624F00CFA132 /* Foundation.framework */; }; 4AFA467513E362AC00CFA132 /* GLibFacade.c in Sources */ = {isa = PBXBuildFile; fileRef = 651A528213E1C30100BCB02A /* GLibFacade.c */; }; - 4AFA467613E362B500CFA132 /* markdown_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B8B113DF6D4000D0980C /* markdown_parser.c */; }; 4AFA467A13E363FA00CFA132 /* markdown_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66113DF47CC00D0980C /* markdown_lib.c */; }; 4AFA467D13E3640600CFA132 /* markdown_output.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66313DF47CC00D0980C /* markdown_output.c */; }; 65F0B69E13DF47CC00D0980C /* markdown.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66713DF47CC00D0980C /* markdown.c */; }; @@ -358,7 +357,6 @@ buildActionMask = 2147483647; files = ( 4AFA467513E362AC00CFA132 /* GLibFacade.c in Sources */, - 4AFA467613E362B500CFA132 /* markdown_parser.c in Sources */, 4AFA467A13E363FA00CFA132 /* markdown_lib.c in Sources */, 4AFA467D13E3640600CFA132 /* markdown_output.c in Sources */, 79C2C98116E774BF002B79F3 /* markdown_parser_lib.c in Sources */, @@ -465,10 +463,7 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); + GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., "peg-0.1.9/", @@ -482,6 +477,7 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., "peg-0.1.9/", @@ -495,6 +491,7 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., "peg-0.1.9/", diff --git a/parsing_functions.c b/parsing_functions.c index 4664e3b4..324b123b 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -4,18 +4,7 @@ /* These yy_* functions come from markdown_parser.c which is * generated from markdown_parser.leg * */ -typedef int (*yyrule)(); - -extern int yyparse(); -extern int yyparsefrom(yyrule); -extern int yy_References(); -extern int yy_Notes(); -extern int yy_Doc(); - -extern int yy_AutoLabels(); -extern int yy_DocWithMetaData(); -extern int yy_MetaDataOnly(); -extern int yy_DocForOPML(); +#include "markdown_parser.c" #include "utility_functions.h" #include "parsing_functions.h" @@ -92,16 +81,27 @@ void free_element(element *elt) { free(elt); } +yycontext* create_parsing_context() { + yycontext *context = malloc(sizeof(yycontext)); + memset(context, 0, sizeof(yycontext)); + + return context; +} + element * parse_references(char *string, int extensions) { char *oldcharbuf; syntax_extensions = extensions; + yycontext *context = create_parsing_context(); + oldcharbuf = charbuf; charbuf = string; - yyparsefrom(yy_References); /* first pass, just to collect references */ + yyparsefrom(context, yy_References); /* first pass, just to collect references */ charbuf = oldcharbuf; + free(context); + return references; } @@ -112,11 +112,15 @@ element * parse_notes(char *string, int extensions, element *reference_list) { syntax_extensions = extensions; if (extension(EXT_NOTES)) { + yycontext *context = create_parsing_context(); + references = reference_list; oldcharbuf = charbuf; charbuf = string; - yyparsefrom(yy_Notes); /* second pass for notes */ + yyparsefrom(context, yy_Notes); /* second pass for notes */ charbuf = oldcharbuf; + + free(context); } return notes; @@ -130,11 +134,15 @@ element * parse_labels(char *string, int extensions, element *reference_list, el notes = note_list; labels = NULL; + yycontext *context = create_parsing_context(); + oldcharbuf = charbuf; charbuf = string; - yyparsefrom(yy_AutoLabels); /* third pass, to collect labels */ + yyparsefrom(context, yy_AutoLabels); /* third pass, to collect labels */ charbuf = oldcharbuf; + free(context); + return labels; } @@ -149,7 +157,11 @@ element * parse_markdown(char *string, int extensions, element *reference_list, oldcharbuf = charbuf; charbuf = string; - yyparsefrom(yy_Doc); + yycontext *context = create_parsing_context(); + + yyparsefrom(context, yy_Doc); + + free(context); charbuf = oldcharbuf; /* restore charbuf to original value */ @@ -174,8 +186,11 @@ element * parse_markdown_with_metadata(char *string, int extensions, element *re charbuf = string; start_time = clock(); - - yyparsefrom(yy_DocWithMetaData); + + yycontext *context = create_parsing_context(); + yyparsefrom(context, yy_DocWithMetaData); + free(context); + charbuf = oldcharbuf; /* restore charbuf to original value */ /* reset start_time for subsequent passes */ @@ -199,8 +214,10 @@ element * parse_metadata_only(char *string, int extensions) { oldcharbuf = charbuf; charbuf = string; - yyparsefrom(yy_MetaDataOnly); - + yycontext *context = create_parsing_context(); + yyparsefrom(context, yy_MetaDataOnly); + free(context); + charbuf = oldcharbuf; /* restore charbuf to original value */ return parse_result; @@ -214,7 +231,9 @@ element * parse_markdown_for_opml(char *string, int extensions) { oldcharbuf = charbuf; charbuf = string; - yyparsefrom(yy_DocForOPML); + yycontext *context = create_parsing_context(); + yyparsefrom(context, yy_DocForOPML); + free(context); charbuf = oldcharbuf; /* restore charbuf to original value */ return parse_result; From eb4425823342eb12ebc3c25f70e4f8bfb7f533dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 17:19:43 +0100 Subject: [PATCH 19/97] Making libMMD re-entrant --- MultiMarkdown.xcodeproj/project.pbxproj | 4 + markdown_output.c | 171 +++++++++++------------- markdown_parser.leg | 108 +++++++-------- parsing_functions.c | 157 +++++++++------------- utility_functions.c | 56 ++++---- utility_functions.h | 34 ++--- 6 files changed, 247 insertions(+), 283 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 6f48ea47..ae32d557 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 79C2C98416E7766B002B79F3 /* utility_functions.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B69A13DF47CC00D0980C /* utility_functions.c */; }; 79C2C98516E7766F002B79F3 /* parsing_functions.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66A13DF47CC00D0980C /* parsing_functions.c */; }; 79C2C98616E7767F002B79F3 /* odf.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66813DF47CC00D0980C /* odf.c */; }; + 79C2C98C16E78708002B79F3 /* utility_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C2C98B16E78708002B79F3 /* utility_functions.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -103,6 +104,7 @@ 79C2C97E16E774B6002B79F3 /* markdown_parser_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = markdown_parser_lib.h; sourceTree = ""; }; 79C2C98016E774BF002B79F3 /* markdown_parser_lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = markdown_parser_lib.c; sourceTree = ""; }; 79C2C98216E775D7002B79F3 /* parsing_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsing_functions.h; sourceTree = ""; }; + 79C2C98B16E78708002B79F3 /* utility_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utility_functions.h; sourceTree = ""; }; 8DD76FB20486AB0100D96B5E /* multimarkdown */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = multimarkdown; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -161,6 +163,7 @@ 65F0B66913DF47CC00D0980C /* odf.h */, 79C2C98216E775D7002B79F3 /* parsing_functions.h */, 65F0B66A13DF47CC00D0980C /* parsing_functions.c */, + 79C2C98B16E78708002B79F3 /* utility_functions.h */, 65F0B69A13DF47CC00D0980C /* utility_functions.c */, ); name = Source; @@ -229,6 +232,7 @@ files = ( 79C2C97F16E774B6002B79F3 /* markdown_parser_lib.h in Headers */, 79C2C98316E775D7002B79F3 /* parsing_functions.h in Headers */, + 79C2C98C16E78708002B79F3 /* utility_functions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/markdown_output.c b/markdown_output.c index 1c9f5d84..3d5f4dd7 100644 --- a/markdown_output.c +++ b/markdown_output.c @@ -42,9 +42,9 @@ static bool am_printing_html_footnote = FALSE; static int footnote_counter_to_print = 0; static int odf_list_needs_end_p = 0; -static void print_html_string(GString *out, char *str, bool obfuscate); -static void print_html_element_list(GString *out, element *list, bool obfuscate); -static void print_html_element(GString *out, element *elt, bool obfuscate); +static void print_html_string(int ext, GString *out, char *str, bool obfuscate); +static void print_html_element_list(int ext, GString *out, element *list, bool obfuscate); +static void print_html_element(int ext, GString *out, element *elt, bool obfuscate); static void print_latex_string(GString *out, char *str); static void print_latex_element_list(GString *out, element *list); static void print_latex_element(GString *out, element *elt); @@ -60,8 +60,8 @@ static bool list_contains_key(element *list, int key); /* MultiMarkdown Routines */ -static void print_html_header(GString *out, element *elt, bool obfuscate); -static void print_html_footer(GString *out, bool obfuscate); +static void print_html_header(int ext, GString *out, element *elt, bool obfuscate); +static void print_html_footer(int ext, GString *out, bool obfuscate); static void print_latex_header(GString *out, element *elt); static void print_latex_footer(GString *out); @@ -78,7 +78,7 @@ static void print_opml_element(GString *out, element *elt); static void print_opml_metadata(GString *out, element *elt); static void print_opml_section_and_children(GString *out, element *list); -element * print_html_headingsection(GString *out, element *list, bool obfuscate); +element * print_html_headingsection(int ext, GString *out, element *list, bool obfuscate); static bool is_html_complete_doc(element *meta); static int find_latex_mode(int format, element *list); @@ -137,7 +137,7 @@ static bool list_contains_key(element *list, int key) { /* print_html_string - print string, escaping for HTML * If obfuscate selected, convert characters to hex or decimal entities at random */ -static void print_html_string(GString *out, char *str, bool obfuscate) { +static void print_html_string(int ext, GString *out, char *str, bool obfuscate) { while (*str != '\0') { switch (*str) { case '&': @@ -167,12 +167,12 @@ static void print_html_string(GString *out, char *str, bool obfuscate) { } /* print_html_element_list - print a list of elements as HTML */ -static void print_html_element_list(GString *out, element *list, bool obfuscate) { +static void print_html_element_list(int ext, GString *out, element *list, bool obfuscate) { while (list != NULL) { if (list->key == HEADINGSECTION) { - list = print_html_headingsection(out, list, obfuscate); + list = print_html_headingsection(ext, out, list, obfuscate); } else { - print_html_element(out, list, obfuscate); + print_html_element(ext, out, list, obfuscate); list = list->next; } } @@ -184,7 +184,7 @@ static void add_endnote(element *elt) { } /* print_html_element - print an element as HTML */ -static void print_html_element(GString *out, element *elt, bool obfuscate) { +static void print_html_element(int ext, GString *out, element *elt, bool obfuscate) { int lev; char *label; element *attribute; @@ -199,7 +199,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { g_string_append_printf(out, "
\n"); break; case STR: - print_html_string(out, elt->contents.str, obfuscate); + print_html_string(ext, out, elt->contents.str, obfuscate); break; case ELLIPSIS: localize_typography(out, ELLIP, language, HTMLOUT); @@ -215,17 +215,17 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { break; case SINGLEQUOTED: localize_typography(out, LSQUOTE, language, HTMLOUT); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); localize_typography(out, RSQUOTE, language, HTMLOUT); break; case DOUBLEQUOTED: localize_typography(out, LDQUOTE, language, HTMLOUT); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); localize_typography(out, RDQUOTE, language, HTMLOUT); break; case CODE: g_string_append_printf(out, ""); - print_html_string(out, elt->contents.str, obfuscate); + print_html_string(ext, out, elt->contents.str, obfuscate); g_string_append_printf(out, ""); break; case HTML: @@ -235,16 +235,16 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { if (strstr(elt->contents.link->url, "mailto:") == elt->contents.link->url) obfuscate = true; /* obfuscate mailto: links */ g_string_append_printf(out, "contents.link->url, obfuscate); + print_html_string(ext, out, elt->contents.link->url, obfuscate); g_string_append_printf(out, "\""); if (strlen(elt->contents.link->title) > 0) { g_string_append_printf(out, " title=\""); - print_html_string(out, elt->contents.link->title, obfuscate); + print_html_string(ext, out, elt->contents.link->title, obfuscate); g_string_append_printf(out, "\""); } - print_html_element_list(out, elt->contents.link->attr, obfuscate); + print_html_element_list(ext, out, elt->contents.link->attr, obfuscate); g_string_append_printf(out, ">"); - print_html_element_list(out, elt->contents.link->label, obfuscate); + print_html_element_list(ext, out, elt->contents.link->label, obfuscate); g_string_append_printf(out, ""); break; case IMAGEBLOCK: @@ -254,20 +254,20 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { g_string_append_printf(out, "
\n"); } g_string_append_printf(out, "contents.link->url, obfuscate); + print_html_string(ext, out, elt->contents.link->url, obfuscate); g_string_append_printf(out, "\" alt=\""); print_raw_element_list(out,elt->contents.link->label); - if ( (extension(EXT_COMPATIBILITY)) || + if ( (ext & EXT_COMPATIBILITY) || (strcmp(elt->contents.link->identifier, "") == 0) ) { g_string_append_printf(out, "\""); } else { - if (!(extension(EXT_COMPATIBILITY))) { + if (!(ext & EXT_COMPATIBILITY)) { g_string_append_printf(out, "\" id=\"%s\"",elt->contents.link->identifier); } } if (strlen(elt->contents.link->title) > 0) { g_string_append_printf(out, " title=\""); - print_html_string(out, elt->contents.link->title, obfuscate); + print_html_string(ext, out, elt->contents.link->title, obfuscate); g_string_append_printf(out, "\""); } width = NULL; @@ -288,12 +288,12 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { g_string_append_printf(out, "width:%s;", width); g_string_append_printf(out, "\""); } - print_html_element_list(out, elt->contents.link->attr, obfuscate); + print_html_element_list(ext, out, elt->contents.link->attr, obfuscate); g_string_append_printf(out, " />"); if (elt->key == IMAGEBLOCK) { if (elt->contents.link->label != NULL) { g_string_append_printf(out, "\n
"); - print_html_element_list(out, elt->contents.link->label, obfuscate); + print_html_element_list(ext, out, elt->contents.link->label, obfuscate); g_string_append_printf(out, "
"); } g_string_append_printf(out, "
\n"); @@ -303,16 +303,16 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { break; case EMPH: g_string_append_printf(out, ""); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, ""); break; case STRONG: g_string_append_printf(out, ""); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, ""); break; case LIST: - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); break; case RAW: /* Shouldn't occur - these are handled by process_raw_blocks() */ @@ -323,23 +323,23 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { if (lev > 6) lev = 6; pad(out, 2); - if ( extension(EXT_COMPATIBILITY)) { + if ( ext & EXT_COMPATIBILITY) { /* Use regular Markdown header format */ g_string_append_printf(out, "", lev); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); } else if (elt->children->key == AUTOLABEL) { /* use label for header since one was specified (MMD)*/ g_string_append_printf(out, "", lev,elt->children->contents.str); - print_html_element_list(out, elt->children->next, obfuscate); - } else if ( extension(EXT_NO_LABELS)) { + print_html_element_list(ext, out, elt->children->next, obfuscate); + } else if ( ext & EXT_NO_LABELS) { /* Don't generate a label */ g_string_append_printf(out, "", lev); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); } else { /* generate a label by default for MMD */ label = label_from_element_list(elt->children, obfuscate); g_string_append_printf(out, "", lev, label); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); free(label); } g_string_append_printf(out, "", lev); @@ -347,13 +347,13 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { break; case PLAIN: pad(out, 1); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); padded = 0; break; case PARA: pad(out, 2); g_string_append_printf(out, "

"); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); if (am_printing_html_footnote && ( elt->next == NULL)) { g_string_append_printf(out, "  ↩", footnote_counter_to_print); /* Only print once. For now, it's the first paragraph, until @@ -376,7 +376,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { case VERBATIM: pad(out, 2); g_string_append_printf(out, "%s", "

");
-        print_html_string(out, elt->contents.str, obfuscate);
+        print_html_string(ext, out, elt->contents.str, obfuscate);
         g_string_append_printf(out, "%s", "
"); padded = 0; break; @@ -384,7 +384,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { pad(out, 2); g_string_append_printf(out, "%s", "
    "); padded = 0; - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); pad(out, 1); g_string_append_printf(out, "%s", "
"); padded = 0; @@ -393,7 +393,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { pad(out, 2); g_string_append_printf(out, "%s", "
    "); padded = 0; - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); pad(out, 1); g_string_append_printf(out, "
"); padded = 0; @@ -402,7 +402,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { pad(out, 1); g_string_append_printf(out, "
  • "); padded = 2; - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "
  • "); padded = 0; break; @@ -410,7 +410,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { pad(out, 2); g_string_append_printf(out, "
    \n"); padded = 2; - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); pad(out, 1); g_string_append_printf(out, "
    "); padded = 0; @@ -453,11 +453,11 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { break; case GLOSSARYTERM: g_string_append_printf(out,""); - print_html_string(out, elt->children->contents.str, obfuscate); + print_html_string(ext, out, elt->children->contents.str, obfuscate); g_string_append_printf(out, ""); if ((elt->next != NULL) && (elt->next->key == GLOSSARYSORTKEY) ) { g_string_append_printf(out, ""); - print_html_string(out, elt->next->contents.str, obfuscate); + print_html_string(ext, out, elt->next->contents.str, obfuscate); g_string_append_printf(out, ""); } g_string_append_printf(out, ": "); @@ -479,7 +479,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { g_string_append_printf(out, ""); if (locator != NULL) { g_string_append_printf(out, "["); - print_html_element(out,locator,obfuscate); + print_html_element(ext, out,locator,obfuscate); g_string_append_printf(out, "]"); } g_string_append_printf(out, "%s",elt->contents.str); @@ -505,7 +505,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { elt->children->contents.str); } else { g_string_append_printf(out, "[", elt->children->contents.str); - print_html_element(out,locator,obfuscate); + print_html_element(ext, out,locator,obfuscate); g_string_append_printf(out,", %s]", elt->children->contents.str); } @@ -525,20 +525,20 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { } break; case LOCATOR: - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); break; case DEFLIST: pad(out,1); padded = 1; g_string_append_printf(out, "
    \n"); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "
    \n"); padded = 0; break; case TERM: pad(out,1); g_string_append_printf(out, "
    "); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "
    \n"); padded = 1; break; @@ -546,7 +546,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { pad(out,1); padded = 1; g_string_append_printf(out, "
    "); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "
    \n"); padded = 0; break; @@ -554,19 +554,19 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { /* Metadata is present, so this should be a "complete" document */ html_footer = is_html_complete_doc(elt); if (html_footer) { - print_html_header(out, elt, obfuscate); + print_html_header(ext, out, elt, obfuscate); } else { - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); } break; case METAKEY: if (strcmp(elt->contents.str, "title") == 0) { g_string_append_printf(out, "\t"); - print_html_element(out, elt->children, obfuscate); + print_html_element(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n"); } else if (strcmp(elt->contents.str, "css") == 0) { g_string_append_printf(out, "\tchildren, obfuscate); + print_html_element(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\"/>\n"); } else if (strcmp(elt->contents.str, "xhtmlheader") == 0) { print_raw_element(out, elt->children); @@ -590,23 +590,23 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { free(label); } else { g_string_append_printf(out, "\tcontents.str, obfuscate); + print_html_string(ext, out, elt->contents.str, obfuscate); g_string_append_printf(out, "\" content=\""); - print_html_element(out, elt->children, obfuscate); + print_html_element(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\"/>\n"); } break; case METAVALUE: - print_html_string(out, elt->contents.str, obfuscate); + print_html_string(ext, out, elt->contents.str, obfuscate); break; case FOOTER: break; case HEADINGSECTION: - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); break; case TABLE: g_string_append_printf(out, "\n\n\n"); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "
    \n"); break; case TABLESEPARATOR: @@ -619,7 +619,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { label = label_from_element_list(elt->children,obfuscate); } g_string_append_printf(out, "", label); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n"); free(label); break; @@ -646,19 +646,19 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { g_string_append_printf(out, "\n"); cell_type = 'h'; g_string_append_printf(out, "\n\n"); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n"); cell_type = 'd'; break; case TABLEBODY: g_string_append_printf(out, "\n\n"); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n"); break; case TABLEROW: g_string_append_printf(out, "\n"); table_column = 0; - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n"); break; case TABLECELL: @@ -678,7 +678,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { } g_string_append_printf(out, ">"); padded = 2; - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n", cell_type); table_column++; break; @@ -707,7 +707,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) { } } -static void print_html_endnotes(GString *out) { +static void print_html_endnotes(int ext, GString *out) { int counter = 0; GSList *note; element *note_elt; @@ -724,12 +724,12 @@ static void print_html_endnotes(GString *out) { element *temp = note_elt; while ( temp != NULL ) { if (temp->key == NOTELABEL) - print_html_string(out, temp->contents.str, 0); + print_html_string(ext, out, temp->contents.str, 0); temp = temp->next; } g_string_append_printf(out, "
    "); padded = 2; - print_html_element_list(out, note_elt->children, false); + print_html_element_list(ext, out, note_elt->children, false); pad(out, 1); g_string_append_printf(out, ""); } else { @@ -737,7 +737,7 @@ static void print_html_endnotes(GString *out) { padded = 2; am_printing_html_footnote = TRUE; footnote_counter_to_print = counter; - print_html_element_list(out, note_elt, false); + print_html_element_list(ext, out, note_elt, false); am_printing_html_footnote = FALSE; footnote_counter_to_print = 0; pad(out, 1); @@ -1742,7 +1742,7 @@ static void print_odf_element(GString *out, element *elt) { g_string_append_printf(out, ""); break; case STR: - print_html_string(out, elt->contents.str, 0); + print_html_string(0, out, elt->contents.str, 0); break; case ELLIPSIS: localize_typography(out, ELLIP, language, HTMLOUT); @@ -1768,7 +1768,7 @@ static void print_odf_element(GString *out, element *elt) { break; case CODE: g_string_append_printf(out, ""); - print_html_string(out, elt->contents.str, 0); + print_html_string(0, out, elt->contents.str, 0); g_string_append_printf(out, ""); break; case HTML: @@ -1793,14 +1793,14 @@ static void print_odf_element(GString *out, element *elt) { } } else { g_string_append_printf(out, "contents.link->url, 0); + print_html_string(0, out, elt->contents.link->url, 0); g_string_append_printf(out, "\""); if (strlen(elt->contents.link->title) > 0) { g_string_append_printf(out, " office:name=\""); - print_html_string(out, elt->contents.link->title, 0); + print_html_string(0, out, elt->contents.link->title, 0); g_string_append_printf(out, "\""); } - /* print_html_element_list(out, elt->contents.link->attr, obfuscate);*/ + /* print_html_element_list(ext, out, elt->contents.link->attr, obfuscate);*/ g_string_append_printf(out, ">"); print_odf_element_list(out, elt->contents.link->label); g_string_append_printf(out, ""); @@ -2234,12 +2234,12 @@ void print_element_list(GString *out, element *elt, int format, int exts) { format = find_latex_mode(format, elt); switch (format) { case HTML_FORMAT: - print_html_element_list(out, elt, false); + print_html_element_list(exts, out, elt, false); if (endnotes != NULL) { pad(out, 2); - print_html_endnotes(out); + print_html_endnotes(exts, out); } - if (html_footer == TRUE) print_html_footer(out, false); + if (html_footer == TRUE) print_html_footer(exts, out, false); break; case LATEX_FORMAT: print_latex_element_list(out, elt); @@ -2296,16 +2296,16 @@ void print_element_list(GString *out, element *elt, int format, int exts) { ***********************************************************************/ -void print_html_header(GString *out, element *elt, bool obfuscate) { +void print_html_header(int ext, GString *out, element *elt, bool obfuscate) { g_string_append_printf(out, "\n\n\n\t\n"); - print_html_element_list(out, elt->children, obfuscate); + print_html_element_list(ext, out, elt->children, obfuscate); g_string_append_printf(out, "\n\n\n"); } -void print_html_footer(GString *out, bool obfuscate) { +void print_html_footer(int ext, GString *out, bool obfuscate) { g_string_append_printf(out, "\n\n\n"); } @@ -2480,13 +2480,13 @@ static void print_beamer_element(GString *out, element *elt) { } -element * print_html_headingsection(GString *out, element *list, bool obfuscate) { +element * print_html_headingsection(int ext, GString *out, element *list, bool obfuscate) { element *base = list; - print_html_element_list(out, list->children, obfuscate); + print_html_element_list(ext, out, list->children, obfuscate); list = list->next; while ( (list != NULL) && (list->key == HEADINGSECTION) && (list->children->key > base->children->key) && (list->children->key <= H6)) { - list = print_html_headingsection(out, list, obfuscate); + list = print_html_headingsection(ext, out, list, obfuscate); } return list; @@ -2822,12 +2822,3 @@ void print_odf_body_element_list(GString *out, element *list) { list = list->next; } } - -/* bogus function just references a couple globals defined in utility_functions.c but not used in this source file */ -static void bogus_function() -{ - static char* bogus; - bogus = charbuf; - static element* bogus2; - bogus2 = parse_result; -} diff --git a/markdown_parser.leg b/markdown_parser.leg index 3fd1903a..3ebafb27 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -41,9 +41,9 @@ #define YY_INPUT(buf, result, max_size) \ { \ - int yyc; \ - if (charbuf && *charbuf != '\0') { \ - yyc= *charbuf++; \ + int yyc = read_character(ctx->state); \ + if (ctx->state->charbuf && *(ctx->state->charbuf) != '\0') { \ + next_character(ctx->state);\ } else { \ yyc= EOF; \ } \ @@ -64,15 +64,15 @@ %} Doc = BOM? a:StartList ( Block { a = cons($$, a); } )* - { parse_result = reverse(a); } + { ctx->state->parse_result = reverse(a); } DocWithMetaData = BOM? a:StartList b:StartList - ( &{ !extension(EXT_COMPATIBILITY) } + ( &{ !extension(ctx->state, EXT_COMPATIBILITY) } &( MetaDataKey Sp ':' Sp (!Newline)) MetaData { a = cons($$, a); b = mk_element(FOOTER);})? ( Block { a = cons($$, a); } )* { if (b != NULL) a = cons(b, a); - parse_result = reverse(a); + ctx->state->parse_result = reverse(a); } MetaData = a:StartList !([A-Za-z]+ "://") @@ -85,13 +85,13 @@ MetaDataOnly = BOM? a:StartList ( MetaData { a = cons($$, a); } )? # SkipBlock* .* - { parse_result = reverse(a); } + { ctx->state->parse_result = reverse(a); } MetaDataOnly2 = BOM? a:StartList ( MetaData { a = cons($$, a); } )? # SkipBlock* .* - { parse_result = mk_list(LIST,a); } + { ctx->state->parse_result = mk_list(LIST,a); } MetaDataKeyValue = a:MetaDataKey Sp ':' Sp b:MetaDataValue @@ -123,8 +123,8 @@ MetaDataValue = a:StartList Block = BlankLine* ( BlockQuote | Verbatim - | &{ !extension(EXT_COMPATIBILITY) } DefinitionList - | &{ !extension(EXT_COMPATIBILITY) } Glossary + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } DefinitionList + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } Glossary | Note | Reference | HorizontalRule @@ -134,8 +134,8 @@ Block = BlankLine* | HtmlBlock | MarkdownHtmlBlock | StyleBlock - | &{ !extension(EXT_COMPATIBILITY) } Table - | &{ !extension(EXT_COMPATIBILITY) } ImageBlock + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } Table + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } ImageBlock | !(Sp? HtmlBlockOpenDiv) Para | Plain ) @@ -144,8 +144,8 @@ HeadingSectionBlock = !Heading ( BlockQuote | Verbatim - | &{ !extension(EXT_COMPATIBILITY) } DefinitionList - | &{ !extension(EXT_COMPATIBILITY) } Glossary + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } DefinitionList + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } Glossary | Note | Reference | HorizontalRule @@ -154,8 +154,8 @@ HeadingSectionBlock = | HtmlBlock | MarkdownHtmlBlock | StyleBlock - | &{ !extension(EXT_COMPATIBILITY) } Table - | &{ !extension(EXT_COMPATIBILITY) } ImageBlock + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } Table + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } ImageBlock | !(Sp? HtmlBlockOpenDiv) Para | Plain ) @@ -165,7 +165,7 @@ Para = NonindentSpace a:Inlines BlankLine+ Plain = a:Inlines { $$ = a; $$->key = PLAIN; } -AtxInline = !Newline !( &{ !extension(EXT_COMPATIBILITY) } Sp AutoLabel Sp? '#'* Sp Newline) !(Sp? '#'* Sp Newline) Inline +AtxInline = !Newline !( &{ !extension(ctx->state, EXT_COMPATIBILITY) } Sp AutoLabel Sp? '#'* Sp Newline) !(Sp? '#'* Sp Newline) Inline AtxStart = < ( "######" | "#####" | "####" | "###" | "##" | "#" ) > { $$ = mk_element(H1 + (strlen(yytext) - 1)); } @@ -181,11 +181,11 @@ SetextBottom1 = '='+ Newline SetextBottom2 = '-'+ Newline SetextHeading1 = &(RawLine SetextBottom1) - a:StartList ( !Endline !( &{ !extension(EXT_COMPATIBILITY) } Sp AutoLabel ) Inline { a = cons($$, a); } )+ ( Sp b:AutoLabel { append_list(b,a);} Sp? )? Sp? Newline + a:StartList ( !Endline !( &{ !extension(ctx->state, EXT_COMPATIBILITY) } Sp AutoLabel ) Inline { a = cons($$, a); } )+ ( Sp b:AutoLabel { append_list(b,a);} Sp? )? Sp? Newline SetextBottom1 { $$ = mk_list(H1, a); } SetextHeading2 = &(RawLine SetextBottom2) -a:StartList ( !Endline !( &{ !extension(EXT_COMPATIBILITY) } Sp AutoLabel ) Inline { a = cons($$, a); } )+ ( Sp b:AutoLabel { append_list(b,a)} Sp? )? Sp? Newline +a:StartList ( !Endline !( &{ !extension(ctx->state, EXT_COMPATIBILITY) } Sp AutoLabel ) Inline { a = cons($$, a); } )+ ( Sp b:AutoLabel { append_list(b,a)} Sp? )? Sp? Newline SetextBottom2 { $$ = mk_list(H2, a); } Heading = SetextHeading | AtxHeading @@ -517,11 +517,11 @@ HtmlBlockInTags = HtmlBlockAddress HtmlBlock = !MarkdownHtmlTagOpen < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing ) > BlankLine+ - { if (extension(EXT_FILTER_HTML)) { + { if (extension(ctx->state, EXT_FILTER_HTML)) { $$ = mk_list(LIST, NULL); } else { $$ = mk_str(yytext); - if ( extension(EXT_PROCESS_HTML)) $$->key = RAW; + if ( extension(ctx->state, EXT_PROCESS_HTML)) $$->key = RAW; else $$->key = HTMLBLOCK; } } @@ -546,7 +546,7 @@ StyleClose = '<' Spnl '/' ("style" | "STYLE") Spnl '>' InStyleTags = StyleOpen (!StyleClose .)* StyleClose StyleBlock = < InStyleTags > BlankLine* - { if (extension(EXT_FILTER_STYLES)) { + { if (extension(ctx->state, EXT_FILTER_STYLES)) { $$ = mk_list(LIST, NULL); } else { $$ = mk_str(yytext); @@ -558,15 +558,15 @@ Inlines = a:StartList ( !Endline Inline { a = cons($$, a); } | c:Endline &Inline { a = cons(c, a); } )+ Endline? { $$ = mk_list(LIST, a); } -Inline = &{ check_timeout() } +Inline = &{ check_timeout(ctx->state) } Str - | &{ !extension(EXT_COMPATIBILITY) } MathSpan + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } MathSpan | Endline | UlOrStarLine | Space | Strong | Emph - | &{ !extension(EXT_COMPATIBILITY) } CitationReference + | &{ !extension(ctx->state, EXT_COMPATIBILITY) } CitationReference | Image | Link | NoteReference @@ -590,7 +590,7 @@ Str = a:StartList < NormalChar+ > { a = cons(mk_str(yytext), a); } StrChunk = < (NormalChar | '_'+ &Alphanumeric)+ > { $$ = mk_str(yytext); } | AposChunk -AposChunk = &{ extension(EXT_SMART) } '\'' &Alphanumeric +AposChunk = &{ extension(ctx->state, EXT_SMART) } '\'' &Alphanumeric { $$ = mk_element(APOSTROPHE); } EscapedChar = '\\' !Newline < [-\\`|*_{}[\]()#+.!><] > @@ -674,12 +674,12 @@ ReferenceLink = ReferenceLinkDouble | ReferenceLinkSingle ReferenceLinkDouble = a:Label < Spnl > !"[]" b:Label { link match; - if (find_reference(&match, b->children)) { + if (find_reference(ctx->state, &match, b->children)) { $$ = mk_link(a->children, match.url, match.title, match.attr, match.identifier); free(a); free_element_list(b); - } else if ( !extension(EXT_COMPATIBILITY) && - find_label(&match, b->children)) { + } else if ( !extension(ctx->state, EXT_COMPATIBILITY) && + find_label(ctx->state, &match, b->children)) { GString *text = g_string_new(""); print_raw_element_list(text, b->children); char *lab = label_from_string(text->str,0); @@ -701,11 +701,11 @@ ReferenceLinkDouble = a:Label < Spnl > !"[]" b:Label ReferenceLinkSingle = a:Label < (Spnl "[]")? > { link match; - if (find_reference(&match, a->children)) { + if (find_reference(ctx->state, &match, a->children)) { $$ = mk_link(a->children, match.url, match.title, match.attr, match.identifier); free(a); - } else if ( !extension(EXT_COMPATIBILITY) && - find_label(&match, a->children)) { + } else if ( !extension(ctx->state, EXT_COMPATIBILITY) && + find_label(ctx->state, &match, a->children)) { GString *text = g_string_new(""); print_raw_element_list(text, a->children); char *lab = label_from_string(text->str,0); @@ -758,7 +758,7 @@ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . Reference = a:StartList NonindentSpace !"[]" l:Label ':' Spnl s:RefSrc t:RefTitle - ( &{ !extension(EXT_COMPATIBILITY) } + ( &{ !extension(ctx->state, EXT_COMPATIBILITY) } (Attributes { a = cons($$,a);})? )? BlankLine+ { @@ -809,7 +809,7 @@ QuotedValue = '"' < (!'"' .)* > '"' UnQuotedValue = < (AlphanumericAscii | '.')+ > -Label = '[' !'[' ( !'^' !'#' &{ extension(EXT_NOTES) } | &. &{ !extension(EXT_NOTES) } ) +Label = '[' !'[' ( !'^' !'#' &{ extension(ctx->state, EXT_NOTES) } | &. &{ !extension(ctx->state, EXT_NOTES) } ) a:StartList ( !']' Inline { a = cons($$, a); } )* ']' @@ -826,17 +826,17 @@ RefTitle = ( RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle ) EmptyTitle = < "" > RefTitleSingle = Spnl '\'' < ( !( '\'' Sp Newline | Newline | - &{ !extension(EXT_COMPATIBILITY) } '\'' Sp AlphanumericAscii+ '=' ) . )* > '\'' + &{ !extension(ctx->state, EXT_COMPATIBILITY) } '\'' Sp AlphanumericAscii+ '=' ) . )* > '\'' RefTitleDouble = Spnl '"' < ( !('"' Sp Newline | Newline | - &{ !extension(EXT_COMPATIBILITY) } '"' Sp AlphanumericAscii+ '=' ) . )* > '"' + &{ !extension(ctx->state, EXT_COMPATIBILITY) } '"' Sp AlphanumericAscii+ '=' ) . )* > '"' RefTitleParens = Spnl '(' < ( !(')' Sp Newline | Newline | - &{ !extension(EXT_COMPATIBILITY) } ')' Sp AlphanumericAscii+ '=' ) . )* > ')' + &{ !extension(ctx->state, EXT_COMPATIBILITY) } ')' Sp AlphanumericAscii+ '=' ) . )* > ')' References = a:StartList ( b:Reference { a = cons(b, a); } | SkipBlock )* - { references = reverse(a); } + { ctx->state->references = reverse(a); } Ticks1 = "`" !'`' Ticks2 = "``" !'`' @@ -853,7 +853,7 @@ Code = ( Ticks1 Sp < ( ( !'`' Nonspacechar )+ | !Ticks1 '`'+ | !( Sp Ticks1 ) ( { $$ = mk_str(yytext); $$->key = CODE; } RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) > - { if (extension(EXT_FILTER_HTML)) { + { if (extension(ctx->state, EXT_FILTER_HTML)) { $$ = mk_list(LIST, NULL); } else { $$ = mk_str(yytext); @@ -905,10 +905,10 @@ SkipBlock = HtmlBlock # Syntax extensions -ExtendedSpecialChar = &{ extension(EXT_SMART) } ('.' | '-' | '\'' | '"') - | &{ extension(EXT_NOTES) } ( '^' ) +ExtendedSpecialChar = &{ extension(ctx->state, EXT_SMART) } ('.' | '-' | '\'' | '"') + | &{ extension(ctx->state, EXT_NOTES) } ( '^' ) -Smart = &{ extension(EXT_SMART) } +Smart = &{ extension(ctx->state, EXT_SMART) } ( Ellipsis | Dash | SingleQuoted | DoubleQuoted | Apostrophe ) Apostrophe = '\'' @@ -950,10 +950,10 @@ DoubleQuoted = DoubleQuoteStart DoubleQuoteEnd { $$ = mk_list(DOUBLEQUOTED, a); } -NoteReference = &{ extension(EXT_NOTES) } +NoteReference = &{ extension(ctx->state, EXT_NOTES) } ref:RawNoteReference { element *match; - if (find_note(&match, ref->contents.str)) { + if (find_note(ctx->state, &match, ref->contents.str)) { $$ = mk_element(NOTE); assert(match->children != NULL); $$->children = match->children; @@ -970,7 +970,7 @@ NoteReference = &{ extension(EXT_NOTES) } RawNoteReference = ( "[^" | "[#" ) < ( !Newline !']' . )+ > ']' { $$ = mk_str(yytext); } -Glossary = &{ extension(EXT_NOTES) } +Glossary = &{ extension(ctx->state, EXT_NOTES) } a:StartList NonindentSpace ref:RawNoteReference ':' Sp "glossary:" Sp (GlossaryTerm { a = cons($$, a); }) @@ -994,7 +994,7 @@ GlossarySortKey = '(' < (!')' !Newline .)* > ')' { $$ = mk_str(yytext); $$->key = GLOSSARYSORTKEY; } -Note = &{ extension(EXT_NOTES) } +Note = &{ extension(ctx->state, EXT_NOTES) } NonindentSpace ref:RawNoteReference ':' Sp a:StartList ( RawNoteBlock { a = cons($$, a); } ) @@ -1007,7 +1007,7 @@ Note = &{ extension(EXT_NOTES) } $$->contents.str = strdup(ref->contents.str); } -InlineNote = &{ extension(EXT_NOTES) } +InlineNote = &{ extension(ctx->state, EXT_NOTES) } "^[" a:StartList ( !']' Inline { a = cons($$, a); } )+ @@ -1017,7 +1017,7 @@ InlineNote = &{ extension(EXT_NOTES) } Notes = a:StartList ( (b:Glossary | b:Note) { a = cons(b, a); } | SkipBlock )* - { notes = reverse(a); } + { ctx->state->notes = reverse(a); } RawNoteBlock = a:StartList ( !BlankLine OptionallyIndentedLine { a = cons($$, a); } )+ @@ -1033,7 +1033,7 @@ CitationReference = CitationReferenceDouble | CitationReferenceSingle CitationReferenceDouble = !"[]" b:Label < Spnl > !"[]" ref:RawCitationReference { element *match; - if (find_note(&match, ref->contents.str)) { + if (find_note(ctx->state, &match, ref->contents.str)) { /* This citation is specified within the document */ $$ = mk_element(CITATION); assert(match->children != NULL); @@ -1067,7 +1067,7 @@ CitationReferenceDouble = !"[]" b:Label < Spnl > !"[]" ref:RawCitationReference CitationReferenceSingle = (( "[]" Spnl ref:RawCitationReference ) | ( ref:RawCitationReference < (Spnl "[]")? > )) { element *match; - if (find_note(&match, ref->contents.str)) { + if (find_note(ctx->state, &match, ref->contents.str)) { $$ = mk_element(CITATION); assert(match->children != NULL); $$->children = match->children; @@ -1087,7 +1087,7 @@ RawCitationReference = "[#" < ( !Newline !']' . )+ > ']' { $$ = mk_str(yytext); } -AutoLabels = ( &{ !extension(EXT_COMPATIBILITY) && !extension(EXT_NO_LABELS)} +AutoLabels = ( &{ !extension(ctx->state, EXT_COMPATIBILITY) && !extension(ctx->state, EXT_NO_LABELS)} a:StartList ( b:Heading { GString *label = g_string_new(""); @@ -1131,7 +1131,7 @@ AutoLabels = ( &{ !extension(EXT_COMPATIBILITY) && !extension(EXT_NO_LABELS)} g_string_free(label,true); free_element_list(c);} | SkipBlock )* - { labels = a; }) + { ctx->state->labels = a; }) DefinitionList = a:StartList &(TermLine+ Newline? NonindentSpace ':') ( @@ -1278,11 +1278,11 @@ MathSpan = '\\' < ( DocForOPML = BOM? a:StartList - ( &{ !extension(EXT_COMPATIBILITY) } + ( &{ !extension(ctx->state, EXT_COMPATIBILITY) } &( MetaDataKey Sp ':' Sp (!Newline)) MetaData { a = cons($$, a); })? ( OPMLBlock { a = cons($$, a); } )* - { parse_result = reverse(a); + { ctx->state->parse_result = reverse(a); } OPMLBlock = BlankLine* diff --git a/parsing_functions.c b/parsing_functions.c index 324b123b..9d529cb6 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -4,12 +4,15 @@ /* These yy_* functions come from markdown_parser.c which is * generated from markdown_parser.leg * */ -#include "markdown_parser.c" #include "utility_functions.h" #include "parsing_functions.h" #include "markdown_peg.h" +#define YY_CTX_MEMBERS markdown_parser_state *state; + +#include "markdown_parser.c" + static void free_element_contents(element elt); /* free_element_list - free list of elements recursively */ @@ -81,94 +84,87 @@ void free_element(element *elt) { free(elt); } -yycontext* create_parsing_context() { +markdown_parser_state *create_markdown_parser_state(char *string, int extensions, element *references, element *notes, element *labels) +{ + markdown_parser_state *state = malloc(sizeof(markdown_parser_state)); + + state->charbuf = string; + state->syntax_extensions = extensions; + state->references = references; + state->notes = notes; + state->labels = labels; + + state->start_time = 0; + state->parse_aborted = 0; + state->parse_result = NULL; + + return state; +} + +yycontext* create_parsing_context(char *string, int extensions, element *references, element *notes, element *labels) { yycontext *context = malloc(sizeof(yycontext)); memset(context, 0, sizeof(yycontext)); + + context->state = create_markdown_parser_state(string, extensions, references, notes, labels); return context; } -element * parse_references(char *string, int extensions) { +void free_parsing_context(yycontext *context) +{ + free(context->state); + free(context); +} + - char *oldcharbuf; - syntax_extensions = extensions; - yycontext *context = create_parsing_context(); +element * parse_references(char *string, int extensions) +{ + yycontext *context = create_parsing_context(string, extensions, NULL, NULL, NULL); - oldcharbuf = charbuf; - charbuf = string; yyparsefrom(context, yy_References); /* first pass, just to collect references */ - charbuf = oldcharbuf; - - free(context); + element *references = context->state->references; + + free_parsing_context(context); return references; } element * parse_notes(char *string, int extensions, element *reference_list) { - char *oldcharbuf; - notes = NULL; - syntax_extensions = extensions; - - if (extension(EXT_NOTES)) { - yycontext *context = create_parsing_context(); - - references = reference_list; - oldcharbuf = charbuf; - charbuf = string; + yycontext *context = create_parsing_context(string, extensions, reference_list, NULL, NULL); + element *notes = NULL; + + if (extension(context->state, EXT_NOTES)) { yyparsefrom(context, yy_Notes); /* second pass for notes */ - charbuf = oldcharbuf; - - free(context); + notes = context->state->notes; } + + free_parsing_context(context); return notes; } element * parse_labels(char *string, int extensions, element *reference_list, element *note_list) { - char *oldcharbuf; - syntax_extensions = extensions; - references = reference_list; - notes = note_list; - labels = NULL; - - yycontext *context = create_parsing_context(); + yycontext *context = create_parsing_context(string, extensions, reference_list, note_list, NULL); - oldcharbuf = charbuf; - charbuf = string; yyparsefrom(context, yy_AutoLabels); /* third pass, to collect labels */ - charbuf = oldcharbuf; - - free(context); + element *labels = context->state->labels; + + free_parsing_context(context); return labels; } element * parse_markdown(char *string, int extensions, element *reference_list, element *note_list, element *label_list) { - char *oldcharbuf; - syntax_extensions = extensions; - references = reference_list; - notes = note_list; - labels = label_list; - - oldcharbuf = charbuf; - charbuf = string; - - yycontext *context = create_parsing_context(); + yycontext *context = create_parsing_context(string, extensions, reference_list, note_list, label_list); yyparsefrom(context, yy_Doc); + element *parse_result = context->state->parse_result; - free(context); - - charbuf = oldcharbuf; /* restore charbuf to original value */ - -/* if (parse_aborted) { - free_element_list(parse_result); - return NULL; - }*/ + free_parsing_context(context); return parse_result; @@ -176,28 +172,17 @@ element * parse_markdown(char *string, int extensions, element *reference_list, element * parse_markdown_with_metadata(char *string, int extensions, element *reference_list, element *note_list, element *label_list) { - char *oldcharbuf; - syntax_extensions = extensions; - references = reference_list; - notes = note_list; - labels = label_list; - - oldcharbuf = charbuf; - charbuf = string; - - start_time = clock(); + yycontext *context = create_parsing_context(string, extensions, reference_list, note_list, label_list); + context->state->start_time = clock(); - yycontext *context = create_parsing_context(); yyparsefrom(context, yy_DocWithMetaData); - free(context); - charbuf = oldcharbuf; /* restore charbuf to original value */ - - /* reset start_time for subsequent passes */ - start_time = 0; - - if (parse_aborted) { - parse_aborted = 0; + element *parse_result = context->state->parse_result; + int is_aborted = context->state->parse_aborted; + + free_parsing_context(context); + + if (is_aborted) { free_element_list(parse_result); return NULL; } @@ -208,34 +193,22 @@ element * parse_markdown_with_metadata(char *string, int extensions, element *re element * parse_metadata_only(char *string, int extensions) { - char *oldcharbuf; - syntax_extensions = extensions; + yycontext *context = create_parsing_context(string, extensions, NULL, NULL, NULL); - oldcharbuf = charbuf; - charbuf = string; - - yycontext *context = create_parsing_context(); yyparsefrom(context, yy_MetaDataOnly); - free(context); + element *parse_result = context->state->parse_result; + free_parsing_context(context); - charbuf = oldcharbuf; /* restore charbuf to original value */ return parse_result; - } element * parse_markdown_for_opml(char *string, int extensions) { - char *oldcharbuf; - syntax_extensions = extensions; - - oldcharbuf = charbuf; - charbuf = string; - - yycontext *context = create_parsing_context(); + yycontext *context = create_parsing_context(string, extensions, NULL, NULL, NULL); yyparsefrom(context, yy_DocForOPML); - free(context); + element *parse_result = context->state->parse_result; + + free_parsing_context(context); - charbuf = oldcharbuf; /* restore charbuf to original value */ return parse_result; - } diff --git a/utility_functions.c b/utility_functions.c index 40e0caef..05ed9d2b 100644 --- a/utility_functions.c +++ b/utility_functions.c @@ -63,23 +63,6 @@ GString *concat_string_list(element *list) { return result; } -/********************************************************************** - - Global variables used in parsing - - ***********************************************************************/ - - -char *charbuf = ""; /* Buffer of characters to be parsed. */ -element *references = NULL; /* List of link references found. */ -element *notes = NULL; /* List of footnotes found. */ -element *parse_result; /* Results of parse. */ -int syntax_extensions; /* Syntax extensions selected. */ - -element *labels = NULL; /* List of labels found in document. */ -clock_t start_time = 0; /* Used for ensuring we're not stuck in a loop */ -bool parse_aborted = 0; /* flag indicating we ran out of time */ - /********************************************************************** Auxiliary functions for parsing actions. @@ -144,8 +127,8 @@ element * mk_link(element *label, char *url, char *title, element *attr, char *i } /* extension = returns true if extension is selected */ -bool extension(int ext) { - return (syntax_extensions & ext); +bool extension(markdown_parser_state *state, int ext) { + return (state->syntax_extensions & ext); } /* match_inlines - returns true if inline lists match (case-insensitive...) */ @@ -193,8 +176,8 @@ bool match_inlines(element *l1, element *l2) { /* find_reference - return true if link found in references matching label. * 'link' is modified with the matching url and title. */ -bool find_reference(link *result, element *label) { - element *cur = references; /* pointer to walk up list of references */ +bool find_reference(markdown_parser_state *state, link *result, element *label) { + element *cur = state->references; /* pointer to walk up list of references */ link *curitem; while (cur != NULL) { curitem = cur->contents.link; @@ -211,8 +194,8 @@ bool find_reference(link *result, element *label) { /* find_note - return true if note found in notes matching label. if found, 'result' is set to point to matched note. */ -bool find_note(element **result, char *label) { - element *cur = notes; /* pointer to walk up list of notes */ +bool find_note(markdown_parser_state *state, element **result, char *label) { + element *cur = state->notes; /* pointer to walk up list of notes */ while (cur != NULL) { if (strcmp(label, cur->contents.str) == 0) { *result = cur; @@ -298,9 +281,9 @@ char *label_from_string(char *str, bool obfuscate) { /* find_label - return true if header, table, etc is found matching label. * 'link' is modified with the matching url and title. */ -bool find_label(link *result, element *label) { +bool find_label(markdown_parser_state *state, link *result, element *label) { char *lab; - element *cur = labels; /* pointer to walk up list of references */ + element *cur = state->labels; /* pointer to walk up list of references */ GString *text = g_string_new(""); print_raw_element_list(text, label); lab = label_from_string(text->str,0); @@ -512,28 +495,37 @@ void trim_trailing_whitespace(char *str) { } /* Don't let us get caught in "infinite" loop */ -bool check_timeout() { +bool check_timeout(markdown_parser_state *state) { /* Once we abort, keep aborting */ - if (parse_aborted) + if (state->parse_aborted) return 0; /* We're not timing this run */ - if (start_time == 0) + if (state->start_time == 0) return 1; clock_t end = clock(); - double elapsed = ((double) (end - start_time)) / CLOCKS_PER_SEC; + double elapsed = ((double) (end - state->start_time)) / CLOCKS_PER_SEC; /* fprintf(stderr,"%2.2f elapsed; (%4.2f CLOCKS_PER_SEC)\n",elapsed,CLOCKS_PER_SEC); */ /* fprintf(stderr,"%2.2f elapsed\n",elapsed); */ - /* If > 3 clock seconds, then abort */ - float max = 3; + /* If > 30 clock seconds, then abort */ + float max = 30; if (elapsed > max) { - parse_aborted = 1; + state->parse_aborted = 1; return 0; } return 1; } +char read_character(markdown_parser_state *state) +{ + return *(state->charbuf); +} + +void next_character(markdown_parser_state *state) +{ + state->charbuf ++; +} diff --git a/utility_functions.h b/utility_functions.h index a1989510..b1685ffe 100644 --- a/utility_functions.h +++ b/utility_functions.h @@ -26,16 +26,17 @@ GString *concat_string_list(element *list); ***********************************************************************/ -extern char *charbuf; /* Buffer of characters to be parsed. */ -extern element *references; /* List of link references found. */ -extern element *notes; /* List of footnotes found. */ -extern element *parse_result; /* Results of parse. */ -extern int syntax_extensions; /* Syntax extensions selected. */ - - -extern element *labels; /* List of labels found in document. */ -extern clock_t start_time; /* Used for ensuring we're not stuck in a loop */ -extern bool parse_aborted; /* flag indicating we ran out of time */ +typedef struct _markdown_parser_state{ + char *charbuf; /* Buffer of characters to be parsed. */ + element *references; /* List of link references found. */ + element *notes; /* List of footnotes found. */ + element *parse_result; /* Results of parse. */ + int syntax_extensions; /* Syntax extensions selected. */ + + element *labels; /* List of labels found in document. */ + clock_t start_time; /* Used for ensuring we're not stuck in a loop */ + bool parse_aborted; /* flag indicating we ran out of time */ +}markdown_parser_state; /********************************************************************** @@ -63,31 +64,34 @@ element * mk_list(int key, element *lst); /* mk_link - constructor for LINK element */ element * mk_link(element *label, char *url, char *title, element *attr, char *id); /* extension = returns true if extension is selected */ -bool extension(int ext); +bool extension(markdown_parser_state *state, int ext); /* match_inlines - returns true if inline lists match (case-insensitive...) */ bool match_inlines(element *l1, element *l2); /* find_reference - return true if link found in references matching label. * 'link' is modified with the matching url and title. */ -bool find_reference(link *result, element *label); +bool find_reference(markdown_parser_state *state, link *result, element *label); /* find_note - return true if note found in notes matching label. if found, 'result' is set to point to matched note. */ -bool find_note(element **result, char *label); +bool find_note(markdown_parser_state *state, element **result, char *label); char *label_from_string(char *str, bool obfuscate); void localize_typography(GString *out, int character, int language, int output); void print_raw_element_list(GString *out, element *list); void append_list(element *new, element *list); -bool find_label(link *result, element *label); -bool check_timeout(); +bool find_label(markdown_parser_state *state, link *result, element *label); +bool check_timeout(markdown_parser_state *state); void trim_trailing_whitespace(char *str); char *label_from_element_list(element *list, bool obfuscate); void print_raw_element_list(GString *out, element *list); void print_raw_element(GString *out, element *elt); +char read_character(markdown_parser_state *state); +void next_character(markdown_parser_state *state); + #endif From 69c0056d2b27ee082e472db2195c9a7a643d392b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 18:00:42 +0100 Subject: [PATCH 20/97] Do not use a function call for reading characters --- markdown_parser.leg | 4 ++-- parsing_functions.c | 2 +- utility_functions.c | 10 ---------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 3ebafb27..07bcc1f2 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -41,9 +41,9 @@ #define YY_INPUT(buf, result, max_size) \ { \ - int yyc = read_character(ctx->state); \ + int yyc = *(ctx->state->charbuf); \ if (ctx->state->charbuf && *(ctx->state->charbuf) != '\0') { \ - next_character(ctx->state);\ + ctx->state->charbuf ++;\ } else { \ yyc= EOF; \ } \ diff --git a/parsing_functions.c b/parsing_functions.c index 9d529cb6..9e45084f 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -29,7 +29,7 @@ void free_element_list(element * elt) { elt = next; } } - + /* free_element_contents - free element contents depending on type */ static void free_element_contents(element elt) { switch (elt.key) { diff --git a/utility_functions.c b/utility_functions.c index 05ed9d2b..6a3f9928 100644 --- a/utility_functions.c +++ b/utility_functions.c @@ -519,13 +519,3 @@ bool check_timeout(markdown_parser_state *state) { } return 1; } - -char read_character(markdown_parser_state *state) -{ - return *(state->charbuf); -} - -void next_character(markdown_parser_state *state) -{ - state->charbuf ++; -} From 630cf23187fdf638f6d1756223a9db8daef1b24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 22:24:23 +0100 Subject: [PATCH 21/97] Free parsing context element --- parsing_functions.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parsing_functions.c b/parsing_functions.c index 9e45084f..4b4b655c 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -112,6 +112,8 @@ yycontext* create_parsing_context(char *string, int extensions, element *referen void free_parsing_context(yycontext *context) { + free(context->thunks); + free(context->state); free(context); } From f7a1eff6ec161be74357da81835880b318bb8eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 6 Mar 2013 23:21:08 +0100 Subject: [PATCH 22/97] Fixes memory leaks in libMMD --- markdown_parser_lib.c | 2 -- parsing_functions.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/markdown_parser_lib.c b/markdown_parser_lib.c index 1ecd3631..4dd35a74 100644 --- a/markdown_parser_lib.c +++ b/markdown_parser_lib.c @@ -20,8 +20,6 @@ element *markdown_to_ast(const char *markdownString, int extensions) element *notes; element *labels; GString *formatted_text; - GString *out; - out = g_string_new(""); formatted_text = preformat_text((char*)markdownString); diff --git a/parsing_functions.c b/parsing_functions.c index 4b4b655c..e90f9e4f 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -112,6 +112,8 @@ yycontext* create_parsing_context(char *string, int extensions, element *referen void free_parsing_context(yycontext *context) { + free(context->buf); + free(context->text); free(context->thunks); free(context->state); From 388e2fae2168ad98d44d1b58d0c9dfa51054fedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 7 Mar 2013 12:42:56 +0100 Subject: [PATCH 23/97] Allow to keep inline tags in AST if requested --- markdown_lib.h | 1 + markdown_parser.leg | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/markdown_lib.h b/markdown_lib.h index 2e7b33a5..d183eefb 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -13,6 +13,7 @@ enum markdown_extensions { EXT_COMPATIBILITY = 1 << 4, EXT_PROCESS_HTML = 1 << 5, EXT_NO_LABELS = 1 << 6, + EXT_KEEP_TAGS = 1 << 7 }; enum markdown_formats { diff --git a/markdown_parser.leg b/markdown_parser.leg index 07bcc1f2..6d3111ec 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -631,7 +631,9 @@ EmphStar = '*' !Whitespace | b:StrongStar { a = cons(b, a); } )+ '*' - { $$ = mk_list(EMPH, a); } + { $$ = mk_list(EMPH, a); + if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "*"; + } EmphUl = '_' !Whitespace a:StartList @@ -639,7 +641,9 @@ EmphUl = '_' !Whitespace | b:StrongUl { a = cons(b, a); } )+ '_' - { $$ = mk_list(EMPH, a); } + { $$ = mk_list(EMPH, a); + if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "_"; + } Strong = StrongStar | StrongUl @@ -647,13 +651,17 @@ StrongStar = "**" !Whitespace a:StartList ( !"**" b:Inline { a = cons(b, a); })+ "**" - { $$ = mk_list(STRONG, a); } + { $$ = mk_list(STRONG, a); + if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "**"; + } StrongUl = "__" !Whitespace a:StartList ( !"__" b:Inline { a = cons(b, a); })+ "__" - { $$ = mk_list(STRONG, a); } + { $$ = mk_list(STRONG, a); + if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "__"; + } ImageBlock = Image Sp Newline BlankLine+ From 0a60375fa29b08585a32f09f73ff7d809b5f857e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 7 Mar 2013 15:23:24 +0100 Subject: [PATCH 24/97] ULYSSES-2280 Provide list enumerator to markdown AST --- markdown_parser.leg | 14 ++++++++++---- parsing_functions.c | 5 ++++- utility_functions.c | 12 ++++++++++++ utility_functions.h | 4 +--- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 6d3111ec..f3a04390 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -226,11 +226,14 @@ HorizontalRule = NonindentSpace Sp Newline BlankLine+ { $$ = mk_element(HRULE); } -Bullet = !HorizontalRule NonindentSpace ('+' | '*' | '-') Spacechar+ +Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') Spacechar+ > + {{ $$ = mk_str(yytext); }} BulletList = &Bullet (ListTight | ListLoose) { $$->key = BULLETLIST; } +BulletOrEnum = ( Bullet | Enumerator ) + ListTight = a:StartList ( ListItemTight { a = cons($$, a); } )+ BlankLine* !(Bullet | Enumerator) @@ -246,7 +249,7 @@ ListLoose = a:StartList } )+ { $$ = mk_list(LIST, a); } -ListItem = ( Bullet | Enumerator ) +ListItem = m:BulletOrEnum a:StartList ListBlock { a = cons($$, a); } ( ListContinuationBlock { a = cons($$, a); } )* @@ -255,10 +258,11 @@ ListItem = ( Bullet | Enumerator ) raw->key = RAW; $$ = mk_element(LISTITEM); $$->children = raw; + if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = string_from_element_list(m, true); } ListItemTight = - ( Bullet | Enumerator ) + m:BulletOrEnum a:StartList ListBlock { a = cons($$, a); } ( !BlankLine @@ -269,6 +273,7 @@ ListItemTight = raw->key = RAW; $$ = mk_element(LISTITEM); $$->children = raw; + if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = string_from_element_list(m, true); } ListBlock = a:StartList @@ -285,7 +290,8 @@ ListContinuationBlock = a:StartList ( Indent ListBlock { a = cons($$, a); } )+ { $$ = mk_str_from_list(a, false); } -Enumerator = NonindentSpace [0-9]+ '.' Spacechar+ +Enumerator = < NonindentSpace [0-9]+ '.' Spacechar+ > + {{ $$ = mk_str(yytext); }} OrderedList = &Enumerator (ListTight | ListLoose) { $$->key = ORDEREDLIST; } diff --git a/parsing_functions.c b/parsing_functions.c index e90f9e4f..46d7dcbb 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -56,7 +56,10 @@ static void free_element_contents(element elt) { case ENDASH: case GLOSSARYSORTKEY: case MATHSPAN: - free(elt.contents.str); + case LISTITEM: + if (elt.contents.str) + free(elt.contents.str); + elt.contents.str = NULL; break; case LINK: diff --git a/utility_functions.c b/utility_functions.c index 6a3f9928..acfa75c1 100644 --- a/utility_functions.c +++ b/utility_functions.c @@ -231,6 +231,18 @@ void print_raw_element_list(GString *out, element *list) { } } +/* string_from_element_list */ +/* Creates a flat string from an element list */ +char *string_from_element_list(element *list, bool freeList) { + GString *raw = g_string_new(""); + print_raw_element(raw, list); + + if (freeList) + free(list); + + return g_string_free(raw, false); +} + /* label_from_element_list */ /* Returns a null-terminated string, which must be freed after use. */ diff --git a/utility_functions.h b/utility_functions.h index b1685ffe..1adb6a18 100644 --- a/utility_functions.h +++ b/utility_functions.h @@ -78,6 +78,7 @@ if found, 'result' is set to point to matched note. */ bool find_note(markdown_parser_state *state, element **result, char *label); +char *string_from_element_list(element *list, bool freeList); char *label_from_string(char *str, bool obfuscate); void localize_typography(GString *out, int character, int language, int output); @@ -90,8 +91,5 @@ char *label_from_element_list(element *list, bool obfuscate); void print_raw_element_list(GString *out, element *list); void print_raw_element(GString *out, element *elt); -char read_character(markdown_parser_state *state); -void next_character(markdown_parser_state *state); - #endif From 3bed070aa322a5e35da92978d7316f2cff829756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 7 Mar 2013 16:29:32 +0100 Subject: [PATCH 25/97] Remove extension request for storing tags --- markdown_lib.h | 3 +-- markdown_parser.leg | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/markdown_lib.h b/markdown_lib.h index d183eefb..b2c0afc3 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -12,8 +12,7 @@ enum markdown_extensions { EXT_FILTER_STYLES = 1 << 3, EXT_COMPATIBILITY = 1 << 4, EXT_PROCESS_HTML = 1 << 5, - EXT_NO_LABELS = 1 << 6, - EXT_KEEP_TAGS = 1 << 7 + EXT_NO_LABELS = 1 << 6 }; enum markdown_formats { diff --git a/markdown_parser.leg b/markdown_parser.leg index f3a04390..1da5de6e 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -258,7 +258,7 @@ ListItem = m:BulletOrEnum raw->key = RAW; $$ = mk_element(LISTITEM); $$->children = raw; - if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = string_from_element_list(m, true); + $$->contents.str = string_from_element_list(m, true); } ListItemTight = @@ -273,7 +273,7 @@ ListItemTight = raw->key = RAW; $$ = mk_element(LISTITEM); $$->children = raw; - if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = string_from_element_list(m, true); + $$->contents.str = string_from_element_list(m, true); } ListBlock = a:StartList @@ -638,7 +638,7 @@ EmphStar = '*' !Whitespace )+ '*' { $$ = mk_list(EMPH, a); - if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "*"; + $$->contents.str = "*"; } EmphUl = '_' !Whitespace @@ -648,7 +648,7 @@ EmphUl = '_' !Whitespace )+ '_' { $$ = mk_list(EMPH, a); - if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "_"; + $$->contents.str = "_"; } Strong = StrongStar | StrongUl @@ -658,7 +658,7 @@ StrongStar = "**" !Whitespace ( !"**" b:Inline { a = cons(b, a); })+ "**" { $$ = mk_list(STRONG, a); - if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "**"; + $$->contents.str = "**"; } StrongUl = "__" !Whitespace @@ -666,7 +666,7 @@ StrongUl = "__" !Whitespace ( !"__" b:Inline { a = cons(b, a); })+ "__" { $$ = mk_list(STRONG, a); - if (extension(ctx->state, EXT_KEEP_TAGS)) $$->contents.str = "__"; + $$->contents.str = "__"; } From e08dd0b4ee086977dd72c5156ab26c2e15bfab08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 7 Mar 2013 20:04:20 +0100 Subject: [PATCH 26/97] ULYSSES-2281 Keep whitespaces during parse --- markdown_lib.h | 3 ++- markdown_parser.leg | 44 ++++++++++++++++++++++++++++++++++++-------- utility_functions.c | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/markdown_lib.h b/markdown_lib.h index b2c0afc3..e00c2e85 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -12,7 +12,8 @@ enum markdown_extensions { EXT_FILTER_STYLES = 1 << 3, EXT_COMPATIBILITY = 1 << 4, EXT_PROCESS_HTML = 1 << 5, - EXT_NO_LABELS = 1 << 6 + EXT_NO_LABELS = 1 << 6, + EXT_KEEP_WHITESPACES = 1 << 7 }; enum markdown_formats { diff --git a/markdown_parser.leg b/markdown_parser.leg index 1da5de6e..5bb116d5 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -159,8 +159,16 @@ HeadingSectionBlock = | !(Sp? HtmlBlockOpenDiv) Para | Plain ) -Para = NonindentSpace a:Inlines BlankLine+ - { $$ = a; $$->key = PARA; } +Para = s:CapturingNonindentSpace { } + a:Inlines + BlankLine+ + { + if (s) + a->children = cons(s, a->children); + + $$ = a; + $$->key = PARA; + } Plain = a:Inlines { $$ = a; $$->key = PLAIN; } @@ -226,7 +234,7 @@ HorizontalRule = NonindentSpace Sp Newline BlankLine+ { $$ = mk_element(HRULE); } -Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') Spacechar+ > +Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') > &(Spacechar+) {{ $$ = mk_str(yytext); }} BulletList = &Bullet (ListTight | ListLoose) @@ -251,19 +259,24 @@ ListLoose = a:StartList ListItem = m:BulletOrEnum a:StartList + s:Space { if (extension(ctx->state, EXT_KEEP_WHITESPACES)) a = cons(s, a); } ListBlock { a = cons($$, a); } ( ListContinuationBlock { a = cons($$, a); } )* - { element *raw; + { + element *raw; raw = mk_str_from_list(a, false); - raw->key = RAW; + + raw->key = RAW; $$ = mk_element(LISTITEM); $$->children = raw; + $$->contents.str = string_from_element_list(m, true); } ListItemTight = m:BulletOrEnum a:StartList + s:Space { if (extension(ctx->state, EXT_KEEP_WHITESPACES)) a = cons(s, a); } ListBlock { a = cons($$, a); } ( !BlankLine ListContinuationBlock { a = cons($$, a); } )* @@ -290,7 +303,7 @@ ListContinuationBlock = a:StartList ( Indent ListBlock { a = cons($$, a); } )+ { $$ = mk_str_from_list(a, false); } -Enumerator = < NonindentSpace [0-9]+ '.' Spacechar+ > +Enumerator = < NonindentSpace [0-9]+ '.' > &(Spacechar+) {{ $$ = mk_str(yytext); }} OrderedList = &Enumerator (ListTight | ListLoose) @@ -585,8 +598,13 @@ Inline = &{ check_timeout(ctx->state) } | Smart | Symbol -Space = Spacechar+ - { $$ = mk_str(" "); +Space = < Spacechar+ > + { + if (extension(ctx->state, EXT_KEEP_WHITESPACES)) + $$ = mk_str(yytext); + else + $$ = mk_str(" "); + $$->key = SPACE; } Str = a:StartList < NormalChar+ > { a = cons(mk_str(yytext), a); } @@ -903,6 +921,16 @@ Indent = "\t" | " " IndentedLine = Indent Line OptionallyIndentedLine = Indent? Line +CapturingNonindentSpace = + { + if (extension(ctx->state, EXT_KEEP_WHITESPACES)) { + $$ = mk_str(yytext); + $$->key = SPACE; + } + else + $$ = NULL; + } + # StartList starts a list data structure that can be added to with cons: StartList = &. { $$ = NULL; } diff --git a/utility_functions.c b/utility_functions.c index acfa75c1..85dd21ea 100644 --- a/utility_functions.c +++ b/utility_functions.c @@ -53,7 +53,7 @@ GString *concat_string_list(element *list) { element *next; result = g_string_new(""); while (list != NULL) { - assert(list->key == STR); + assert(list->key == STR || list->key == SPACE); assert(list->contents.str != NULL); g_string_append(result, list->contents.str); next = list->next; From 05fe616c54a58328d4b274abfef6112309b85968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Fri, 8 Mar 2013 14:46:29 +0100 Subject: [PATCH 27/97] Adapt to recent XCode --- MultiMarkdown.xcodeproj/project.pbxproj | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index ae32d557..4910fafc 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXAggregateTarget section */ @@ -300,10 +300,10 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0410; + LastUpgradeCheck = 0460; }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MultiMarkdown" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( @@ -440,7 +440,6 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; SDKROOT = macosx; }; name = Debug; @@ -457,7 +456,6 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.4; - PREBINDING = NO; SDKROOT = macosx; }; name = Release; @@ -467,6 +465,7 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., @@ -481,6 +480,7 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., @@ -495,6 +495,7 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., @@ -516,7 +517,6 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.4; - PREBINDING = NO; SDKROOT = macosx; }; name = "Release10.6+"; @@ -535,9 +535,9 @@ 651A542A13E20D2400BCB02A /* Release10.6+ */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = Peg; ZERO_LINK = NO; }; @@ -546,9 +546,9 @@ 651A542B13E20D2400BCB02A /* Release10.6+ */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = "MultiMarkdown Tests"; ZERO_LINK = NO; }; @@ -557,6 +557,7 @@ 65F0B88913DF6C0D00D0980C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -567,9 +568,9 @@ 65F0B88A13DF6C0D00D0980C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = Peg; ZERO_LINK = NO; }; @@ -578,6 +579,7 @@ 65F0B8EB13DF714F00D0980C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -588,9 +590,9 @@ 65F0B8EC13DF714F00D0980C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; PRODUCT_NAME = "MultiMarkdown Tests"; ZERO_LINK = NO; }; From 0f8e21249a79da30913d97beae4b8b75d056823f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Fri, 8 Mar 2013 16:05:04 +0100 Subject: [PATCH 28/97] Keep newlines in headings done properly --- markdown_parser.leg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 5bb116d5..9d9f8e69 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -178,7 +178,7 @@ AtxInline = !Newline !( &{ !extension(ctx->state, EXT_COMPATIBILITY) } Sp AutoLa AtxStart = < ( "######" | "#####" | "####" | "###" | "##" | "#" ) > { $$ = mk_element(H1 + (strlen(yytext) - 1)); } -AtxHeading = s:AtxStart Sp? a:StartList ( AtxInline { a = cons($$, a); } )+ ( Sp? b:AutoLabel { append_list(b,a);})? (Sp? '#'* Sp)? Newline +AtxHeading = s:AtxStart Sp? a:StartList ( AtxInline { a = cons($$, a); } (l:LineBreak { a = cons(l, a); })? )+ ( Sp? b:AutoLabel { append_list(b,a);})? (Sp? '#'* Sp)? Newline { $$ = mk_list(s->key,a); free(s); } From 9d5e4889bc7bd3789706f3122e1b44e6a2fdb52a Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Sun, 10 Mar 2013 16:03:34 +0100 Subject: [PATCH 29/97] Do not install. Signed-off-by: Max Seelemann --- Configuration/Release.xcconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/Configuration/Release.xcconfig b/Configuration/Release.xcconfig index 4cd5500b..eb5e5b83 100644 --- a/Configuration/Release.xcconfig +++ b/Configuration/Release.xcconfig @@ -11,3 +11,4 @@ COPY_PHASE_STRIP = NO STRIP_INSTALLED_PRODUCT = YES SEPARATE_STRIP = YES +SKIP_INSTALL = YES From a95d450229625f4930de3e723f5dafe03261d68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Mon, 11 Mar 2013 15:28:17 +0100 Subject: [PATCH 30/97] Do not close HTML blocks when containg markdown placeholder --- markdown_parser.leg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 9d9f8e69..11da7929 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -534,7 +534,7 @@ HtmlBlockInTags = HtmlBlockAddress | HtmlBlockTr | HtmlBlockScript -HtmlBlock = !MarkdownHtmlTagOpen < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing ) > +HtmlBlock = !MarkdownHtmlTagOpen < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing ) > ("")? BlankLine+ { if (extension(ctx->state, EXT_FILTER_HTML)) { $$ = mk_list(LIST, NULL); From 325969ab8428482bf7174bc9fd94a3961aebee3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Mon, 11 Mar 2013 21:32:52 +0100 Subject: [PATCH 31/97] Do not parse for magic character --- markdown_parser.leg | 2 +- parsing_functions.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 11da7929..2dd00328 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -534,7 +534,7 @@ HtmlBlockInTags = HtmlBlockAddress | HtmlBlockTr | HtmlBlockScript -HtmlBlock = !MarkdownHtmlTagOpen < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing ) > ("")? +HtmlBlock = !MarkdownHtmlTagOpen < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing ) > BlankLine+ { if (extension(ctx->state, EXT_FILTER_HTML)) { $$ = mk_list(LIST, NULL); diff --git a/parsing_functions.c b/parsing_functions.c index 46d7dcbb..5ec6207e 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -123,8 +123,6 @@ void free_parsing_context(yycontext *context) free(context); } - - element * parse_references(char *string, int extensions) { yycontext *context = create_parsing_context(string, extensions, NULL, NULL, NULL); @@ -174,7 +172,6 @@ element * parse_markdown(char *string, int extensions, element *reference_list, free_parsing_context(context); return parse_result; - } element * parse_markdown_with_metadata(char *string, int extensions, element *reference_list, element *note_list, element *label_list) { From 955c453110d92f5235ec9e10e6044ac053cc8475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 20 Mar 2013 12:16:39 +0100 Subject: [PATCH 32/97] Keep spaces in markdown enumerators --- markdown_parser.leg | 7 +++---- parsing_functions.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 2dd00328..7d68af44 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -234,7 +234,7 @@ HorizontalRule = NonindentSpace Sp Newline BlankLine+ { $$ = mk_element(HRULE); } -Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') > &(Spacechar+) +Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') ( &{ extension(ctx->state, EXT_KEEP_WHITESPACES)} Spacechar)? > &(Spacechar*) {{ $$ = mk_str(yytext); }} BulletList = &Bullet (ListTight | ListLoose) @@ -259,7 +259,6 @@ ListLoose = a:StartList ListItem = m:BulletOrEnum a:StartList - s:Space { if (extension(ctx->state, EXT_KEEP_WHITESPACES)) a = cons(s, a); } ListBlock { a = cons($$, a); } ( ListContinuationBlock { a = cons($$, a); } )* { @@ -273,10 +272,10 @@ ListItem = m:BulletOrEnum $$->contents.str = string_from_element_list(m, true); } + ListItemTight = m:BulletOrEnum a:StartList - s:Space { if (extension(ctx->state, EXT_KEEP_WHITESPACES)) a = cons(s, a); } ListBlock { a = cons($$, a); } ( !BlankLine ListContinuationBlock { a = cons($$, a); } )* @@ -303,7 +302,7 @@ ListContinuationBlock = a:StartList ( Indent ListBlock { a = cons($$, a); } )+ { $$ = mk_str_from_list(a, false); } -Enumerator = < NonindentSpace [0-9]+ '.' > &(Spacechar+) +Enumerator = < NonindentSpace [0-9]+ '.' ( &{ extension(ctx->state, EXT_KEEP_WHITESPACES)} Spacechar)? > &(Spacechar*) {{ $$ = mk_str(yytext); }} OrderedList = &Enumerator (ListTight | ListLoose) diff --git a/parsing_functions.c b/parsing_functions.c index 5ec6207e..cdf9652e 100644 --- a/parsing_functions.c +++ b/parsing_functions.c @@ -29,7 +29,7 @@ void free_element_list(element * elt) { elt = next; } } - + /* free_element_contents - free element contents depending on type */ static void free_element_contents(element elt) { switch (elt.key) { From 81ac3938b05c8e9ee03d4be1da93c73ed12894f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Wed, 20 Mar 2013 13:53:00 +0100 Subject: [PATCH 33/97] Fix parsing of bullet point whitespaces to match ulysses --- markdown_parser.leg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 7d68af44..1df9a815 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -234,7 +234,7 @@ HorizontalRule = NonindentSpace Sp Newline BlankLine+ { $$ = mk_element(HRULE); } -Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') ( &{ extension(ctx->state, EXT_KEEP_WHITESPACES)} Spacechar)? > &(Spacechar*) +Bullet = !HorizontalRule < NonindentSpace ('+' | '*' | '-') Spacechar > &(Spacechar*) {{ $$ = mk_str(yytext); }} BulletList = &Bullet (ListTight | ListLoose) @@ -302,7 +302,7 @@ ListContinuationBlock = a:StartList ( Indent ListBlock { a = cons($$, a); } )+ { $$ = mk_str_from_list(a, false); } -Enumerator = < NonindentSpace [0-9]+ '.' ( &{ extension(ctx->state, EXT_KEEP_WHITESPACES)} Spacechar)? > &(Spacechar*) +Enumerator = < NonindentSpace [0-9]+ '.' Spacechar > &(Spacechar*) {{ $$ = mk_str(yytext); }} OrderedList = &Enumerator (ListTight | ListLoose) From 95cfa57bcad3bd214cb042c2cc7af7d119e6ece3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 11 Apr 2013 15:34:35 +0200 Subject: [PATCH 34/97] Provide an option for keeping escapes --- markdown_lib.h | 3 ++- markdown_parser.leg | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/markdown_lib.h b/markdown_lib.h index e00c2e85..bec131a7 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -13,7 +13,8 @@ enum markdown_extensions { EXT_COMPATIBILITY = 1 << 4, EXT_PROCESS_HTML = 1 << 5, EXT_NO_LABELS = 1 << 6, - EXT_KEEP_WHITESPACES = 1 << 7 + EXT_KEEP_WHITESPACES = 1 << 7, + EXT_KEEP_ESCAPES = 1 << 8 }; enum markdown_formats { diff --git a/markdown_parser.leg b/markdown_parser.leg index 1df9a815..aef346f4 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -593,7 +593,8 @@ Inline = &{ check_timeout(ctx->state) } | MarkdownHtmlTagOpen | RawHtml | Entity - | EscapedChar + | &{ !extension(ctx->state, EXT_KEEP_ESCAPES) }EscapedChar + | &{ extension(ctx->state, EXT_KEEP_ESCAPES) }KeptEscapedChar | Smart | Symbol @@ -619,6 +620,9 @@ AposChunk = &{ extension(ctx->state, EXT_SMART) } '\'' &Alphanumeric EscapedChar = '\\' !Newline < [-\\`|*_{}[\]()#+.!><] > { $$ = mk_str(yytext); } +KeptEscapedChar = < '\\' !Newline [-\\`|*_{}[\]()#+.!><] > + { $$ = mk_str(yytext); } + Entity = ( HexEntity | DecEntity | CharEntity ) { $$ = mk_str(yytext); $$->key = HTML; } From b1dde761b07e4123ebcca741b8b16bcec46a76e6 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Wed, 17 Apr 2013 11:37:20 +0200 Subject: [PATCH 35/97] Added ARMv7s compiling. Signed-off-by: Max Seelemann --- Configuration/Common.xcconfig | 4 ++-- MultiMarkdown.xcodeproj/project.pbxproj | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Configuration/Common.xcconfig b/Configuration/Common.xcconfig index 0697c15b..de43716d 100644 --- a/Configuration/Common.xcconfig +++ b/Configuration/Common.xcconfig @@ -8,9 +8,9 @@ SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator ARCHS[sdk=macosx*] = i386 x86_64 -ARCHS[sdk=iphoneos*] = armv6 armv7 +ARCHS[sdk=iphoneos*] = armv7 armv7s ARCHS[sdk=iphonesimulator*] = i386 -VALID_ARCHS[sdk=iphoneos*] = armv6 armv7 +VALID_ARCHS[sdk=iphoneos*] = armv7 armv7s VALID_ARCHS[sdk=iphonesimulator*] = i386 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym GCC_VERSION = diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 4910fafc..15ac3cea 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -465,12 +465,15 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., "peg-0.1.9/", ); + HEADER_SEARCH_PATHS = .; + INSTALL_PATH = "@rpath"; + MACOSX_DEPLOYMENT_TARGET = 10.6.8; + ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = MultiMarkdown; }; name = Debug; From 75648201fc1ea327d84e2e19416a8f652b73ff09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 16 May 2013 11:03:03 +0200 Subject: [PATCH 36/97] Fixes project file to recognize changes in .leg file --- MultiMarkdown.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 4910fafc..9a8d75a7 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -331,9 +331,11 @@ files = ( ); inputPaths = ( + "$(SRCROOT)/markdown_parser.leg", ); name = "Generate Parser"; outputPaths = ( + "$(SRCROOT)/markdown_parser.c", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; From 036c11e00145e8f1778ddd71506213877502a33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 16 May 2013 11:03:21 +0200 Subject: [PATCH 37/97] ULYSSES-2798 Keep magic blank lines --- markdown_lib.h | 19 ++++++++++--------- markdown_parser.leg | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/markdown_lib.h b/markdown_lib.h index bec131a7..e7c6a867 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -6,15 +6,16 @@ #include "glib.h" enum markdown_extensions { - EXT_SMART = 1 << 0, - EXT_NOTES = 1 << 1, - EXT_FILTER_HTML = 1 << 2, - EXT_FILTER_STYLES = 1 << 3, - EXT_COMPATIBILITY = 1 << 4, - EXT_PROCESS_HTML = 1 << 5, - EXT_NO_LABELS = 1 << 6, - EXT_KEEP_WHITESPACES = 1 << 7, - EXT_KEEP_ESCAPES = 1 << 8 + EXT_SMART = 1 << 0, + EXT_NOTES = 1 << 1, + EXT_FILTER_HTML = 1 << 2, + EXT_FILTER_STYLES = 1 << 3, + EXT_COMPATIBILITY = 1 << 4, + EXT_PROCESS_HTML = 1 << 5, + EXT_NO_LABELS = 1 << 6, + EXT_KEEP_WHITESPACES = 1 << 7, + EXT_KEEP_ESCAPES = 1 << 8, + EXT_KEEP_MAGIC_BLANK_LINES = 1 << 9 }; enum markdown_formats { diff --git a/markdown_parser.leg b/markdown_parser.leg index aef346f4..f874783f 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -277,7 +277,7 @@ ListItemTight = m:BulletOrEnum a:StartList ListBlock { a = cons($$, a); } - ( !BlankLine + ( !MagicBlankLine ListContinuationBlock { a = cons($$, a); } )* !ListContinuationBlock { element *raw; @@ -289,14 +289,18 @@ ListItemTight = } ListBlock = a:StartList - !BlankLine Line { a = cons($$, a); } + !MagicBlankLine Line { a = cons($$, a); } ( ListBlockLine { a = cons($$, a); } )* { $$ = mk_str_from_list(a, false); } ListContinuationBlock = a:StartList - ( < BlankLine* > - { if (strlen(yytext) == 0) + ( < MagicBlankLine* > + { if (strlen(yytext) == 0) { + if (extension(ctx->state, EXT_KEEP_MAGIC_BLANK_LINES)) + a = cons(mk_str(yytext), a); + a = cons(mk_str("\001"), a); /* block separator */ + } else a = cons(mk_str(yytext), a); } ) ( Indent ListBlock { a = cons($$, a); } )+ @@ -308,7 +312,7 @@ Enumerator = < NonindentSpace [0-9]+ '.' Spacechar > &(Spacechar*) OrderedList = &Enumerator (ListTight | ListLoose) { $$->key = ORDEREDLIST; } -ListBlockLine = !BlankLine +ListBlockLine = !MagicBlankLine !( Indent? (Bullet | Enumerator) ) !HorizontalRule OptionallyIndentedLine @@ -898,6 +902,10 @@ RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) > BlankLine = Sp Newline +# PEG doesn't support \uXXXX characters, so we encode \ueeee as octal byte sequence + +MagicBlankLine = ( &{ extension(ctx->state, EXT_KEEP_MAGIC_BLANK_LINES) } '\356' '\273' '\256')? Sp Newline + Quoted = '"' (!'"' .)* '"' | '\'' (!'\'' .)* '\'' HtmlAttribute = (AlphanumericAscii | '-')+ Spnl ('=' Spnl (Quoted | (!'>' Nonspacechar)+))? Spnl HtmlComment = "" .)* "-->" From 5f041e55c2664cd339ba95a379f12441087ce4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 16 May 2013 14:50:32 +0200 Subject: [PATCH 38/97] ULYSSES-2800 Support for magic blank lines in foot notes --- markdown_parser.leg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index f874783f..61affada 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -951,8 +951,8 @@ Line = RawLine RawLine = ( < (!'\r' !'\n' .)* Newline > | < .+ > Eof ) SkipBlock = HtmlBlock - | ( !'#' !SetextBottom1 !SetextBottom2 !BlankLine RawLine )+ BlankLine* - | BlankLine+ + | ( !'#' !SetextBottom1 !SetextBottom2 !MagicBlankLine RawLine )+ MagicBlankLine* + | MagicBlankLine+ | RawLine @@ -1073,8 +1073,8 @@ Notes = a:StartList { ctx->state->notes = reverse(a); } RawNoteBlock = a:StartList - ( !BlankLine OptionallyIndentedLine { a = cons($$, a); } )+ - ( < BlankLine* > { a = cons(mk_str(yytext), a); } ) + ( !MagicBlankLine OptionallyIndentedLine { a = cons($$, a); } )+ + ( < MagicBlankLine* > { a = cons(mk_str(yytext), a); } ) { $$ = mk_str_from_list(a, true); $$->key = RAW; } From a95d9795c60f31741b1b9228378ab33722f524c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 16 May 2013 16:31:58 +0200 Subject: [PATCH 39/97] ULYSSES-2792 Reference lists should consume magic blank lines --- markdown_parser.leg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 61affada..663237ca 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -799,7 +799,7 @@ Reference = a:StartList NonindentSpace !"[]" l:Label ':' Spnl s:RefSrc t:RefTitle ( &{ !extension(ctx->state, EXT_COMPATIBILITY) } (Attributes { a = cons($$,a);})? )? - BlankLine+ + MagicBlankLine+ { char *label; GString *text = g_string_new(""); From 9d15b72a499af3e6c6d82d595d31a217e4d01366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 16 May 2013 17:07:20 +0200 Subject: [PATCH 40/97] ULYSSES-2799 Consume magic blank lines inside code blocks --- markdown_parser.leg | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 663237ca..e38e0dca 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -218,12 +218,20 @@ BlockQuoteRaw = a:StartList NonblankIndentedLine = !BlankLine IndentedLine -VerbatimChunk = a:StartList - ( BlankLine { a = cons(mk_str("\n"), a); } )* +FirstVerbatimChunk = a:StartList ( NonblankIndentedLine { a = cons($$, a); } )+ { $$ = mk_str_from_list(a, false); } -Verbatim = a:StartList ( VerbatimChunk { a = cons($$, a); } )+ BlankLine* +FollowingVerbatimChunk = a:StartList + ( MagicBlankLine { a = cons(mk_str("\n"), a); } )* + ( NonblankIndentedLine { a = cons($$, a); } )+ + { $$ = mk_str_from_list(a, false); } + + +Verbatim = a:StartList + FirstVerbatimChunk { a = cons($$, a); } + ( FollowingVerbatimChunk { a = cons($$, a); } )* + BlankLine* { $$ = mk_str_from_list(a, false); $$->key = VERBATIM; } From f77284fc50df62c7ec2526a47bf9124260607c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 16 May 2013 20:12:09 +0200 Subject: [PATCH 41/97] Fixes a project setting --- MultiMarkdown.xcodeproj/project.pbxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index d70500c6..6dafb0a9 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -472,7 +472,6 @@ ., "peg-0.1.9/", ); - HEADER_SEARCH_PATHS = .; INSTALL_PATH = "@rpath"; MACOSX_DEPLOYMENT_TARGET = 10.6.8; ONLY_ACTIVE_ARCH = NO; From c2a0ba03326ffd0fe245629ad082a0fa137a6a96 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Tue, 18 Jun 2013 12:46:42 +0200 Subject: [PATCH 42/97] Updated Project. Signed-off-by: Max Seelemann --- MultiMarkdown.xcodeproj/project.pbxproj | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 6dafb0a9..485e742e 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -300,7 +300,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0460; + LastUpgradeCheck = 0500; }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MultiMarkdown" */; compatibilityVersion = "Xcode 3.2"; @@ -432,11 +432,6 @@ 1DEB928A08733DD80010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -449,11 +444,6 @@ 1DEB928B08733DD80010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -512,11 +502,6 @@ 651A542813E20D2400BCB02A /* Release10.6+ */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; From 975c6e5486689bc876af73598a45d8ae51f0ae35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Tue, 7 Jan 2014 16:40:32 +0100 Subject: [PATCH 43/97] Ignore three-dash separators to be compatible with Jekyll frontmatter --- markdown_parser.leg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index e38e0dca..53417994 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -237,7 +237,7 @@ Verbatim = a:StartList HorizontalRule = NonindentSpace ( '*' Sp '*' Sp '*' (Sp '*')* - | '-' Sp '-' Sp '-' (Sp '-')* + | '-' Sp '-' Sp '-' Sp '-' (Sp '-')* | '_' Sp '_' Sp '_' (Sp '_')*) Sp Newline BlankLine+ { $$ = mk_element(HRULE); } From 50d50cad81c2616dc13d899e16254570821ad945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Tue, 7 Jan 2014 16:56:20 +0100 Subject: [PATCH 44/97] Replace strtok by strsep --- markdown_lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/markdown_lib.c b/markdown_lib.c index a556d2a3..3a8c20e2 100644 --- a/markdown_lib.c +++ b/markdown_lib.c @@ -122,14 +122,16 @@ element * process_raw_blocks(element *input, int extensions, element *references while (current != NULL) { if (current->key == RAW) { + char *nextString = current->contents.str; + /* \001 is used to indicate boundaries between nested lists when there * is no blank line. We split the string by \001 and parse * each chunk separately. */ - contents = strtok(current->contents.str, "\001"); + contents = strsep(&nextString, "\001"); current->key = LIST; current->children = parse_markdown(contents, extensions, references, notes, labels); last_child = current->children; - while ((contents = strtok(NULL, "\001"))) { + while ((contents = strsep(&nextString, "\001"))) { while (last_child->next != NULL) last_child = last_child->next; last_child->next = parse_markdown(contents, extensions, references, notes, labels); From 48e8756a60ea701e1d7cc0c22ff82892f7a2e23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 8 May 2014 20:38:51 +0200 Subject: [PATCH 45/97] ULYSSES-3966 Ensure whitespaces are kept when keeping inline double links --- markdown_parser.leg | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/markdown_parser.leg b/markdown_parser.leg index 53417994..551363b4 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -619,6 +619,15 @@ Space = < Spacechar+ > $$->key = SPACE; } +OptionalSpace = < Spacechar* > + { + if (extension(ctx->state, EXT_KEEP_WHITESPACES)) + $$ = mk_str(yytext); + else + $$ = mk_str(" "); + + $$->key = SPACE; } + Str = a:StartList < NormalChar+ > { a = cons(mk_str(yytext), a); } ( StrChunk { a = cons($$, a); } )* { if (a->next == NULL) { $$ = a; } else { $$ = mk_list(LIST, a); } } @@ -719,7 +728,7 @@ Link = ExplicitLink | ReferenceLink | AutoLink ReferenceLink = ReferenceLinkDouble | ReferenceLinkSingle -ReferenceLinkDouble = a:Label < Spnl > !"[]" b:Label +ReferenceLinkDouble = a:Label s:OptionalSpace !"[]" b:Label { link match; if (find_reference(ctx->state, &match, b->children)) { $$ = mk_link(a->children, match.url, match.title, match.attr, match.identifier); @@ -741,7 +750,7 @@ ReferenceLinkDouble = a:Label < Spnl > !"[]" b:Label } else { element *result; result = mk_element(LIST); - result->children = cons(mk_str("["), cons(a, cons(mk_str("]"), cons(mk_str("["), cons(b, mk_str("]")))))); + result->children = cons(mk_str("["), cons(a, cons(mk_str("]"), cons(s, cons(mk_str("["), cons(b, mk_str("]"))))))); $$ = result; } } From 8c302c022df1e9e175a15d099176cf93f5ce10d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Thu, 14 Nov 2013 12:32:49 +0100 Subject: [PATCH 46/97] Adaptations for ARM64 --- Configuration/Common.xcconfig | 4 ++-- GLibFacade.h | 4 ++-- markdown_parser.leg | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Configuration/Common.xcconfig b/Configuration/Common.xcconfig index de43716d..75216a8c 100644 --- a/Configuration/Common.xcconfig +++ b/Configuration/Common.xcconfig @@ -8,9 +8,9 @@ SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator ARCHS[sdk=macosx*] = i386 x86_64 -ARCHS[sdk=iphoneos*] = armv7 armv7s +ARCHS[sdk=iphoneos*] = armv7 armv7s arm64 ARCHS[sdk=iphonesimulator*] = i386 -VALID_ARCHS[sdk=iphoneos*] = armv7 armv7s +VALID_ARCHS[sdk=iphoneos*] = armv7 armv7s arm64 VALID_ARCHS[sdk=iphonesimulator*] = i386 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym GCC_VERSION = diff --git a/GLibFacade.h b/GLibFacade.h index 6b5928ab..7f4d175f 100644 --- a/GLibFacade.h +++ b/GLibFacade.h @@ -43,8 +43,8 @@ typedef struct /* Where in the str buffer will we add new characters */ /* or append new strings? */ - int currentStringBufferSize; - int currentStringLength; + size_t currentStringBufferSize; + size_t currentStringLength; } GString; GString* g_string_new(char *startingString); diff --git a/markdown_parser.leg b/markdown_parser.leg index 551363b4..c8db2c4e 100644 --- a/markdown_parser.leg +++ b/markdown_parser.leg @@ -176,7 +176,7 @@ Plain = a:Inlines AtxInline = !Newline !( &{ !extension(ctx->state, EXT_COMPATIBILITY) } Sp AutoLabel Sp? '#'* Sp Newline) !(Sp? '#'* Sp Newline) Inline AtxStart = < ( "######" | "#####" | "####" | "###" | "##" | "#" ) > - { $$ = mk_element(H1 + (strlen(yytext) - 1)); } + { $$ = mk_element(H1 + (int)(strlen(yytext) - 1)); } AtxHeading = s:AtxStart Sp? a:StartList ( AtxInline { a = cons($$, a); } (l:LineBreak { a = cons(l, a); })? )+ ( Sp? b:AutoLabel { append_list(b,a);})? (Sp? '#'* Sp)? Newline { $$ = mk_list(s->key,a); From c0c91a7c0255aa4ff30f0f7f015a19e46e45cc96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Gra=CC=88ter?= Date: Mon, 9 Dec 2013 12:21:36 +0100 Subject: [PATCH 47/97] Fixes an architecture setting --- MultiMarkdown.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 485e742e..7ebf8816 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -457,6 +457,11 @@ baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = ( + armv7, + armv7s, + arm64, + ); GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., @@ -466,6 +471,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.6.8; ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = MultiMarkdown; + "VALID_ARCHS[sdk=iphoneos*]" = "armv7 armv7s arm64"; }; name = Debug; }; @@ -474,6 +480,11 @@ baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = ( + armv7, + armv7s, + arm64, + ); COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( @@ -481,6 +492,7 @@ "peg-0.1.9/", ); PRODUCT_NAME = MultiMarkdown; + "VALID_ARCHS[sdk=iphoneos*]" = "armv7 armv7s arm64"; }; name = Release; }; @@ -489,6 +501,11 @@ baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + "ARCHS[sdk=iphoneos*]" = ( + armv7, + armv7s, + arm64, + ); COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( @@ -496,6 +513,7 @@ "peg-0.1.9/", ); PRODUCT_NAME = MultiMarkdown; + "VALID_ARCHS[sdk=iphoneos*]" = "armv7 armv7s arm64"; }; name = "Release10.6+"; }; From 726d8be6618264e6d1875de32b3836f03f016aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Go=CC=88tz=20Fabian?= Date: Fri, 1 Aug 2014 11:37:45 +0200 Subject: [PATCH 48/97] Fixed architecture settings for iOS simulator. --- MultiMarkdown.xcodeproj/project.pbxproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 7ebf8816..6074be2c 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -462,6 +462,7 @@ armv7s, arm64, ); + "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( ., @@ -472,6 +473,7 @@ ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = MultiMarkdown; "VALID_ARCHS[sdk=iphoneos*]" = "armv7 armv7s arm64"; + "VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64"; }; name = Debug; }; @@ -485,6 +487,7 @@ armv7s, arm64, ); + "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD_32_64_BIT)"; COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( @@ -493,6 +496,7 @@ ); PRODUCT_NAME = MultiMarkdown; "VALID_ARCHS[sdk=iphoneos*]" = "armv7 armv7s arm64"; + "VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64"; }; name = Release; }; @@ -506,6 +510,7 @@ armv7s, arm64, ); + "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD_32_64_BIT)"; COMBINE_HIDPI_IMAGES = YES; GCC_PREPROCESSOR_DEFINITIONS = YY_CTX_LOCAL; HEADER_SEARCH_PATHS = ( @@ -514,6 +519,7 @@ ); PRODUCT_NAME = MultiMarkdown; "VALID_ARCHS[sdk=iphoneos*]" = "armv7 armv7s arm64"; + "VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64"; }; name = "Release10.6+"; }; From 18530b9e73b9349cc927b4804d4326b9aa65edc5 Mon Sep 17 00:00:00 2001 From: Max Seelemann Date: Mon, 22 Sep 2014 23:41:59 +0200 Subject: [PATCH 49/97] Added 64 bit archs. --- Configuration/Common.xcconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/Common.xcconfig b/Configuration/Common.xcconfig index 75216a8c..8dc82aff 100644 --- a/Configuration/Common.xcconfig +++ b/Configuration/Common.xcconfig @@ -9,9 +9,9 @@ SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator ARCHS[sdk=macosx*] = i386 x86_64 ARCHS[sdk=iphoneos*] = armv7 armv7s arm64 -ARCHS[sdk=iphonesimulator*] = i386 +ARCHS[sdk=iphonesimulator*] = i386 x86_64 VALID_ARCHS[sdk=iphoneos*] = armv7 armv7s arm64 -VALID_ARCHS[sdk=iphonesimulator*] = i386 +VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 DEBUG_INFORMATION_FORMAT = dwarf-with-dsym GCC_VERSION = GCC_VERSION[arch=x86_64] = com.apple.compilers.llvm.clang.1_0 From 0cd52f79ec3c9da10279e2933974ac11b20fdc6d Mon Sep 17 00:00:00 2001 From: Friedrich Graeter Date: Wed, 1 Oct 2014 16:36:10 +0200 Subject: [PATCH 50/97] Remove pegleg sources to simplify compilation --- Makefile | 192 ---- MultiMarkdown.xcodeproj/project.pbxproj | 284 +----- leg | Bin 0 -> 56776 bytes peg-0.1.9/Makefile | 65 -- peg-0.1.9/compile.c | 717 -------------- peg-0.1.9/examples/Makefile | 88 -- peg-0.1.9/examples/accept.c | 11 - peg-0.1.9/examples/accept.peg | 8 - peg-0.1.9/examples/accept.ref | 32 - peg-0.1.9/examples/basic.leg | 361 ------- peg-0.1.9/examples/basic.ref | 10 - peg-0.1.9/examples/bench.bas | 8 - peg-0.1.9/examples/calc.leg | 46 - peg-0.1.9/examples/calc.ref | 3 - peg-0.1.9/examples/dc.c | 17 - peg-0.1.9/examples/dc.peg | 27 - peg-0.1.9/examples/dc.ref | 1 - peg-0.1.9/examples/dcv.c | 20 - peg-0.1.9/examples/dcv.peg | 34 - peg-0.1.9/examples/dcv.ref | 3 - peg-0.1.9/examples/fibonacci.bas | 17 - peg-0.1.9/examples/left.c | 17 - peg-0.1.9/examples/left.peg | 3 - peg-0.1.9/examples/localctx.c | 13 - peg-0.1.9/examples/localctx.ref | 10 - peg-0.1.9/examples/rule.c | 11 - peg-0.1.9/examples/rule.peg | 8 - peg-0.1.9/examples/rule.ref | 32 - peg-0.1.9/examples/test.bas | 12 - peg-0.1.9/examples/test.c | 8 - peg-0.1.9/examples/test.peg | 13 - peg-0.1.9/examples/test.ref | 10 - peg-0.1.9/examples/username.leg | 14 - peg-0.1.9/examples/wc.leg | 22 - peg-0.1.9/examples/wc.ref | 55 -- peg-0.1.9/leg.c | 1209 ----------------------- peg-0.1.9/leg.leg | 292 ------ peg-0.1.9/peg.1 | 933 ----------------- peg-0.1.9/peg.c | 173 ---- peg-0.1.9/peg.peg | 77 -- peg-0.1.9/peg.peg-c | 912 ----------------- peg-0.1.9/tree.c | 352 ------- peg-0.1.9/version.h | 3 - peg-0.1.9/tree.h => tree.h | 0 44 files changed, 1 insertion(+), 6122 deletions(-) delete mode 100644 Makefile create mode 100755 leg delete mode 100644 peg-0.1.9/Makefile delete mode 100644 peg-0.1.9/compile.c delete mode 100644 peg-0.1.9/examples/Makefile delete mode 100644 peg-0.1.9/examples/accept.c delete mode 100644 peg-0.1.9/examples/accept.peg delete mode 100644 peg-0.1.9/examples/accept.ref delete mode 100644 peg-0.1.9/examples/basic.leg delete mode 100644 peg-0.1.9/examples/basic.ref delete mode 100644 peg-0.1.9/examples/bench.bas delete mode 100644 peg-0.1.9/examples/calc.leg delete mode 100644 peg-0.1.9/examples/calc.ref delete mode 100644 peg-0.1.9/examples/dc.c delete mode 100644 peg-0.1.9/examples/dc.peg delete mode 100644 peg-0.1.9/examples/dc.ref delete mode 100644 peg-0.1.9/examples/dcv.c delete mode 100644 peg-0.1.9/examples/dcv.peg delete mode 100644 peg-0.1.9/examples/dcv.ref delete mode 100644 peg-0.1.9/examples/fibonacci.bas delete mode 100644 peg-0.1.9/examples/left.c delete mode 100644 peg-0.1.9/examples/left.peg delete mode 100644 peg-0.1.9/examples/localctx.c delete mode 100644 peg-0.1.9/examples/localctx.ref delete mode 100644 peg-0.1.9/examples/rule.c delete mode 100644 peg-0.1.9/examples/rule.peg delete mode 100644 peg-0.1.9/examples/rule.ref delete mode 100644 peg-0.1.9/examples/test.bas delete mode 100644 peg-0.1.9/examples/test.c delete mode 100644 peg-0.1.9/examples/test.peg delete mode 100644 peg-0.1.9/examples/test.ref delete mode 100644 peg-0.1.9/examples/username.leg delete mode 100644 peg-0.1.9/examples/wc.leg delete mode 100644 peg-0.1.9/examples/wc.ref delete mode 100644 peg-0.1.9/leg.c delete mode 100644 peg-0.1.9/leg.leg delete mode 100644 peg-0.1.9/peg.1 delete mode 100644 peg-0.1.9/peg.c delete mode 100644 peg-0.1.9/peg.peg delete mode 100644 peg-0.1.9/peg.peg-c delete mode 100644 peg-0.1.9/tree.c delete mode 100644 peg-0.1.9/version.h rename peg-0.1.9/tree.h => tree.h (100%) diff --git a/Makefile b/Makefile deleted file mode 100644 index d623f3da..00000000 --- a/Makefile +++ /dev/null @@ -1,192 +0,0 @@ -VERSION=3.7 -PROGRAM=multimarkdown - -UNAME=$(shell uname) - -ifeq ($(UNAME), Darwin) -define FINALNOTES - ***\n\ -*** WARNING: Since you are on Darwin, you probably meant to use the Xcode\n\ -*** version instead.\n\ -*** It produces a version of the binary that is capable of running on\n\ -*** multiple versions of Mac OS X and on PPC, i386, or x86_64 machines.\n\ -*** -endef -else - FINALNOTES=Build complete. -endif - -CFLAGS ?= -Wall -O3 -include GLibFacade.h -I ./ -D MD_USE_GET_OPT=1 -D_GNU_SOURCE -ifeq ($(UNAME), SunOS) - CC = gcc - # Use of is valid only in a c99 compilation environment - CFLAGS += --std=c99 -else - CFLAGS += -ansi -endif - -# make ARCH=ppc -# build for ppc architecture - Only works on machines with PPC compilation support installed -# probably only Snow Leopard machines with Xcode 3 installed -ifeq ($(ARCH), ppc) - CFLAGS += -arch ppc -endif - -# make ARCH=i386 -# build for i386 architecture - useful with older machines or those running 10.4? -ifeq ($(ARCH), i386) - CFLAGS += -arch i386 -endif - -CFLAGS ?= -Wall -O3 -ansi -D_GNU_SOURCE # -flto for newer GCC versions -OBJS=markdown_parser.o markdown_output.o markdown_lib.o GLibFacade.o utility_functions.o parsing_functions.o odf.o -PEGDIR=peg-0.1.9 -LEG=$(PEGDIR)/leg$(X) -PKG_CONFIG = pkg-config - -ALL : $(PROGRAM) - -$(LEG): $(PEGDIR) - CC=gcc $(MAKE) -C $(PEGDIR) - -%.o : %.c markdown_peg.h - $(CC) -c $(CFLAGS) -o $@ $< - -$(PROGRAM) : markdown.c $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $< - @echo "$(FINALNOTES)" - -markdown_parser.c : markdown_parser.leg $(LEG) markdown_peg.h parsing_functions.c utility_functions.c - $(LEG) -o $@ $< - -.PHONY: clean test - -clean: - rm -f markdown_parser.c $(PROGRAM) $(OBJS); \ - rm -rf mac_installer/Package_Root/usr/local/bin; \ - rm -rf mac_installer/Support_Root; \ - rm mac_installer/Resources/*.html; \ - rm windows_installer/README.txt; \ - rm windows_installer/multimarkdown.exe; \ - rm windows_installer/multimarkdown.xml.backup; \ - rm windows_installer/LICENSE.html; \ - rm -rf mac_installer/*.pkg - -distclean: clean - $(MAKE) -C $(PEGDIR) clean - -test: $(PROGRAM) - cd MarkdownTest; \ - ./MarkdownTest.pl --Script=../$(PROGRAM) --Tidy --Flags="--compatibility" - -mmd-test: $(PROGRAM) - cd MarkdownTest; \ - ./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=MultiMarkdownTests - -compat-test: $(PROGRAM) - cd MarkdownTest; \ - ./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=CompatibilityTests --Flags="--compatibility" - -latex-test: $(PROGRAM) - cd MarkdownTest; \ - ./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=MultiMarkdownTests --Flags="-t latex" --ext=".tex"; \ - ./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=BeamerTests --Flags="-t latex" --ext=".tex"; \ - ./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=MemoirTests --Flags="-t latex" --ext=".tex" - -xslt-test: $(PROGRAM) - cd MarkdownTest; \ - ./MarkdownTest.pl --Script=/bin/cat --testdir=MultiMarkdownTests \ - --TrailFlags="| ../Support/bin/mmd2tex-xslt" --ext=".tex"; \ - ./MarkdownTest.pl --Script=/bin/cat --testdir=BeamerTests \ - --TrailFlags="| ../Support/bin/mmd2tex-xslt" --ext=".tex"; \ - ./MarkdownTest.pl --Script=/bin/cat --testdir=MemoirTests \ - --TrailFlags="| ../Support/bin/mmd2tex-xslt" --ext=".tex"; \ - -leak-check: $(PROGRAM) - valgrind --leak-check=full ./multimarkdown TEST.markdown > TEST.html - - -# Compile multimarkdown.exe and prep files necessary for installer - -windows: $(PROGRAM) - rm *.o - /usr/bin/i586-mingw32msvc-cc -c -Wall -O3 -ansi markdown*.c GLibFacade.c - /usr/bin/i586-mingw32msvc-cc markdown*.o GLibFacade.o \ - -Wl,--dy,--warn-unresolved-symbols,-lglib-2.0 -o multimarkdown.exe - -# Get readme and other files ready -# This has to be run before BitRock can create the installer -win-prep: - mkdir -p windows_installer - cp multimarkdown.exe windows_installer/ - cp README.markdown windows_installer/README.txt - ./multimarkdown LICENSE > windows_installer/LICENSE.html - -# After building the installer with BitRock, this creates a properly named -# zipfile -# You have to move the .exe from BitRock to the windows_installer folder -# Also - create a portable mmd zipfile -win-installer: - zip -r windows_installer/MultiMarkdown-Windows-$(VERSION).zip windows_installer/MMD-windows-$(VERSION).exe -x windows_installer/MultiMarkdown*.zip - cd windows_installer; zip -r MultiMarkdown-Windows-Portable-$(VERSION).zip *.bat multimarkdown.exe README.txt LICENSE.html -x install_multimarkdown.bat - -# Build Mac installer - requires that you first build multimarkdown itself, -# either with "make" or with Xcode - -mac-installer: - mkdir -p mac_installer/Package_Root/usr/local/bin - mkdir -p mac_installer/Support_Root/Library/Application\ Support - cp multimarkdown scripts/mmd* mac_installer/Package_Root/usr/local/bin/ - ./multimarkdown README > mac_installer/Resources/README.html - ./multimarkdown mac_installer/Resources/Welcome.txt > mac_installer/Resources/Welcome.html - ./multimarkdown LICENSE > mac_installer/Resources/License.html - ./multimarkdown mac_installer/Resources/Support_Welcome.txt > mac_installer/Resources/Support_Welcome.html - git clone Support mac_installer/Support_Root/Library/Application\ Support/MultiMarkdown - cd mac_installer; /Applications/PackageMaker.app/Contents/MacOS/PackageMaker \ - --doc "Make Support Installer.pmdoc" \ - --title "MultiMarkdown Support Files" \ - --version $(VERSION) \ - --filter "\.DS_Store" \ - --filter "\.git" \ - --id net.fletcherpenney.MMD-Support.pkg \ - --domain user \ - --out "MultiMarkdown-Support-Mac-$(VERSION).pkg" \ - --no-relocate; \ - /Applications/PackageMaker.app/Contents/MacOS/PackageMaker \ - --doc "Make OS X Installer.pmdoc" \ - --title "MultiMarkdown" \ - --version $(VERSION) \ - --filter "\.DS_Store" \ - --filter "\.git" \ - --id net.fletcherpenney.multimarkdown.pkg \ - --out "MultiMarkdown-Mac-$(VERSION).pkg" - cd mac_installer; zip -r MultiMarkdown-Mac-$(VERSION).zip MultiMarkdown-Mac-$(VERSION).pkg - cd mac_installer; zip -r MultiMarkdown-Support-Mac-$(VERSION).zip MultiMarkdown-Support-Mac-$(VERSION).pkg - -# Requires installation of the platypus command line tool to create -# a drag and drop application for Mac OS X - -drop: - mkdir drag; rm -rf drag/*.app; \ - /usr/local/bin/platypus -D -a 'MMD to LaTeX' -o 'Text Window' -p '/bin/sh' -V '3.0' -I 'net.fletcherpenney.MMD2LaTeX' -X '*' -T '****|fold' -N 'PATH=/usr/local/bin' -c 'scripts/mmd2tex' 'drag/MMD2LaTeX.app'; \ - /usr/local/bin/platypus -D -a 'MMD to HTML' -o 'Text Window' -p '/bin/sh' -V '3.0' -I 'net.fletcherpenney.MMD2HTML' -X '*' -T '****|fold' -N 'PATH=/usr/local/bin' -c 'scripts/mmd' 'drag/MMD2HTML.app'; \ - /usr/local/bin/platypus -D -a 'MMD to OPML' -o 'Text Window' -p '/bin/sh' -V '3.0' -I 'net.fletcherpenney.MMD2OPML' -X '*' -T '****|fold' -N 'PATH=/usr/local/bin' -c 'scripts/mmd2opml' 'drag/MMD2OPML.app'; \ - /usr/local/bin/platypus -D -a 'MMD to ODF' -o 'Text Window' -p '/bin/sh' -V '3.0' -I 'net.fletcherpenney.MMD2ODF' -X '*' -T '****|fold' -N 'PATH=/usr/local/bin' -c 'scripts/mmd2odf' 'drag/MMD2ODF.app'; - -# Create HTML and PDF (if latex installed) documentation -docs: $(PROGRAM) - cd documentation; \ - ../Support/Utilities/mmd_merge.pl index.txt > manual.txt; \ - mkdir -p ../manual; \ - ../multimarkdown manual.txt > ../manual/index.html; \ - ../multimarkdown -b -t latex manual.txt; \ - latexmk -pdf manual.tex; \ - latexmk -c manual.tex; \ - mv manual.pdf ../manual/mmd-manual.pdf; \ - rm ../documentation/manual.t*; - - -# For me to push updated documentation to my github site -docs-live: docs - cd manual; git add mmd-manual.pdf index.html; \ - git commit -m "update manual"; git push origin gh-pages; \ diff --git a/MultiMarkdown.xcodeproj/project.pbxproj b/MultiMarkdown.xcodeproj/project.pbxproj index 6074be2c..41c4a58b 100644 --- a/MultiMarkdown.xcodeproj/project.pbxproj +++ b/MultiMarkdown.xcodeproj/project.pbxproj @@ -6,28 +6,11 @@ objectVersion = 46; objects = { -/* Begin PBXAggregateTarget section */ - 65F0B8EA13DF714E00D0980C /* Run Tests */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 65F0B8ED13DF716D00D0980C /* Build configuration list for PBXAggregateTarget "Run Tests" */; - buildPhases = ( - 65F0B8E913DF714E00D0980C /* Run Tests */, - ); - dependencies = ( - 65F0B8FD13DF724D00D0980C /* PBXTargetDependency */, - ); - name = "Run Tests"; - productName = "MultiMarkdown Tests"; - }; -/* End PBXAggregateTarget section */ - /* Begin PBXBuildFile section */ 4AFA467413E3625F00CFA132 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFA466913E3624F00CFA132 /* Foundation.framework */; }; 4AFA467513E362AC00CFA132 /* GLibFacade.c in Sources */ = {isa = PBXBuildFile; fileRef = 651A528213E1C30100BCB02A /* GLibFacade.c */; }; 4AFA467A13E363FA00CFA132 /* markdown_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66113DF47CC00D0980C /* markdown_lib.c */; }; 4AFA467D13E3640600CFA132 /* markdown_output.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66313DF47CC00D0980C /* markdown_output.c */; }; - 65F0B69E13DF47CC00D0980C /* markdown.c in Sources */ = {isa = PBXBuildFile; fileRef = 65F0B66713DF47CC00D0980C /* markdown.c */; }; - 65F89EA713E37B9D006A34B8 /* libMultiMarkdown.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFA466213E3624F00CFA132 /* libMultiMarkdown.a */; }; 79C2C97F16E774B6002B79F3 /* markdown_parser_lib.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C2C97E16E774B6002B79F3 /* markdown_parser_lib.h */; }; 79C2C98116E774BF002B79F3 /* markdown_parser_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 79C2C98016E774BF002B79F3 /* markdown_parser_lib.c */; }; 79C2C98316E775D7002B79F3 /* parsing_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C2C98216E775D7002B79F3 /* parsing_functions.h */; }; @@ -37,42 +20,6 @@ 79C2C98C16E78708002B79F3 /* utility_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 79C2C98B16E78708002B79F3 /* utility_functions.h */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 4AFA467813E3633800CFA132 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 65F0B88813DF6C0D00D0980C; - remoteInfo = Peg; - }; - 65F0B8FC13DF724D00D0980C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 8DD76FA90486AB0100D96B5E; - remoteInfo = MultiMarkdown; - }; - 65F89EAC13E37BAC006A34B8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4AFA466113E3624F00CFA132; - remoteInfo = libMultiMarkdown; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 8DD76FAF0486AB0100D96B5E /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 8; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 4AFA466213E3624F00CFA132 /* libMultiMarkdown.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMultiMarkdown.a; sourceTree = BUILT_PRODUCTS_DIR; }; 4AFA466413E3624F00CFA132 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; @@ -92,7 +39,6 @@ 65F0B66913DF47CC00D0980C /* odf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = odf.h; sourceTree = ""; }; 65F0B66A13DF47CC00D0980C /* parsing_functions.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = parsing_functions.c; sourceTree = ""; }; 65F0B69A13DF47CC00D0980C /* utility_functions.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = utility_functions.c; sourceTree = ""; }; - 65F0B6C513DF485F00D0980C /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; 65F0B6D713DF4C6B00D0980C /* MarkdownMacPrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkdownMacPrefix.h; sourceTree = ""; }; 65F0B6F313DF4D9800D0980C /* glib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glib.h; sourceTree = ""; }; 65F0B8B113DF6D4000D0980C /* markdown_parser.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = markdown_parser.c; sourceTree = ""; }; @@ -100,12 +46,10 @@ 65F89EB813E37BEF006A34B8 /* Common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Common.xcconfig; sourceTree = ""; }; 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 79C2C97C16E772E9002B79F3 /* peg-0.1.9 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "peg-0.1.9"; sourceTree = ""; }; 79C2C97E16E774B6002B79F3 /* markdown_parser_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = markdown_parser_lib.h; sourceTree = ""; }; 79C2C98016E774BF002B79F3 /* markdown_parser_lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = markdown_parser_lib.c; sourceTree = ""; }; 79C2C98216E775D7002B79F3 /* parsing_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsing_functions.h; sourceTree = ""; }; 79C2C98B16E78708002B79F3 /* utility_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utility_functions.h; sourceTree = ""; }; - 8DD76FB20486AB0100D96B5E /* multimarkdown */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = multimarkdown; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -117,14 +61,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8DD76FAD0486AB0100D96B5E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 65F89EA713E37B9D006A34B8 /* libMultiMarkdown.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -151,8 +87,6 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( - 79C2C97C16E772E9002B79F3 /* peg-0.1.9 */, - 65F0B6C513DF485F00D0980C /* Makefile */, 65F0B66113DF47CC00D0980C /* markdown_lib.c */, 65F0B66213DF47CC00D0980C /* markdown_lib.h */, 65F0B66313DF47CC00D0980C /* markdown_output.c */, @@ -172,7 +106,6 @@ 1AB674ADFE9D54B511CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 8DD76FB20486AB0100D96B5E /* multimarkdown */, 4AFA466213E3624F00CFA132 /* libMultiMarkdown.a */, ); name = Products; @@ -238,23 +171,6 @@ }; /* End PBXHeadersBuildPhase section */ -/* Begin PBXLegacyTarget section */ - 65F0B88813DF6C0D00D0980C /* Peg */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "$(ACTION)"; - buildConfigurationList = 65F0B88F13DF6C3E00D0980C /* Build configuration list for PBXLegacyTarget "Peg" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/make; - buildWorkingDirectory = "./peg-0.1.9"; - dependencies = ( - ); - name = Peg; - passBuildSettingsInEnvironment = 1; - productName = Peg; - }; -/* End PBXLegacyTarget section */ - /* Begin PBXNativeTarget section */ 4AFA466113E3624F00CFA132 /* libMultiMarkdown */ = { isa = PBXNativeTarget; @@ -268,32 +184,12 @@ buildRules = ( ); dependencies = ( - 4AFA467913E3633800CFA132 /* PBXTargetDependency */, ); name = libMultiMarkdown; productName = multimarkdown; productReference = 4AFA466213E3624F00CFA132 /* libMultiMarkdown.a */; productType = "com.apple.product-type.library.static"; }; - 8DD76FA90486AB0100D96B5E /* MultiMarkdown */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "MultiMarkdown" */; - buildPhases = ( - 8DD76FAB0486AB0100D96B5E /* Sources */, - 8DD76FAD0486AB0100D96B5E /* Frameworks */, - 8DD76FAF0486AB0100D96B5E /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - 65F89EAD13E37BAC006A34B8 /* PBXTargetDependency */, - ); - name = MultiMarkdown; - productInstallPath = "$(HOME)/bin"; - productName = MultiMarkdown; - productReference = 8DD76FB20486AB0100D96B5E /* multimarkdown */; - productType = "com.apple.product-type.tool"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -316,10 +212,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 8DD76FA90486AB0100D96B5E /* MultiMarkdown */, 4AFA466113E3624F00CFA132 /* libMultiMarkdown */, - 65F0B88813DF6C0D00D0980C /* Peg */, - 65F0B8EA13DF714E00D0980C /* Run Tests */, ); }; /* End PBXProject section */ @@ -339,21 +232,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "./peg-0.1.9/leg -o markdown_parser.c markdown_parser.leg"; - }; - 65F0B8E913DF714E00D0980C /* Run Tests */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Tests"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# shell script goes here\ncd ${PROJECT_DIR}/MarkdownTest\n\n# Basic Markdown Tests\n./MarkdownTest.pl --Script=\"${BUILT_PRODUCTS_DIR}/MultiMarkdown\" --testdir=\"${PROJECT_DIR}/MarkdownTest/Tests\"\n\n# MultiMarkdown extensions\n./MarkdownTest.pl --Script=\"${BUILT_PRODUCTS_DIR}/MultiMarkdown\" --testdir=\"${PROJECT_DIR}/MarkdownTest/MultiMarkdownTests\"\n"; + shellScript = "\"$SRCROOT/leg\" -o markdown_parser.c markdown_parser.leg"; }; /* End PBXShellScriptBuildPhase section */ @@ -372,63 +251,9 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 8DD76FAB0486AB0100D96B5E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 65F0B69E13DF47CC00D0980C /* markdown.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 4AFA467913E3633800CFA132 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 65F0B88813DF6C0D00D0980C /* Peg */; - targetProxy = 4AFA467813E3633800CFA132 /* PBXContainerItemProxy */; - }; - 65F0B8FD13DF724D00D0980C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 8DD76FA90486AB0100D96B5E /* MultiMarkdown */; - targetProxy = 65F0B8FC13DF724D00D0980C /* PBXContainerItemProxy */; - }; - 65F89EAD13E37BAC006A34B8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4AFA466113E3624F00CFA132 /* libMultiMarkdown */; - targetProxy = 65F89EAC13E37BAC006A34B8 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin XCBuildConfiguration section */ - 1DEB928608733DD80010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 65F89EB913E37BEF006A34B8 /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - HEADER_SEARCH_PATHS = .; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = multimarkdown; - }; - name = Debug; - }; - 1DEB928708733DD80010E9CD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 65F89EBA13E37C2A006A34B8 /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; - GCC_MODEL_TUNING = G5; - GCC_PREFIX_HEADER = MarkdownMacPrefix.h; - HEADER_SEARCH_PATHS = .; - INSTALL_PATH = /usr/local/bin; - OTHER_CFLAGS = "-DSTANDALONE_MAC_VERSION=1"; - PRODUCT_NAME = multimarkdown; - SEPARATE_STRIP = YES; - STRIP_INSTALLED_PRODUCT = YES; - }; - name = Release; - }; 1DEB928A08733DD80010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -534,96 +359,9 @@ }; name = "Release10.6+"; }; - 651A542913E20D2400BCB02A /* Release10.6+ */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 65F89E8113E379ED006A34B8 /* Release10.6+.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - HEADER_SEARCH_PATHS = .; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = multimarkdown; - }; - name = "Release10.6+"; - }; - 651A542A13E20D2400BCB02A /* Release10.6+ */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = Peg; - ZERO_LINK = NO; - }; - name = "Release10.6+"; - }; - 651A542B13E20D2400BCB02A /* Release10.6+ */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "MultiMarkdown Tests"; - ZERO_LINK = NO; - }; - name = "Release10.6+"; - }; - 65F0B88913DF6C0D00D0980C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = Peg; - }; - name = Debug; - }; - 65F0B88A13DF6C0D00D0980C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = Peg; - ZERO_LINK = NO; - }; - name = Release; - }; - 65F0B8EB13DF714F00D0980C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "MultiMarkdown Tests"; - }; - name = Debug; - }; - 65F0B8EC13DF714F00D0980C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "MultiMarkdown Tests"; - ZERO_LINK = NO; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "MultiMarkdown" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB928608733DD80010E9CD /* Debug */, - 1DEB928708733DD80010E9CD /* Release */, - 651A542913E20D2400BCB02A /* Release10.6+ */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MultiMarkdown" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -644,26 +382,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 65F0B88F13DF6C3E00D0980C /* Build configuration list for PBXLegacyTarget "Peg" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 65F0B88913DF6C0D00D0980C /* Debug */, - 65F0B88A13DF6C0D00D0980C /* Release */, - 651A542A13E20D2400BCB02A /* Release10.6+ */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 65F0B8ED13DF716D00D0980C /* Build configuration list for PBXAggregateTarget "Run Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 65F0B8EB13DF714F00D0980C /* Debug */, - 65F0B8EC13DF714F00D0980C /* Release */, - 651A542B13E20D2400BCB02A /* Release10.6+ */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; diff --git a/leg b/leg new file mode 100755 index 0000000000000000000000000000000000000000..02002e958213307b89365ebbcb461fe5a76e8777 GIT binary patch literal 56776 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 O=}H@Y6E;?B+W!Uf1ckZ) literal 0 HcmV?d00001 diff --git a/peg-0.1.9/Makefile b/peg-0.1.9/Makefile deleted file mode 100644 index c10fbda8..00000000 --- a/peg-0.1.9/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -CFLAGS = -g -Wall $(OFLAGS) $(XFLAGS) -OFLAGS = -O3 -DNDEBUG -#OFLAGS = -pg - -OBJS = tree.o compile.o - -all : peg leg - -peg : peg.o $(OBJS) - $(CC) $(CFLAGS) -o $@-new peg.o $(OBJS) - mv $@-new $@ - -leg : leg.o $(OBJS) - $(CC) $(CFLAGS) -o $@-new leg.o $(OBJS) - mv $@-new $@ - -ROOT = -PREFIX = /usr/local -BINDIR = $(ROOT)$(PREFIX)/bin - -install : $(BINDIR)/peg $(BINDIR)/leg - -$(BINDIR)/% : % - cp -p $< $@ - strip $@ - -uninstall : .FORCE - rm -f $(BINDIR)/peg - rm -f $(BINDIR)/leg - -peg.o : peg.c peg.peg-c - -%.peg-c : %.peg compile.c - ./peg -o $@ $< - -leg.o : leg.c - -leg.c : leg.leg compile.c - ./leg -o $@ $< - -check : check-peg check-leg - -check-peg : peg .FORCE - ./peg < peg.peg > peg.out - diff peg.peg-c peg.out - rm peg.out - -check-leg : leg .FORCE - ./leg < leg.leg > leg.out - diff leg.c leg.out - rm leg.out - -test examples : .FORCE - $(SHELL) -ec '(cd examples; $(MAKE))' - -clean : .FORCE - rm -f *~ *.o *.peg.[cd] *.leg.[cd] - $(SHELL) -ec '(cd examples; $(MAKE) $@)' - -spotless : clean .FORCE - rm -f peg - rm -f leg - $(SHELL) -ec '(cd examples; $(MAKE) $@)' - -.FORCE : diff --git a/peg-0.1.9/compile.c b/peg-0.1.9/compile.c deleted file mode 100644 index 74506b76..00000000 --- a/peg-0.1.9/compile.c +++ /dev/null @@ -1,717 +0,0 @@ -/* Copyright (c) 2007, 2012 by Ian Piumarta - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the 'Software'), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software. Acknowledgement - * of the use of this Software in supporting documentation would be - * appreciated but is not required. - * - * THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. - * - * Last edited: 2012-04-29 16:09:36 by piumarta on emilia - */ - -#include -#include -#include -#include - -#include "version.h" -#include "tree.h" - -static int yyl(void) -{ - static int prev= 0; - return ++prev; -} - -static void charClassSet (unsigned char bits[], int c) { bits[c >> 3] |= (1 << (c & 7)); } -static void charClassClear(unsigned char bits[], int c) { bits[c >> 3] &= ~(1 << (c & 7)); } - -typedef void (*setter)(unsigned char bits[], int c); - -static inline int oigit(int c) { return '0' <= c && c <= '7'; } - -static int cnext(unsigned char **ccp) -{ - unsigned char *cclass= *ccp; - int c= *cclass++; - if (c) - { - if ('\\' == c && *cclass) - { - switch (c= *cclass++) - { - case 'a': c= '\a'; break; /* bel */ - case 'b': c= '\b'; break; /* bs */ - case 'e': c= '\e'; break; /* esc */ - case 'f': c= '\f'; break; /* ff */ - case 'n': c= '\n'; break; /* nl */ - case 'r': c= '\r'; break; /* cr */ - case 't': c= '\t'; break; /* ht */ - case 'v': c= '\v'; break; /* vt */ - default: - if (oigit(c)) - { - c -= '0'; - if (oigit(*cclass)) c= (c << 3) + *cclass++ - '0'; - if (oigit(*cclass)) c= (c << 3) + *cclass++ - '0'; - } - break; - } - } - *ccp= cclass; - } - return c; -} - -static char *makeCharClass(unsigned char *cclass) -{ - unsigned char bits[32]; - setter set; - int c, prev= -1; - static char string[256]; - char *ptr; - - if ('^' == *cclass) - { - memset(bits, 255, 32); - set= charClassClear; - ++cclass; - } - else - { - memset(bits, 0, 32); - set= charClassSet; - } - - while (*cclass) - { - if ('-' == *cclass && cclass[1] && prev >= 0) - { - ++cclass; - for (c= cnext(&cclass); prev <= c; ++prev) - set(bits, prev); - prev= -1; - } - else - { - c= cnext(&cclass); - set(bits, prev= c); - } - } - - ptr= string; - for (c= 0; c < 32; ++c) - ptr += sprintf(ptr, "\\%03o", bits[c]); - - return string; -} - -static void begin(void) { fprintf(output, "\n {"); } -static void end(void) { fprintf(output, "\n }"); } -static void label(int n) { fprintf(output, "\n l%d:;\t", n); } -static void jump(int n) { fprintf(output, " goto l%d;", n); } -static void save(int n) { fprintf(output, " int yypos%d= ctx->pos, yythunkpos%d= ctx->thunkpos;", n, n); } -static void restore(int n) { fprintf(output, " ctx->pos= yypos%d; ctx->thunkpos= yythunkpos%d;", n, n); } - -static void Node_compile_c_ko(Node *node, int ko) -{ - assert(node); - switch (node->type) - { - case Rule: - fprintf(stderr, "\ninternal error #1 (%s)\n", node->rule.name); - exit(1); - break; - - case Dot: - fprintf(output, " if (!yymatchDot(ctx)) goto l%d;", ko); - break; - - case Name: - fprintf(output, " if (!yy_%s(ctx)) goto l%d;", node->name.rule->rule.name, ko); - if (node->name.variable) - fprintf(output, " yyDo(ctx, yySet, %d, 0);", node->name.variable->variable.offset); - break; - - case Character: - case String: - { - int len= strlen(node->string.value); - if (1 == len) - { - if ('\'' == node->string.value[0]) - fprintf(output, " if (!yymatchChar(ctx, '\\'')) goto l%d;", ko); - else - fprintf(output, " if (!yymatchChar(ctx, '%s')) goto l%d;", node->string.value, ko); - } - else - if (2 == len && '\\' == node->string.value[0]) - fprintf(output, " if (!yymatchChar(ctx, '%s')) goto l%d;", node->string.value, ko); - else - fprintf(output, " if (!yymatchString(ctx, \"%s\")) goto l%d;", node->string.value, ko); - } - break; - - case Class: - fprintf(output, " if (!yymatchClass(ctx, (unsigned char *)\"%s\")) goto l%d;", makeCharClass(node->cclass.value), ko); - break; - - case Action: - fprintf(output, " yyDo(ctx, yy%s, ctx->begin, ctx->end);", node->action.name); - break; - - case Predicate: - fprintf(output, " yyText(ctx, ctx->begin, ctx->end); if (!(%s)) goto l%d;", node->action.text, ko); - break; - - case Alternate: - { - int ok= yyl(); - begin(); - save(ok); - for (node= node->alternate.first; node; node= node->alternate.next) - if (node->alternate.next) - { - int next= yyl(); - Node_compile_c_ko(node, next); - jump(ok); - label(next); - restore(ok); - } - else - Node_compile_c_ko(node, ko); - end(); - label(ok); - } - break; - - case Sequence: - for (node= node->sequence.first; node; node= node->sequence.next) - Node_compile_c_ko(node, ko); - break; - - case PeekFor: - { - int ok= yyl(); - begin(); - save(ok); - Node_compile_c_ko(node->peekFor.element, ko); - restore(ok); - end(); - } - break; - - case PeekNot: - { - int ok= yyl(); - begin(); - save(ok); - Node_compile_c_ko(node->peekFor.element, ok); - jump(ko); - label(ok); - restore(ok); - end(); - } - break; - - case Query: - { - int qko= yyl(), qok= yyl(); - begin(); - save(qko); - Node_compile_c_ko(node->query.element, qko); - jump(qok); - label(qko); - restore(qko); - end(); - label(qok); - } - break; - - case Star: - { - int again= yyl(), out= yyl(); - label(again); - begin(); - save(out); - Node_compile_c_ko(node->star.element, out); - jump(again); - label(out); - restore(out); - end(); - } - break; - - case Plus: - { - int again= yyl(), out= yyl(); - Node_compile_c_ko(node->plus.element, ko); - label(again); - begin(); - save(out); - Node_compile_c_ko(node->plus.element, out); - jump(again); - label(out); - restore(out); - end(); - } - break; - - default: - fprintf(stderr, "\nNode_compile_c_ko: illegal node type %d\n", node->type); - exit(1); - } -} - - -static int countVariables(Node *node) -{ - int count= 0; - while (node) - { - ++count; - node= node->variable.next; - } - return count; -} - -static void defineVariables(Node *node) -{ - int count= 0; - while (node) - { - fprintf(output, "#define %s ctx->val[%d]\n", node->variable.name, --count); - node->variable.offset= count; - node= node->variable.next; - } - fprintf(output, "#define yy ctx->yy\n"); - fprintf(output, "#define yypos ctx->pos\n"); - fprintf(output, "#define yythunkpos ctx->thunkpos\n"); -} - -static void undefineVariables(Node *node) -{ - fprintf(output, "#undef yythunkpos\n"); - fprintf(output, "#undef yypos\n"); - fprintf(output, "#undef yy\n"); - while (node) - { - fprintf(output, "#undef %s\n", node->variable.name); - node= node->variable.next; - } -} - - -static void Rule_compile_c2(Node *node) -{ - assert(node); - assert(Rule == node->type); - - if (!node->rule.expression) - fprintf(stderr, "rule '%s' used but not defined\n", node->rule.name); - else - { - int ko= yyl(), safe; - - if ((!(RuleUsed & node->rule.flags)) && (node != start)) - fprintf(stderr, "rule '%s' defined but not used\n", node->rule.name); - - safe= ((Query == node->rule.expression->type) || (Star == node->rule.expression->type)); - - fprintf(output, "\nYY_RULE(int) yy_%s(yycontext *ctx)\n{", node->rule.name); - if (!safe) save(0); - if (node->rule.variables) - fprintf(output, " yyDo(ctx, yyPush, %d, 0);", countVariables(node->rule.variables)); - fprintf(output, "\n yyprintf((stderr, \"%%s\\n\", \"%s\"));", node->rule.name); - Node_compile_c_ko(node->rule.expression, ko); - fprintf(output, "\n yyprintf((stderr, \" ok %%s @ %%s\\n\", \"%s\", ctx->buf+ctx->pos));", node->rule.name); - if (node->rule.variables) - fprintf(output, " yyDo(ctx, yyPop, %d, 0);", countVariables(node->rule.variables)); - fprintf(output, "\n return 1;"); - if (!safe) - { - label(ko); - restore(0); - fprintf(output, "\n yyprintf((stderr, \" fail %%s @ %%s\\n\", \"%s\", ctx->buf+ctx->pos));", node->rule.name); - fprintf(output, "\n return 0;"); - } - fprintf(output, "\n}"); - } - - if (node->rule.next) - Rule_compile_c2(node->rule.next); -} - -static char *header= "\ -#include \n\ -#include \n\ -#include \n\ -"; - -static char *preamble= "\ -#ifndef YY_LOCAL\n\ -#define YY_LOCAL(T) static T\n\ -#endif\n\ -#ifndef YY_ACTION\n\ -#define YY_ACTION(T) static T\n\ -#endif\n\ -#ifndef YY_RULE\n\ -#define YY_RULE(T) static T\n\ -#endif\n\ -#ifndef YY_PARSE\n\ -#define YY_PARSE(T) T\n\ -#endif\n\ -#ifndef YYPARSE\n\ -#define YYPARSE yyparse\n\ -#endif\n\ -#ifndef YYPARSEFROM\n\ -#define YYPARSEFROM yyparsefrom\n\ -#endif\n\ -#ifndef YY_INPUT\n\ -#define YY_INPUT(buf, result, max_size) \\\n\ - { \\\n\ - int yyc= getchar(); \\\n\ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \\\n\ - yyprintf((stderr, \"<%c>\", yyc)); \\\n\ - }\n\ -#endif\n\ -#ifndef YY_BEGIN\n\ -#define YY_BEGIN ( ctx->begin= ctx->pos, 1)\n\ -#endif\n\ -#ifndef YY_END\n\ -#define YY_END ( ctx->end= ctx->pos, 1)\n\ -#endif\n\ -#ifdef YY_DEBUG\n\ -# define yyprintf(args) fprintf args\n\ -#else\n\ -# define yyprintf(args)\n\ -#endif\n\ -#ifndef YYSTYPE\n\ -#define YYSTYPE int\n\ -#endif\n\ -\n\ -#ifndef YY_PART\n\ -\n\ -typedef struct _yycontext yycontext;\n\ -typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng);\n\ -typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk;\n\ -\n\ -struct _yycontext {\n\ - char *buf;\n\ - int buflen;\n\ - int pos;\n\ - int limit;\n\ - char *text;\n\ - int textlen;\n\ - int begin;\n\ - int end;\n\ - int textmax;\n\ - yythunk *thunks;\n\ - int thunkslen;\n\ - int thunkpos;\n\ - YYSTYPE yy;\n\ - YYSTYPE *val;\n\ - YYSTYPE *vals;\n\ - int valslen;\n\ -#ifdef YY_CTX_MEMBERS\n\ - YY_CTX_MEMBERS\n\ -#endif\n\ -};\n\ -\n\ -#ifdef YY_CTX_LOCAL\n\ -#define YY_CTX_PARAM_ yycontext *yyctx,\n\ -#define YY_CTX_PARAM yycontext *yyctx\n\ -#define YY_CTX_ARG_ yyctx,\n\ -#define YY_CTX_ARG yyctx\n\ -#else\n\ -#define YY_CTX_PARAM_\n\ -#define YY_CTX_PARAM\n\ -#define YY_CTX_ARG_\n\ -#define YY_CTX_ARG\n\ -yycontext yyctx0;\n\ -yycontext *yyctx= &yyctx0;\n\ -#endif\n\ -\n\ -YY_LOCAL(int) yyrefill(yycontext *ctx)\n\ -{\n\ - int yyn;\n\ - while (ctx->buflen - ctx->pos < 512)\n\ - {\n\ - ctx->buflen *= 2;\n\ - ctx->buf= (char *)realloc(ctx->buf, ctx->buflen);\n\ - }\n\ - YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos));\n\ - if (!yyn) return 0;\n\ - ctx->limit += yyn;\n\ - return 1;\n\ -}\n\ -\n\ -YY_LOCAL(int) yymatchDot(yycontext *ctx)\n\ -{\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - ++ctx->pos;\n\ - return 1;\n\ -}\n\ -\n\ -YY_LOCAL(int) yymatchChar(yycontext *ctx, int c)\n\ -{\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - if ((unsigned char)ctx->buf[ctx->pos] == c)\n\ - {\n\ - ++ctx->pos;\n\ - yyprintf((stderr, \" ok yymatchChar(ctx, %c) @ %s\\n\", c, ctx->buf+ctx->pos));\n\ - return 1;\n\ - }\n\ - yyprintf((stderr, \" fail yymatchChar(ctx, %c) @ %s\\n\", c, ctx->buf+ctx->pos));\n\ - return 0;\n\ -}\n\ -\n\ -YY_LOCAL(int) yymatchString(yycontext *ctx, char *s)\n\ -{\n\ - int yysav= ctx->pos;\n\ - while (*s)\n\ - {\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - if (ctx->buf[ctx->pos] != *s)\n\ - {\n\ - ctx->pos= yysav;\n\ - return 0;\n\ - }\n\ - ++s;\n\ - ++ctx->pos;\n\ - }\n\ - return 1;\n\ -}\n\ -\n\ -YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits)\n\ -{\n\ - int c;\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - c= (unsigned char)ctx->buf[ctx->pos];\n\ - if (bits[c >> 3] & (1 << (c & 7)))\n\ - {\n\ - ++ctx->pos;\n\ - yyprintf((stderr, \" ok yymatchClass @ %s\\n\", ctx->buf+ctx->pos));\n\ - return 1;\n\ - }\n\ - yyprintf((stderr, \" fail yymatchClass @ %s\\n\", ctx->buf+ctx->pos));\n\ - return 0;\n\ -}\n\ -\n\ -YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end)\n\ -{\n\ - while (ctx->thunkpos >= ctx->thunkslen)\n\ - {\n\ - ctx->thunkslen *= 2;\n\ - ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen);\n\ - }\n\ - ctx->thunks[ctx->thunkpos].begin= begin;\n\ - ctx->thunks[ctx->thunkpos].end= end;\n\ - ctx->thunks[ctx->thunkpos].action= action;\n\ - ++ctx->thunkpos;\n\ -}\n\ -\n\ -YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end)\n\ -{\n\ - int yyleng= end - begin;\n\ - if (yyleng <= 0)\n\ - yyleng= 0;\n\ - else\n\ - {\n\ - while (ctx->textlen < (yyleng + 1))\n\ - {\n\ - ctx->textlen *= 2;\n\ - ctx->text= (char *)realloc(ctx->text, ctx->textlen);\n\ - }\n\ - memcpy(ctx->text, ctx->buf + begin, yyleng);\n\ - }\n\ - ctx->text[yyleng]= '\\0';\n\ - return yyleng;\n\ -}\n\ -\n\ -YY_LOCAL(void) yyDone(yycontext *ctx)\n\ -{\n\ - int pos;\n\ - for (pos= 0; pos < ctx->thunkpos; ++pos)\n\ - {\n\ - yythunk *thunk= &ctx->thunks[pos];\n\ - int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin;\n\ - yyprintf((stderr, \"DO [%d] %p %s\\n\", pos, thunk->action, ctx->text));\n\ - thunk->action(ctx, ctx->text, yyleng);\n\ - }\n\ - ctx->thunkpos= 0;\n\ -}\n\ -\n\ -YY_LOCAL(void) yyCommit(yycontext *ctx)\n\ -{\n\ - if ((ctx->limit -= ctx->pos))\n\ - {\n\ - memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit);\n\ - }\n\ - ctx->begin -= ctx->pos;\n\ - ctx->end -= ctx->pos;\n\ - ctx->pos= ctx->thunkpos= 0;\n\ -}\n\ -\n\ -YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)\n\ -{\n\ - if (tp0)\n\ - {\n\ - fprintf(stderr, \"accept denied at %d\\n\", tp0);\n\ - return 0;\n\ - }\n\ - else\n\ - {\n\ - yyDone(ctx);\n\ - yyCommit(ctx);\n\ - }\n\ - return 1;\n\ -}\n\ -\n\ -YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; }\n\ -YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; }\n\ -YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; }\n\ -\n\ -#endif /* YY_PART */\n\ -\n\ -#define YYACCEPT yyAccept(ctx, yythunkpos0)\n\ -\n\ -"; - -static char *footer= "\n\ -\n\ -#ifndef YY_PART\n\ -\n\ -typedef int (*yyrule)(yycontext *ctx);\n\ -\n\ -YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)\n\ -{\n\ - int yyok;\n\ - if (!yyctx->buflen)\n\ - {\n\ - yyctx->buflen= 1024;\n\ - yyctx->buf= (char *)malloc(yyctx->buflen);\n\ - yyctx->textlen= 1024;\n\ - yyctx->text= (char *)malloc(yyctx->textlen);\n\ - yyctx->thunkslen= 32;\n\ - yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen);\n\ - yyctx->valslen= 32;\n\ - yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen);\n\ - yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0;\n\ - }\n\ - yyctx->begin= yyctx->end= yyctx->pos;\n\ - yyctx->thunkpos= 0;\n\ - yyctx->val= yyctx->vals;\n\ - yyok= yystart(yyctx);\n\ - if (yyok) yyDone(yyctx);\n\ - yyCommit(yyctx);\n\ - return yyok;\n\ -}\n\ -\n\ -YY_PARSE(int) YYPARSE(YY_CTX_PARAM)\n\ -{\n\ - return YYPARSEFROM(YY_CTX_ARG_ yy_%s);\n\ -}\n\ -\n\ -#endif\n\ -"; - -void Rule_compile_c_header(void) -{ - fprintf(output, "/* A recursive-descent parser generated by peg %d.%d.%d */\n", PEG_MAJOR, PEG_MINOR, PEG_LEVEL); - fprintf(output, "\n"); - fprintf(output, "%s", header); - fprintf(output, "#define YYRULECOUNT %d\n", ruleCount); -} - -int consumesInput(Node *node) -{ - if (!node) return 0; - - switch (node->type) - { - case Rule: - { - int result= 0; - if (RuleReached & node->rule.flags) - fprintf(stderr, "possible infinite left recursion in rule '%s'\n", node->rule.name); - else - { - node->rule.flags |= RuleReached; - result= consumesInput(node->rule.expression); - node->rule.flags &= ~RuleReached; - } - return result; - } - break; - - case Dot: return 1; - case Name: return consumesInput(node->name.rule); - case Character: - case String: return strlen(node->string.value) > 0; - case Class: return 1; - case Action: return 0; - case Predicate: return 0; - - case Alternate: - { - Node *n; - for (n= node->alternate.first; n; n= n->alternate.next) - if (!consumesInput(n)) - return 0; - } - return 1; - - case Sequence: - { - Node *n; - for (n= node->alternate.first; n; n= n->alternate.next) - if (consumesInput(n)) - return 1; - } - return 0; - - case PeekFor: return 0; - case PeekNot: return 0; - case Query: return 0; - case Star: return 0; - case Plus: return consumesInput(node->plus.element); - - default: - fprintf(stderr, "\nconsumesInput: illegal node type %d\n", node->type); - exit(1); - } - return 0; -} - - -void Rule_compile_c(Node *node) -{ - Node *n; - - for (n= rules; n; n= n->rule.next) - consumesInput(n); - - fprintf(output, "%s", preamble); - for (n= node; n; n= n->rule.next) - fprintf(output, "YY_RULE(int) yy_%s(yycontext *ctx); /* %d */\n", n->rule.name, n->rule.id); - fprintf(output, "\n"); - for (n= actions; n; n= n->action.list) - { - fprintf(output, "YY_ACTION(void) yy%s(yycontext *ctx, char *yytext, int yyleng)\n{\n", n->action.name); - defineVariables(n->action.rule->rule.variables); - fprintf(output, " yyprintf((stderr, \"do yy%s\\n\"));\n", n->action.name); - fprintf(output, " %s;\n", n->action.text); - undefineVariables(n->action.rule->rule.variables); - fprintf(output, "}\n"); - } - Rule_compile_c2(node); - fprintf(output, footer, start->rule.name); -} diff --git a/peg-0.1.9/examples/Makefile b/peg-0.1.9/examples/Makefile deleted file mode 100644 index 30d3cc8f..00000000 --- a/peg-0.1.9/examples/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -EXAMPLES = test rule accept wc dc dcv calc basic localctx - -CFLAGS = -g -O3 - -DIFF = diff -TEE = cat > - -all : $(EXAMPLES) - -test : .FORCE - ../peg -o test.peg.c test.peg - $(CC) $(CFLAGS) -o test test.c - echo 'ab.ac.ad.ae.afg.afh.afg.afh.afi.afj.' | ./$@ | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -rule : .FORCE - ../peg -o rule.peg.c rule.peg - $(CC) $(CFLAGS) -o rule rule.c - echo 'abcbcdabcbcdabcbcdabcbcd' | ./$@ | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -accept : .FORCE - ../peg -o accept.peg.c accept.peg - $(CC) $(CFLAGS) -o accept accept.c - echo 'abcbcdabcbcdabcbcdabcbcd' | ./$@ | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -wc : .FORCE - ../leg -o wc.leg.c wc.leg - $(CC) $(CFLAGS) -o wc wc.leg.c - cat wc.leg | ./$@ | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -dc : .FORCE - ../peg -o dc.peg.c dc.peg - $(CC) $(CFLAGS) -o dc dc.c - echo ' 2 *3 *(3+ 4) ' | ./dc | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -dcv : .FORCE - ../peg -o dcv.peg.c dcv.peg - $(CC) $(CFLAGS) -o dcv dcv.c - echo 'a = 6; b = 7; a * b' | ./dcv | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -calc : .FORCE - ../leg -o calc.leg.c calc.leg - $(CC) $(CFLAGS) -o calc calc.leg.c - echo 'a = 6; b = 7; a * b' | ./calc | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -basic : .FORCE - ../leg -o basic.leg.c basic.leg - $(CC) $(CFLAGS) -o basic basic.leg.c - ( echo 'load "test"'; echo "run" ) | ./basic | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -localctx : .FORCE - ../peg -o test.peg.c test.peg - $(CC) $(CFLAGS) -o localctx localctx.c - echo 'ab.ac.ad.ae.afg.afh.afg.afh.afi.afj.' | ./$@ | $(TEE) $@.out - $(DIFF) $@.ref $@.out - rm -f $@.out - @echo - -clean : .FORCE - rm -f *~ *.o *.[pl]eg.[cd] $(EXAMPLES) - rm -rf *.dSYM - -spotless : clean - -.FORCE : diff --git a/peg-0.1.9/examples/accept.c b/peg-0.1.9/examples/accept.c deleted file mode 100644 index 781e3b11..00000000 --- a/peg-0.1.9/examples/accept.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -#include "accept.peg.c" - -int main() -{ - while (yyparse()); - - return 0; -} diff --git a/peg-0.1.9/examples/accept.peg b/peg-0.1.9/examples/accept.peg deleted file mode 100644 index 9b28e404..00000000 --- a/peg-0.1.9/examples/accept.peg +++ /dev/null @@ -1,8 +0,0 @@ -start <- abcd+ - -abcd <- 'a' { printf("A %d\n", yypos); } bc { printf("ABC %d\n", yypos); } &{YYACCEPT} - / 'b' { printf("B %d\n", yypos); } cd { printf("BCD %d\n", yypos); } &{YYACCEPT} - -bc <- 'b' { printf("B %d\n", yypos); } 'c' { printf("C %d\n", yypos); } - -cd <- 'c' { printf("C %d\n", yypos); } 'd' { printf("D %d\n", yypos); } diff --git a/peg-0.1.9/examples/accept.ref b/peg-0.1.9/examples/accept.ref deleted file mode 100644 index 789f5283..00000000 --- a/peg-0.1.9/examples/accept.ref +++ /dev/null @@ -1,32 +0,0 @@ -A 3 -B 3 -C 3 -ABC 3 -B 3 -C 3 -D 3 -BCD 3 -A 3 -B 3 -C 3 -ABC 3 -B 3 -C 3 -D 3 -BCD 3 -A 3 -B 3 -C 3 -ABC 3 -B 3 -C 3 -D 3 -BCD 3 -A 3 -B 3 -C 3 -ABC 3 -B 3 -C 3 -D 3 -BCD 3 diff --git a/peg-0.1.9/examples/basic.leg b/peg-0.1.9/examples/basic.leg deleted file mode 100644 index ed38a8d7..00000000 --- a/peg-0.1.9/examples/basic.leg +++ /dev/null @@ -1,361 +0,0 @@ -# A 'syntax-directed interpreter' (all execution is a side-effect of parsing). -# Inspired by Dennis Allison's original Tiny BASIC grammar, circa 1975. -# -# Copyright (c) 2007 by Ian Piumarta -# All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the 'Software'), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, provided that the above copyright notice(s) and this -# permission notice appear in all copies of the Software. Acknowledgement -# of the use of this Software in supporting documentation would be -# appreciated but is not required. -# -# THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. -# -# Last edited: 2012-04-29 15:14:06 by piumarta on emilia - -%{ -# include - - typedef struct line line; - - struct line - { - int number; - int length; - char *text; - }; - - line *lines= 0; - int numLines= 0; - int pc= -1, epc= -1; - int batch= 0; - - int nextline(char *buf, int max); - -# define min(x, y) ((x) < (y) ? (x) : (y)) - -# define YY_INPUT(buf, result, max_size) \ - { \ - if ((pc >= 0) && (pc < numLines)) \ - { \ - line *linep= lines+pc++; \ - result= min(max_size, linep->length); \ - memcpy(buf, linep->text, result); \ - } \ - else \ - result= nextline(buf, max_size); \ - } - - union value { - int number; - char *string; - int (*binop)(int lhs, int rhs); - }; - -# define YYSTYPE union value - - int variables[26]; - - void accept(int number, char *line); - - void save(char *name); - void load(char *name); - void type(char *name); - - int lessThan(int lhs, int rhs) { return lhs < rhs; } - int lessEqual(int lhs, int rhs) { return lhs <= rhs; } - int notEqual(int lhs, int rhs) { return lhs != rhs; } - int equalTo(int lhs, int rhs) { return lhs == rhs; } - int greaterEqual(int lhs, int rhs) { return lhs >= rhs; } - int greaterThan(int lhs, int rhs) { return lhs > rhs; } - - int input(void); - - int stack[1024], sp= 0; - - char *help; - - void error(char *fmt, ...); - int findLine(int n, int create); -%} - -line = - s:statement CR -| - n:number < ( !CR . )* CR > { accept(n.number, yytext); } -| - CR -| - < ( !CR . )* CR > { epc= pc; error("syntax error"); } -| - !. { exit(0); } - -statement = 'print'- expr-list -| 'if'- e1:expression r:relop e2:expression { if (!r.binop(e1.number, e2.number)) yythunkpos= 0; } - 'then'- statement -| 'goto'- e:expression { epc= pc; if ((pc= findLine(e.number, 0)) < 0) error("no such line"); } -| 'input'- var-list -| 'let'- v:var EQUAL e:expression { variables[v.number]= e.number; } -| 'gosub'- e:expression { epc= pc; if (sp < 1024) stack[sp++]= pc, pc= findLine(e.number, 0); else error("too many gosubs"); - if (pc < 0) error("no such line"); } -| 'return'- { epc= pc; if ((pc= sp ? stack[--sp] : -1) < 0) error("no gosub"); } -| 'clear'- { while (numLines) accept(lines->number, "\n"); } -| 'list'- { int i; for (i= 0; i < numLines; ++i) printf("%5d %s", lines[i].number, lines[i].text); } -| 'run'- s:string { load(s.string); pc= 0; } -| 'run'- { pc= 0; } -| 'end'- { pc= -1; if (batch) exit(0); } -| 'rem'- ( !CR . )* -| ('bye'|'quit'|'exit')- { exit(0); } -| 'save'- s:string { save(s.string); } -| 'load'- s:string { load(s.string); } -| 'type'- s:string { type(s.string); } -| 'dir'- { system("ls *.bas"); } -| 'help'- { fprintf(stderr, "%s", help); } - -expr-list = ( e:string { printf("%s", e.string); } - | e:expression { printf("%d", e.number); } - )? ( COMMA ( e:string { printf("%s", e.string); } - | e:expression { printf("%d", e.number); } - ) - )* ( COMMA - | !COMMA { printf("\n"); } - ) - -var-list = v:var { variables[v.number]= input(); } - ( COMMA v:var { variables[v.number]= input(); } - )* - -expression = ( PLUS? l:term - | MINUS l:term { l.number = -l.number } - ) ( PLUS r:term { l.number += r.number } - | MINUS r:term { l.number -= r.number } - )* { $$.number = l.number } - -term = l:factor ( STAR r:factor { l.number *= r.number } - | SLASH r:factor { l.number /= r.number } - )* { $$.number = l.number } - -factor = v:var { $$.number = variables[v.number] } -| n:number -| OPEN expression CLOSE - -var = < [a-z] > - { $$.number = yytext[0] - 'a' } - -number = < digit+ > - { $$.number = atoi(yytext); } - -digit = [0-9] - -string = '"' < [^\"]* > '"' - { $$.string = yytext; } - -relop = '<=' - { $$.binop= lessEqual; } -| '<>' - { $$.binop= notEqual; } -| '<' - { $$.binop= lessThan; } -| '>=' - { $$.binop= greaterEqual; } -| '>' - { $$.binop= greaterThan; } -| '=' - { $$.binop= equalTo; } - -EQUAL = '=' - CLOSE = ')' - OPEN = '(' - -SLASH = '/' - STAR = '*' - MINUS = '-' - -PLUS = '+' - COMMA = ',' - - -- = [ \t]* - -CR = '\n' | '\r' | '\r\n' - -%% - -#include -#include - -char *help= - "print | [, | ...] [,]\n" - "if <|<=|<>|=|>=|> then \n" - "input [, ...] let = \n" - "goto gosub \n" - "end return\n" - "list clear\n" - "run [\"filename\"] rem \n" - "dir type \"filename\"\n" - "save \"filename\" load \"filename\"\n" - "bye|quit|exit help\n" - ; - -void error(char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - if (epc > 0) - fprintf(stderr, "\nline %d: %s", lines[epc-1].number, lines[epc-1].text); - else - fprintf(stderr, "\n"); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - epc= pc= -1; -} - -#ifdef USE_READLINE -# include -# include -#endif - -int nextline(char *buf, int max) -{ - pc= -1; - if (batch) exit(0); - if (isatty(fileno(stdin))) - { -# ifdef USE_READLINE - char *line= readline(">"); - if (line) - { - int len= strlen(line); - if (len >= max) len= max - 1; - strncpy(buf, line, len); - (buf)[len]= '\n'; - add_history(line); - free(line); - return len + 1; - } - else - { - printf("\n"); - return 0; - } -# endif - putchar('>'); - fflush(stdout); - } - return fgets(buf, max, stdin) ? strlen(buf) : 0; -} - -int maxLines= 0; - -int findLine(int n, int create) -{ - int lo= 0, hi= numLines - 1; - while (lo <= hi) - { - int mid= (lo + hi) / 2, lno= lines[mid].number; - if (lno > n) - hi= mid - 1; - else if (lno < n) - lo= mid + 1; - else - return mid; - } - if (create) - { - if (numLines == maxLines) - { - maxLines *= 2; - lines= realloc(lines, sizeof(line) * maxLines); - } - if (lo < numLines) - memmove(lines + lo + 1, lines + lo, sizeof(line) * (numLines - lo)); - ++numLines; - lines[lo].number= n; - lines[lo].text= 0; - return lo; - } - return -1; -} - -void accept(int n, char *s) -{ - if (s[0] < 32) /* delete */ - { - int lno= findLine(n, 0); - if (lno >= 0) - { - if (lno < numLines - 1) - memmove(lines + lno, lines + lno + 1, sizeof(line) * (numLines - lno - 1)); - --numLines; - } - } - else /* insert */ - { - int lno= findLine(n, 1); - if (lines[lno].text) free(lines[lno].text); - lines[lno].length= strlen(s); - lines[lno].text= strdup(s); - } -} - -char *extend(char *name) -{ - static char path[1024]; - int len= strlen(name); - sprintf(path, "%s%s", name, (((len > 4) && !strcasecmp(".bas", name + len - 4)) ? "" : ".bas")); - return path; -} - -void save(char *name) -{ - FILE *f= fopen(name= extend(name), "w"); - if (!f) - perror(name); - else - { - int i; - for (i= 0; i < numLines; ++i) - fprintf(f, "%d %s", lines[i].number, lines[i].text); - fclose(f); - } -} - -void load(char *name) -{ - FILE *f= fopen(name= extend(name), "r"); - if (!f) - perror(name); - else - { - int lineNumber; - char lineText[1024]; - while ((1 == fscanf(f, " %d ", &lineNumber)) && fgets(lineText, sizeof(lineText), f)) - accept(lineNumber, lineText); - fclose(f); - } -} - -void type(char *name) -{ - FILE *f= fopen(name= extend(name), "r"); - if (!f) - perror(name); - else - { - int c, d; - while ((c= getc(f)) >= 0) - putchar(d= c); - fclose(f); - if ('\n' != d && '\r' != d) putchar('\n'); - } -} - -int input(void) -{ - char line[32]; - fgets(line, sizeof(line), stdin); - return atoi(line); -} - -int main(int argc, char **argv) -{ - lines= malloc(sizeof(line) * (maxLines= 32)); - numLines= 0; - - if (argc > 1) - { - batch= 1; - while (argc-- > 1) - load(*++argv); - pc= 0; - } - - while (!feof(stdin)) - yyparse(); - - return 0; -} diff --git a/peg-0.1.9/examples/basic.ref b/peg-0.1.9/examples/basic.ref deleted file mode 100644 index 90d916c8..00000000 --- a/peg-0.1.9/examples/basic.ref +++ /dev/null @@ -1,10 +0,0 @@ - 1 - 2 4 - 3 6 9 - 4 8 12 16 - 5 10 15 20 25 - 6 12 18 24 30 36 - 7 14 21 28 35 42 49 - 8 16 24 32 40 48 56 64 - 9 18 27 36 45 54 63 72 81 - 10 20 30 40 50 60 70 80 90 100 diff --git a/peg-0.1.9/examples/bench.bas b/peg-0.1.9/examples/bench.bas deleted file mode 100644 index ffdbd44f..00000000 --- a/peg-0.1.9/examples/bench.bas +++ /dev/null @@ -1,8 +0,0 @@ -100 let n=100000 -120 let m=0 -110 let s=0 -130 let m=m+1 -140 let s=s+m -150 if m -int vars[26]; -%} - -Stmt = - e:Expr EOL { printf("%d\n", e); } - | ( !EOL . )* EOL { printf("error\n"); } - -Expr = i:ID ASSIGN s:Sum { $$= vars[i]= s; } - | s:Sum { $$= s; } - -Sum = l:Product - ( PLUS r:Product { l += r; } - | MINUS r:Product { l -= r; } - )* { $$= l; } - -Product = l:Value - ( TIMES r:Value { l *= r; } - | DIVIDE r:Value { l /= r; } - )* { $$= l; } - -Value = i:NUMBER { $$= atoi(yytext); } - | i:ID !ASSIGN { $$= vars[i]; } - | OPEN i:Expr CLOSE { $$= i; } - -NUMBER = < [0-9]+ > - { $$= atoi(yytext); } -ID = < [a-z] > - { $$= yytext[0] - 'a'; } -ASSIGN = '=' - -PLUS = '+' - -MINUS = '-' - -TIMES = '*' - -DIVIDE = '/' - -OPEN = '(' - -CLOSE = ')' - - -- = [ \t]* -EOL = '\n' | '\r\n' | '\r' | ';' - -%% - -int main() -{ - while (yyparse()); - - return 0; -} diff --git a/peg-0.1.9/examples/calc.ref b/peg-0.1.9/examples/calc.ref deleted file mode 100644 index dbd7d59e..00000000 --- a/peg-0.1.9/examples/calc.ref +++ /dev/null @@ -1,3 +0,0 @@ -6 -7 -42 diff --git a/peg-0.1.9/examples/dc.c b/peg-0.1.9/examples/dc.c deleted file mode 100644 index 32bf1a54..00000000 --- a/peg-0.1.9/examples/dc.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -int stack[1024]; -int stackp= -1; - -int push(int n) { return stack[++stackp]= n; } -int pop(void) { return stack[stackp--]; } - -#include "dc.peg.c" - -int main() -{ - while (yyparse()); - - return 0; -} diff --git a/peg-0.1.9/examples/dc.peg b/peg-0.1.9/examples/dc.peg deleted file mode 100644 index 75dcb671..00000000 --- a/peg-0.1.9/examples/dc.peg +++ /dev/null @@ -1,27 +0,0 @@ -# Grammar - -Expr <- SPACE Sum EOL { printf("%d\n", pop()); } - / (!EOL .)* EOL { printf("error\n"); } - -Sum <- Product ( PLUS Product { int r= pop(), l= pop(); push(l + r); } - / MINUS Product { int r= pop(), l= pop(); push(l - r); } - )* - -Product <- Value ( TIMES Value { int r= pop(), l= pop(); push(l * r); } - / DIVIDE Value { int r= pop(), l= pop(); push(l / r); } - )* - -Value <- NUMBER { push(atoi(yytext)); } - / OPEN Sum CLOSE - -# Lexemes - -NUMBER <- < [0-9]+ > SPACE -PLUS <- '+' SPACE -MINUS <- '-' SPACE -TIMES <- '*' SPACE -DIVIDE <- '/' SPACE -OPEN <- '(' SPACE -CLOSE <- ')' SPACE -SPACE <- [ \t]* -EOL <- '\n' / '\r\n' / '\r' diff --git a/peg-0.1.9/examples/dc.ref b/peg-0.1.9/examples/dc.ref deleted file mode 100644 index d81cc071..00000000 --- a/peg-0.1.9/examples/dc.ref +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/peg-0.1.9/examples/dcv.c b/peg-0.1.9/examples/dcv.c deleted file mode 100644 index 0c5c46d8..00000000 --- a/peg-0.1.9/examples/dcv.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -int stack[1024]; -int stackp= -1; -int var= 0; -int vars[26]; - -int push(int n) { return stack[++stackp]= n; } -int pop(void) { return stack[stackp--]; } -int top(void) { return stack[stackp]; } - -#include "dcv.peg.c" - -int main() -{ - while (yyparse()); - - return 0; -} diff --git a/peg-0.1.9/examples/dcv.peg b/peg-0.1.9/examples/dcv.peg deleted file mode 100644 index 2ae3a8cb..00000000 --- a/peg-0.1.9/examples/dcv.peg +++ /dev/null @@ -1,34 +0,0 @@ -# Grammar - -Stmt <- SPACE Expr EOL { printf("%d\n", pop()); } - / (!EOL .)* EOL { printf("error\n"); } - -Expr <- ID { var= yytext[0] } ASSIGN Sum { vars[var - 'a']= top(); } - / Sum - -Sum <- Product ( PLUS Product { int r= pop(), l= pop(); push(l + r); } - / MINUS Product { int r= pop(), l= pop(); push(l - r); } - )* - -Product <- Value ( TIMES Value { int r= pop(), l= pop(); push(l * r); } - / DIVIDE Value { int r= pop(), l= pop(); push(l / r); } - )* - -Value <- NUMBER { push(atoi(yytext)); } - / < ID > !ASSIGN { push(vars[yytext[0] - 'a']); } - / OPEN Expr CLOSE - -# Lexemes - -NUMBER <- < [0-9]+ > SPACE -ID <- < [a-z] > SPACE -ASSIGN <- '=' SPACE -PLUS <- '+' SPACE -MINUS <- '-' SPACE -TIMES <- '*' SPACE -DIVIDE <- '/' SPACE -OPEN <- '(' SPACE -CLOSE <- ')' SPACE - -SPACE <- [ \t]* -EOL <- '\n' / '\r\n' / '\r' / ';' diff --git a/peg-0.1.9/examples/dcv.ref b/peg-0.1.9/examples/dcv.ref deleted file mode 100644 index dbd7d59e..00000000 --- a/peg-0.1.9/examples/dcv.ref +++ /dev/null @@ -1,3 +0,0 @@ -6 -7 -42 diff --git a/peg-0.1.9/examples/fibonacci.bas b/peg-0.1.9/examples/fibonacci.bas deleted file mode 100644 index 1872bd3b..00000000 --- a/peg-0.1.9/examples/fibonacci.bas +++ /dev/null @@ -1,17 +0,0 @@ -100 let n=32 -110 gosub 200 -120 print "fibonacci(",n,") = ", m -130 end - -200 let c=n -210 let b=1 -220 if c<2 then goto 400 -230 let c=c-1 -240 let a=1 -300 let c=c-1 -310 let d=a+b -320 let a=b -330 let b=d+1 -340 if c<>0 then goto 300 -400 let m=b -410 return diff --git a/peg-0.1.9/examples/left.c b/peg-0.1.9/examples/left.c deleted file mode 100644 index ac8cd0bd..00000000 --- a/peg-0.1.9/examples/left.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#define YY_INPUT(buf, result, max) \ -{ \ - int c= getchar(); \ - result= (EOF == c) ? 0 : (*(buf)= c, 1); \ - if (EOF != c) printf("<%c>\n", c); \ -} - -#include "left.peg.c" - -int main() -{ - printf(yyparse() ? "success\n" : "failure\n"); - - return 0; -} diff --git a/peg-0.1.9/examples/left.peg b/peg-0.1.9/examples/left.peg deleted file mode 100644 index f282227d..00000000 --- a/peg-0.1.9/examples/left.peg +++ /dev/null @@ -1,3 +0,0 @@ -# Grammar - -S <- (S 'a' / 'a') !'a' diff --git a/peg-0.1.9/examples/localctx.c b/peg-0.1.9/examples/localctx.c deleted file mode 100644 index 837ebc88..00000000 --- a/peg-0.1.9/examples/localctx.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -#define YY_CTX_LOCAL - -#include "test.peg.c" - -int main() -{ - yycontext ctx; - memset(&ctx, 0, sizeof(yycontext)); - while (yyparse(&ctx)); - return 0; -} diff --git a/peg-0.1.9/examples/localctx.ref b/peg-0.1.9/examples/localctx.ref deleted file mode 100644 index 2d181091..00000000 --- a/peg-0.1.9/examples/localctx.ref +++ /dev/null @@ -1,10 +0,0 @@ -a1 ab1 . -a2 ac2 . -a3 ad3 . -a3 ae3 . -a4 af4 afg4 . -a4 af5 afh5 . -a4 af4 afg4 . -a4 af5 afh5 . -af6 afi6 a6 . -af6 af7 afj7 a6 . diff --git a/peg-0.1.9/examples/rule.c b/peg-0.1.9/examples/rule.c deleted file mode 100644 index 15eb0c64..00000000 --- a/peg-0.1.9/examples/rule.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -#include "rule.peg.c" - -int main() -{ - while (yyparse()); - - return 0; -} diff --git a/peg-0.1.9/examples/rule.peg b/peg-0.1.9/examples/rule.peg deleted file mode 100644 index 60a32faa..00000000 --- a/peg-0.1.9/examples/rule.peg +++ /dev/null @@ -1,8 +0,0 @@ -start <- abcd+ - -abcd <- 'a' { printf("A %d\n", yypos); } bc { printf("ABC %d\n", yypos); } - / 'b' { printf("B %d\n", yypos); } cd { printf("BCD %d\n", yypos); } - -bc <- 'b' { printf("B %d\n", yypos); } 'c' { printf("C %d\n", yypos); } - -cd <- 'c' { printf("C %d\n", yypos); } 'd' { printf("D %d\n", yypos); } diff --git a/peg-0.1.9/examples/rule.ref b/peg-0.1.9/examples/rule.ref deleted file mode 100644 index 4249ebec..00000000 --- a/peg-0.1.9/examples/rule.ref +++ /dev/null @@ -1,32 +0,0 @@ -A 24 -B 24 -C 24 -ABC 24 -B 24 -C 24 -D 24 -BCD 24 -A 24 -B 24 -C 24 -ABC 24 -B 24 -C 24 -D 24 -BCD 24 -A 24 -B 24 -C 24 -ABC 24 -B 24 -C 24 -D 24 -BCD 24 -A 24 -B 24 -C 24 -ABC 24 -B 24 -C 24 -D 24 -BCD 24 diff --git a/peg-0.1.9/examples/test.bas b/peg-0.1.9/examples/test.bas deleted file mode 100644 index 8a96e107..00000000 --- a/peg-0.1.9/examples/test.bas +++ /dev/null @@ -1,12 +0,0 @@ -10 let i=1 -20 gosub 100 -30 let i=i+1 -40 if i<=10 then goto 20 -50 end - -100 let j=1 -110 print " ", i*j, -120 let j=j+1 -130 if j<=i then goto 110 -140 print -150 return diff --git a/peg-0.1.9/examples/test.c b/peg-0.1.9/examples/test.c deleted file mode 100644 index 0403422c..00000000 --- a/peg-0.1.9/examples/test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "test.peg.c" - -int main() -{ - while (yyparse()); - return 0; -} diff --git a/peg-0.1.9/examples/test.peg b/peg-0.1.9/examples/test.peg deleted file mode 100644 index 716d5237..00000000 --- a/peg-0.1.9/examples/test.peg +++ /dev/null @@ -1,13 +0,0 @@ -start <- body '.' { printf(".\n"); } - -body <- 'a' { printf("a1 "); } 'b' { printf("ab1 "); } - - / 'a' { printf("a2 "); } 'c' { printf("ac2 "); } - - / 'a' { printf("a3 "); } ( 'd' { printf("ad3 "); } / 'e' { printf("ae3 "); } ) - - / 'a' { printf("a4 "); } ( 'f' { printf("af4 "); } 'g' { printf("afg4 "); } - / 'f' { printf("af5 "); } 'h' { printf("afh5 "); } ) - - / 'a' { printf("a6 "); } ( 'f' &{ printf("af6 ") } 'i' &{ printf("afi6 ") } - / 'f' &{ printf("af7 ") } 'j' &{ printf("afj7 ") } ) diff --git a/peg-0.1.9/examples/test.ref b/peg-0.1.9/examples/test.ref deleted file mode 100644 index 2d181091..00000000 --- a/peg-0.1.9/examples/test.ref +++ /dev/null @@ -1,10 +0,0 @@ -a1 ab1 . -a2 ac2 . -a3 ad3 . -a3 ae3 . -a4 af4 afg4 . -a4 af5 afh5 . -a4 af4 afg4 . -a4 af5 afh5 . -af6 afi6 a6 . -af6 af7 afj7 a6 . diff --git a/peg-0.1.9/examples/username.leg b/peg-0.1.9/examples/username.leg deleted file mode 100644 index 2170052a..00000000 --- a/peg-0.1.9/examples/username.leg +++ /dev/null @@ -1,14 +0,0 @@ -%{ -#include -%} - -start = "username" { printf("%s", getlogin()); } -| < . > { putchar(yytext[0]); } - -%% - -int main() -{ - while (yyparse()); - return 0; -} diff --git a/peg-0.1.9/examples/wc.leg b/peg-0.1.9/examples/wc.leg deleted file mode 100644 index 59199c89..00000000 --- a/peg-0.1.9/examples/wc.leg +++ /dev/null @@ -1,22 +0,0 @@ -%{ -#include -int lines= 0, words= 0, chars= 0; -%} - -start = (line | word | char) - -line = < (( '\n' '\r'* ) | ( '\r' '\n'* )) > { lines++; chars += yyleng; } -word = < [a-zA-Z]+ > { words++; chars += yyleng; printf("<%s>\n", yytext); } -char = . { chars++; } - -%% - -int main() -{ - while (yyparse()) - ; - printf("%d lines\n", lines); - printf("%d chars\n", chars); - printf("%d words\n", words); - return 0; -} diff --git a/peg-0.1.9/examples/wc.ref b/peg-0.1.9/examples/wc.ref deleted file mode 100644 index 083a46e6..00000000 --- a/peg-0.1.9/examples/wc.ref +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -22 lines -425 chars -52 words diff --git a/peg-0.1.9/leg.c b/peg-0.1.9/leg.c deleted file mode 100644 index 91b696d1..00000000 --- a/peg-0.1.9/leg.c +++ /dev/null @@ -1,1209 +0,0 @@ -/* A recursive-descent parser generated by peg 0.1.9 */ - -#include -#include -#include -#define YYRULECOUNT 36 - -# include "tree.h" -# include "version.h" - -# include -# include -# include -# include -# include -# include - - typedef struct Header Header; - - struct Header { - char *text; - Header *next; - }; - - FILE *input= 0; - - int verboseFlag= 0; - - static int lineNumber= 0; - static char *fileName= 0; - static char *trailer= 0; - static Header *headers= 0; - - void makeHeader(char *text); - void makeTrailer(char *text); - - void yyerror(char *message); - -# define YY_INPUT(buf, result, max) \ - { \ - int c= getc(input); \ - if ('\n' == c || '\r' == c) ++lineNumber; \ - result= (EOF == c) ? 0 : (*(buf)= c, 1); \ - } - -# define YY_LOCAL(T) static T -# define YY_RULE(T) static T - -#ifndef YY_LOCAL -#define YY_LOCAL(T) static T -#endif -#ifndef YY_ACTION -#define YY_ACTION(T) static T -#endif -#ifndef YY_RULE -#define YY_RULE(T) static T -#endif -#ifndef YY_PARSE -#define YY_PARSE(T) T -#endif -#ifndef YYPARSE -#define YYPARSE yyparse -#endif -#ifndef YYPARSEFROM -#define YYPARSEFROM yyparsefrom -#endif -#ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - { \ - int yyc= getchar(); \ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ - yyprintf((stderr, "<%c>", yyc)); \ - } -#endif -#ifndef YY_BEGIN -#define YY_BEGIN ( ctx->begin= ctx->pos, 1) -#endif -#ifndef YY_END -#define YY_END ( ctx->end= ctx->pos, 1) -#endif -#ifdef YY_DEBUG -# define yyprintf(args) fprintf args -#else -# define yyprintf(args) -#endif -#ifndef YYSTYPE -#define YYSTYPE int -#endif - -#ifndef YY_PART - -typedef struct _yycontext yycontext; -typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng); -typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; - -struct _yycontext { - char *buf; - int buflen; - int pos; - int limit; - char *text; - int textlen; - int begin; - int end; - int textmax; - yythunk *thunks; - int thunkslen; - int thunkpos; - YYSTYPE yy; - YYSTYPE *val; - YYSTYPE *vals; - int valslen; -#ifdef YY_CTX_MEMBERS - YY_CTX_MEMBERS -#endif -}; - -#ifdef YY_CTX_LOCAL -#define YY_CTX_PARAM_ yycontext *yyctx, -#define YY_CTX_PARAM yycontext *yyctx -#define YY_CTX_ARG_ yyctx, -#define YY_CTX_ARG yyctx -#else -#define YY_CTX_PARAM_ -#define YY_CTX_PARAM -#define YY_CTX_ARG_ -#define YY_CTX_ARG -yycontext yyctx0; -yycontext *yyctx= &yyctx0; -#endif - -YY_LOCAL(int) yyrefill(yycontext *ctx) -{ - int yyn; - while (ctx->buflen - ctx->pos < 512) - { - ctx->buflen *= 2; - ctx->buf= (char *)realloc(ctx->buf, ctx->buflen); - } - YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos)); - if (!yyn) return 0; - ctx->limit += yyn; - return 1; -} - -YY_LOCAL(int) yymatchDot(yycontext *ctx) -{ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; - ++ctx->pos; - return 1; -} - -YY_LOCAL(int) yymatchChar(yycontext *ctx, int c) -{ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; - if ((unsigned char)ctx->buf[ctx->pos] == c) - { - ++ctx->pos; - yyprintf((stderr, " ok yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos)); - return 1; - } - yyprintf((stderr, " fail yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos)); - return 0; -} - -YY_LOCAL(int) yymatchString(yycontext *ctx, char *s) -{ - int yysav= ctx->pos; - while (*s) - { - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; - if (ctx->buf[ctx->pos] != *s) - { - ctx->pos= yysav; - return 0; - } - ++s; - ++ctx->pos; - } - return 1; -} - -YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits) -{ - int c; - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; - c= (unsigned char)ctx->buf[ctx->pos]; - if (bits[c >> 3] & (1 << (c & 7))) - { - ++ctx->pos; - yyprintf((stderr, " ok yymatchClass @ %s\n", ctx->buf+ctx->pos)); - return 1; - } - yyprintf((stderr, " fail yymatchClass @ %s\n", ctx->buf+ctx->pos)); - return 0; -} - -YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end) -{ - while (ctx->thunkpos >= ctx->thunkslen) - { - ctx->thunkslen *= 2; - ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen); - } - ctx->thunks[ctx->thunkpos].begin= begin; - ctx->thunks[ctx->thunkpos].end= end; - ctx->thunks[ctx->thunkpos].action= action; - ++ctx->thunkpos; -} - -YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end) -{ - int yyleng= end - begin; - if (yyleng <= 0) - yyleng= 0; - else - { - while (ctx->textlen < (yyleng + 1)) - { - ctx->textlen *= 2; - ctx->text= (char *)realloc(ctx->text, ctx->textlen); - } - memcpy(ctx->text, ctx->buf + begin, yyleng); - } - ctx->text[yyleng]= '\0'; - return yyleng; -} - -YY_LOCAL(void) yyDone(yycontext *ctx) -{ - int pos; - for (pos= 0; pos < ctx->thunkpos; ++pos) - { - yythunk *thunk= &ctx->thunks[pos]; - int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin; - yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, ctx->text)); - thunk->action(ctx, ctx->text, yyleng); - } - ctx->thunkpos= 0; -} - -YY_LOCAL(void) yyCommit(yycontext *ctx) -{ - if ((ctx->limit -= ctx->pos)) - { - memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit); - } - ctx->begin -= ctx->pos; - ctx->end -= ctx->pos; - ctx->pos= ctx->thunkpos= 0; -} - -YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0) -{ - if (tp0) - { - fprintf(stderr, "accept denied at %d\n", tp0); - return 0; - } - else - { - yyDone(ctx); - yyCommit(ctx); - } - return 1; -} - -YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; } -YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; } -YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; } - -#endif /* YY_PART */ - -#define YYACCEPT yyAccept(ctx, yythunkpos0) - -YY_RULE(int) yy_end_of_line(yycontext *ctx); /* 36 */ -YY_RULE(int) yy_comment(yycontext *ctx); /* 35 */ -YY_RULE(int) yy_space(yycontext *ctx); /* 34 */ -YY_RULE(int) yy_braces(yycontext *ctx); /* 33 */ -YY_RULE(int) yy_range(yycontext *ctx); /* 32 */ -YY_RULE(int) yy_char(yycontext *ctx); /* 31 */ -YY_RULE(int) yy_END(yycontext *ctx); /* 30 */ -YY_RULE(int) yy_BEGIN(yycontext *ctx); /* 29 */ -YY_RULE(int) yy_DOT(yycontext *ctx); /* 28 */ -YY_RULE(int) yy_class(yycontext *ctx); /* 27 */ -YY_RULE(int) yy_literal(yycontext *ctx); /* 26 */ -YY_RULE(int) yy_CLOSE(yycontext *ctx); /* 25 */ -YY_RULE(int) yy_OPEN(yycontext *ctx); /* 24 */ -YY_RULE(int) yy_COLON(yycontext *ctx); /* 23 */ -YY_RULE(int) yy_PLUS(yycontext *ctx); /* 22 */ -YY_RULE(int) yy_STAR(yycontext *ctx); /* 21 */ -YY_RULE(int) yy_QUESTION(yycontext *ctx); /* 20 */ -YY_RULE(int) yy_primary(yycontext *ctx); /* 19 */ -YY_RULE(int) yy_NOT(yycontext *ctx); /* 18 */ -YY_RULE(int) yy_suffix(yycontext *ctx); /* 17 */ -YY_RULE(int) yy_action(yycontext *ctx); /* 16 */ -YY_RULE(int) yy_AND(yycontext *ctx); /* 15 */ -YY_RULE(int) yy_prefix(yycontext *ctx); /* 14 */ -YY_RULE(int) yy_BAR(yycontext *ctx); /* 13 */ -YY_RULE(int) yy_sequence(yycontext *ctx); /* 12 */ -YY_RULE(int) yy_SEMICOLON(yycontext *ctx); /* 11 */ -YY_RULE(int) yy_expression(yycontext *ctx); /* 10 */ -YY_RULE(int) yy_EQUAL(yycontext *ctx); /* 9 */ -YY_RULE(int) yy_identifier(yycontext *ctx); /* 8 */ -YY_RULE(int) yy_RPERCENT(yycontext *ctx); /* 7 */ -YY_RULE(int) yy_end_of_file(yycontext *ctx); /* 6 */ -YY_RULE(int) yy_trailer(yycontext *ctx); /* 5 */ -YY_RULE(int) yy_definition(yycontext *ctx); /* 4 */ -YY_RULE(int) yy_declaration(yycontext *ctx); /* 3 */ -YY_RULE(int) yy__(yycontext *ctx); /* 2 */ -YY_RULE(int) yy_grammar(yycontext *ctx); /* 1 */ - -YY_ACTION(void) yy_9_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_9_primary\n")); - push(makePredicate("YY_END")); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_8_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_8_primary\n")); - push(makePredicate("YY_BEGIN")); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_7_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_7_primary\n")); - push(makeAction(yytext)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_6_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_6_primary\n")); - push(makeDot()); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_5_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_5_primary\n")); - push(makeClass(yytext)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_4_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_4_primary\n")); - push(makeString(yytext)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_3_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_3_primary\n")); - push(makeName(findRule(yytext))); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_2_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_2_primary\n")); - Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_primary(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_primary\n")); - push(makeVariable(yytext)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_3_suffix(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_3_suffix\n")); - push(makePlus (pop())); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_2_suffix(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_2_suffix\n")); - push(makeStar (pop())); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_suffix(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_suffix\n")); - push(makeQuery(pop())); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_3_prefix(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_3_prefix\n")); - push(makePeekNot(pop())); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_2_prefix(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_2_prefix\n")); - push(makePeekFor(pop())); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_prefix(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_prefix\n")); - push(makePredicate(yytext)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_sequence(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_sequence\n")); - Node *f= pop(); push(Sequence_append(pop(), f)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_expression(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_expression\n")); - Node *f= pop(); push(Alternate_append(pop(), f)); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_2_definition(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_2_definition\n")); - Node *e= pop(); Rule_setExpression(pop(), e); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_definition(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_definition\n")); - if (push(beginRule(findRule(yytext)))->rule.expression) - fprintf(stderr, "rule '%s' redefined\n", yytext); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_trailer(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_trailer\n")); - makeTrailer(yytext); ; -#undef yythunkpos -#undef yypos -#undef yy -} -YY_ACTION(void) yy_1_declaration(yycontext *ctx, char *yytext, int yyleng) -{ -#define yy ctx->yy -#define yypos ctx->pos -#define yythunkpos ctx->thunkpos - yyprintf((stderr, "do yy_1_declaration\n")); - makeHeader(yytext); ; -#undef yythunkpos -#undef yypos -#undef yy -} - -YY_RULE(int) yy_end_of_line(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "end_of_line")); - { int yypos2= ctx->pos, yythunkpos2= ctx->thunkpos; if (!yymatchString(ctx, "\r\n")) goto l3; goto l2; - l3:; ctx->pos= yypos2; ctx->thunkpos= yythunkpos2; if (!yymatchChar(ctx, '\n')) goto l4; goto l2; - l4:; ctx->pos= yypos2; ctx->thunkpos= yythunkpos2; if (!yymatchChar(ctx, '\r')) goto l1; - } - l2:; - yyprintf((stderr, " ok %s @ %s\n", "end_of_line", ctx->buf+ctx->pos)); - return 1; - l1:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "end_of_line", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_comment(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(ctx, '#')) goto l5; - l6:; - { int yypos7= ctx->pos, yythunkpos7= ctx->thunkpos; - { int yypos8= ctx->pos, yythunkpos8= ctx->thunkpos; if (!yy_end_of_line(ctx)) goto l8; goto l7; - l8:; ctx->pos= yypos8; ctx->thunkpos= yythunkpos8; - } if (!yymatchDot(ctx)) goto l7; goto l6; - l7:; ctx->pos= yypos7; ctx->thunkpos= yythunkpos7; - } if (!yy_end_of_line(ctx)) goto l5; - yyprintf((stderr, " ok %s @ %s\n", "comment", ctx->buf+ctx->pos)); - return 1; - l5:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "comment", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_space(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "space")); - { int yypos10= ctx->pos, yythunkpos10= ctx->thunkpos; if (!yymatchChar(ctx, ' ')) goto l11; goto l10; - l11:; ctx->pos= yypos10; ctx->thunkpos= yythunkpos10; if (!yymatchChar(ctx, '\t')) goto l12; goto l10; - l12:; ctx->pos= yypos10; ctx->thunkpos= yythunkpos10; if (!yy_end_of_line(ctx)) goto l9; - } - l10:; - yyprintf((stderr, " ok %s @ %s\n", "space", ctx->buf+ctx->pos)); - return 1; - l9:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "space", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_braces(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "braces")); - { int yypos14= ctx->pos, yythunkpos14= ctx->thunkpos; if (!yymatchChar(ctx, '{')) goto l15; - l16:; - { int yypos17= ctx->pos, yythunkpos17= ctx->thunkpos; if (!yy_braces(ctx)) goto l17; goto l16; - l17:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17; - } if (!yymatchChar(ctx, '}')) goto l15; goto l14; - l15:; ctx->pos= yypos14; ctx->thunkpos= yythunkpos14; - { int yypos18= ctx->pos, yythunkpos18= ctx->thunkpos; if (!yymatchChar(ctx, '}')) goto l18; goto l13; - l18:; ctx->pos= yypos18; ctx->thunkpos= yythunkpos18; - } if (!yymatchDot(ctx)) goto l13; - } - l14:; - yyprintf((stderr, " ok %s @ %s\n", "braces", ctx->buf+ctx->pos)); - return 1; - l13:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "braces", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_range(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "range")); - { int yypos20= ctx->pos, yythunkpos20= ctx->thunkpos; if (!yy_char(ctx)) goto l21; if (!yymatchChar(ctx, '-')) goto l21; if (!yy_char(ctx)) goto l21; goto l20; - l21:; ctx->pos= yypos20; ctx->thunkpos= yythunkpos20; if (!yy_char(ctx)) goto l19; - } - l20:; - yyprintf((stderr, " ok %s @ %s\n", "range", ctx->buf+ctx->pos)); - return 1; - l19:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "range", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_char(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "char")); - { int yypos23= ctx->pos, yythunkpos23= ctx->thunkpos; if (!yymatchChar(ctx, '\\')) goto l24; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\204\040\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l24; goto l23; - l24:; ctx->pos= yypos23; ctx->thunkpos= yythunkpos23; if (!yymatchChar(ctx, '\\')) goto l25; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; goto l23; - l25:; ctx->pos= yypos23; ctx->thunkpos= yythunkpos23; if (!yymatchChar(ctx, '\\')) goto l26; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; - { int yypos27= ctx->pos, yythunkpos27= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l27; goto l28; - l27:; ctx->pos= yypos27; ctx->thunkpos= yythunkpos27; - } - l28:; goto l23; - l26:; ctx->pos= yypos23; ctx->thunkpos= yythunkpos23; - { int yypos29= ctx->pos, yythunkpos29= ctx->thunkpos; if (!yymatchChar(ctx, '\\')) goto l29; goto l22; - l29:; ctx->pos= yypos29; ctx->thunkpos= yythunkpos29; - } if (!yymatchDot(ctx)) goto l22; - } - l23:; - yyprintf((stderr, " ok %s @ %s\n", "char", ctx->buf+ctx->pos)); - return 1; - l22:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "char", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_END(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "END")); if (!yymatchChar(ctx, '>')) goto l30; if (!yy__(ctx)) goto l30; - yyprintf((stderr, " ok %s @ %s\n", "END", ctx->buf+ctx->pos)); - return 1; - l30:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "END", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_BEGIN(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar(ctx, '<')) goto l31; if (!yy__(ctx)) goto l31; - yyprintf((stderr, " ok %s @ %s\n", "BEGIN", ctx->buf+ctx->pos)); - return 1; - l31:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BEGIN", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_DOT(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar(ctx, '.')) goto l32; if (!yy__(ctx)) goto l32; - yyprintf((stderr, " ok %s @ %s\n", "DOT", ctx->buf+ctx->pos)); - return 1; - l32:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "DOT", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_class(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "class")); if (!yymatchChar(ctx, '[')) goto l33; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l33; - l34:; - { int yypos35= ctx->pos, yythunkpos35= ctx->thunkpos; - { int yypos36= ctx->pos, yythunkpos36= ctx->thunkpos; if (!yymatchChar(ctx, ']')) goto l36; goto l35; - l36:; ctx->pos= yypos36; ctx->thunkpos= yythunkpos36; - } if (!yy_range(ctx)) goto l35; goto l34; - l35:; ctx->pos= yypos35; ctx->thunkpos= yythunkpos35; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l33; if (!yymatchChar(ctx, ']')) goto l33; if (!yy__(ctx)) goto l33; - yyprintf((stderr, " ok %s @ %s\n", "class", ctx->buf+ctx->pos)); - return 1; - l33:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "class", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_literal(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "literal")); - { int yypos38= ctx->pos, yythunkpos38= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l39; - l40:; - { int yypos41= ctx->pos, yythunkpos41= ctx->thunkpos; - { int yypos42= ctx->pos, yythunkpos42= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l42; goto l41; - l42:; ctx->pos= yypos42; ctx->thunkpos= yythunkpos42; - } if (!yy_char(ctx)) goto l41; goto l40; - l41:; ctx->pos= yypos41; ctx->thunkpos= yythunkpos41; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l39; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; if (!yy__(ctx)) goto l39; goto l38; - l39:; ctx->pos= yypos38; ctx->thunkpos= yythunkpos38; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l37; - l43:; - { int yypos44= ctx->pos, yythunkpos44= ctx->thunkpos; - { int yypos45= ctx->pos, yythunkpos45= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l45; goto l44; - l45:; ctx->pos= yypos45; ctx->thunkpos= yythunkpos45; - } if (!yy_char(ctx)) goto l44; goto l43; - l44:; ctx->pos= yypos44; ctx->thunkpos= yythunkpos44; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l37; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; if (!yy__(ctx)) goto l37; - } - l38:; - yyprintf((stderr, " ok %s @ %s\n", "literal", ctx->buf+ctx->pos)); - return 1; - l37:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "literal", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_CLOSE(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(ctx, ')')) goto l46; if (!yy__(ctx)) goto l46; - yyprintf((stderr, " ok %s @ %s\n", "CLOSE", ctx->buf+ctx->pos)); - return 1; - l46:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "CLOSE", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_OPEN(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar(ctx, '(')) goto l47; if (!yy__(ctx)) goto l47; - yyprintf((stderr, " ok %s @ %s\n", "OPEN", ctx->buf+ctx->pos)); - return 1; - l47:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OPEN", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_COLON(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(ctx, ':')) goto l48; if (!yy__(ctx)) goto l48; - yyprintf((stderr, " ok %s @ %s\n", "COLON", ctx->buf+ctx->pos)); - return 1; - l48:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "COLON", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_PLUS(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar(ctx, '+')) goto l49; if (!yy__(ctx)) goto l49; - yyprintf((stderr, " ok %s @ %s\n", "PLUS", ctx->buf+ctx->pos)); - return 1; - l49:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PLUS", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_STAR(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar(ctx, '*')) goto l50; if (!yy__(ctx)) goto l50; - yyprintf((stderr, " ok %s @ %s\n", "STAR", ctx->buf+ctx->pos)); - return 1; - l50:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STAR", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_QUESTION(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar(ctx, '?')) goto l51; if (!yy__(ctx)) goto l51; - yyprintf((stderr, " ok %s @ %s\n", "QUESTION", ctx->buf+ctx->pos)); - return 1; - l51:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "QUESTION", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_primary(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "primary")); - { int yypos53= ctx->pos, yythunkpos53= ctx->thunkpos; if (!yy_identifier(ctx)) goto l54; yyDo(ctx, yy_1_primary, ctx->begin, ctx->end); if (!yy_COLON(ctx)) goto l54; if (!yy_identifier(ctx)) goto l54; - { int yypos55= ctx->pos, yythunkpos55= ctx->thunkpos; if (!yy_EQUAL(ctx)) goto l55; goto l54; - l55:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; - } yyDo(ctx, yy_2_primary, ctx->begin, ctx->end); goto l53; - l54:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_identifier(ctx)) goto l56; - { int yypos57= ctx->pos, yythunkpos57= ctx->thunkpos; if (!yy_EQUAL(ctx)) goto l57; goto l56; - l57:; ctx->pos= yypos57; ctx->thunkpos= yythunkpos57; - } yyDo(ctx, yy_3_primary, ctx->begin, ctx->end); goto l53; - l56:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_OPEN(ctx)) goto l58; if (!yy_expression(ctx)) goto l58; if (!yy_CLOSE(ctx)) goto l58; goto l53; - l58:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_literal(ctx)) goto l59; yyDo(ctx, yy_4_primary, ctx->begin, ctx->end); goto l53; - l59:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_class(ctx)) goto l60; yyDo(ctx, yy_5_primary, ctx->begin, ctx->end); goto l53; - l60:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_DOT(ctx)) goto l61; yyDo(ctx, yy_6_primary, ctx->begin, ctx->end); goto l53; - l61:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_action(ctx)) goto l62; yyDo(ctx, yy_7_primary, ctx->begin, ctx->end); goto l53; - l62:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_BEGIN(ctx)) goto l63; yyDo(ctx, yy_8_primary, ctx->begin, ctx->end); goto l53; - l63:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_END(ctx)) goto l52; yyDo(ctx, yy_9_primary, ctx->begin, ctx->end); - } - l53:; - yyprintf((stderr, " ok %s @ %s\n", "primary", ctx->buf+ctx->pos)); - return 1; - l52:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "primary", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_NOT(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar(ctx, '!')) goto l64; if (!yy__(ctx)) goto l64; - yyprintf((stderr, " ok %s @ %s\n", "NOT", ctx->buf+ctx->pos)); - return 1; - l64:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NOT", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_suffix(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary(ctx)) goto l65; - { int yypos66= ctx->pos, yythunkpos66= ctx->thunkpos; - { int yypos68= ctx->pos, yythunkpos68= ctx->thunkpos; if (!yy_QUESTION(ctx)) goto l69; yyDo(ctx, yy_1_suffix, ctx->begin, ctx->end); goto l68; - l69:; ctx->pos= yypos68; ctx->thunkpos= yythunkpos68; if (!yy_STAR(ctx)) goto l70; yyDo(ctx, yy_2_suffix, ctx->begin, ctx->end); goto l68; - l70:; ctx->pos= yypos68; ctx->thunkpos= yythunkpos68; if (!yy_PLUS(ctx)) goto l66; yyDo(ctx, yy_3_suffix, ctx->begin, ctx->end); - } - l68:; goto l67; - l66:; ctx->pos= yypos66; ctx->thunkpos= yythunkpos66; - } - l67:; - yyprintf((stderr, " ok %s @ %s\n", "suffix", ctx->buf+ctx->pos)); - return 1; - l65:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "suffix", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_action(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "action")); if (!yymatchChar(ctx, '{')) goto l71; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l71; - l72:; - { int yypos73= ctx->pos, yythunkpos73= ctx->thunkpos; if (!yy_braces(ctx)) goto l73; goto l72; - l73:; ctx->pos= yypos73; ctx->thunkpos= yythunkpos73; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l71; if (!yymatchChar(ctx, '}')) goto l71; if (!yy__(ctx)) goto l71; - yyprintf((stderr, " ok %s @ %s\n", "action", ctx->buf+ctx->pos)); - return 1; - l71:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "action", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_AND(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar(ctx, '&')) goto l74; if (!yy__(ctx)) goto l74; - yyprintf((stderr, " ok %s @ %s\n", "AND", ctx->buf+ctx->pos)); - return 1; - l74:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AND", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_prefix(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "prefix")); - { int yypos76= ctx->pos, yythunkpos76= ctx->thunkpos; if (!yy_AND(ctx)) goto l77; if (!yy_action(ctx)) goto l77; yyDo(ctx, yy_1_prefix, ctx->begin, ctx->end); goto l76; - l77:; ctx->pos= yypos76; ctx->thunkpos= yythunkpos76; if (!yy_AND(ctx)) goto l78; if (!yy_suffix(ctx)) goto l78; yyDo(ctx, yy_2_prefix, ctx->begin, ctx->end); goto l76; - l78:; ctx->pos= yypos76; ctx->thunkpos= yythunkpos76; if (!yy_NOT(ctx)) goto l79; if (!yy_suffix(ctx)) goto l79; yyDo(ctx, yy_3_prefix, ctx->begin, ctx->end); goto l76; - l79:; ctx->pos= yypos76; ctx->thunkpos= yythunkpos76; if (!yy_suffix(ctx)) goto l75; - } - l76:; - yyprintf((stderr, " ok %s @ %s\n", "prefix", ctx->buf+ctx->pos)); - return 1; - l75:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "prefix", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_BAR(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar(ctx, '|')) goto l80; if (!yy__(ctx)) goto l80; - yyprintf((stderr, " ok %s @ %s\n", "BAR", ctx->buf+ctx->pos)); - return 1; - l80:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BAR", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_sequence(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "sequence")); if (!yy_prefix(ctx)) goto l81; - l82:; - { int yypos83= ctx->pos, yythunkpos83= ctx->thunkpos; if (!yy_prefix(ctx)) goto l83; yyDo(ctx, yy_1_sequence, ctx->begin, ctx->end); goto l82; - l83:; ctx->pos= yypos83; ctx->thunkpos= yythunkpos83; - } - yyprintf((stderr, " ok %s @ %s\n", "sequence", ctx->buf+ctx->pos)); - return 1; - l81:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "sequence", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_SEMICOLON(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(ctx, ';')) goto l84; if (!yy__(ctx)) goto l84; - yyprintf((stderr, " ok %s @ %s\n", "SEMICOLON", ctx->buf+ctx->pos)); - return 1; - l84:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SEMICOLON", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_expression(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence(ctx)) goto l85; - l86:; - { int yypos87= ctx->pos, yythunkpos87= ctx->thunkpos; if (!yy_BAR(ctx)) goto l87; if (!yy_sequence(ctx)) goto l87; yyDo(ctx, yy_1_expression, ctx->begin, ctx->end); goto l86; - l87:; ctx->pos= yypos87; ctx->thunkpos= yythunkpos87; - } - yyprintf((stderr, " ok %s @ %s\n", "expression", ctx->buf+ctx->pos)); - return 1; - l85:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "expression", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_EQUAL(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar(ctx, '=')) goto l88; if (!yy__(ctx)) goto l88; - yyprintf((stderr, " ok %s @ %s\n", "EQUAL", ctx->buf+ctx->pos)); - return 1; - l88:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EQUAL", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_identifier(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "identifier")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l89; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\040\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l89; - l90:; - { int yypos91= ctx->pos, yythunkpos91= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l91; goto l90; - l91:; ctx->pos= yypos91; ctx->thunkpos= yythunkpos91; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l89; if (!yy__(ctx)) goto l89; - yyprintf((stderr, " ok %s @ %s\n", "identifier", ctx->buf+ctx->pos)); - return 1; - l89:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "identifier", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_RPERCENT(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString(ctx, "%}")) goto l92; if (!yy__(ctx)) goto l92; - yyprintf((stderr, " ok %s @ %s\n", "RPERCENT", ctx->buf+ctx->pos)); - return 1; - l92:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RPERCENT", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_end_of_file(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "end_of_file")); - { int yypos94= ctx->pos, yythunkpos94= ctx->thunkpos; if (!yymatchDot(ctx)) goto l94; goto l93; - l94:; ctx->pos= yypos94; ctx->thunkpos= yythunkpos94; - } - yyprintf((stderr, " ok %s @ %s\n", "end_of_file", ctx->buf+ctx->pos)); - return 1; - l93:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "end_of_file", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_trailer(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString(ctx, "%%")) goto l95; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l95; - l96:; - { int yypos97= ctx->pos, yythunkpos97= ctx->thunkpos; if (!yymatchDot(ctx)) goto l97; goto l96; - l97:; ctx->pos= yypos97; ctx->thunkpos= yythunkpos97; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l95; yyDo(ctx, yy_1_trailer, ctx->begin, ctx->end); - yyprintf((stderr, " ok %s @ %s\n", "trailer", ctx->buf+ctx->pos)); - return 1; - l95:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "trailer", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_definition(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier(ctx)) goto l98; yyDo(ctx, yy_1_definition, ctx->begin, ctx->end); if (!yy_EQUAL(ctx)) goto l98; if (!yy_expression(ctx)) goto l98; yyDo(ctx, yy_2_definition, ctx->begin, ctx->end); - { int yypos99= ctx->pos, yythunkpos99= ctx->thunkpos; if (!yy_SEMICOLON(ctx)) goto l99; goto l100; - l99:; ctx->pos= yypos99; ctx->thunkpos= yythunkpos99; - } - l100:; - yyprintf((stderr, " ok %s @ %s\n", "definition", ctx->buf+ctx->pos)); - return 1; - l98:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "definition", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy_declaration(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString(ctx, "%{")) goto l101; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l101; - l102:; - { int yypos103= ctx->pos, yythunkpos103= ctx->thunkpos; - { int yypos104= ctx->pos, yythunkpos104= ctx->thunkpos; if (!yymatchString(ctx, "%}")) goto l104; goto l103; - l104:; ctx->pos= yypos104; ctx->thunkpos= yythunkpos104; - } if (!yymatchDot(ctx)) goto l103; goto l102; - l103:; ctx->pos= yypos103; ctx->thunkpos= yythunkpos103; - } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l101; if (!yy_RPERCENT(ctx)) goto l101; yyDo(ctx, yy_1_declaration, ctx->begin, ctx->end); - yyprintf((stderr, " ok %s @ %s\n", "declaration", ctx->buf+ctx->pos)); - return 1; - l101:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "declaration", ctx->buf+ctx->pos)); - return 0; -} -YY_RULE(int) yy__(yycontext *ctx) -{ - yyprintf((stderr, "%s\n", "_")); - l106:; - { int yypos107= ctx->pos, yythunkpos107= ctx->thunkpos; - { int yypos108= ctx->pos, yythunkpos108= ctx->thunkpos; if (!yy_space(ctx)) goto l109; goto l108; - l109:; ctx->pos= yypos108; ctx->thunkpos= yythunkpos108; if (!yy_comment(ctx)) goto l107; - } - l108:; goto l106; - l107:; ctx->pos= yypos107; ctx->thunkpos= yythunkpos107; - } - yyprintf((stderr, " ok %s @ %s\n", "_", ctx->buf+ctx->pos)); - return 1; -} -YY_RULE(int) yy_grammar(yycontext *ctx) -{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; - yyprintf((stderr, "%s\n", "grammar")); if (!yy__(ctx)) goto l110; - { int yypos113= ctx->pos, yythunkpos113= ctx->thunkpos; if (!yy_declaration(ctx)) goto l114; goto l113; - l114:; ctx->pos= yypos113; ctx->thunkpos= yythunkpos113; if (!yy_definition(ctx)) goto l110; - } - l113:; - l111:; - { int yypos112= ctx->pos, yythunkpos112= ctx->thunkpos; - { int yypos115= ctx->pos, yythunkpos115= ctx->thunkpos; if (!yy_declaration(ctx)) goto l116; goto l115; - l116:; ctx->pos= yypos115; ctx->thunkpos= yythunkpos115; if (!yy_definition(ctx)) goto l112; - } - l115:; goto l111; - l112:; ctx->pos= yypos112; ctx->thunkpos= yythunkpos112; - } - { int yypos117= ctx->pos, yythunkpos117= ctx->thunkpos; if (!yy_trailer(ctx)) goto l117; goto l118; - l117:; ctx->pos= yypos117; ctx->thunkpos= yythunkpos117; - } - l118:; if (!yy_end_of_file(ctx)) goto l110; - yyprintf((stderr, " ok %s @ %s\n", "grammar", ctx->buf+ctx->pos)); - return 1; - l110:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "grammar", ctx->buf+ctx->pos)); - return 0; -} - -#ifndef YY_PART - -typedef int (*yyrule)(yycontext *ctx); - -YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart) -{ - int yyok; - if (!yyctx->buflen) - { - yyctx->buflen= 1024; - yyctx->buf= (char *)malloc(yyctx->buflen); - yyctx->textlen= 1024; - yyctx->text= (char *)malloc(yyctx->textlen); - yyctx->thunkslen= 32; - yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen); - yyctx->valslen= 32; - yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen); - yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0; - } - yyctx->begin= yyctx->end= yyctx->pos; - yyctx->thunkpos= 0; - yyctx->val= yyctx->vals; - yyok= yystart(yyctx); - if (yyok) yyDone(yyctx); - yyCommit(yyctx); - return yyok; -} - -YY_PARSE(int) YYPARSE(YY_CTX_PARAM) -{ - return YYPARSEFROM(YY_CTX_ARG_ yy_grammar); -} - -#endif - - -void yyerror(char *message) -{ - fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message); - if (yyctx->text[0]) fprintf(stderr, " near token '%s'", yyctx->text); - if (yyctx->pos < yyctx->limit || !feof(input)) - { - yyctx->buf[yyctx->limit]= '\0'; - fprintf(stderr, " before text \""); - while (yyctx->pos < yyctx->limit) - { - if ('\n' == yyctx->buf[yyctx->pos] || '\r' == yyctx->buf[yyctx->pos]) break; - fputc(yyctx->buf[yyctx->pos++], stderr); - } - if (yyctx->pos == yyctx->limit) - { - int c; - while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) - fputc(c, stderr); - } - fputc('\"', stderr); - } - fprintf(stderr, "\n"); - exit(1); -} - -void makeHeader(char *text) -{ - Header *header= (Header *)malloc(sizeof(Header)); - header->text= strdup(text); - header->next= headers; - headers= header; -} - -void makeTrailer(char *text) -{ - trailer= strdup(text); -} - -static void version(char *name) -{ - printf("%s version %d.%d.%d\n", name, PEG_MAJOR, PEG_MINOR, PEG_LEVEL); -} - -static void usage(char *name) -{ - version(name); - fprintf(stderr, "usage: %s [