bibtex/0000755000176000001440000000000013731452745011572 5ustar ripleyusersbibtex/NAMESPACE0000644000176000001440000000063513125421761013004 0ustar ripleyusers# Generated by roxygen2: do not edit by hand export(do_read_bib) export(read.bib) export(write.bib) importFrom(stringr,str_trim) importFrom(tools,deparseLatex) importFrom(tools,latexToUtf8) importFrom(tools,parseLatex) importFrom(utils,as.personList) importFrom(utils,bibentry) importFrom(utils,citation) importFrom(utils,installed.packages) importFrom(utils,person) importFrom(utils,toBibtex) useDynLib(bibtex) bibtex/README.md0000644000176000001440000000045113125417226013041 0ustar ripleyusers# bibtex [![Travis-CI Build Status](https://travis-ci.org/romainfrancois/bibtex.svg?branch=master)](https://travis-ci.org/romainfrancois/bibtex) ## Installation You can install bibtex from github with: ```R # install.packages("devtools") devtools::install_github("romainfrancois/bibtex") ``` bibtex/man/0000755000176000001440000000000013730050146012331 5ustar ripleyusersbibtex/man/read.bib.Rd0000644000176000001440000000343513730050146014273 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{read.bib} \alias{read.bib} \title{bibtex parser} \usage{ read.bib(file = findBibFile(package), package = "bibtex", encoding = "unknown", header = if (length(preamble)) paste(preamble, sep = "\\n") else "", footer = "") } \arguments{ \item{file}{bib file to parse. By default, the file \file{REFERENCES.bib} in the root directory of the package given by the \code{package} argument is used.} \item{package}{package from which we want to read the bibliography. Only used if \code{file} is unspecified. Core R packages (base, datasets, graphics, grDevices, methods, stats, stats4, tools and utils) are treated specially: this package contains bibtex entries for these packages.} \item{encoding}{encoding} \item{header}{header of the citation list. By default this is made from the \samp{Preamble} entries found in the bib file.} \item{footer}{footer of the citation list} } \value{ An object of class \code{"bibentry"}, similar to those obtained by the \code{\link[utils]{bibentry}} function. } \description{ Parser for bibliography databases written in the bib format. } \examples{ ## this package has a REFERENCES.bib file bib <- read.bib( package = "bibtex" ) ## bibtex collects bibtex entries for R base packages base.bib <- read.bib( package = "base" ) \dontshow{ bib <- read.bib( package = "base" ) bib <- read.bib( package = "datasets" ) bib <- read.bib( package = "graphics" ) bib <- read.bib( package = "grDevices" ) bib <- read.bib( package = "methods" ) bib <- read.bib( package = "stats" ) bib <- read.bib( package = "stats4" ) bib <- read.bib( package = "tools" ) bib <- read.bib( package = "utils" ) } } \references{ Nelson H. F. Beebe. bibparse 1.04. 1999. \url{http://www.math.utah.edu/~beebe/} } bibtex/man/do_read_bib.Rd0000644000176000001440000000132113125421011015015 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{do_read_bib} \alias{do_read_bib} \title{convenience wrapper around .External call} \usage{ do_read_bib(file, encoding = "unknown", srcfile) } \arguments{ \item{file}{file name} \item{encoding}{encoding} \item{srcfile}{output of \code{\link{srcfile}}} } \description{ This is a convenience function for packages that do need to call the internal functionality of \code{\link{read.bib}} but does different processing. This is a simple wrapper around the \code{.External} code used by \code{\link{read.bib}} } \details{ The parser is greatly inspired from the \samp{bibparse} library. } \seealso{ \code{\link[utils]{bibentry}} } bibtex/man/write.bib.Rd0000644000176000001440000000241613577230255014522 0ustar ripleyusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bibtex.R \name{write.bib} \alias{write.bib} \title{Generate a Bibtex File from Package Citations} \usage{ write.bib(entry, file = "Rpackages.bib", append = FALSE, verbose = TRUE) } \arguments{ \item{entry}{a \code{\link{bibentry}} object or a character vector of package names. If \code{NULL}, then the list of all installed packages is used.} \item{file}{output Bibtex file.} \item{append}{logical. If \code{TRUE} content is appended to the file.} \item{verbose}{a logical to toggle verbosity.} } \value{ the list of Bibtex objects -- invisibly. } \description{ Generates a Bibtex file from a list of packages or all the installed packages. It is useful for adding relevant citations in Sweave documents. } \examples{ write.bib(c('bibtex', 'utils', 'tools'), file='references') bibs <- read.bib('references.bib') write.bib(bibs, 'references2.bib') md5 <- tools::md5sum(c('references.bib', 'references2.bib')) md5[1] == md5[2] \dontshow{unlink(c('references.bib', 'references2.bib'))} } \references{ \emph{[R] Creating bibtex file of all installed packages?} Achim Zeileis. R-help mailing list. } \author{ Renaud Gaujoux, based on the function \code{Rpackages.bib} from Achim Zeileis (see \emph{References}). } bibtex/DESCRIPTION0000644000176000001440000000167113731452745013305 0ustar ripleyusersPackage: bibtex Version: 0.4.2.3 Title: Bibtex Parser Authors@R: c( person("Romain", "Francois", role = c("aut", "cre"), email = "romain@r-enthusiasts.com"), person("Kurt", "Hornik", role = "ctb", email = "Kurt.Hornik@R-project.org"), person("Michael", "Koohafkan", role = "ctb", email = "michael.koohafkan@gmail.com"), person(c("Mathew", "W."), "McLean", role = "ctb", email = "mathew.w.mclean@gmail.com" ) ) Description: Utility to parse a bibtex file. Depends: R (>= 3.0.2) Imports: stringr, utils Suggests: testthat License: GPL (>= 2) LazyLoad: yes BugReports: https://github.com/romainfrancois/bibtex/issues URL: https://github.com/romainfrancois/bibtex RoxygenNote: 6.0.1.9000 NeedsCompilation: yes Author: Romain Francois [aut, cre], Kurt Hornik [ctb], Michael Koohafkan [ctb], Mathew W. McLean [ctb] Maintainer: ORPHANED Packaged: 2020-09-19 19:01:11 UTC; ripley Repository: CRAN Date/Publication: 2020-09-19 21:02:37 bibtex/tests/0000755000176000001440000000000013125410150012711 5ustar ripleyusersbibtex/tests/testthat/0000755000176000001440000000000013731452745014574 5ustar ripleyusersbibtex/tests/testthat/test-bibtex.R0000644000176000001440000000205413125420423017133 0ustar ripleyuserscontext("bibtex") test_that("arrange.single.author does not add extra trailing space in given names (#7)", { given <- bibtex:::ArrangeSingleAuthor('Jean-Claude {Van Damme}')$given expect_false( grepl( "[[:space:]]$", given ) ) }) test_that("read.bib Ignores entry but does not stop with invalid author/editor (#12)", { f <- file.path(system.file("bib", "badFormat.bib", package = "bibtex")) bib <- read.bib(f) expect_true(length(bib) == 1L) }) test_that("read.bib can use ? in key (#9)", { tmp <- tempfile(fileext = ".bib") entry <- "@Misc{key?,\n author = \"Smith, Bob\",\n title = \"The Title\",\n year = 2012, \n}" writeLines(entry, tmp) out <- read.bib(tmp) expect_equal( names(out), "key?" ) }) test_that("make.bib.entry can generate year from date (#15)", { tmp <- tempfile( fileext = ".bib") entry <- '@Article{newspaper, author = {Author Smith}, title = {Article title}, date = {2016-12-21}, journal = {Newspaper name}, }' writeLines(entry, tmp) out <- read.bib(tmp) expect_equal( out$year, "2016" ) }) bibtex/tests/testthat/test-authors.R0000755000176000001440000000276213125441771017365 0ustar ripleyuserscontext("Author Parsing") library(bibtex) test_that("Smith, Jr., John", { authors <- "Smith, Jr., John" parsed <- bibtex:::ArrangeAuthors(authors) expect_equal(length(parsed$family), 2L) }) test_that("Smith, Jr., John and Mary {Tyler Moore}", { authors <- "Smith, Jr., John and Mary {Tyler Moore}" parsed <- bibtex:::ArrangeAuthors(authors) expect_match(parsed[[2]]$family, "Tyler Moore") }) test_that("Smith, Jr., John and {MATLAB, Inc.}", { authors <- "Smith, Jr., John and {MATLAB, Inc.}" parsed <- bibtex:::ArrangeAuthors(authors) expect_match(parsed[[2]]$family, "MATLAB, Inc.") expect_equal(length(unlist(parsed$family[1])), 2L) }) test_that("Smith, John Paul and {MATLAB, Inc.}", { authors <- "Smith, John Paul and {MATLAB, Inc.}" parsed <- bibtex:::ArrangeAuthors(authors) expect_equal(length(unlist(parsed$given[1])), 2L) }) test_that("{de Gama}, Vasco", { authors <- "{de Gama}, Vasco" parsed <- bibtex:::ArrangeSingleAuthor(authors) expect_equal(length(parsed$family), 2L) }) test_that("Mark von Bommel", { authors <- "Mark von Bommel" parsed <- bibtex:::ArrangeSingleAuthor(authors) expect_equal(length(parsed$family), 2L) }) test_that("de la Soul, Posdnous", { authors <- "de la Soul, Posdnous" parsed <- bibtex:::ArrangeSingleAuthor(authors) expect_equal(length(parsed$family), 2L) }) test_that("des White, Jr., Walter", { authors <- "des White, Jr., Walter" parsed <- bibtex:::ArrangeSingleAuthor(authors) expect_equal(length(parsed$family), 3L) }) bibtex/tests/testthat.R0000644000176000001440000000007513125410150014676 0ustar ripleyuserslibrary("testthat") library("bibtex") test_check("bibtex") bibtex/src/0000755000176000001440000000000013731452554012357 5ustar ripleyusersbibtex/src/biblex.c0000644000176000001440000016650213603431410013764 0ustar ripleyusers // #line 3 "" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart(yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif extern yy_size_t yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires * access to the local variable yy_act. Since yyless() is a macro, it would break * existing scanners that call yyless() from OUTSIDE yylex. * One obvious solution it to make yy_act a global. I tried that, and saw * a 5% performance hit in a non-yylineno scanner, because yy_act is * normally declared as a register variable-- so it is not worth it. */ #define YY_LESS_LINENO(n) \ do { \ yy_size_t yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ yy_size_t yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart (FILE *input_file ); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); void yy_delete_buffer (YY_BUFFER_STATE b ); void yy_flush_buffer (YY_BUFFER_STATE b ); void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); void yypop_buffer_state (void ); static void yyensure_buffer_stack (void ); static void yy_load_buffer_state (void ); static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); void *yyalloc (yy_size_t ); void *yyrealloc (void *,yy_size_t ); void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; #define YY_FLEX_LEX_COMPAT extern int yylineno; int yylineno = 1; //extern char yytext[]; static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); // static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (yy_size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ if ( yyleng + (yy_more_offset) >= YYLMAX ) \ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ yy_flex_strncpy( &yytext[(yy_more_offset)], (yytext_ptr), yyleng + 1 ); \ yyleng += (yy_more_offset); \ (yy_prev_more_offset) = (yy_more_offset); \ (yy_more_offset) = 0; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 20 #define YY_END_OF_BUFFER 21 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_acclist[93] = { 0, 6, 6, 21, 19, 20, 18, 19, 20, 17, 20, 10, 19, 20, 9, 19, 20, 19, 20, 6, 19, 20, 13, 19, 20, 14, 19, 20, 16, 19, 20, 6, 7, 19, 20, 15, 19, 20, 1, 19, 20, 6, 19, 20, 6, 19, 20, 6, 19, 20, 6, 19, 20, 11, 19, 20, 12, 19, 20, 18, 8, 6, 6, 7, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 2, 6, 3, 6, 6, 4, 6 } ; static yyconst flex_int16_t yy_accept[55] = { 0, 1, 2, 3, 4, 6, 9, 11, 14, 17, 19, 22, 25, 28, 31, 35, 38, 41, 44, 47, 50, 53, 56, 59, 60, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 86, 88, 90, 91, 93, 93 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 4, 5, 1, 6, 1, 7, 8, 9, 1, 7, 10, 7, 7, 7, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 7, 1, 1, 12, 1, 7, 13, 14, 15, 16, 17, 18, 7, 19, 7, 20, 7, 7, 21, 22, 23, 24, 25, 7, 26, 27, 28, 29, 7, 7, 7, 7, 7, 1, 1, 1, 1, 7, 1, 14, 15, 16, 17, 18, 7, 19, 7, 20, 7, 7, 21, 22, 23, 24, 25, 7, 26, 27, 28, 29, 7, 7, 7, 7, 7, 30, 1, 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[32] = { 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1 } ; static yyconst flex_int16_t yy_base[56] = { 0, 0, 0, 67, 68, 64, 68, 68, 68, 62, 0, 68, 68, 68, 53, 68, 68, 39, 39, 35, 32, 68, 68, 57, 55, 55, 0, 45, 33, 38, 35, 26, 49, 28, 28, 34, 27, 28, 16, 22, 20, 19, 24, 25, 20, 10, 19, 15, 0, 0, 0, 17, 0, 68, 31, 32 } ; static yyconst flex_int16_t yy_def[56] = { 0, 53, 1, 53, 53, 53, 53, 53, 53, 54, 55, 53, 53, 53, 55, 53, 53, 55, 55, 55, 55, 53, 53, 53, 54, 53, 55, 55, 55, 55, 55, 55, 53, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 53, 53 } ; static yyconst flex_int16_t yy_nxt[100] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 10, 10, 17, 10, 10, 10, 18, 10, 10, 10, 10, 19, 10, 20, 10, 10, 21, 22, 24, 24, 26, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 32, 36, 35, 34, 33, 27, 32, 25, 23, 31, 30, 29, 28, 27, 25, 23, 53, 3, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53 } ; static yyconst flex_int16_t yy_chk[100] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 54, 54, 55, 51, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 25, 24, 23, 20, 19, 18, 17, 14, 9, 5, 3, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53 } ; /* Table of booleans, true if rule could match eol. */ static yyconst flex_int32_t yy_rule_can_match_eol[21] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, }; extern int yy_flex_debug; int yy_flex_debug = 0; static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; static char *yy_full_match; static int yy_lp; #define REJECT \ { \ *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ ++(yy_lp); \ goto find_rule; \ } static int yy_more_offset = 0; static int yy_prev_more_offset = 0; #define yymore() ((yy_more_offset) = yy_flex_strlen( yytext )) #define YY_NEED_STRLEN #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET \ { \ (yy_more_offset) = (yy_prev_more_offset); \ yyleng -= (yy_more_offset); \ } #ifndef YYLMAX #define YYLMAX 8192 #endif static char yytext[YYLMAX]; char *yytext_ptr; #line 1 "biblex.l" #line 4 "biblex.l" /* {{{ Declarations */ #include #define extern #include #undef extern #include #ifdef stdout # undef stdout #endif #define stdout 0 // enable some debugging with this: // #define LEXER_DEBUG 1 #define YYSTYPE SEXP #include #include #include #include typedef int token_t ; static void compact_space(); static void eof_error(); static int next_char(); static token_t out_braced_literal(); static token_t out_braced_string(); static token_t out_lbrace(); static token_t out_lparen(); static token_t out_protected_string(token_t t); static token_t out_rbrace(); static token_t out_rparen(); static token_t out_string(); static token_t out_token(token_t t_); static void overflow( const char* ); static int brace_level = 0; int do_lex_output = 0; static token_t last_object = TOKEN_UNKNOWN; static token_t last_token = TOKEN_UNKNOWN; static int paren_level = 0; #define BYTE_VAL(c) ((unsigned int)((c) & 0xff)) #define EOFILE 0 #define ISPRINT(c) isprint(BYTE_VAL(c)) #define ISDIGIT(c) isdigit(BYTE_VAL(c)) #define ISSPACE(c) isspace(BYTE_VAL(c)) #define RETURN(n) return (n) #undef YYLMAX #if defined(HAVE_IBMPC) #define YYLMAX 32760 #else #define YYLMAX BIBYYLMAX #endif #define YY_USER_ACTION do { \ start_line_number = line_number ; \ start_col_number = col_number ; \ start_byte_number = byte_number ; \ } while( 0 ) ; /* }}} */ /* {{{ Lexer grammar */ /* increase transition and output table sizes */ /* abbrev, entry, key, field name syntax */ /* BibTeX entry opening delimiter */ /* one white space character */ /* \013 == \v, but lex doesn't */ /* recognize \v */ /* optional `horizontal' space */ #line 616 "" #define INITIAL 0 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int yylex_destroy (void ); int yyget_debug (void ); void yyset_debug (int debug_flag ); YY_EXTRA_TYPE yyget_extra (void ); void yyset_extra (YY_EXTRA_TYPE user_defined ); FILE *yyget_in (void ); void yyset_in (FILE * in_str ); FILE *yyget_out (void ); void yyset_out (FILE * out_str ); yy_size_t yyget_leng (void ); char *yyget_text (void ); int yyget_lineno (void ); void yyset_lineno (int line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap (void ); #else extern int yywrap (void ); #endif #endif static void yyunput (int c,char *buf_ptr ); #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void ); #else static int input (void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int yylex (void); #define YY_DECL int yylex (void) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 83 "biblex.l" #line 800 "" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif /* Create the reject buffer large enough to save one state per allowed character. */ if ( ! (yy_state_buf) ) (yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE ); if ( ! (yy_state_buf) ) YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); (yy_state_ptr) = (yy_state_buf); *(yy_state_ptr)++ = yy_current_state; yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 54 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; *(yy_state_ptr)++ = yy_current_state; ++yy_cp; } while ( yy_base[yy_current_state] != 68 ); yy_find_action: yy_current_state = *--(yy_state_ptr); (yy_lp) = yy_accept[yy_current_state]; goto find_rule; /* Shut up GCC warning -Wall */ find_rule: /* we branch to this label when backing up */ for ( ; ; ) /* until we find what rule we matched */ { if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) { yy_act = yy_acclist[(yy_lp)]; { (yy_full_match) = yy_cp; break; } } --yy_cp; yy_current_state = *--(yy_state_ptr); (yy_lp) = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { yy_size_t yyl; for ( yyl = (yy_prev_more_offset); yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) yylineno++; ; } do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 1: YY_RULE_SETUP #line 84 "biblex.l" RETURN (out_token(TOKEN_AT)); YY_BREAK case 2: YY_RULE_SETUP #line 86 "biblex.l" {RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_COMMENT) : out_token(TOKEN_ABBREV)); } YY_BREAK case 3: YY_RULE_SETUP #line 90 "biblex.l" {RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_INCLUDE) : out_token(TOKEN_ABBREV)); } YY_BREAK case 4: YY_RULE_SETUP #line 94 "biblex.l" { RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_PREAMBLE) : out_token(TOKEN_ABBREV)); } YY_BREAK case 5: YY_RULE_SETUP #line 98 "biblex.l" { RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_STRING) : out_token(TOKEN_ABBREV)); } YY_BREAK case 6: YY_RULE_SETUP #line 102 "biblex.l" { if (last_object == TOKEN_STRING) RETURN(out_token(TOKEN_ABBREV)); switch (last_token) { case TOKEN_COMMA: RETURN(out_token(TOKEN_FIELD)); case TOKEN_LBRACE: RETURN(out_token(TOKEN_KEY)); case TOKEN_AT: RETURN(out_token(TOKEN_ENTRY)); default: RETURN(out_token(TOKEN_ABBREV)); } } YY_BREAK case 7: YY_RULE_SETUP #line 118 "biblex.l" RETURN (out_token(TOKEN_VALUE)); YY_BREAK case 8: /* rule 8 can match eol */ YY_RULE_SETUP #line 120 "biblex.l" RETURN (out_token(TOKEN_INLINE)); YY_BREAK case 9: YY_RULE_SETUP #line 122 "biblex.l" RETURN (out_token(TOKEN_SHARP)); YY_BREAK case 10: YY_RULE_SETUP #line 124 "biblex.l" RETURN (out_string()); YY_BREAK case 11: YY_RULE_SETUP #line 126 "biblex.l" RETURN (out_lbrace()); YY_BREAK case 12: YY_RULE_SETUP #line 128 "biblex.l" RETURN (out_rbrace()); YY_BREAK case 13: YY_RULE_SETUP #line 130 "biblex.l" RETURN (out_lparen()); YY_BREAK case 14: YY_RULE_SETUP #line 132 "biblex.l" RETURN (out_rparen()); YY_BREAK case 15: YY_RULE_SETUP #line 134 "biblex.l" RETURN (out_token(TOKEN_EQUALS)); YY_BREAK case 16: YY_RULE_SETUP #line 136 "biblex.l" RETURN (out_token(TOKEN_COMMA)); YY_BREAK case 17: /* rule 17 can match eol */ YY_RULE_SETUP #line 138 "biblex.l" RETURN (out_token(TOKEN_NEWLINE)); YY_BREAK case 18: YY_RULE_SETUP #line 140 "biblex.l" RETURN (out_token(TOKEN_SPACE)); YY_BREAK case 19: YY_RULE_SETUP #line 142 "biblex.l" RETURN (out_token(TOKEN_LITERAL)); YY_BREAK case 20: YY_RULE_SETUP #line 144 "biblex.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK #line 1027 "" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (void) { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart(yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (void) { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); (yy_state_ptr) = (yy_state_buf); *(yy_state_ptr)++ = yy_current_state; for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 54 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; *(yy_state_ptr)++ = yy_current_state; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { register int yy_is_jam; register YY_CHAR yy_c = 1; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 54 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 53); if ( ! yy_is_jam ) *(yy_state_ptr)++ = yy_current_state; return yy_is_jam ? 0 : yy_current_state; } static void yyunput (int c, register char * yy_bp ) { register char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register yy_size_t number_to_move = (yy_n_chars) + 2; register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; if ( c == '\n' ){ --yylineno; } (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) #else static int input (void) #endif { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart(yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); if ( c == '\n' ) yylineno++; ; return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_init_buffer(YY_CURRENT_BUFFER,input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } static void yy_load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer(b,file ); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yy_delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yyfree((void *) b->yy_ch_buf ); yyfree((void *) b ); } #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yy_flush_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void yyensure_buffer_stack (void) { yy_size_t num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer(b ); return b; } /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { return yy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param bytes the byte buffer to scan * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n, i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif // static void yy_fatal_error (yyconst char* msg ) // { // (void) fprintf( stderr, "%s\n", msg ); // exit( YY_EXIT_FAILURE ); // } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. * */ int yyget_lineno (void) { return yylineno; } /** Get the input stream. * */ FILE *yyget_in (void) { return yyin; } /** Get the output stream. * */ FILE *yyget_out (void) { return yyout; } /** Get the length of the current token. * */ yy_size_t yyget_leng (void) { return yyleng; } /** Get the current token. * */ char *yyget_text (void) { return yytext; } /** Set the current line number. * @param line_number * */ void yyset_lineno (int line_number ) { yylineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. * * @see yy_switch_to_buffer */ void yyset_in (FILE * in_str ) { yyin = in_str ; } void yyset_out (FILE * out_str ) { yyout = out_str ; } int yyget_debug (void) { return yy_flex_debug; } void yyset_debug (int bdebug ) { yy_flex_debug = bdebug ; } static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. */ /* We do not touch yylineno unless the option is enabled. */ yylineno = 1; (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; (yy_state_buf) = 0; (yy_state_ptr) = 0; (yy_full_match) = 0; (yy_lp) = 0; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * yylex_init() */ return 0; } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } /* Destroy the stack itself. */ yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; yyfree ( (yy_state_buf) ); (yy_state_buf) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *yyalloc (yy_size_t size ) { return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void yyfree (void * ptr ) { free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 144 "biblex.l" /*}}} */ /*{{{ compact_space */ /** * compact runs of space to single blank */ static void compact_space(){ char *p; char *q; for (p = q = (char*)&yytext[0]; *p ; ) { *q++ = ISSPACE(*p) ? ' ' : *p; if (ISSPACE(*p)){ while (ISSPACE(*p)) ++p; } else{ ++p; } } *q = '\0'; } /*}}}*/ /* {{{ next_char */ /** * Gets the next character from the stream */ static int next_char() { int c; c = input(); if ( c == R_EOF ){ eof_error(); } else if (c == '\n'){ line_number++; col_number = 0; byte_number = 0; } else { col_number++; byte_number++; /* only advance column for 1st byte in UTF-8 */ if (0x80 <= (unsigned char)c && (unsigned char)c <= 0xBF && known_to_be_utf8){ col_number--; } if( c == '\t' ) { col_number = ((col_number + 7) & ~7); } } return (c); } /*}}}*/ /* {{{ out_ functions */ static token_t out_braced_literal(){ int c; int n; int plevel = paren_level; for (n = 1; brace_level > 0; ) { c = next_char(); if (c == EOF){ break; } if (n > (YYLMAX - 2)){ overflow( "out_braced_literal" ); } yytext[n++] = c; switch (c){ case '(': plevel++; break; case ')': plevel--; break; case '{': brace_level++; break; case '}': brace_level--; break; default: break; } if ((paren_level > 0) && (plevel == 0)){ break; } } yytext[0] = '{'; yytext[n-1] = '}'; yytext[n] = '\0'; return (out_token(TOKEN_LITERAL)); } /* convert braced to quoted string */ static token_t out_braced_string() { #ifdef LEXER_DEBUG Rprintf( " \n" ) ; #endif int blevel; int c; int n; for (blevel = 1, n = 1; (blevel > 0); ){ c = next_char(); if (c == EOF){ break; } if (n > (YYLMAX - 5)){ overflow("out_braced_string"); } yytext[n++] = c; switch (c){ case '\\': { c = next_char() ; if( c == '"' ){ #ifdef LEXER_DEBUG Rprintf( "seeing bs and quote : %s\n", yytext ) ; #endif yytext[n++] = '"' ; } else if( c == '&' ) { #ifdef LEXER_DEBUG Rprintf( "seeing bs and ampersand : %s\n", yytext ) ; #endif yytext[n++] = '&' ; } else { yytext[n++] = c ; } break ; } case '{': blevel++; break; case '}': blevel--; break; case '"': { if (blevel == 1){ if (yytext[n-2] == '\\') { c = next_char(); if (c == EOF){ break; } yytext[n-2] = '{'; yytext[n-1] = '\\'; yytext[n++] = '"'; yytext[n++] = c; yytext[n++] = '}'; } else { yytext[n-1] = '{'; yytext[n++] = '"'; yytext[n++] = '}'; } } break; } default: break; } } yytext[0] = '"'; yytext[n-1] = '"'; yytext[n] = '\0'; #ifdef LEXER_DEBUG Rprintf( "[out_braced_string] yytext = ///%s///\n", yytext ) ; #endif return (out_token(TOKEN_VALUE)); } static token_t out_lbrace(){ if (brace_level == 0){ brace_level++; switch (last_object) { case TOKEN_COMMENT: case TOKEN_INCLUDE: return (out_braced_literal()); default: return (out_token(TOKEN_LBRACE)); } } else { return (out_braced_string()); } } static token_t out_lparen(){ switch (last_token) { case TOKEN_ENTRY: case TOKEN_PREAMBLE: case TOKEN_STRING: yytext[0] = '{'; paren_level++; brace_level++; return (out_token(TOKEN_LBRACE)); case TOKEN_COMMENT: case TOKEN_INCLUDE: yytext[0] = '{'; paren_level++; brace_level++; return (out_braced_literal()); default: return (out_token(TOKEN_LITERAL)); } } static token_t out_protected_string(token_t t){ char octal[4 + 1]; const char *token = (const char*)&yytext[0]; if (*token == (char)'\0') /* ignore empty tokens */ return (TOKEN_VALUE); output('"'); /* supply missing quote delimiters */ if ((yytext[0] != '"') && (t == TOKEN_VALUE)){ output('\\'); output('\"'); } for (; *token; ++token){ switch (*token) { case '"': case '\\': output('\\'); output(*token); break; case '\b': output('\\'); output('b'); break; case '\f': output('\\'); output('f'); break; case '\n': output('\\'); output('n'); break; case '\r': output('\\'); output('r'); break; case '\t': output('\\'); output('t'); break; case '\v': output('\\'); output('v'); break; default: if (ISPRINT(*token)){ output(*token); } else { (void)sprintf(octal,"\\%03o",BYTE_VAL(*token)); output(octal[0]); output(octal[1]); output(octal[2]); output(octal[3]); } break; } } /* supply missing quote delimiters */ if ((yytext[0] != '"') && (t == TOKEN_VALUE)){ output('\\'); output('\"'); } output('"'); output('\n'); return (TOKEN_VALUE); } static token_t out_rbrace() { if (brace_level == 1) { brace_level--; return (out_token(TOKEN_RBRACE)); } else{ return (out_token(TOKEN_LITERAL)); } } static token_t out_rparen(){ paren_level--; if (paren_level == 0){ yytext[0] = '}'; brace_level--; return (out_token(TOKEN_RBRACE)); } else { return (out_token(TOKEN_LITERAL)); } } static token_t out_string(){ int blevel; int c; int n; for (blevel = 0, n = 1; ; ) { c = next_char(); if (c == EOF){ break; } if (n > (YYLMAX - 2)){ overflow("out_string"); } yytext[n++] = c; switch (c){ case '{': blevel++; break; case '}': blevel--; break; case '"': if (blevel == 0){ goto LOOP_EXIT; } default: break; } } LOOP_EXIT: yytext[n++] = '\0'; #ifdef LEXER_DEBUG Rprintf( "[out_string] yytext = ///%s///\n", yytext ) ; #endif return (out_token(TOKEN_VALUE)); } /* ALL token output is directed through this function */ static token_t out_token(token_t t){ int n; if (do_lex_output){ Rprintf("%d\t", (int)t); } switch (t) { case TOKEN_AT: last_object = TOKEN_UNKNOWN; if (do_lex_output) Rprintf("\"%s\"\n", yytext); break; case TOKEN_VALUE: if (do_lex_output){ /* supply surrounding quotes */ if (ISDIGIT(yytext[0])) { n = strlen((const char*)&yytext[0]); if ((n + 3) > YYLMAX){ overflow("out_token"); } yytext[n+2] = '\0'; yytext[n+1] = '"'; for (; n > 0; --n){ yytext[n] = yytext[n-1]; } } else compact_space(); out_protected_string(t); } break; case TOKEN_COMMENT: case TOKEN_INCLUDE: if (do_lex_output){ out_protected_string(t); } last_object = t; break; case TOKEN_ENTRY: case TOKEN_PREAMBLE: case TOKEN_STRING: if (do_lex_output){ Rprintf("\"%s\"\n", yytext); } last_object = t; break; case TOKEN_FIELD: case TOKEN_KEY: if (do_lex_output){ Rprintf("\"%s\"\n", yytext); } break; case TOKEN_INLINE: case TOKEN_NEWLINE: line_number++; col_number = 0; byte_number = 0; if (do_lex_output) { out_protected_string(t); } break; case TOKEN_LITERAL: default: if (do_lex_output){ out_protected_string(t); } break; } if (!((t == TOKEN_INLINE) || (t == TOKEN_SPACE) || (t == TOKEN_NEWLINE))) last_token = t; /* remember last non-space token type */ const char * token = (const char*)&yytext[0] ; if( t == TOKEN_AT ){ last_at_location.first_line = start_line_number ; last_at_location.first_column = start_col_number ; last_at_location.first_byte = start_byte_number ; } setToken( token, strlen(token) ); return (t); } /* }}} */ int yywrap() { return 1; } static void overflow(const char* from){ #ifdef LEXER_DEBUG Rprintf( "[overflow/%s] yytext = ///%s///\n", from, yytext ) ; #endif error("String too long for %ld-character buffer\n", YYLMAX); } static void eof_error(){ error( "End-of-file in value string\n" ); } /* never called, but calms down -Wall */ void dummy(){ yyunput( 0, 0 ) ; yy_flex_strlen(0) ; } /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ bibtex/src/init.c0000644000176000001440000000063213125442042013453 0ustar ripleyusers#include #include #include // for NULL #include /* .External calls */ extern SEXP do_read_bib(SEXP); static const R_ExternalMethodDef ExternalEntries[] = { {"do_read_bib", (DL_FUNC) &do_read_bib, 3}, {NULL, NULL, 0} }; void R_init_bibtex(DllInfo *dll){ R_registerRoutines(dll, NULL, NULL, NULL, ExternalEntries); R_useDynamicSymbols(dll, FALSE); } bibtex/src/Makevars0000644000176000001440000000004213125442042014033 0ustar ripleyusersPKG_CPPFLAGS = -I../inst/include/ bibtex/src/stretchyList.c0000644000176000001440000000223613125442042015213 0ustar ripleyusers#include /* Stretchy List Structures : Lists are created and grown using a special */ /* dotted pair. The CAR of the list points to the last cons-cell in the */ /* list and the CDR points to the first. The list can be extracted from */ /* the pair by taking its CDR, while the CAR gives fast access to the end */ /* of the list. */ /** * Creates a stretchy-list dotted pair */ SEXP NewList(void) { SEXP s = CONS(R_NilValue, R_NilValue); SETCAR(s, s); return s; } /** * Add a new element at the __end__ of a stretchy list * * @param l stretchy list to expand * @param s element to add at the __end__ of the list * @return */ SEXP GrowList(SEXP l, SEXP s) { SEXP tmp; PROTECT(s); tmp = CONS(s, R_NilValue); UNPROTECT(1); SETCDR(CAR(l), tmp); SETCAR(l, tmp); return l; } /** * Insert a new element at the __head__ of a stretchy list * * @param l stretchy list in which we want to insert s * @param s element to add to l * @return the stretchy list l appended by s */ SEXP Insert(SEXP l, SEXP s){ SEXP tmp; PROTECT(s); tmp = CONS(s, CDR(l)); UNPROTECT(1); SETCDR(l, tmp); return l; } bibtex/src/bibparse.c0000644000176000001440000035312413731452554014322 0ustar ripleyusers/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Using locations. */ #define YYLSP_NEEDED 1 /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { TOKEN_ABBREV = 258, TOKEN_AT = 259, TOKEN_COMMA = 260, TOKEN_COMMENT = 261, TOKEN_ENTRY = 262, TOKEN_EQUALS = 263, TOKEN_FIELD = 264, TOKEN_INCLUDE = 265, TOKEN_INLINE = 266, TOKEN_KEY = 267, TOKEN_LBRACE = 268, TOKEN_LITERAL = 269, TOKEN_NEWLINE = 270, TOKEN_PREAMBLE = 271, TOKEN_RBRACE = 272, TOKEN_SHARP = 273, TOKEN_SPACE = 274, TOKEN_STRING = 275, TOKEN_VALUE = 276, TOKEN_UNKNOWN = 277 }; #endif /* Tokens. */ #define TOKEN_ABBREV 258 #define TOKEN_AT 259 #define TOKEN_COMMA 260 #define TOKEN_COMMENT 261 #define TOKEN_ENTRY 262 #define TOKEN_EQUALS 263 #define TOKEN_FIELD 264 #define TOKEN_INCLUDE 265 #define TOKEN_INLINE 266 #define TOKEN_KEY 267 #define TOKEN_LBRACE 268 #define TOKEN_LITERAL 269 #define TOKEN_NEWLINE 270 #define TOKEN_PREAMBLE 271 #define TOKEN_RBRACE 272 #define TOKEN_SHARP 273 #define TOKEN_SPACE 274 #define TOKEN_STRING 275 #define TOKEN_VALUE 276 #define TOKEN_UNKNOWN 277 /* Copy the first part of user declarations. */ #line 1 "bibparse.y" /*{{{ first part of declarations */ #include // static char yytext[BIBYYLMAX]; // #define YYDEBUG 1 /* need for -d option support */ #define YYERROR_VERBOSE 1 /* better warning messages */ #define YYSTYPE SEXP /* semantic values */ #define streql(s, t) (!strcmp((s), (t))) /** * Aliases to R standard PROTECT macro, in case we want to do * something else as well */ #define _PROTECT_WITH_INDEX(s,index) { PROTECT_WITH_INDEX(s,index); } #define _PROTECT(s) { PROTECT(s); } #define _UNPROTECT(n) { UNPROTECT(n); } #define _UNPROTECT_PTR(s) { UNPROTECT_PTR(s); } #define _REPROTECT(s,index) REPROTECT(s,index) /** * Set to 1 when a syntax error was seen to indicate that * tokens supplied by the lexer should not be wrapped into SEXP */ static int recovering ; /** * Set to 1 after a syntax error was seen, and before the * recovering process has started */ static int popping ; /** * used in the popping mechanism, the error message is compared to this * and the popping stops if anything else happens */ const char* error_msg_popping = "Error: popping"; /** * The keyname of the current entry (used in warning messages) */ static char* currentKey = 0 ; /** * the line number where the current entry starts (used in warning messages) */ int currentKeyLine ; static SEXP srcfile; char * bibfile ; /** * this is defined as a macro, so that it has access to yylval to be able * to unprotect it. * * the macro sets the "popping" to 1 to indicate that symbols being * destructed should be UNPROTECT'ed as well, and calls the _yyerror * function which sends an R warning with the problem */ #define yyerror(s) \ do { \ _UNPROTECT_PTR( yylval ) ; \ popping = 1; \ _yyerror(s); \ } \ while(0) ; //extern YYLTYPE yylloc ; # define YYLLOC_DEFAULT(Current, Rhs, N) \ do { \ if (YYID (N)){ \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).first_byte = YYRHSLOC (Rhs, 1).first_byte; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ (Current).last_byte = YYRHSLOC (Rhs, N).last_byte; \ } else { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ (Current).first_byte = (Current).last_byte = \ YYRHSLOC (Rhs, 0).last_byte; \ } \ } while (YYID (0)) // #define XXDEBUG 1 /* functions used in the parsing process */ SEXP makeSrcRef(YYLTYPE) ; static SEXP xx_object_list_1(SEXP); static SEXP xx_object_list_2(SEXP,SEXP); static SEXP xx_object(SEXP); static SEXP xx_atobject_comment(SEXP); static SEXP xx_atobject_entry(SEXP, YYLTYPE); static SEXP xx_atobject_include(SEXP); static SEXP xx_atobject_preamble(SEXP); static SEXP xx_atobject_string(SEXP); static SEXP xx_token_entry( SEXP, SEXP); static SEXP xx_token_entry_empty(SEXP) ; static SEXP xx_entry_head( SEXP, SEXP) ; static SEXP xx_entry_head_nokey( SEXP ) ; static SEXP xx_keyname_key( SEXP) ; static SEXP xx_keyname_abbrev( SEXP) ; static SEXP xx_include( SEXP ) ; static SEXP xx_preamble(SEXP) ; static SEXP xx_string(SEXP) ; static SEXP xx_value( SEXP, SEXP) ; static SEXP xx_assignement_list1(SEXP); static SEXP xx_assignement_list2(SEXP, SEXP); static SEXP xx_assignement(SEXP, SEXP); static SEXP xx_lhs_field( SEXP ) ; static SEXP xx_lhs_abbrev( SEXP ); static SEXP xx_space( SEXP ); static SEXP xx_space_inline( SEXP ) ; static SEXP xx_space_newline( SEXP ) ; static SEXP xx_forward( SEXP ) ; static SEXP xx_null( ) ; static SEXP xx_expand_abbrev( SEXP ) ; static SEXP xx_simple_value( SEXP ) ; /* functions to unprotect one or more SEXP */ void junk1( SEXP); void junk2( SEXP, SEXP); void junk3( SEXP, SEXP, SEXP); void junk4( SEXP, SEXP, SEXP, SEXP); void junk5( SEXP, SEXP, SEXP, SEXP, SEXP); void junk6( SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); void junk7( SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); static PROTECT_INDEX INCLUDE_INDEX ; static PROTECT_INDEX COMMENT_INDEX ; static PROTECT_INDEX STRING_INDEX ; static PROTECT_INDEX PREAMBLE_INDEX ; static PROTECT_INDEX ENTRIES_INDEX ; static SEXP includes; static SEXP comments; static SEXP strings; static SEXP preamble; static SEXP entries; static void recordInclude( SEXP ) ; static void recordComment( SEXP ) ; static void recordString( SEXP ) ; static void recordPreamble( SEXP ) ; static SEXP asVector( SEXP, int ); /*}}}*/ /*{{{ Grammar */ /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; } YYLTYPE; # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 216 of yacc.c. */ #line 316 "bibparse.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int i) #else static int YYID (i) int i; #endif { return i; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss; YYSTYPE yyvs; YYLTYPE yyls; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 8 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 85 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 23 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 21 /* YYNRULES -- Number of rules. */ #define YYNRULES 59 /* YYNRULES -- Number of states. */ #define YYNSTATES 101 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 277 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 5, 9, 11, 15, 19, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 74, 78, 82, 88, 91, 100, 107, 109, 111, 115, 123, 131, 133, 139, 141, 143, 145, 150, 157, 159, 161, 162, 164, 166, 169, 171, 173 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 24, 0, -1, 41, -1, 41, 25, 41, -1, 26, -1, 25, 41, 26, -1, 4, 41, 28, -1, 27, 41, 26, -1, 3, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, -1, 22, -1, 29, -1, 30, -1, 33, -1, 34, -1, 35, -1, 1, 17, -1, 6, 41, 14, -1, 31, 38, 17, -1, 31, 38, 5, 41, 17, -1, 31, 17, -1, 7, 41, 13, 41, 32, 41, 5, 41, -1, 7, 41, 13, 41, 5, 41, -1, 12, -1, 3, -1, 10, 41, 14, -1, 16, 41, 13, 41, 36, 41, 17, -1, 20, 41, 13, 41, 39, 41, 17, -1, 37, -1, 36, 41, 18, 41, 37, -1, 21, -1, 3, -1, 39, -1, 38, 5, 41, 39, -1, 40, 41, 8, 41, 36, 41, -1, 9, -1, 3, -1, -1, 42, -1, 43, -1, 42, 43, -1, 19, -1, 11, -1, 15, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 219, 219, 220, 223, 224, 227, 231, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 258, 259, 260, 261, 262, 263, 266, 269, 270, 271, 274, 275, 278, 279, 282, 285, 288, 291, 292, 295, 296, 299, 300, 303, 306, 307, 310, 311, 314, 315, 318, 319, 320 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "TOKEN_ABBREV", "TOKEN_AT", "TOKEN_COMMA", "TOKEN_COMMENT", "TOKEN_ENTRY", "TOKEN_EQUALS", "TOKEN_FIELD", "TOKEN_INCLUDE", "TOKEN_INLINE", "TOKEN_KEY", "TOKEN_LBRACE", "TOKEN_LITERAL", "TOKEN_NEWLINE", "TOKEN_PREAMBLE", "TOKEN_RBRACE", "TOKEN_SHARP", "TOKEN_SPACE", "TOKEN_STRING", "TOKEN_VALUE", "TOKEN_UNKNOWN", "$accept", "file", "object_list", "object", "anything", "at_object", "comment", "entry", "entry_head", "key_name", "include", "preamble", "string", "value", "simple_value", "assignment_list", "assignment", "assignment_lhs", "opt_space", "space", "single_space", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 29, 30, 30, 30, 31, 31, 32, 32, 33, 34, 35, 36, 36, 37, 37, 38, 38, 39, 40, 40, 41, 41, 42, 42, 43, 43, 43 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 3, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 5, 2, 8, 6, 1, 1, 3, 7, 7, 1, 5, 1, 1, 1, 4, 6, 1, 1, 0, 1, 1, 2, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 53, 58, 59, 57, 0, 2, 54, 55, 1, 8, 53, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 53, 4, 53, 56, 0, 3, 0, 0, 53, 53, 53, 53, 53, 6, 27, 28, 0, 29, 30, 31, 5, 7, 32, 0, 0, 0, 0, 0, 52, 51, 36, 0, 48, 53, 33, 53, 41, 53, 53, 53, 34, 0, 0, 0, 0, 0, 53, 40, 53, 39, 53, 47, 46, 53, 44, 53, 35, 49, 0, 38, 0, 0, 0, 53, 53, 42, 53, 43, 50, 37, 0, 45 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 4, 29, 30, 31, 42, 43, 44, 45, 79, 46, 47, 48, 82, 83, 60, 61, 62, 5, 6, 7 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -20 static const yytype_int8 yypact[] = { 49, -20, -20, -20, 3, 29, 49, -20, -20, -20, 49, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, 49, -20, 49, -20, 0, 29, 29, -12, 49, 49, 49, 49, 49, -20, -20, -20, 6, -20, -20, -20, -20, -20, -20, -6, 11, -1, 13, 46, -20, -20, -20, -3, -20, 49, -20, 49, -20, 49, 49, 49, -20, 55, 50, 1, 9, 8, 49, -20, 49, -20, 49, -20, -20, 49, -20, 49, -20, -20, 1, -20, 56, 53, 62, 49, 49, -20, 49, -20, 48, -20, 1, -20 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -20, -20, -20, 41, -20, -20, -20, -20, -20, -20, -20, -20, -20, -14, -19, -20, 4, -20, -10, -20, 75 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { 33, 36, 68, 8, 80, 51, 37, 38, 63, 57, 39, 57, 57, 65, 69, 58, 40, 58, 58, 34, 41, 35, 81, 59, 64, 85, 66, 52, 53, 54, 55, 56, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 70, 76, 71, 77, 72, 73, 74, 67, 1, 93, 78, 75, 2, 87, 95, 88, 3, 89, 94, 95, 90, 92, 91, 49, 50, 84, 86, 96, 100, 32, 97, 98, 0, 99 }; static const yytype_int8 yycheck[] = { 10, 1, 5, 0, 3, 17, 6, 7, 14, 3, 10, 3, 3, 14, 17, 9, 16, 9, 9, 29, 20, 31, 21, 17, 13, 17, 13, 37, 38, 39, 40, 41, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 62, 3, 64, 5, 66, 67, 68, 13, 11, 5, 12, 8, 15, 75, 18, 77, 19, 79, 17, 18, 82, 87, 84, 34, 35, 73, 74, 17, 99, 6, 92, 93, -1, 95 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 11, 15, 19, 24, 41, 42, 43, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25, 26, 27, 43, 41, 41, 41, 1, 6, 7, 10, 16, 20, 28, 29, 30, 31, 33, 34, 35, 26, 26, 17, 41, 41, 41, 41, 41, 3, 9, 17, 38, 39, 40, 14, 13, 14, 13, 13, 5, 17, 41, 41, 41, 41, 41, 8, 3, 5, 12, 32, 3, 21, 36, 37, 39, 17, 39, 41, 41, 41, 41, 41, 36, 5, 17, 18, 17, 41, 41, 41, 37 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, Location); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; #endif { if (!yyvaluep) return; YYUSE (yylocationp); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void yy_stack_print (bottom, top) yytype_int16 *bottom; yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) #else static void yy_reduce_print (yyvsp, yylsp, yyrule) YYSTYPE *yyvsp; YYLTYPE *yylsp; int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) ); fprintf (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, yylsp, Rule); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, including the terminating null byte. If YYRESULT is null, do not copy anything; just return the number of bytes that would be copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ static YYSIZE_T yysyntax_error (char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; else { int yytype = YYTRANSLATE (yychar); YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; # if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); YY_("syntax error, unexpected %s, expecting %s"); YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); # endif char *yyfmt; char const *yyf; static char const yyunexpected[] = "syntax error, unexpected %s"; static char const yyexpecting[] = ", expecting %s"; static char const yyor[] = " or %s"; char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; yyarg[0] = yytname[yytype]; yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; if (yysize_overflow) return YYSIZE_MAXIMUM; if (yyresult) { /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ char *yyp = yyresult; int yyi = 0; while ((*yyp = *yyf) != '\0') { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else { yyp++; yyf++; } } } return yysize; } } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) #else static void yydestruct (yymsg, yytype, yyvaluep, yylocationp) const char *yymsg; int yytype; YYSTYPE *yyvaluep; YYLTYPE *yylocationp; #endif { YYUSE (yyvaluep); YYUSE (yylocationp); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { case 3: /* "TOKEN_ABBREV" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1335 "bibparse.c" break; case 4: /* "TOKEN_AT" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1376 "bibparse.c" break; case 5: /* "TOKEN_COMMA" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1417 "bibparse.c" break; case 6: /* "TOKEN_COMMENT" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1458 "bibparse.c" break; case 7: /* "TOKEN_ENTRY" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1499 "bibparse.c" break; case 8: /* "TOKEN_EQUALS" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1540 "bibparse.c" break; case 9: /* "TOKEN_FIELD" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1581 "bibparse.c" break; case 10: /* "TOKEN_INCLUDE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1622 "bibparse.c" break; case 11: /* "TOKEN_INLINE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1663 "bibparse.c" break; case 12: /* "TOKEN_KEY" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1704 "bibparse.c" break; case 13: /* "TOKEN_LBRACE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1745 "bibparse.c" break; case 14: /* "TOKEN_LITERAL" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1786 "bibparse.c" break; case 15: /* "TOKEN_NEWLINE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1827 "bibparse.c" break; case 16: /* "TOKEN_PREAMBLE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1868 "bibparse.c" break; case 17: /* "TOKEN_RBRACE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1909 "bibparse.c" break; case 18: /* "TOKEN_SHARP" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1950 "bibparse.c" break; case 19: /* "TOKEN_SPACE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 1991 "bibparse.c" break; case 20: /* "TOKEN_STRING" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2032 "bibparse.c" break; case 21: /* "TOKEN_VALUE" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2073 "bibparse.c" break; case 22: /* "TOKEN_UNKNOWN" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2114 "bibparse.c" break; case 29: /* "comment" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2155 "bibparse.c" break; case 30: /* "entry" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2196 "bibparse.c" break; case 31: /* "entry_head" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2237 "bibparse.c" break; case 32: /* "key_name" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2278 "bibparse.c" break; case 33: /* "include" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2319 "bibparse.c" break; case 34: /* "preamble" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2360 "bibparse.c" break; case 35: /* "string" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2401 "bibparse.c" break; case 36: /* "value" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2442 "bibparse.c" break; case 37: /* "simple_value" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2483 "bibparse.c" break; case 38: /* "assignment_list" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2524 "bibparse.c" break; case 39: /* "assignment" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2565 "bibparse.c" break; case 40: /* "assignment_lhs" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2606 "bibparse.c" break; case 41: /* "opt_space" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2647 "bibparse.c" break; case 42: /* "space" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2688 "bibparse.c" break; case 43: /* "single_space" */ #line 180 "bibparse.y" { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( (*yyvaluep) ) ; } else{ popping = 0; } } }; #line 2729 "bibparse.c" break; default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The look-ahead symbol. */ int yychar; /* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /* Location data for the look-ahead symbol. */ static YYLTYPE yylloc; /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () #endif #endif { int yystate; int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss = yyssa; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[2]; #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; yylsp = yyls; #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 0; #endif goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); YYSTACK_RELOCATE (yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a look-ahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; *++yylsp = yylloc; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 219 "bibparse.y" { junk1((yyvsp[(1) - (1)])); YYACCEPT ; ;} break; case 3: #line 220 "bibparse.y" { junk3((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)])) ; YYACCEPT ; ;} break; case 4: #line 223 "bibparse.y" { (yyval) = xx_object_list_1((yyvsp[(1) - (1)])); ;} break; case 5: #line 224 "bibparse.y" { (yyval) = xx_object_list_2((yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); junk1((yyvsp[(2) - (3)])) ; ;} break; case 6: #line 227 "bibparse.y" { (yyval) = xx_object((yyvsp[(3) - (3)])); junk2((yyvsp[(1) - (3)]),(yyvsp[(2) - (3)])); ;} break; case 7: #line 231 "bibparse.y" { /* this eats whatever is between two entries, lexing until a TOKEN_AT is found */ (yyval) = xx_forward((yyvsp[(3) - (3)])); junk2((yyvsp[(1) - (3)]),(yyvsp[(2) - (3)])) ; ;} break; case 8: #line 238 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 9: #line 239 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 10: #line 240 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 11: #line 241 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 12: #line 242 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 13: #line 243 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 14: #line 244 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 15: #line 245 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 16: #line 246 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 17: #line 247 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 18: #line 248 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 19: #line 249 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 20: #line 250 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 21: #line 251 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 22: #line 252 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 23: #line 253 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 24: #line 254 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 25: #line 255 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 26: #line 256 "bibparse.y" { (yyval) = xx_forward( (yyvsp[(1) - (1)])) ; ;} break; case 27: #line 258 "bibparse.y" { (yyval) = xx_atobject_comment((yyvsp[(1) - (1)])); ;} break; case 28: #line 259 "bibparse.y" { (yyval) = xx_atobject_entry((yyvsp[(1) - (1)]), (yyloc));;} break; case 29: #line 260 "bibparse.y" { (yyval) = xx_atobject_include((yyvsp[(1) - (1)]));;} break; case 30: #line 261 "bibparse.y" { (yyval) = xx_atobject_preamble((yyvsp[(1) - (1)]));;} break; case 31: #line 262 "bibparse.y" { (yyval) = xx_atobject_string((yyvsp[(1) - (1)]));;} break; case 32: #line 263 "bibparse.y" { (yyval) = xx_null() ; YYUSE((yyvsp[(2) - (2)])) ; recovering = 0; ;} break; case 33: #line 266 "bibparse.y" {junk2((yyvsp[(1) - (3)]),(yyvsp[(2) - (3)])); (yyval) = xx_forward((yyvsp[(3) - (3)])); ;} break; case 34: #line 269 "bibparse.y" { (yyval) = xx_token_entry( (yyvsp[(1) - (3)]), (yyvsp[(2) - (3)])); junk1((yyvsp[(3) - (3)])); ;} break; case 35: #line 270 "bibparse.y" { (yyval) = xx_token_entry( (yyvsp[(1) - (5)]), (yyvsp[(2) - (5)])); junk3((yyvsp[(3) - (5)]),(yyvsp[(4) - (5)]),(yyvsp[(5) - (5)])); ;} break; case 36: #line 271 "bibparse.y" { (yyval) = xx_token_entry_empty((yyvsp[(1) - (2)])) ; junk1((yyvsp[(2) - (2)])) ; ;} break; case 37: #line 274 "bibparse.y" { (yyval) = xx_entry_head( (yyvsp[(1) - (8)]), (yyvsp[(5) - (8)])) ; junk6((yyvsp[(2) - (8)]),(yyvsp[(3) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(6) - (8)]),(yyvsp[(7) - (8)]),(yyvsp[(8) - (8)])) ; ;} break; case 38: #line 275 "bibparse.y" { (yyval) = xx_entry_head_nokey( (yyvsp[(1) - (6)])) ; junk5((yyvsp[(2) - (6)]),(yyvsp[(3) - (6)]),(yyvsp[(4) - (6)]),(yyvsp[(5) - (6)]),(yyvsp[(6) - (6)])) ; ;} break; case 39: #line 278 "bibparse.y" { (yyval) = xx_keyname_key( (yyvsp[(1) - (1)])) ;;} break; case 40: #line 279 "bibparse.y" { (yyval) = xx_keyname_abbrev( (yyvsp[(1) - (1)])) ; ;} break; case 41: #line 282 "bibparse.y" { (yyval) = xx_include( (yyvsp[(3) - (3)]) ) ; junk2((yyvsp[(1) - (3)]),(yyvsp[(2) - (3)])) ; ;} break; case 42: #line 285 "bibparse.y" { (yyval) = xx_preamble((yyvsp[(5) - (7)])) ; junk6((yyvsp[(1) - (7)]),(yyvsp[(2) - (7)]),(yyvsp[(3) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(6) - (7)]),(yyvsp[(7) - (7)])) ; ;} break; case 43: #line 288 "bibparse.y" { (yyval) = xx_string((yyvsp[(5) - (7)])) ; junk6( (yyvsp[(1) - (7)]), (yyvsp[(2) - (7)]), (yyvsp[(3) - (7)]), (yyvsp[(4) - (7)]), (yyvsp[(6) - (7)]), (yyvsp[(7) - (7)])) ; ;} break; case 44: #line 291 "bibparse.y" {(yyval) = xx_forward((yyvsp[(1) - (1)])) ; ;} break; case 45: #line 292 "bibparse.y" { (yyval) = xx_value( (yyvsp[(1) - (5)]), (yyvsp[(5) - (5)])) ; junk3( (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)])); ;} break; case 46: #line 295 "bibparse.y" { (yyval) = xx_simple_value((yyvsp[(1) - (1)])); ;} break; case 47: #line 296 "bibparse.y" { (yyval) = xx_expand_abbrev((yyvsp[(1) - (1)])); ;} break; case 48: #line 299 "bibparse.y" { (yyval) = xx_assignement_list1((yyvsp[(1) - (1)])); ;} break; case 49: #line 300 "bibparse.y" { (yyval) = xx_assignement_list2((yyvsp[(1) - (4)]), (yyvsp[(4) - (4)])); junk2((yyvsp[(2) - (4)]),(yyvsp[(3) - (4)])); ;} break; case 50: #line 303 "bibparse.y" { (yyval) = xx_assignement((yyvsp[(1) - (6)]), (yyvsp[(5) - (6)])); junk4((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(4) - (6)]), (yyvsp[(6) - (6)])); ;} break; case 51: #line 306 "bibparse.y" { (yyval) = xx_lhs_field( (yyvsp[(1) - (1)]) ) ; ;} break; case 52: #line 307 "bibparse.y" { (yyval) = xx_lhs_abbrev( (yyvsp[(1) - (1)]) ); ;} break; case 53: #line 310 "bibparse.y" { (yyval) = xx_null() ; ;} break; case 54: #line 311 "bibparse.y" { (yyval) = xx_forward((yyvsp[(1) - (1)])) ;;} break; case 55: #line 314 "bibparse.y" { (yyval) = xx_forward((yyvsp[(1) - (1)])) ;;} break; case 56: #line 315 "bibparse.y" { (yyval) = xx_forward((yyvsp[(1) - (2)])); junk1((yyvsp[(2) - (2)])) ; ;} break; case 57: #line 318 "bibparse.y" { (yyval) = xx_space( (yyvsp[(1) - (1)]) ) ; ;} break; case 58: #line 319 "bibparse.y" { (yyval) = xx_space_inline( (yyvsp[(1) - (1)]) ) ; ;} break; case 59: #line 320 "bibparse.y" { (yyval) = xx_space_newline( (yyvsp[(1) - (1)]) ) ; ;} break; /* Line 1267 of yacc.c. */ #line 3350 "bibparse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } } #endif } yyerror_range[0] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); yychar = YYEMPTY; } } /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the look-ahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } #line 322 "bibparse.y" /*}}} end of grammar */ /*{{{ functions borrowed from gram.y */ #ifdef Win32 static char * fixmode(const char *mode){ /* Rconnection can have a mode of 4 chars plus a null; we might * add one char */ static char fixedmode[6]; fixedmode[4] = '\0'; strncpy(fixedmode, mode, 4); if (!strpbrk(fixedmode, "bt")) { strcat(fixedmode, "t"); } return fixedmode; } #else #define fixmode(mode) (mode) #endif FILE * _fopen(const char *filename, const char *mode){ return(filename ? fopen(filename, fixmode(mode)) : NULL ); } /*}}}*/ /*{{{ yyerror */ void _yyerror(const char *s){ warning( "\n%s:%d:%d\n\t%s\n\tDropping the entry `%s` (starting at line %d) ", bibfile, line_number, col_number, s, currentKey, currentKeyLine ) ; /* indicates that we are recovering from an error */ recovering = 1 ; } /*}}}*/ /*{{{ yywarning */ static void yywarning(const char *s){ warning( "\n%s:%d:%d\n\t%s", bibfile, line_number, col_number, s ) ; } /*}}}*/ /*{{{ R interface */ /** * .Internal( "do_read_bib", file = file ) */ SEXP do_read_bib(SEXP args) { SEXP filename = CADR(args) ; const char* fname = CHAR(STRING_ELT(filename,0) ) ; bibfile = (char*)fname ; const char* encoding = CHAR(STRING_ELT( CADDR(args), 0 ) ); known_to_be_latin1 = known_to_be_utf8 = FALSE; if(streql(encoding, "latin1")) { known_to_be_latin1 = TRUE; } else if(streql(encoding, "UTF-8")) { known_to_be_utf8 = TRUE; } else if(!streql( encoding, "unknown") ){ warning( "encoding '%s' will be ignored", encoding ) ; } srcfile = CADDDR(args); FILE* fp ; if((fp = _fopen(R_ExpandFileName( fname ), "r")) == NULL){ error( "unable to open file to read", 0); } yyset_in( fp ) ; /* so that the lexer reads from the file */ #if YYDEBUG yydebug = 0 ; /* setting this to 1 gives a lot of messages */ #endif popping = 0; line_number = 1; col_number = 0; byte_number = 0; /* set up the data */ _PROTECT_WITH_INDEX( includes = NewList() , &INCLUDE_INDEX ) ; _PROTECT_WITH_INDEX( comments = NewList() , &COMMENT_INDEX ) ; _PROTECT_WITH_INDEX( strings = NewList() , &STRING_INDEX ) ; _PROTECT_WITH_INDEX( preamble = NewList() , &PREAMBLE_INDEX ) ; _PROTECT_WITH_INDEX( entries = NewList() , &ENTRIES_INDEX ) ; /* call the parser */ recovering = 0; /* int res = yyparse() ; */ yyparse() ; /* structure the data */ SEXP ans; if( isNull( CDR(entries) ) ){ PROTECT( ans = allocVector( VECSXP, 0) ) ; } else { PROTECT( ans = CDR(entries) ) ; } SEXP obj ; _PROTECT(obj = asVector( comments, 0 ) ); setAttrib( ans , install("comment") , obj ); _UNPROTECT_PTR( obj ) ; _PROTECT(obj = asVector( includes, 0 ) ); setAttrib( ans , install("include") , obj ); _UNPROTECT_PTR( obj ) ; _PROTECT(obj = asVector( strings , 1 ) ); setAttrib( ans , install("strings") , obj ); _UNPROTECT_PTR( obj ) ; _PROTECT(obj = asVector( preamble, 0 ) ); setAttrib( ans , install("preamble"), obj ); _UNPROTECT_PTR( obj ) ; _UNPROTECT_PTR( entries ) ; _UNPROTECT_PTR( ans ); fclose(fp); return ans ; } /*}}}*/ /*{{{ xx_* parser helpers */ /** * Object list with one object * * @param object the object */ static SEXP xx_object_list_1(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans, tmp ; _PROTECT( tmp = NewList() ) ; if( object == R_NilValue) { _PROTECT( ans = tmp ) ; } else{ _PROTECT( ans = GrowList( tmp, object) ) ; } _UNPROTECT_PTR( tmp) ; _UNPROTECT_PTR( object) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Adds an object to an object list * * @param */ static SEXP xx_object_list_2(SEXP list, SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; if( object == R_NilValue ){ _PROTECT( ans = list ); } else{ _PROTECT( ans = GrowList( list, object ) ); } _UNPROTECT_PTR( object ) ; _UNPROTECT_PTR( list ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * recognizes an object, adds it to the list of entries * * @param object object */ static SEXP xx_object(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = object ) ; _UNPROTECT_PTR( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Comment object * * @param object */ static SEXP xx_atobject_comment(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = R_NilValue ) ; recordComment( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Entry object * * @param object the entry object */ static SEXP xx_atobject_entry(SEXP object, YYLTYPE loc){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans, head, o, names; _PROTECT( head = getAttrib( object, install("head") ) ); int n = length( object ) ; _PROTECT( ans = allocVector( STRSXP, n) ) ; _PROTECT( names = allocVector( STRSXP, n) ) ; _PROTECT( o = object ) ; int i; for( i=0; i\n" ) ; #endif _UNPROTECT_PTR( ans ) ; _PROTECT( ans = R_NilValue ); return ans ; } /** * Include object * * @param object the include object */ static SEXP xx_atobject_include(SEXP object ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = R_NilValue ) ; recordInclude( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * A preamble object */ static SEXP xx_atobject_preamble(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = R_NilValue ) ; recordPreamble( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * string object */ static SEXP xx_atobject_string(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = R_NilValue ) ; recordString( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * actual entry object * * @param head the entry head * @param list the assignement list */ static SEXP xx_token_entry( SEXP head, SEXP list){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP data ; _PROTECT( data = CDR(list) ) ; setAttrib( data, install("head"), head) ; _UNPROTECT_PTR( list ) ; _UNPROTECT_PTR( head ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return data; } /** * actual entry object with no assignements * * @param head */ static SEXP xx_token_entry_empty(SEXP head){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = R_NilValue ) ; setAttrib( ans, install("head"), head) ; _UNPROTECT_PTR( head ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /** * entry head * * @param kind kind of entry * @param keyname the name of the entry */ static SEXP xx_entry_head( SEXP kind, SEXP keyname ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = allocVector( STRSXP, 2) ) ; SET_STRING_ELT( ans, 0, STRING_ELT(keyname, 0) ) ; SET_STRING_ELT( ans, 1, STRING_ELT(kind, 0) ) ; _UNPROTECT_PTR(kind) ; _UNPROTECT_PTR(keyname) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * entry head * * @param kind kind of entry */ static SEXP xx_entry_head_nokey( SEXP kind){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = allocVector( STRSXP, 2) ) ; SET_STRING_ELT( ans, 0, NA_STRING ) ; SET_STRING_ELT( ans, 1, STRING_ELT(kind, 0) ) ; _UNPROTECT_PTR(kind) ; warning( "\n%s:%d:%d\n\tno key for the entry at line %d", bibfile, line_number, col_number, currentKeyLine ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * sets the currentKey as the first element of the 'key' parameter * and returns currentKey */ char* set_current_key( SEXP key ){ // free currentKey if needed if( currentKey ) free( currentKey ) ; // grab the first element of key currentKey = ( length( key ) > 0 ) ? strdup( CHAR( STRING_ELT(key,0) ) ) : 0 ; return currentKey ; } /** * name of an entry * * @param key keyname */ static SEXP xx_keyname_key( SEXP key){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif currentKey = set_current_key( key ) ; currentKeyLine = line_number ; return key; } /** * name of an entry */ static SEXP xx_keyname_abbrev( SEXP abbrev){ SEXP res = xx_expand_abbrev( abbrev ) ; currentKey = set_current_key( abbrev ) ; currentKeyLine = line_number ; return res; } /** * "include" object * * @param object */ static SEXP xx_include( SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return object ; } /** * preamble object * * @param object preamble object */ static SEXP xx_preamble(SEXP value){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return value; } /** * string object * * @param object the assignement */ static SEXP xx_string(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return object ; } /** * value, paste( left, right , sep = "" ) * * @param */ static SEXP xx_value( SEXP left , SEXP right ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; const char* left_ = CHAR( STRING_ELT( left, 0) ) ; const char* right_ = CHAR( STRING_ELT( right, 0) ) ; int n_left = strlen( left_); int n_right = strlen( right_); int n = n_left + n_right ; char res[n] ; int i, j; for( i=0; i\n" ) ; #endif return ans ; } /** * creates a new assignement list * * @param object assignement object */ static SEXP xx_assignement_list1(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans, tmp; _PROTECT( tmp = NewList( ) ) ; _PROTECT( ans = GrowList( tmp, object) ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Augments an assignement list with a new assignement * * @param list assignement list * @param object new assignement */ static SEXP xx_assignement_list2(SEXP list, SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = GrowList( list, object) ) ; _UNPROTECT_PTR( list ) ; _UNPROTECT_PTR( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /** * assignement * * @param lhs left side * @param value value */ static SEXP xx_assignement(SEXP lhs, SEXP value){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = value ) ; setAttrib( ans, install("names"), lhs ) ; _UNPROTECT_PTR( lhs ) ; _UNPROTECT_PTR( value ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /** * field lhs * * @param field */ static SEXP xx_lhs_field( SEXP field){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return field ; } static SEXP xx_lhs_abbrev( SEXP abbrev){ return xx_expand_abbrev( abbrev ) ; } static SEXP xx_space( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_space_inline( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_space_newline( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_forward( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_simple_value( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; /* all of what follows simply removes the " from the start and the end of the value, it might be better to do this in the lexer instead */ const char* data = CHAR( STRING_ELT( s, 0 ) ); int n = strlen(data); if( n >= 2) { char first = data[0]; char last = data[n-1]; if( first == '"' && last == '"' ){ _PROTECT( ans = allocVector( STRSXP, 1 ) ); if( n == 2 ){ SET_STRING_ELT( ans, 0, mkChar("") ) ; } else { char noquote[n-2] ; for( int i=1; i\n" ) ; #endif return ans ; } static SEXP xx_null( ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = R_NilValue ); #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /*}}}*/ /*{{{ various record functions */ static void recordInclude( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( includes, object ) ); _REPROTECT( includes = tmp, INCLUDE_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static void recordComment( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( comments, object ) ); _REPROTECT( comments = tmp, COMMENT_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static void recordString( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( strings, object ) ); _REPROTECT( strings = tmp, STRING_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static void recordPreamble( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( preamble, object ) ); _REPROTECT( preamble = tmp, PREAMBLE_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static SEXP xx_expand_abbrev( SEXP abbrev ){ SEXP ans, tmp ; /* use the abbreviation name by default */ _PROTECT( ans = allocVector( STRSXP, 1 ) ) ; SET_STRING_ELT( ans, 0, STRING_ELT( abbrev, 0) ) ; _PROTECT( tmp = CDR(strings) ) ; int n = length( tmp ) ; const char * target = CHAR( STRING_ELT( abbrev, 0) ) ; SEXP item ; for(int i=0; i c( a = "aa", b = "bb" ) */ static SEXP asVector( SEXP x, int donames){ SEXP ans, names = R_NilValue ; SEXP tmp ; int n = length( CDR(x) ) ; _PROTECT( ans = allocVector( STRSXP, n) ) ; if( donames ){ _PROTECT( names = allocVector( STRSXP, n) ) ; } SEXP item; _PROTECT( tmp = CDR( x ) ); for( int i=0; i 0 && i > 0){ if (s[i] == '{'){ paren <- paren - 1L }else if (s[i] == '}'){ paren <- paren + 1L } i <- i - 1L } last <- paste0(s[(i+2):(length(s)-1)], collapse = '') first <- NULL if (i > 0) first <- paste0(s[seq_len(i-1)], collapse = '') person(UnlistSplitClean(first), cleanupLatex(last)) # Mathew {McLean IX} }else{ vonrx <- "(^|[[:space:]])([[:lower:]+[:space:]?]+)[[:space:]]" m <- regexec(vonrx, parts) von <- unlist(regmatches(parts, m))[3L] if (!is.na(von)){ name <- unlist(strsplit(parts, vonrx)) if (length(name) == 1L){ # von Bommel person(family=c(cleanupLatex(von), cleanupLatex(name))) }else{ # Mark von Bommel person(given = UnlistSplitClean(name[1L]), family=c(cleanupLatex(von), cleanupLatex(name[2L]))) } }else{ # George Bernard Shaw name <- UnlistSplitClean(parts) len.name <- length(name) if (len.name <= 1L){ person(family = name) }else{ person(given = name[seq_len(len.name - 1L)], family = name[len.name]) } } } }else if (len.parts == 2L){ if (grepl('^[{]', parts[1L])){ # e.g. {de Gama}, Vasco person(UnlistSplitClean(parts[2L]), UnlistSplitClean(parts[1L])) }else{ vonrx <- "^([[:lower:]+[:space:]?]+)[[:space:]]" m <- regexec(vonrx, parts[1L]) von <- unlist(regmatches(parts[1L], m))[2] if (is.na(von)){ # e.g. Smith, John Paul person(UnlistSplitClean(parts[2L]), cleanupLatex(parts[1L])) }else{ # e.g. de la Soul, John person(UnlistSplitClean(parts[2L]), c(cleanupLatex(von), cleanupLatex(sub(vonrx, '', parts[1L])))) } } }else if (len.parts == 3L){ vonrx <- "^([[:lower:]+[:space:]?]+)[[:space:]]" m <- regexec(vonrx, parts[1L]) von <- unlist(regmatches(parts[1L], m))[2] if (is.na(von)){ # e.g. White, Jr., Walter person(UnlistSplitClean(parts[3L]), c(cleanupLatex(parts[1L]), cleanupLatex(parts[2L]))) }else{ # e.g. des White, Jr., Walter person(UnlistSplitClean(parts[3L]), c(cleanupLatex(von), cleanupLatex(sub(vonrx, '', parts[1L])), cleanupLatex(parts[2L]))) } }else{ stop('Invalid author/editor format.') } } #' @importFrom utils bibentry person citation installed.packages toBibtex make.bib.entry <- function( x ){ type <- attr( x, "entry" ) key <- attr( x, "key" ) y <- as.list( x ) names(y) <- tolower( names(y) ) err.fun <- function(e){ message( sprintf( "ignoring entry '%s' (line %d) because :\n\t%s\n", key, attr(x, "srcref")[1], conditionMessage( e ) ) ) NULL } if( "author" %in% names(y) ){ y[["author"]] <- tryCatch(ArrangeAuthors( y[["author"]] ), error = err.fun) if (is.null(y[["author"]])) return() } if( "editor" %in% names(y) ){ y[["editor"]] <- tryCatch(ArrangeAuthors( y[["editor"]] ), error = err.fun) if (is.null(y[["editor"]])) return() } # if there is a date entryn try to extract the year (#15) fields <- names(y) if( "date" %in% fields && !"year" %in% fields ){ y$year <- format( as.Date( y$date), "%Y" ) } tryCatch(bibentry( bibtype = type, key = key, other = y ), error = err.fun) } make.citation.list <- function( x, header, footer){ rval <- list() for( i in seq_along(x) ){ if( !is.null(x[[i]] ) ) rval <- c( rval, x[[i]] ) } class(rval) <- c( "bibentry" ) rval } findBibFile <- function(package) { if( package %in% c("base", "datasets", "graphics", "grDevices", "methods", "stats", "stats4", "tools", "utils" ) ) { system.file( "bib", sprintf( "%s.bib", package ), package = "bibtex" ) } else { attempt <- system.file( "REFERENCES.bib", package = package ) if( !nzchar(attempt) ){ stop( sprintf( "no bibtex database for package '%s'", package ) ) } attempt } } #' convenience wrapper around .External call #' #' This is a convenience function for packages that do need to call the internal #' functionality of \code{\link{read.bib}} but does different processing. This is #' a simple wrapper around the \code{.External} code used by \code{\link{read.bib}} #' #' The parser is greatly inspired from the \samp{bibparse} library. #' #' @seealso \code{\link[utils]{bibentry}} #' #' @param file file name #' @param encoding encoding #' @param srcfile output of \code{\link{srcfile}} #' @export do_read_bib <- function(file, encoding = "unknown", srcfile){ .External( "do_read_bib", file=file, encoding=encoding, srcfile=srcfile, PACKAGE = "bibtex" ) } #' bibtex parser #' #' Parser for bibliography databases written in the bib format. #' #' @param file bib file to parse. By default, the file #' \file{REFERENCES.bib} in the root directory of the package given by #' the \code{package} argument is used. #' @param package package from which we want to read the bibliography. #' Only used if \code{file} is unspecified. #' Core R packages (base, datasets, graphics, grDevices, methods, #' stats, stats4, tools and utils) are treated specially: this package #' contains bibtex entries for these packages. #' @param encoding encoding #' @param header header of the citation list. #' By default this is made from the \samp{Preamble} entries found in #' the bib file. #' @param footer footer of the citation list #' #' @return An object of class \code{"bibentry"}, similar to those obtained by the #' \code{\link[utils]{bibentry}} function. #' #' @references Nelson H. F. Beebe. bibparse 1.04. 1999. \url{http://www.math.utah.edu/~beebe} #' #' @examples #' ## this package has a REFERENCES.bib file #' bib <- read.bib( package = "bibtex" ) #' #' ## bibtex collects bibtex entries for R base packages #' base.bib <- read.bib( package = "base" ) #' #' \dontshow{ #' bib <- read.bib( package = "base" ) #' bib <- read.bib( package = "datasets" ) #' bib <- read.bib( package = "graphics" ) #' bib <- read.bib( package = "grDevices" ) #' bib <- read.bib( package = "methods" ) #' bib <- read.bib( package = "stats" ) #' bib <- read.bib( package = "stats4" ) #' bib <- read.bib( package = "tools" ) #' bib <- read.bib( package = "utils" ) #' } #' @export read.bib <- function(file = findBibFile(package) , package = "bibtex", encoding = "unknown", header = if( length(preamble) ) paste( preamble, sep = "\n" ) else "", footer = "" ) { if( !is.character( file ) ){ stop( "'read.bib' only supports reading from files, 'file' should be a character vector of length one" ) } srcfile <- switch( encoding, "unknown" = srcfile( file ), srcfile( file, encoding = encoding ) ) out <- withCallingHandlers(tryCatch(.External( "do_read_bib", file = file, encoding = encoding, srcfile = srcfile ), error = function(e){ if(!any(grepl("unprotect_ptr", e))) stop(geterrmessage(), call. = FALSE) else stop("Invalid bib file", call. = FALSE) }), warning = function(w){ if( any( grepl( "syntax error, unexpected [$]end", w))) invokeRestart("muffleWarning") }) # keys <- lapply(out, function(x) attr(x, 'key')) at <- attributes(out) if((typeof(out) != "integer") || (getRversion() < "3.0.0")) out <- lapply( out, make.bib.entry ) else out <- list() preamble <- at[["preamble"]] out <- make.citation.list( out, header, footer ) attr( out, "strings") <- at[["strings"]] names(out) <- unlist(out$key) out } #' Generate a Bibtex File from Package Citations #' #' Generates a Bibtex file from a list of packages or all the installed packages. #' It is useful for adding relevant citations in Sweave documents. #' #' @param entry a \code{\link{bibentry}} object or a character vector of package #' names. If \code{NULL}, then the list of all installed packages is used. #' @param file output Bibtex file. #' @param verbose a logical to toggle verbosity. #' @param append logical. If \code{TRUE} content is appended to the file. #' #' @return the list of Bibtex objects -- invisibly. #' @author #' Renaud Gaujoux, based on the function \code{Rpackages.bib} #' from Achim Zeileis (see \emph{References}). #' #' @references #' \emph{[R] Creating bibtex file of all installed packages?} #' Achim Zeileis. R-help mailing list. #' #' @export #' @examples #' #' write.bib(c('bibtex', 'utils', 'tools'), file='references') #' bibs <- read.bib('references.bib') #' write.bib(bibs, 'references2.bib') #' md5 <- tools::md5sum(c('references.bib', 'references2.bib')) #' md5[1] == md5[2] #' write.bib <- function(entry, file="Rpackages.bib", append = FALSE, verbose = TRUE) { bibs <- if( inherits(entry, "bibentry") ) entry else if( is.character(entry) ){ if( length(entry) == 0 ){ if( verbose ) message("Empty package list: nothing to be done.") return(invisible()) } pkgs <- entry if( is.null(pkgs) ) ## use all installed packages pkgs <- unique(installed.packages()[,1]) bibs <- sapply(pkgs, function(x) try(citation(x)), simplify=FALSE) #bibs <- lapply(pkgs, function(x) try(toBibtex(citation(x)))) n.installed <- length(bibs) ## omit failed citation calls ok <- sapply(bibs, inherits, "bibentry") pkgs <- pkgs[ok] bibs <- bibs[ok] n.converted <- sum(ok) ## add bibtex keys to each entry pkgs <- lapply(seq_along(pkgs), function(i) if(length(bibs[[i]]) > 1) paste(pkgs[i], 1:length(bibs[[i]]), sep = "") else pkgs[i]) pkgs <- do.call("c", pkgs) bibs <- do.call("c", bibs) # formatting function for bibtex keys: # names with special characters must be enclosed in {}, others not. as.bibkey <- function(x){ i <- grep("[.]", x) if( length(i) > 0 ) x[i] <- paste("{", x[i], "}", sep='') x } bibs <- mapply(function(b,k){ b$key <- k; b}, bibs, pkgs, SIMPLIFY=FALSE) bibs <- do.call("c", bibs) if(verbose) message("Converted ", n.converted, " of ", n.installed, " package citations to BibTeX") bibs } else stop("Invalid argument 'entry': expected a bibentry object or a character vector of package names.") if( length(bibs) == 0 ){ if( verbose ) message("Empty bibentry list: nothing to be done.") return(invisible()) } ## write everything to a single .bib file if( is.null(file) ) file <- stdout() else if( is.character(file) ){ if( !grepl("\\.bib$", file) ) # add .bib extension if necessary file <- paste(file, '.bib', sep='') } fh <- file(file, open = if(append) "a+" else "w+" ) on.exit( if( isOpen(fh) ) close(fh) ) if( verbose ) message("Writing ", length(bibs) , " Bibtex entries ... ", appendLF=FALSE) writeLines(toBibtex(bibs), fh) #writeLines(do.call("c", lapply(bibs, as.character)), fh) if(verbose) message("OK\nResults written to file '", file, "'") ## return Bibtex items invisibly invisible(bibs) } bibtex/MD50000644000176000001440000000346413731452745012111 0ustar ripleyusers1728d64ae6da98dff93188de1c7c1032 *DESCRIPTION 9d416fd2e02f86754c076d666f446f99 *NAMESPACE e51d06a265ddd5bd5bb90eeba6db02d1 *R/bibtex.R 8533def0c680b458ba3bc9e8cc845b92 *README.md 7b54654c42cc549f21f78c9d795b67f8 *inst/NEWS.Rd 8bcba1916c0c788f5572368d076ecb31 *inst/REFERENCES.bib 328b89785aa42b2f1ba6bae713b6bd88 *inst/bib/badFormat.bib 417941fa83a4ee9cad2e452f3ba86cb7 *inst/bib/base.bib d4b57184262492f10a216a71e660677f *inst/bib/datasets.bib 9c4262a1ee733dfd8d534a344c8002a7 *inst/bib/grDevices.bib 838fb244de8d6987d9bc9f2f2888a2be *inst/bib/graphics.bib c5a048b261add22e9c8432ffa846f9d4 *inst/bib/methods.bib 8b28eb6dcd7a7bb9b15e1efdd8420f76 *inst/bib/stats.bib f8f68566461d5c0c0b3d78be4fc2a380 *inst/bib/stats4.bib 69499be43c7085715449ffd5f29e5434 *inst/bib/tools.bib 7d79aef1c884aabd303c89df2671c017 *inst/bib/utils.bib 1d7ceaeb12fd126f254d5cbe4b426579 *inst/bibparse.output 63cdef32f5ffa6f8bfa8c65b12c2f61b *inst/clean-bibtex.R 1d7ceaeb12fd126f254d5cbe4b426579 *inst/grammar.output 273e0b4310366a2307f3effad757abe0 *inst/grammar/biblex.l 009952af2b733f4d710b0415fe75874a *inst/grammar/bibparse.y 5e48f14f9f8078c8df6c03b619b715f7 *inst/include/bibparse.h efdcc70475b5b4afacb39feefbb8029d *inst/include/bibtex.h 1d7ceaeb12fd126f254d5cbe4b426579 *inst/objects.output 849dec3ea96ed59385b3bd00aff5a7da *man/do_read_bib.Rd ac6db54b389e3b6f73e80787090a16bf *man/read.bib.Rd 18f34f74561260d0bd9356f1a2fbb8db *man/write.bib.Rd 1a315aa73f3882ca3d110365f272fbc0 *src/Makevars eda56fe33675f4d63d38490e1210c3d4 *src/biblex.c 60990dfeadd6e5100939cbd6bf1e820d *src/bibparse.c 01b8caf2eb7c4f177f3ba02be7dd1665 *src/init.c cdc573bb0873053f7658e8d06a516e22 *src/stretchyList.c 078b1afc8cc00f041bfe9ba3cafb0ff7 *tests/testthat.R e6da05e61d88df667ecaff0a870c7bf4 *tests/testthat/test-authors.R b9c12a4b7f3aa27c0feb4eb15c833204 *tests/testthat/test-bibtex.R bibtex/inst/0000755000176000001440000000000013125413074012534 5ustar ripleyusersbibtex/inst/bibparse.output0000644000176000001440000006564713125413074015627 0ustar ripleyusersState 0 conflicts: 3 shift/reduce State 6 conflicts: 3 shift/reduce State 29 conflicts: 3 shift/reduce State 31 conflicts: 3 shift/reduce State 92 conflicts: 3 shift/reduce Grammar 0 $accept: file $end 1 file: opt_space 2 | opt_space object_list opt_space 3 object_list: object 4 | object_list opt_space object 5 object: TOKEN_AT opt_space at_object 6 | anything opt_space object 7 anything: TOKEN_ABBREV 8 | TOKEN_COMMA 9 | TOKEN_COMMENT 10 | TOKEN_ENTRY 11 | TOKEN_EQUALS 12 | TOKEN_FIELD 13 | TOKEN_INCLUDE 14 | TOKEN_INLINE 15 | TOKEN_KEY 16 | TOKEN_LBRACE 17 | TOKEN_LITERAL 18 | TOKEN_NEWLINE 19 | TOKEN_PREAMBLE 20 | TOKEN_RBRACE 21 | TOKEN_SHARP 22 | TOKEN_SPACE 23 | TOKEN_STRING 24 | TOKEN_VALUE 25 | TOKEN_UNKNOWN 26 at_object: comment 27 | entry 28 | include 29 | preamble 30 | string 31 | error TOKEN_RBRACE 32 comment: TOKEN_COMMENT opt_space TOKEN_LITERAL 33 entry: entry_head assignment_list TOKEN_RBRACE 34 | entry_head assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE 35 | entry_head TOKEN_RBRACE 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space 38 key_name: TOKEN_KEY 39 | TOKEN_ABBREV 40 include: TOKEN_INCLUDE opt_space TOKEN_LITERAL 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE 43 value: simple_value 44 | value opt_space TOKEN_SHARP opt_space simple_value 45 simple_value: TOKEN_VALUE 46 | TOKEN_ABBREV 47 assignment_list: assignment 48 | assignment_list TOKEN_COMMA opt_space assignment 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value opt_space 50 assignment_lhs: TOKEN_FIELD 51 | TOKEN_ABBREV 52 opt_space: /* empty */ 53 | space 54 space: single_space 55 | space single_space 56 single_space: TOKEN_SPACE 57 | TOKEN_INLINE 58 | TOKEN_NEWLINE Terminals, with rules where they appear $end (0) 0 error (256) 31 TOKEN_ABBREV (258) 7 39 46 51 TOKEN_AT (259) 5 TOKEN_COMMA (260) 8 34 36 37 48 TOKEN_COMMENT (261) 9 32 TOKEN_ENTRY (262) 10 36 37 TOKEN_EQUALS (263) 11 49 TOKEN_FIELD (264) 12 50 TOKEN_INCLUDE (265) 13 40 TOKEN_INLINE (266) 14 57 TOKEN_KEY (267) 15 38 TOKEN_LBRACE (268) 16 36 37 41 42 TOKEN_LITERAL (269) 17 32 40 TOKEN_NEWLINE (270) 18 58 TOKEN_PREAMBLE (271) 19 41 TOKEN_RBRACE (272) 20 31 33 34 35 41 42 TOKEN_SHARP (273) 21 44 TOKEN_SPACE (274) 22 56 TOKEN_STRING (275) 23 42 TOKEN_VALUE (276) 24 45 TOKEN_UNKNOWN (277) 25 Nonterminals, with rules where they appear $accept (23) on left: 0 file (24) on left: 1 2, on right: 0 object_list (25) on left: 3 4, on right: 2 4 object (26) on left: 5 6, on right: 3 4 6 anything (27) on left: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 , on right: 6 at_object (28) on left: 26 27 28 29 30 31, on right: 5 comment (29) on left: 32, on right: 26 entry (30) on left: 33 34 35, on right: 27 entry_head (31) on left: 36 37, on right: 33 34 35 key_name (32) on left: 38 39, on right: 36 include (33) on left: 40, on right: 28 preamble (34) on left: 41, on right: 29 string (35) on left: 42, on right: 30 value (36) on left: 43 44, on right: 41 44 49 simple_value (37) on left: 45 46, on right: 43 44 assignment_list (38) on left: 47 48, on right: 33 34 48 assignment (39) on left: 49, on right: 42 47 48 assignment_lhs (40) on left: 50 51, on right: 49 opt_space (41) on left: 52 53, on right: 1 2 4 5 6 32 34 36 37 40 41 42 44 48 49 space (42) on left: 54 55, on right: 53 55 single_space (43) on left: 56 57 58, on right: 54 55 state 0 0 $accept: . file $end TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) file go to state 4 opt_space go to state 5 space go to state 6 single_space go to state 7 state 1 57 single_space: TOKEN_INLINE . $default reduce using rule 57 (single_space) state 2 58 single_space: TOKEN_NEWLINE . $default reduce using rule 58 (single_space) state 3 56 single_space: TOKEN_SPACE . $default reduce using rule 56 (single_space) state 4 0 $accept: file . $end $end shift, and go to state 8 state 5 1 file: opt_space . 2 | opt_space . object_list opt_space TOKEN_ABBREV shift, and go to state 9 TOKEN_AT shift, and go to state 10 TOKEN_COMMA shift, and go to state 11 TOKEN_COMMENT shift, and go to state 12 TOKEN_ENTRY shift, and go to state 13 TOKEN_EQUALS shift, and go to state 14 TOKEN_FIELD shift, and go to state 15 TOKEN_INCLUDE shift, and go to state 16 TOKEN_INLINE shift, and go to state 17 TOKEN_KEY shift, and go to state 18 TOKEN_LBRACE shift, and go to state 19 TOKEN_LITERAL shift, and go to state 20 TOKEN_NEWLINE shift, and go to state 21 TOKEN_PREAMBLE shift, and go to state 22 TOKEN_RBRACE shift, and go to state 23 TOKEN_SHARP shift, and go to state 24 TOKEN_SPACE shift, and go to state 25 TOKEN_STRING shift, and go to state 26 TOKEN_VALUE shift, and go to state 27 TOKEN_UNKNOWN shift, and go to state 28 $default reduce using rule 1 (file) object_list go to state 29 object go to state 30 anything go to state 31 state 6 53 opt_space: space . 55 space: space . single_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 53 (opt_space)] TOKEN_NEWLINE [reduce using rule 53 (opt_space)] TOKEN_SPACE [reduce using rule 53 (opt_space)] $default reduce using rule 53 (opt_space) single_space go to state 32 state 7 54 space: single_space . $default reduce using rule 54 (space) state 8 0 $accept: file $end . $default accept state 9 7 anything: TOKEN_ABBREV . $default reduce using rule 7 (anything) state 10 5 object: TOKEN_AT . opt_space at_object TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 33 space go to state 6 single_space go to state 7 state 11 8 anything: TOKEN_COMMA . $default reduce using rule 8 (anything) state 12 9 anything: TOKEN_COMMENT . $default reduce using rule 9 (anything) state 13 10 anything: TOKEN_ENTRY . $default reduce using rule 10 (anything) state 14 11 anything: TOKEN_EQUALS . $default reduce using rule 11 (anything) state 15 12 anything: TOKEN_FIELD . $default reduce using rule 12 (anything) state 16 13 anything: TOKEN_INCLUDE . $default reduce using rule 13 (anything) state 17 14 anything: TOKEN_INLINE . $default reduce using rule 14 (anything) state 18 15 anything: TOKEN_KEY . $default reduce using rule 15 (anything) state 19 16 anything: TOKEN_LBRACE . $default reduce using rule 16 (anything) state 20 17 anything: TOKEN_LITERAL . $default reduce using rule 17 (anything) state 21 18 anything: TOKEN_NEWLINE . $default reduce using rule 18 (anything) state 22 19 anything: TOKEN_PREAMBLE . $default reduce using rule 19 (anything) state 23 20 anything: TOKEN_RBRACE . $default reduce using rule 20 (anything) state 24 21 anything: TOKEN_SHARP . $default reduce using rule 21 (anything) state 25 22 anything: TOKEN_SPACE . $default reduce using rule 22 (anything) state 26 23 anything: TOKEN_STRING . $default reduce using rule 23 (anything) state 27 24 anything: TOKEN_VALUE . $default reduce using rule 24 (anything) state 28 25 anything: TOKEN_UNKNOWN . $default reduce using rule 25 (anything) state 29 2 file: opt_space object_list . opt_space 4 object_list: object_list . opt_space object TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) opt_space go to state 34 space go to state 6 single_space go to state 7 state 30 3 object_list: object . $default reduce using rule 3 (object_list) state 31 6 object: anything . opt_space object TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) opt_space go to state 35 space go to state 6 single_space go to state 7 state 32 55 space: space single_space . $default reduce using rule 55 (space) state 33 5 object: TOKEN_AT opt_space . at_object error shift, and go to state 36 TOKEN_COMMENT shift, and go to state 37 TOKEN_ENTRY shift, and go to state 38 TOKEN_INCLUDE shift, and go to state 39 TOKEN_PREAMBLE shift, and go to state 40 TOKEN_STRING shift, and go to state 41 at_object go to state 42 comment go to state 43 entry go to state 44 entry_head go to state 45 include go to state 46 preamble go to state 47 string go to state 48 state 34 2 file: opt_space object_list opt_space . 4 object_list: object_list opt_space . object TOKEN_ABBREV shift, and go to state 9 TOKEN_AT shift, and go to state 10 TOKEN_COMMA shift, and go to state 11 TOKEN_COMMENT shift, and go to state 12 TOKEN_ENTRY shift, and go to state 13 TOKEN_EQUALS shift, and go to state 14 TOKEN_FIELD shift, and go to state 15 TOKEN_INCLUDE shift, and go to state 16 TOKEN_INLINE shift, and go to state 17 TOKEN_KEY shift, and go to state 18 TOKEN_LBRACE shift, and go to state 19 TOKEN_LITERAL shift, and go to state 20 TOKEN_NEWLINE shift, and go to state 21 TOKEN_PREAMBLE shift, and go to state 22 TOKEN_RBRACE shift, and go to state 23 TOKEN_SHARP shift, and go to state 24 TOKEN_SPACE shift, and go to state 25 TOKEN_STRING shift, and go to state 26 TOKEN_VALUE shift, and go to state 27 TOKEN_UNKNOWN shift, and go to state 28 $default reduce using rule 2 (file) object go to state 49 anything go to state 31 state 35 6 object: anything opt_space . object TOKEN_ABBREV shift, and go to state 9 TOKEN_AT shift, and go to state 10 TOKEN_COMMA shift, and go to state 11 TOKEN_COMMENT shift, and go to state 12 TOKEN_ENTRY shift, and go to state 13 TOKEN_EQUALS shift, and go to state 14 TOKEN_FIELD shift, and go to state 15 TOKEN_INCLUDE shift, and go to state 16 TOKEN_INLINE shift, and go to state 17 TOKEN_KEY shift, and go to state 18 TOKEN_LBRACE shift, and go to state 19 TOKEN_LITERAL shift, and go to state 20 TOKEN_NEWLINE shift, and go to state 21 TOKEN_PREAMBLE shift, and go to state 22 TOKEN_RBRACE shift, and go to state 23 TOKEN_SHARP shift, and go to state 24 TOKEN_SPACE shift, and go to state 25 TOKEN_STRING shift, and go to state 26 TOKEN_VALUE shift, and go to state 27 TOKEN_UNKNOWN shift, and go to state 28 object go to state 50 anything go to state 31 state 36 31 at_object: error . TOKEN_RBRACE TOKEN_RBRACE shift, and go to state 51 state 37 32 comment: TOKEN_COMMENT . opt_space TOKEN_LITERAL TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 52 space go to state 6 single_space go to state 7 state 38 36 entry_head: TOKEN_ENTRY . opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY . opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 53 space go to state 6 single_space go to state 7 state 39 40 include: TOKEN_INCLUDE . opt_space TOKEN_LITERAL TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 54 space go to state 6 single_space go to state 7 state 40 41 preamble: TOKEN_PREAMBLE . opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 55 space go to state 6 single_space go to state 7 state 41 42 string: TOKEN_STRING . opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 56 space go to state 6 single_space go to state 7 state 42 5 object: TOKEN_AT opt_space at_object . $default reduce using rule 5 (object) state 43 26 at_object: comment . $default reduce using rule 26 (at_object) state 44 27 at_object: entry . $default reduce using rule 27 (at_object) state 45 33 entry: entry_head . assignment_list TOKEN_RBRACE 34 | entry_head . assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE 35 | entry_head . TOKEN_RBRACE TOKEN_ABBREV shift, and go to state 57 TOKEN_FIELD shift, and go to state 58 TOKEN_RBRACE shift, and go to state 59 assignment_list go to state 60 assignment go to state 61 assignment_lhs go to state 62 state 46 28 at_object: include . $default reduce using rule 28 (at_object) state 47 29 at_object: preamble . $default reduce using rule 29 (at_object) state 48 30 at_object: string . $default reduce using rule 30 (at_object) state 49 4 object_list: object_list opt_space object . $default reduce using rule 4 (object_list) state 50 6 object: anything opt_space object . $default reduce using rule 6 (object) state 51 31 at_object: error TOKEN_RBRACE . $default reduce using rule 31 (at_object) state 52 32 comment: TOKEN_COMMENT opt_space . TOKEN_LITERAL TOKEN_LITERAL shift, and go to state 63 state 53 36 entry_head: TOKEN_ENTRY opt_space . TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space . TOKEN_LBRACE opt_space TOKEN_COMMA opt_space TOKEN_LBRACE shift, and go to state 64 state 54 40 include: TOKEN_INCLUDE opt_space . TOKEN_LITERAL TOKEN_LITERAL shift, and go to state 65 state 55 41 preamble: TOKEN_PREAMBLE opt_space . TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE TOKEN_LBRACE shift, and go to state 66 state 56 42 string: TOKEN_STRING opt_space . TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE TOKEN_LBRACE shift, and go to state 67 state 57 51 assignment_lhs: TOKEN_ABBREV . $default reduce using rule 51 (assignment_lhs) state 58 50 assignment_lhs: TOKEN_FIELD . $default reduce using rule 50 (assignment_lhs) state 59 35 entry: entry_head TOKEN_RBRACE . $default reduce using rule 35 (entry) state 60 33 entry: entry_head assignment_list . TOKEN_RBRACE 34 | entry_head assignment_list . TOKEN_COMMA opt_space TOKEN_RBRACE 48 assignment_list: assignment_list . TOKEN_COMMA opt_space assignment TOKEN_COMMA shift, and go to state 68 TOKEN_RBRACE shift, and go to state 69 state 61 47 assignment_list: assignment . $default reduce using rule 47 (assignment_list) state 62 49 assignment: assignment_lhs . opt_space TOKEN_EQUALS opt_space value opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 70 space go to state 6 single_space go to state 7 state 63 32 comment: TOKEN_COMMENT opt_space TOKEN_LITERAL . $default reduce using rule 32 (comment) state 64 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE . opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space TOKEN_LBRACE . opt_space TOKEN_COMMA opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 71 space go to state 6 single_space go to state 7 state 65 40 include: TOKEN_INCLUDE opt_space TOKEN_LITERAL . $default reduce using rule 40 (include) state 66 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE . opt_space value opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 72 space go to state 6 single_space go to state 7 state 67 42 string: TOKEN_STRING opt_space TOKEN_LBRACE . opt_space assignment opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 73 space go to state 6 single_space go to state 7 state 68 34 entry: entry_head assignment_list TOKEN_COMMA . opt_space TOKEN_RBRACE 48 assignment_list: assignment_list TOKEN_COMMA . opt_space assignment TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 74 space go to state 6 single_space go to state 7 state 69 33 entry: entry_head assignment_list TOKEN_RBRACE . $default reduce using rule 33 (entry) state 70 49 assignment: assignment_lhs opt_space . TOKEN_EQUALS opt_space value opt_space TOKEN_EQUALS shift, and go to state 75 state 71 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space . key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space . TOKEN_COMMA opt_space TOKEN_ABBREV shift, and go to state 76 TOKEN_COMMA shift, and go to state 77 TOKEN_KEY shift, and go to state 78 key_name go to state 79 state 72 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space . value opt_space TOKEN_RBRACE TOKEN_ABBREV shift, and go to state 80 TOKEN_VALUE shift, and go to state 81 value go to state 82 simple_value go to state 83 state 73 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space . assignment opt_space TOKEN_RBRACE TOKEN_ABBREV shift, and go to state 57 TOKEN_FIELD shift, and go to state 58 assignment go to state 84 assignment_lhs go to state 62 state 74 34 entry: entry_head assignment_list TOKEN_COMMA opt_space . TOKEN_RBRACE 48 assignment_list: assignment_list TOKEN_COMMA opt_space . assignment TOKEN_ABBREV shift, and go to state 57 TOKEN_FIELD shift, and go to state 58 TOKEN_RBRACE shift, and go to state 85 assignment go to state 86 assignment_lhs go to state 62 state 75 49 assignment: assignment_lhs opt_space TOKEN_EQUALS . opt_space value opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 87 space go to state 6 single_space go to state 7 state 76 39 key_name: TOKEN_ABBREV . $default reduce using rule 39 (key_name) state 77 37 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA . opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 88 space go to state 6 single_space go to state 7 state 78 38 key_name: TOKEN_KEY . $default reduce using rule 38 (key_name) state 79 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name . opt_space TOKEN_COMMA opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 89 space go to state 6 single_space go to state 7 state 80 46 simple_value: TOKEN_ABBREV . $default reduce using rule 46 (simple_value) state 81 45 simple_value: TOKEN_VALUE . $default reduce using rule 45 (simple_value) state 82 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value . opt_space TOKEN_RBRACE 44 value: value . opt_space TOKEN_SHARP opt_space simple_value TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 90 space go to state 6 single_space go to state 7 state 83 43 value: simple_value . $default reduce using rule 43 (value) state 84 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment . opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 91 space go to state 6 single_space go to state 7 state 85 34 entry: entry_head assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE . $default reduce using rule 34 (entry) state 86 48 assignment_list: assignment_list TOKEN_COMMA opt_space assignment . $default reduce using rule 48 (assignment_list) state 87 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space . value opt_space TOKEN_ABBREV shift, and go to state 80 TOKEN_VALUE shift, and go to state 81 value go to state 92 simple_value go to state 83 state 88 37 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space . $default reduce using rule 37 (entry_head) state 89 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space . TOKEN_COMMA opt_space TOKEN_COMMA shift, and go to state 93 state 90 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space . TOKEN_RBRACE 44 value: value opt_space . TOKEN_SHARP opt_space simple_value TOKEN_RBRACE shift, and go to state 94 TOKEN_SHARP shift, and go to state 95 state 91 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space . TOKEN_RBRACE TOKEN_RBRACE shift, and go to state 96 state 92 44 value: value . opt_space TOKEN_SHARP opt_space simple_value 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value . opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) opt_space go to state 97 space go to state 6 single_space go to state 7 state 93 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA . opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 98 space go to state 6 single_space go to state 7 state 94 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE . $default reduce using rule 41 (preamble) state 95 44 value: value opt_space TOKEN_SHARP . opt_space simple_value TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 99 space go to state 6 single_space go to state 7 state 96 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE . $default reduce using rule 42 (string) state 97 44 value: value opt_space . TOKEN_SHARP opt_space simple_value 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value opt_space . TOKEN_SHARP shift, and go to state 95 $default reduce using rule 49 (assignment) state 98 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space . $default reduce using rule 36 (entry_head) state 99 44 value: value opt_space TOKEN_SHARP opt_space . simple_value TOKEN_ABBREV shift, and go to state 80 TOKEN_VALUE shift, and go to state 81 simple_value go to state 100 state 100 44 value: value opt_space TOKEN_SHARP opt_space simple_value . $default reduce using rule 44 (value) bibtex/inst/REFERENCES.bib0000644000176000001440000000046213125410150014625 0ustar ripleyusers@Manual{R, title = {R: A Language and Environment for Statistical Computing}, author = {{R Development Core Team}}, organization = {R Foundation for Statistical Computing}, address = {Vienna, Austria}, year = {2009}, note = {{ISBN} 3-900051-07-0}, url = {http://www.R-project.org}, } bibtex/inst/clean-bibtex.R0000644000176000001440000000072513125410150015210 0ustar ripleyuserslines <- readLines( "bibtex/src/biblex.c" ) # remove declaration of yy_fatal_error decl <- grep("static void yy_fatal_error.*;", lines) lines[decl] <- paste( "//", lines[decl] ) # first line of definition of yy_fatal_error def_begin <- grep("static void yy_fatal_error[^;]*$", lines ) def_end <- def_begin + grep( "^}", tail(lines, -def_begin) )[1L] lines[ def_begin:def_end ] <- paste( "// ", lines[def_begin:def_end] ) writeLines( lines, "bibtex/src/biblex.c" ) bibtex/inst/include/0000755000176000001440000000000013730050703014155 5ustar ripleyusersbibtex/inst/include/bibparse.h0000644000176000001440000000645013125413074016124 0ustar ripleyusers/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { TOKEN_ABBREV = 258, TOKEN_AT = 259, TOKEN_COMMA = 260, TOKEN_COMMENT = 261, TOKEN_ENTRY = 262, TOKEN_EQUALS = 263, TOKEN_FIELD = 264, TOKEN_INCLUDE = 265, TOKEN_INLINE = 266, TOKEN_KEY = 267, TOKEN_LBRACE = 268, TOKEN_LITERAL = 269, TOKEN_NEWLINE = 270, TOKEN_PREAMBLE = 271, TOKEN_RBRACE = 272, TOKEN_SHARP = 273, TOKEN_SPACE = 274, TOKEN_STRING = 275, TOKEN_VALUE = 276, TOKEN_UNKNOWN = 277 }; #endif /* Tokens. */ #define TOKEN_ABBREV 258 #define TOKEN_AT 259 #define TOKEN_COMMA 260 #define TOKEN_COMMENT 261 #define TOKEN_ENTRY 262 #define TOKEN_EQUALS 263 #define TOKEN_FIELD 264 #define TOKEN_INCLUDE 265 #define TOKEN_INLINE 266 #define TOKEN_KEY 267 #define TOKEN_LBRACE 268 #define TOKEN_LITERAL 269 #define TOKEN_NEWLINE 270 #define TOKEN_PREAMBLE 271 #define TOKEN_RBRACE 272 #define TOKEN_SHARP 273 #define TOKEN_SPACE 274 #define TOKEN_STRING 275 #define TOKEN_VALUE 276 #define TOKEN_UNKNOWN 277 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE yylval; #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; } YYLTYPE; # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif extern YYLTYPE yylloc; bibtex/inst/include/bibtex.h0000644000176000001440000000422313730050703015604 0ustar ripleyusers#ifndef BIBTEX_BIBTEX_H #define BIBTEX_BIBTEX_H #include #include #include #include #ifndef extern #include #endif #ifdef SUPPORT_MBCS # ifdef Win32 # define USE_UTF8_IF_POSSIBLE # endif #endif #ifdef HAVE_VISIBILITY_ATTRIBUTE # define attribute_visible __attribute__ ((visibility ("default"))) # define attribute_hidden __attribute__ ((visibility ("hidden"))) #else # define attribute_visible # define attribute_hidden #endif #define BIBYYLMAX 131072 void _yyerror(const char *s_); int yylex(void); int yyparse(void); int yywrap(void); #if defined(FLEX_SCANNER) #define input yyinput #define output(c) Rprintf("%c", c) #if !defined(HAVE_FILENO) #define YY_NEVER_INTERACTIVE 1 /* suppresses need for isatty() and fileno() */ #endif #else /* NOT defined(FLEX_SCANNER) */ #endif /* defined(FLEX_SCANNER) */ int yyparse(); extern int error_count; extern char *program_name; /* for error messages */ /* These variables are defined in biblex.c: */ extern int do_lex_output; extern long line_number; extern long col_number ; extern long byte_number ; extern long start_line_number; extern long start_col_number ; extern long start_byte_number; extern const char *the_filename; #define ERROR_PREFIX "??" /* this prefixes all error messages */ #define WARNING_PREFIX "%%" /* this prefixes all warning messages */ extern int yydebug; #if !defined(EXIT_SUCCESS) #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 #endif #define R_EOF -1 FILE * _fopen(const char *filename, const char *mode); void yyset_in (FILE*) ; SEXP NewList() ; SEXP GrowList(SEXP, SEXP) ; SEXP Insert(SEXP, SEXP) ; void setToken( const char*, int) ; SEXP mkString2(const char *, int) ; extern Rboolean known_to_be_utf8 ; // was known_to_be_latin1 but that clashes with R #define known_to_be_latin1 bibtex_known_to_be_latin1 extern Rboolean known_to_be_latin1 ; typedef struct yyltype{ int first_line; int first_column; int first_byte; int last_line; int last_column; int last_byte; } yyltype; # define YYLTYPE yyltype extern YYLTYPE last_at_location ; #define YY_FATAL_ERROR(msg) Rf_error("lex fatal error:\n%s\n", msg); #endif bibtex/inst/NEWS.Rd0000644000176000001440000000171713125410150013575 0ustar ripleyusers\name{NEWS} \title{News for Package \pkg{bibtex}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} \section{Changes in version 0.4.0 (2014-12-31)}{ \itemize{ \item Removed the function \code{yy_fatal_error} which even though it was never actually called, triggered some R CMD check nuisance \item Removed useless dependency on Rcpp which bibtex no longer uses \item Added cite by key functionality to \code{read.bib}, pull request by Michael Koohafkan } } \section{Changes in version 0.3-5 (2013-02-04)}{ \itemize{ \item Fix for bib files with no content. } } \section{Changes in version 0.3-1 (2011-12-11)}{ \itemize{ \item New function \code{write.bib} contributed by Renaud Gaujoux. \item Missing \code{\%} in error reporting in read.bib. Fix provided by Renaud Gaujoux. } } \section{Changes in version 0.3-0 (2011-11-17)}{ \itemize{ \item Fixed long standing bug re backslahes. } } bibtex/inst/objects.output0000755000176000001440000006564713125410150015464 0ustar ripleyusersState 0 conflicts: 3 shift/reduce State 6 conflicts: 3 shift/reduce State 29 conflicts: 3 shift/reduce State 31 conflicts: 3 shift/reduce State 92 conflicts: 3 shift/reduce Grammar 0 $accept: file $end 1 file: opt_space 2 | opt_space object_list opt_space 3 object_list: object 4 | object_list opt_space object 5 object: TOKEN_AT opt_space at_object 6 | anything opt_space object 7 anything: TOKEN_ABBREV 8 | TOKEN_COMMA 9 | TOKEN_COMMENT 10 | TOKEN_ENTRY 11 | TOKEN_EQUALS 12 | TOKEN_FIELD 13 | TOKEN_INCLUDE 14 | TOKEN_INLINE 15 | TOKEN_KEY 16 | TOKEN_LBRACE 17 | TOKEN_LITERAL 18 | TOKEN_NEWLINE 19 | TOKEN_PREAMBLE 20 | TOKEN_RBRACE 21 | TOKEN_SHARP 22 | TOKEN_SPACE 23 | TOKEN_STRING 24 | TOKEN_VALUE 25 | TOKEN_UNKNOWN 26 at_object: comment 27 | entry 28 | include 29 | preamble 30 | string 31 | error TOKEN_RBRACE 32 comment: TOKEN_COMMENT opt_space TOKEN_LITERAL 33 entry: entry_head assignment_list TOKEN_RBRACE 34 | entry_head assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE 35 | entry_head TOKEN_RBRACE 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space 38 key_name: TOKEN_KEY 39 | TOKEN_ABBREV 40 include: TOKEN_INCLUDE opt_space TOKEN_LITERAL 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE 43 value: simple_value 44 | value opt_space TOKEN_SHARP opt_space simple_value 45 simple_value: TOKEN_VALUE 46 | TOKEN_ABBREV 47 assignment_list: assignment 48 | assignment_list TOKEN_COMMA opt_space assignment 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value opt_space 50 assignment_lhs: TOKEN_FIELD 51 | TOKEN_ABBREV 52 opt_space: /* empty */ 53 | space 54 space: single_space 55 | space single_space 56 single_space: TOKEN_SPACE 57 | TOKEN_INLINE 58 | TOKEN_NEWLINE Terminals, with rules where they appear $end (0) 0 error (256) 31 TOKEN_ABBREV (258) 7 39 46 51 TOKEN_AT (259) 5 TOKEN_COMMA (260) 8 34 36 37 48 TOKEN_COMMENT (261) 9 32 TOKEN_ENTRY (262) 10 36 37 TOKEN_EQUALS (263) 11 49 TOKEN_FIELD (264) 12 50 TOKEN_INCLUDE (265) 13 40 TOKEN_INLINE (266) 14 57 TOKEN_KEY (267) 15 38 TOKEN_LBRACE (268) 16 36 37 41 42 TOKEN_LITERAL (269) 17 32 40 TOKEN_NEWLINE (270) 18 58 TOKEN_PREAMBLE (271) 19 41 TOKEN_RBRACE (272) 20 31 33 34 35 41 42 TOKEN_SHARP (273) 21 44 TOKEN_SPACE (274) 22 56 TOKEN_STRING (275) 23 42 TOKEN_VALUE (276) 24 45 TOKEN_UNKNOWN (277) 25 Nonterminals, with rules where they appear $accept (23) on left: 0 file (24) on left: 1 2, on right: 0 object_list (25) on left: 3 4, on right: 2 4 object (26) on left: 5 6, on right: 3 4 6 anything (27) on left: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 , on right: 6 at_object (28) on left: 26 27 28 29 30 31, on right: 5 comment (29) on left: 32, on right: 26 entry (30) on left: 33 34 35, on right: 27 entry_head (31) on left: 36 37, on right: 33 34 35 key_name (32) on left: 38 39, on right: 36 include (33) on left: 40, on right: 28 preamble (34) on left: 41, on right: 29 string (35) on left: 42, on right: 30 value (36) on left: 43 44, on right: 41 44 49 simple_value (37) on left: 45 46, on right: 43 44 assignment_list (38) on left: 47 48, on right: 33 34 48 assignment (39) on left: 49, on right: 42 47 48 assignment_lhs (40) on left: 50 51, on right: 49 opt_space (41) on left: 52 53, on right: 1 2 4 5 6 32 34 36 37 40 41 42 44 48 49 space (42) on left: 54 55, on right: 53 55 single_space (43) on left: 56 57 58, on right: 54 55 state 0 0 $accept: . file $end TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) file go to state 4 opt_space go to state 5 space go to state 6 single_space go to state 7 state 1 57 single_space: TOKEN_INLINE . $default reduce using rule 57 (single_space) state 2 58 single_space: TOKEN_NEWLINE . $default reduce using rule 58 (single_space) state 3 56 single_space: TOKEN_SPACE . $default reduce using rule 56 (single_space) state 4 0 $accept: file . $end $end shift, and go to state 8 state 5 1 file: opt_space . 2 | opt_space . object_list opt_space TOKEN_ABBREV shift, and go to state 9 TOKEN_AT shift, and go to state 10 TOKEN_COMMA shift, and go to state 11 TOKEN_COMMENT shift, and go to state 12 TOKEN_ENTRY shift, and go to state 13 TOKEN_EQUALS shift, and go to state 14 TOKEN_FIELD shift, and go to state 15 TOKEN_INCLUDE shift, and go to state 16 TOKEN_INLINE shift, and go to state 17 TOKEN_KEY shift, and go to state 18 TOKEN_LBRACE shift, and go to state 19 TOKEN_LITERAL shift, and go to state 20 TOKEN_NEWLINE shift, and go to state 21 TOKEN_PREAMBLE shift, and go to state 22 TOKEN_RBRACE shift, and go to state 23 TOKEN_SHARP shift, and go to state 24 TOKEN_SPACE shift, and go to state 25 TOKEN_STRING shift, and go to state 26 TOKEN_VALUE shift, and go to state 27 TOKEN_UNKNOWN shift, and go to state 28 $default reduce using rule 1 (file) object_list go to state 29 object go to state 30 anything go to state 31 state 6 53 opt_space: space . 55 space: space . single_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 53 (opt_space)] TOKEN_NEWLINE [reduce using rule 53 (opt_space)] TOKEN_SPACE [reduce using rule 53 (opt_space)] $default reduce using rule 53 (opt_space) single_space go to state 32 state 7 54 space: single_space . $default reduce using rule 54 (space) state 8 0 $accept: file $end . $default accept state 9 7 anything: TOKEN_ABBREV . $default reduce using rule 7 (anything) state 10 5 object: TOKEN_AT . opt_space at_object TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 33 space go to state 6 single_space go to state 7 state 11 8 anything: TOKEN_COMMA . $default reduce using rule 8 (anything) state 12 9 anything: TOKEN_COMMENT . $default reduce using rule 9 (anything) state 13 10 anything: TOKEN_ENTRY . $default reduce using rule 10 (anything) state 14 11 anything: TOKEN_EQUALS . $default reduce using rule 11 (anything) state 15 12 anything: TOKEN_FIELD . $default reduce using rule 12 (anything) state 16 13 anything: TOKEN_INCLUDE . $default reduce using rule 13 (anything) state 17 14 anything: TOKEN_INLINE . $default reduce using rule 14 (anything) state 18 15 anything: TOKEN_KEY . $default reduce using rule 15 (anything) state 19 16 anything: TOKEN_LBRACE . $default reduce using rule 16 (anything) state 20 17 anything: TOKEN_LITERAL . $default reduce using rule 17 (anything) state 21 18 anything: TOKEN_NEWLINE . $default reduce using rule 18 (anything) state 22 19 anything: TOKEN_PREAMBLE . $default reduce using rule 19 (anything) state 23 20 anything: TOKEN_RBRACE . $default reduce using rule 20 (anything) state 24 21 anything: TOKEN_SHARP . $default reduce using rule 21 (anything) state 25 22 anything: TOKEN_SPACE . $default reduce using rule 22 (anything) state 26 23 anything: TOKEN_STRING . $default reduce using rule 23 (anything) state 27 24 anything: TOKEN_VALUE . $default reduce using rule 24 (anything) state 28 25 anything: TOKEN_UNKNOWN . $default reduce using rule 25 (anything) state 29 2 file: opt_space object_list . opt_space 4 object_list: object_list . opt_space object TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) opt_space go to state 34 space go to state 6 single_space go to state 7 state 30 3 object_list: object . $default reduce using rule 3 (object_list) state 31 6 object: anything . opt_space object TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) opt_space go to state 35 space go to state 6 single_space go to state 7 state 32 55 space: space single_space . $default reduce using rule 55 (space) state 33 5 object: TOKEN_AT opt_space . at_object error shift, and go to state 36 TOKEN_COMMENT shift, and go to state 37 TOKEN_ENTRY shift, and go to state 38 TOKEN_INCLUDE shift, and go to state 39 TOKEN_PREAMBLE shift, and go to state 40 TOKEN_STRING shift, and go to state 41 at_object go to state 42 comment go to state 43 entry go to state 44 entry_head go to state 45 include go to state 46 preamble go to state 47 string go to state 48 state 34 2 file: opt_space object_list opt_space . 4 object_list: object_list opt_space . object TOKEN_ABBREV shift, and go to state 9 TOKEN_AT shift, and go to state 10 TOKEN_COMMA shift, and go to state 11 TOKEN_COMMENT shift, and go to state 12 TOKEN_ENTRY shift, and go to state 13 TOKEN_EQUALS shift, and go to state 14 TOKEN_FIELD shift, and go to state 15 TOKEN_INCLUDE shift, and go to state 16 TOKEN_INLINE shift, and go to state 17 TOKEN_KEY shift, and go to state 18 TOKEN_LBRACE shift, and go to state 19 TOKEN_LITERAL shift, and go to state 20 TOKEN_NEWLINE shift, and go to state 21 TOKEN_PREAMBLE shift, and go to state 22 TOKEN_RBRACE shift, and go to state 23 TOKEN_SHARP shift, and go to state 24 TOKEN_SPACE shift, and go to state 25 TOKEN_STRING shift, and go to state 26 TOKEN_VALUE shift, and go to state 27 TOKEN_UNKNOWN shift, and go to state 28 $default reduce using rule 2 (file) object go to state 49 anything go to state 31 state 35 6 object: anything opt_space . object TOKEN_ABBREV shift, and go to state 9 TOKEN_AT shift, and go to state 10 TOKEN_COMMA shift, and go to state 11 TOKEN_COMMENT shift, and go to state 12 TOKEN_ENTRY shift, and go to state 13 TOKEN_EQUALS shift, and go to state 14 TOKEN_FIELD shift, and go to state 15 TOKEN_INCLUDE shift, and go to state 16 TOKEN_INLINE shift, and go to state 17 TOKEN_KEY shift, and go to state 18 TOKEN_LBRACE shift, and go to state 19 TOKEN_LITERAL shift, and go to state 20 TOKEN_NEWLINE shift, and go to state 21 TOKEN_PREAMBLE shift, and go to state 22 TOKEN_RBRACE shift, and go to state 23 TOKEN_SHARP shift, and go to state 24 TOKEN_SPACE shift, and go to state 25 TOKEN_STRING shift, and go to state 26 TOKEN_VALUE shift, and go to state 27 TOKEN_UNKNOWN shift, and go to state 28 object go to state 50 anything go to state 31 state 36 31 at_object: error . TOKEN_RBRACE TOKEN_RBRACE shift, and go to state 51 state 37 32 comment: TOKEN_COMMENT . opt_space TOKEN_LITERAL TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 52 space go to state 6 single_space go to state 7 state 38 36 entry_head: TOKEN_ENTRY . opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY . opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 53 space go to state 6 single_space go to state 7 state 39 40 include: TOKEN_INCLUDE . opt_space TOKEN_LITERAL TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 54 space go to state 6 single_space go to state 7 state 40 41 preamble: TOKEN_PREAMBLE . opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 55 space go to state 6 single_space go to state 7 state 41 42 string: TOKEN_STRING . opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 56 space go to state 6 single_space go to state 7 state 42 5 object: TOKEN_AT opt_space at_object . $default reduce using rule 5 (object) state 43 26 at_object: comment . $default reduce using rule 26 (at_object) state 44 27 at_object: entry . $default reduce using rule 27 (at_object) state 45 33 entry: entry_head . assignment_list TOKEN_RBRACE 34 | entry_head . assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE 35 | entry_head . TOKEN_RBRACE TOKEN_ABBREV shift, and go to state 57 TOKEN_FIELD shift, and go to state 58 TOKEN_RBRACE shift, and go to state 59 assignment_list go to state 60 assignment go to state 61 assignment_lhs go to state 62 state 46 28 at_object: include . $default reduce using rule 28 (at_object) state 47 29 at_object: preamble . $default reduce using rule 29 (at_object) state 48 30 at_object: string . $default reduce using rule 30 (at_object) state 49 4 object_list: object_list opt_space object . $default reduce using rule 4 (object_list) state 50 6 object: anything opt_space object . $default reduce using rule 6 (object) state 51 31 at_object: error TOKEN_RBRACE . $default reduce using rule 31 (at_object) state 52 32 comment: TOKEN_COMMENT opt_space . TOKEN_LITERAL TOKEN_LITERAL shift, and go to state 63 state 53 36 entry_head: TOKEN_ENTRY opt_space . TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space . TOKEN_LBRACE opt_space TOKEN_COMMA opt_space TOKEN_LBRACE shift, and go to state 64 state 54 40 include: TOKEN_INCLUDE opt_space . TOKEN_LITERAL TOKEN_LITERAL shift, and go to state 65 state 55 41 preamble: TOKEN_PREAMBLE opt_space . TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE TOKEN_LBRACE shift, and go to state 66 state 56 42 string: TOKEN_STRING opt_space . TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE TOKEN_LBRACE shift, and go to state 67 state 57 51 assignment_lhs: TOKEN_ABBREV . $default reduce using rule 51 (assignment_lhs) state 58 50 assignment_lhs: TOKEN_FIELD . $default reduce using rule 50 (assignment_lhs) state 59 35 entry: entry_head TOKEN_RBRACE . $default reduce using rule 35 (entry) state 60 33 entry: entry_head assignment_list . TOKEN_RBRACE 34 | entry_head assignment_list . TOKEN_COMMA opt_space TOKEN_RBRACE 48 assignment_list: assignment_list . TOKEN_COMMA opt_space assignment TOKEN_COMMA shift, and go to state 68 TOKEN_RBRACE shift, and go to state 69 state 61 47 assignment_list: assignment . $default reduce using rule 47 (assignment_list) state 62 49 assignment: assignment_lhs . opt_space TOKEN_EQUALS opt_space value opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 70 space go to state 6 single_space go to state 7 state 63 32 comment: TOKEN_COMMENT opt_space TOKEN_LITERAL . $default reduce using rule 32 (comment) state 64 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE . opt_space key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space TOKEN_LBRACE . opt_space TOKEN_COMMA opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 71 space go to state 6 single_space go to state 7 state 65 40 include: TOKEN_INCLUDE opt_space TOKEN_LITERAL . $default reduce using rule 40 (include) state 66 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE . opt_space value opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 72 space go to state 6 single_space go to state 7 state 67 42 string: TOKEN_STRING opt_space TOKEN_LBRACE . opt_space assignment opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 73 space go to state 6 single_space go to state 7 state 68 34 entry: entry_head assignment_list TOKEN_COMMA . opt_space TOKEN_RBRACE 48 assignment_list: assignment_list TOKEN_COMMA . opt_space assignment TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 74 space go to state 6 single_space go to state 7 state 69 33 entry: entry_head assignment_list TOKEN_RBRACE . $default reduce using rule 33 (entry) state 70 49 assignment: assignment_lhs opt_space . TOKEN_EQUALS opt_space value opt_space TOKEN_EQUALS shift, and go to state 75 state 71 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space . key_name opt_space TOKEN_COMMA opt_space 37 | TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space . TOKEN_COMMA opt_space TOKEN_ABBREV shift, and go to state 76 TOKEN_COMMA shift, and go to state 77 TOKEN_KEY shift, and go to state 78 key_name go to state 79 state 72 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space . value opt_space TOKEN_RBRACE TOKEN_ABBREV shift, and go to state 80 TOKEN_VALUE shift, and go to state 81 value go to state 82 simple_value go to state 83 state 73 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space . assignment opt_space TOKEN_RBRACE TOKEN_ABBREV shift, and go to state 57 TOKEN_FIELD shift, and go to state 58 assignment go to state 84 assignment_lhs go to state 62 state 74 34 entry: entry_head assignment_list TOKEN_COMMA opt_space . TOKEN_RBRACE 48 assignment_list: assignment_list TOKEN_COMMA opt_space . assignment TOKEN_ABBREV shift, and go to state 57 TOKEN_FIELD shift, and go to state 58 TOKEN_RBRACE shift, and go to state 85 assignment go to state 86 assignment_lhs go to state 62 state 75 49 assignment: assignment_lhs opt_space TOKEN_EQUALS . opt_space value opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 87 space go to state 6 single_space go to state 7 state 76 39 key_name: TOKEN_ABBREV . $default reduce using rule 39 (key_name) state 77 37 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA . opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 88 space go to state 6 single_space go to state 7 state 78 38 key_name: TOKEN_KEY . $default reduce using rule 38 (key_name) state 79 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name . opt_space TOKEN_COMMA opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 89 space go to state 6 single_space go to state 7 state 80 46 simple_value: TOKEN_ABBREV . $default reduce using rule 46 (simple_value) state 81 45 simple_value: TOKEN_VALUE . $default reduce using rule 45 (simple_value) state 82 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value . opt_space TOKEN_RBRACE 44 value: value . opt_space TOKEN_SHARP opt_space simple_value TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 90 space go to state 6 single_space go to state 7 state 83 43 value: simple_value . $default reduce using rule 43 (value) state 84 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment . opt_space TOKEN_RBRACE TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 91 space go to state 6 single_space go to state 7 state 85 34 entry: entry_head assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE . $default reduce using rule 34 (entry) state 86 48 assignment_list: assignment_list TOKEN_COMMA opt_space assignment . $default reduce using rule 48 (assignment_list) state 87 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space . value opt_space TOKEN_ABBREV shift, and go to state 80 TOKEN_VALUE shift, and go to state 81 value go to state 92 simple_value go to state 83 state 88 37 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space . $default reduce using rule 37 (entry_head) state 89 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space . TOKEN_COMMA opt_space TOKEN_COMMA shift, and go to state 93 state 90 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space . TOKEN_RBRACE 44 value: value opt_space . TOKEN_SHARP opt_space simple_value TOKEN_RBRACE shift, and go to state 94 TOKEN_SHARP shift, and go to state 95 state 91 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space . TOKEN_RBRACE TOKEN_RBRACE shift, and go to state 96 state 92 44 value: value . opt_space TOKEN_SHARP opt_space simple_value 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value . opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 TOKEN_INLINE [reduce using rule 52 (opt_space)] TOKEN_NEWLINE [reduce using rule 52 (opt_space)] TOKEN_SPACE [reduce using rule 52 (opt_space)] $default reduce using rule 52 (opt_space) opt_space go to state 97 space go to state 6 single_space go to state 7 state 93 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA . opt_space TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 98 space go to state 6 single_space go to state 7 state 94 41 preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE . $default reduce using rule 41 (preamble) state 95 44 value: value opt_space TOKEN_SHARP . opt_space simple_value TOKEN_INLINE shift, and go to state 1 TOKEN_NEWLINE shift, and go to state 2 TOKEN_SPACE shift, and go to state 3 $default reduce using rule 52 (opt_space) opt_space go to state 99 space go to state 6 single_space go to state 7 state 96 42 string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE . $default reduce using rule 42 (string) state 97 44 value: value opt_space . TOKEN_SHARP opt_space simple_value 49 assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value opt_space . TOKEN_SHARP shift, and go to state 95 $default reduce using rule 49 (assignment) state 98 36 entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space . $default reduce using rule 36 (entry_head) state 99 44 value: value opt_space TOKEN_SHARP opt_space . simple_value TOKEN_ABBREV shift, and go to state 80 TOKEN_VALUE shift, and go to state 81 simple_value go to state 100 state 100 44 value: value opt_space TOKEN_SHARP opt_space simple_value . $default reduce using rule 44 (value) bibtex/inst/grammar/0000755000176000001440000000000013731452745014175 5ustar ripleyusersbibtex/inst/grammar/biblex.l0000755000176000001440000002666013125412260015615 0ustar ripleyusers%option nodefault %{ /* {{{ Declarations */ #include #include #ifdef stdout # undef stdout #endif #define stdout 0 // enable some debugging with this: // #define LEXER_DEBUG 1 #define YYSTYPE SEXP #include #include #include #include typedef int token_t ; static void compact_space(); static void eof_error(); static int next_char(); static token_t out_braced_literal(); static token_t out_braced_string(); static token_t out_lbrace(); static token_t out_lparen(); static token_t out_protected_string(token_t t); static token_t out_rbrace(); static token_t out_rparen(); static token_t out_string(); static token_t out_token(token_t t_); static void overflow( const char* ); static int brace_level = 0; int do_lex_output = 0; static token_t last_object = TOKEN_UNKNOWN; static token_t last_token = TOKEN_UNKNOWN; static int paren_level = 0; #define BYTE_VAL(c) ((unsigned int)((c) & 0xff)) #define EOFILE 0 #define ISPRINT(c) isprint(BYTE_VAL(c)) #define ISDIGIT(c) isdigit(BYTE_VAL(c)) #define ISSPACE(c) isspace(BYTE_VAL(c)) #define RETURN(n) return (n) #undef YYLMAX #if defined(HAVE_IBMPC) #define YYLMAX 32760 #else #define YYLMAX BIBYYLMAX #endif #define YY_USER_ACTION do { \ start_line_number = line_number ; \ start_col_number = col_number ; \ start_byte_number = byte_number ; \ } while( 0 ) ; /* }}} */ /* {{{ Lexer grammar */ %} /* increase transition and output table sizes */ %a 3000 %o 6000 /* abbrev, entry, key, field name syntax */ N [-A-Za-z0-9:.+/'_?]* /* BibTeX entry opening delimiter */ O [({] /* one white space character */ /* \013 == \v, but lex doesn't */ /* recognize \v */ W [ \f\r\t\013] /* optional `horizontal' space */ S {W}* %% [@] RETURN (out_token(TOKEN_AT)); [Cc][Oo][Mm][Mm][Ee][Nn][Tt] {RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_COMMENT) : out_token(TOKEN_ABBREV)); } [Ii][Nn][Cc][Ll][Uu][Dd][Ee] {RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_INCLUDE) : out_token(TOKEN_ABBREV)); } [Pp][Rr][Ee][Aa][Mm][Bb][Ll][Ee] { RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_PREAMBLE) : out_token(TOKEN_ABBREV)); } [Ss][Tt][Rr][Ii][Nn][Gg] { RETURN ((last_token == TOKEN_AT) ? out_token(TOKEN_STRING) : out_token(TOKEN_ABBREV)); } {N} { if (last_object == TOKEN_STRING) RETURN(out_token(TOKEN_ABBREV)); switch (last_token) { case TOKEN_COMMA: RETURN(out_token(TOKEN_FIELD)); case TOKEN_LBRACE: RETURN(out_token(TOKEN_KEY)); case TOKEN_AT: RETURN(out_token(TOKEN_ENTRY)); default: RETURN(out_token(TOKEN_ABBREV)); } } [0-9]+ RETURN (out_token(TOKEN_VALUE)); [%].*[\n]{S} RETURN (out_token(TOKEN_INLINE)); [#] RETURN (out_token(TOKEN_SHARP)); ["] RETURN (out_string()); [{] RETURN (out_lbrace()); [}] RETURN (out_rbrace()); [(] RETURN (out_lparen()); [)] RETURN (out_rparen()); [=] RETURN (out_token(TOKEN_EQUALS)); [,] RETURN (out_token(TOKEN_COMMA)); [\n] RETURN (out_token(TOKEN_NEWLINE)); {W}+ RETURN (out_token(TOKEN_SPACE)); . RETURN (out_token(TOKEN_LITERAL)); %% /*}}} */ /*{{{ compact_space */ /** * compact runs of space to single blank */ static void compact_space(){ char *p; char *q; for (p = q = (char*)&yytext[0]; *p ; ) { *q++ = ISSPACE(*p) ? ' ' : *p; if (ISSPACE(*p)){ while (ISSPACE(*p)) ++p; } else{ ++p; } } *q = '\0'; } /*}}}*/ /* {{{ next_char */ /** * Gets the next character from the stream */ static int next_char() { int c; c = input(); if ( c == R_EOF ){ eof_error(); } else if (c == '\n'){ line_number++; col_number = 0; byte_number = 0; } else { col_number++; byte_number++; /* only advance column for 1st byte in UTF-8 */ if (0x80 <= (unsigned char)c && (unsigned char)c <= 0xBF && known_to_be_utf8){ col_number--; } if( c == '\t' ) { col_number = ((col_number + 7) & ~7); } } return (c); } /*}}}*/ /* {{{ out_ functions */ static token_t out_braced_literal(){ int c; int n; int plevel = paren_level; for (n = 1; brace_level > 0; ) { c = next_char(); if (c == EOF){ break; } if (n > (YYLMAX - 2)){ overflow( "out_braced_literal" ); } yytext[n++] = c; switch (c){ case '(': plevel++; break; case ')': plevel--; break; case '{': brace_level++; break; case '}': brace_level--; break; default: break; } if ((paren_level > 0) && (plevel == 0)){ break; } } yytext[0] = '{'; yytext[n-1] = '}'; yytext[n] = '\0'; return (out_token(TOKEN_LITERAL)); } /* convert braced to quoted string */ static token_t out_braced_string() { #ifdef LEXER_DEBUG Rprintf( " \n" ) ; #endif int blevel; int c; int n; for (blevel = 1, n = 1; (blevel > 0); ){ c = next_char(); if (c == EOF){ break; } if (n > (YYLMAX - 5)){ overflow("out_braced_string"); } yytext[n++] = c; switch (c){ case '\\': { c = next_char() ; if( c == '"' ){ #ifdef LEXER_DEBUG Rprintf( "seeing bs and quote : %s\n", yytext ) ; #endif yytext[n++] = '"' ; } else if( c == '&' ) { #ifdef LEXER_DEBUG Rprintf( "seeing bs and ampersand : %s\n", yytext ) ; #endif yytext[n++] = '&' ; } else { yytext[n++] = c ; } break ; } case '{': blevel++; break; case '}': blevel--; break; case '"': { if (blevel == 1){ if (yytext[n-2] == '\\') { c = next_char(); if (c == EOF){ break; } yytext[n-2] = '{'; yytext[n-1] = '\\'; yytext[n++] = '"'; yytext[n++] = c; yytext[n++] = '}'; } else { yytext[n-1] = '{'; yytext[n++] = '"'; yytext[n++] = '}'; } } break; } default: break; } } yytext[0] = '"'; yytext[n-1] = '"'; yytext[n] = '\0'; #ifdef LEXER_DEBUG Rprintf( "[out_braced_string] yytext = ///%s///\n", yytext ) ; #endif return (out_token(TOKEN_VALUE)); } static token_t out_lbrace(){ if (brace_level == 0){ brace_level++; switch (last_object) { case TOKEN_COMMENT: case TOKEN_INCLUDE: return (out_braced_literal()); default: return (out_token(TOKEN_LBRACE)); } } else { return (out_braced_string()); } } static token_t out_lparen(){ switch (last_token) { case TOKEN_ENTRY: case TOKEN_PREAMBLE: case TOKEN_STRING: yytext[0] = '{'; paren_level++; brace_level++; return (out_token(TOKEN_LBRACE)); case TOKEN_COMMENT: case TOKEN_INCLUDE: yytext[0] = '{'; paren_level++; brace_level++; return (out_braced_literal()); default: return (out_token(TOKEN_LITERAL)); } } static token_t out_protected_string(token_t t){ char octal[4 + 1]; const char *token = (const char*)&yytext[0]; if (*token == (char)'\0') /* ignore empty tokens */ return (TOKEN_VALUE); output('"'); /* supply missing quote delimiters */ if ((yytext[0] != '"') && (t == TOKEN_VALUE)){ output('\\'); output('\"'); } for (; *token; ++token){ switch (*token) { case '"': case '\\': output('\\'); output(*token); break; case '\b': output('\\'); output('b'); break; case '\f': output('\\'); output('f'); break; case '\n': output('\\'); output('n'); break; case '\r': output('\\'); output('r'); break; case '\t': output('\\'); output('t'); break; case '\v': output('\\'); output('v'); break; default: if (ISPRINT(*token)){ output(*token); } else { (void)sprintf(octal,"\\%03o",BYTE_VAL(*token)); output(octal[0]); output(octal[1]); output(octal[2]); output(octal[3]); } break; } } /* supply missing quote delimiters */ if ((yytext[0] != '"') && (t == TOKEN_VALUE)){ output('\\'); output('\"'); } output('"'); output('\n'); return (TOKEN_VALUE); } static token_t out_rbrace() { if (brace_level == 1) { brace_level--; return (out_token(TOKEN_RBRACE)); } else{ return (out_token(TOKEN_LITERAL)); } } static token_t out_rparen(){ paren_level--; if (paren_level == 0){ yytext[0] = '}'; brace_level--; return (out_token(TOKEN_RBRACE)); } else { return (out_token(TOKEN_LITERAL)); } } static token_t out_string(){ int blevel; int c; int n; for (blevel = 0, n = 1; ; ) { c = next_char(); if (c == EOF){ break; } if (n > (YYLMAX - 2)){ overflow("out_string"); } yytext[n++] = c; switch (c){ case '{': blevel++; break; case '}': blevel--; break; case '"': if (blevel == 0){ goto LOOP_EXIT; } default: break; } } LOOP_EXIT: yytext[n++] = '\0'; #ifdef LEXER_DEBUG Rprintf( "[out_string] yytext = ///%s///\n", yytext ) ; #endif return (out_token(TOKEN_VALUE)); } /* ALL token output is directed through this function */ static token_t out_token(token_t t){ int n; if (do_lex_output){ Rprintf("%d\t", (int)t); } switch (t) { case TOKEN_AT: last_object = TOKEN_UNKNOWN; if (do_lex_output) Rprintf("\"%s\"\n", yytext); break; case TOKEN_VALUE: if (do_lex_output){ /* supply surrounding quotes */ if (ISDIGIT(yytext[0])) { n = strlen((const char*)&yytext[0]); if ((n + 3) > YYLMAX){ overflow("out_token"); } yytext[n+2] = '\0'; yytext[n+1] = '"'; for (; n > 0; --n){ yytext[n] = yytext[n-1]; } } else compact_space(); out_protected_string(t); } break; case TOKEN_COMMENT: case TOKEN_INCLUDE: if (do_lex_output){ out_protected_string(t); } last_object = t; break; case TOKEN_ENTRY: case TOKEN_PREAMBLE: case TOKEN_STRING: if (do_lex_output){ Rprintf("\"%s\"\n", yytext); } last_object = t; break; case TOKEN_FIELD: case TOKEN_KEY: if (do_lex_output){ Rprintf("\"%s\"\n", yytext); } break; case TOKEN_INLINE: case TOKEN_NEWLINE: line_number++; col_number = 0; byte_number = 0; if (do_lex_output) { out_protected_string(t); } break; case TOKEN_LITERAL: default: if (do_lex_output){ out_protected_string(t); } break; } if (!((t == TOKEN_INLINE) || (t == TOKEN_SPACE) || (t == TOKEN_NEWLINE))) last_token = t; /* remember last non-space token type */ const char * token = (const char*)&yytext[0] ; if( t == TOKEN_AT ){ last_at_location.first_line = start_line_number ; last_at_location.first_column = start_col_number ; last_at_location.first_byte = start_byte_number ; } setToken( token, strlen(token) ); return (t); } /* }}} */ int yywrap() { return 1; } static void overflow(const char* from){ #ifdef LEXER_DEBUG Rprintf( "[overflow/%s] yytext = ///%s///\n", from, yytext ) ; #endif error("String too long for %ld-character buffer\n", YYLMAX); } static void eof_error(){ error( "End-of-file in value string\n" ); } /* never called, but calms down -Wall */ void dummy(){ yyunput( 0, 0 ) ; yy_flex_strlen(0) ; } /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ bibtex/inst/grammar/bibparse.y0000755000176000001440000007125613730051100016147 0ustar ripleyusers%{ /*{{{ first part of declarations */ #include char yytext[BIBYYLMAX]; // #define YYDEBUG 1 /* need for -d option support */ #define YYERROR_VERBOSE 1 /* better warning messages */ #define YYSTYPE SEXP /* semantic values */ #define streql(s, t) (!strcmp((s), (t))) /** * Aliases to R standard PROTECT macro, in case we want to do * something else as well */ #define _PROTECT_WITH_INDEX(s,index) { PROTECT_WITH_INDEX(s,index); } #define _PROTECT(s) { PROTECT(s); } #define _UNPROTECT(n) { UNPROTECT(n); } #define _UNPROTECT_PTR(s) { UNPROTECT_PTR(s); } #define _REPROTECT(s,index) REPROTECT(s,index) /** * Set to 1 when a syntax error was seen to indicate that * tokens supplied by the lexer should not be wrapped into SEXP */ static int recovering ; /** * Set to 1 after a syntax error was seen, and before the * recovering process has started */ static int popping ; /** * used in the popping mechanism, the error message is compared to this * and the popping stops if anything else happens */ const char* error_msg_popping = "Error: popping"; /** * The keyname of the current entry (used in warning messages) */ static char* currentKey = 0 ; /** * the line number where the current entry starts (used in warning messages) */ int currentKeyLine ; static SEXP srcfile; char * bibfile ; /** * this is defined as a macro, so that it has access to yylval to be able * to unprotect it. * * the macro sets the "popping" to 1 to indicate that symbols being * destructed should be UNPROTECT'ed as well, and calls the _yyerror * function which sends an R warning with the problem */ #define yyerror(s) \ do { \ _UNPROTECT_PTR( yylval ) ; \ popping = 1; \ _yyerror(s); \ } \ while(0) ; extern YYLTYPE yylloc ; # define YYLLOC_DEFAULT(Current, Rhs, N) \ do { \ if (YYID (N)){ \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).first_byte = YYRHSLOC (Rhs, 1).first_byte; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ (Current).last_byte = YYRHSLOC (Rhs, N).last_byte; \ } else { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ (Current).first_byte = (Current).last_byte = \ YYRHSLOC (Rhs, 0).last_byte; \ } \ } while (YYID (0)) // #define XXDEBUG 1 /* functions used in the parsing process */ SEXP makeSrcRef(YYLTYPE) ; static SEXP xx_object_list_1(SEXP); static SEXP xx_object_list_2(SEXP,SEXP); static SEXP xx_object(SEXP); static SEXP xx_atobject_comment(SEXP); static SEXP xx_atobject_entry(SEXP, YYLTYPE); static SEXP xx_atobject_include(SEXP); static SEXP xx_atobject_preamble(SEXP); static SEXP xx_atobject_string(SEXP); static SEXP xx_token_entry( SEXP, SEXP); static SEXP xx_token_entry_empty(SEXP) ; static SEXP xx_entry_head( SEXP, SEXP) ; static SEXP xx_entry_head_nokey( SEXP ) ; static SEXP xx_keyname_key( SEXP) ; static SEXP xx_keyname_abbrev( SEXP) ; static SEXP xx_include( SEXP ) ; static SEXP xx_preamble(SEXP) ; static SEXP xx_string(SEXP) ; static SEXP xx_value( SEXP, SEXP) ; static SEXP xx_assignement_list1(SEXP); static SEXP xx_assignement_list2(SEXP, SEXP); static SEXP xx_assignement(SEXP, SEXP); static SEXP xx_lhs_field( SEXP ) ; static SEXP xx_lhs_abbrev( SEXP ); static SEXP xx_space( SEXP ); static SEXP xx_space_inline( SEXP ) ; static SEXP xx_space_newline( SEXP ) ; static SEXP xx_forward( SEXP ) ; static SEXP xx_null( ) ; static SEXP xx_expand_abbrev( SEXP ) ; static SEXP xx_simple_value( SEXP ) ; /* functions to unprotect one or more SEXP */ void junk1( SEXP); void junk2( SEXP, SEXP); void junk3( SEXP, SEXP, SEXP); void junk4( SEXP, SEXP, SEXP, SEXP); void junk5( SEXP, SEXP, SEXP, SEXP, SEXP); void junk6( SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); void junk7( SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); static PROTECT_INDEX INCLUDE_INDEX ; static PROTECT_INDEX COMMENT_INDEX ; static PROTECT_INDEX STRING_INDEX ; static PROTECT_INDEX PREAMBLE_INDEX ; static PROTECT_INDEX ENTRIES_INDEX ; static SEXP includes; static SEXP comments; static SEXP strings; static SEXP preamble; static SEXP entries; static void recordInclude( SEXP ) ; static void recordComment( SEXP ) ; static void recordString( SEXP ) ; static void recordPreamble( SEXP ) ; static SEXP asVector( SEXP, int ); /*}}}*/ /*{{{ Grammar */ %} %token TOKEN_ABBREV %token TOKEN_AT %token TOKEN_COMMA %token TOKEN_COMMENT %token TOKEN_ENTRY %token TOKEN_EQUALS %token TOKEN_FIELD %token TOKEN_INCLUDE %token TOKEN_INLINE %token TOKEN_KEY %token TOKEN_LBRACE %token TOKEN_LITERAL %token TOKEN_NEWLINE %token TOKEN_PREAMBLE %token TOKEN_RBRACE %token TOKEN_SHARP %token TOKEN_SPACE %token TOKEN_STRING %token TOKEN_VALUE %token TOKEN_UNKNOWN %nonassoc TOKEN_EQUALS %left TOKEN_SPACE TOKEN_INLINE TOKEN_NEWLINE %left TOKEN_SHARP %destructor { /* this handles UNPROTECTING SEXP that are popped when a syntax error is detected. When a syntax error is detected, the following happens : - yyerror is called which sets recovering and popping to 1 - some symbols are "popped" from the semantic value stack using this destructor, this is: as many symbols as it takes to be back to this rule: | error TOKEN_RBRACE then "popping" is set to 0 so that no more symbols are UNPROTECTED then, the lexer provides as many tokens as necessary to present the TOKEN_RBRACE token, however tokens are not converted to SEXP because recovering is 1 finally, when TOKEN_RBRACE is seen, recovering is set to 0 to indicate that tokens should now be converted to SEXP again The issue is that all symbols (terminals and non terminals have to be listed in this destructor. (There probably is a better way) */ if( popping ){ if( streql( error_msg_popping, yymsg ) ){ UNPROTECT_PTR( $$ ) ; } else{ popping = 0; } } } opt_space space single_space assignment assignment_list assignment_lhs value simple_value include preamble entry entry_head string key_name comment TOKEN_ABBREV TOKEN_AT TOKEN_COMMA TOKEN_COMMENT TOKEN_ENTRY TOKEN_EQUALS TOKEN_FIELD TOKEN_INCLUDE TOKEN_INLINE TOKEN_KEY TOKEN_LBRACE TOKEN_LITERAL TOKEN_NEWLINE TOKEN_PREAMBLE TOKEN_RBRACE TOKEN_SHARP TOKEN_SPACE TOKEN_STRING TOKEN_VALUE TOKEN_UNKNOWN %% file: opt_space { junk1($1); YYACCEPT ; } | opt_space object_list opt_space { junk3($1, $2, $3) ; YYACCEPT ; } ; object_list: object { $$ = xx_object_list_1($1); } | object_list opt_space object { $$ = xx_object_list_2($1,$3); junk1($2) ; } ; object: TOKEN_AT opt_space at_object { $$ = xx_object($3); junk2($1,$2); } | anything opt_space object { /* this eats whatever is between two entries, lexing until a TOKEN_AT is found */ $$ = xx_forward($3); junk2($1,$2) ; } ; anything: TOKEN_ABBREV { $$ = xx_forward( $1) ; } | TOKEN_COMMA { $$ = xx_forward( $1) ; } | TOKEN_COMMENT { $$ = xx_forward( $1) ; } | TOKEN_ENTRY { $$ = xx_forward( $1) ; } | TOKEN_EQUALS { $$ = xx_forward( $1) ; } | TOKEN_FIELD { $$ = xx_forward( $1) ; } | TOKEN_INCLUDE { $$ = xx_forward( $1) ; } | TOKEN_INLINE { $$ = xx_forward( $1) ; } | TOKEN_KEY { $$ = xx_forward( $1) ; } | TOKEN_LBRACE { $$ = xx_forward( $1) ; } | TOKEN_LITERAL { $$ = xx_forward( $1) ; } | TOKEN_NEWLINE { $$ = xx_forward( $1) ; } | TOKEN_PREAMBLE { $$ = xx_forward( $1) ; } | TOKEN_RBRACE { $$ = xx_forward( $1) ; } | TOKEN_SHARP { $$ = xx_forward( $1) ; } | TOKEN_SPACE { $$ = xx_forward( $1) ; } | TOKEN_STRING { $$ = xx_forward( $1) ; } | TOKEN_VALUE { $$ = xx_forward( $1) ; } | TOKEN_UNKNOWN { $$ = xx_forward( $1) ; } at_object: comment { $$ = xx_atobject_comment($1); } | entry { $$ = xx_atobject_entry($1, @$);} | include { $$ = xx_atobject_include($1);} | preamble { $$ = xx_atobject_preamble($1);} | string { $$ = xx_atobject_string($1);} | error TOKEN_RBRACE { $$ = xx_null() ; YYUSE($2) ; recovering = 0; } ; comment: TOKEN_COMMENT opt_space TOKEN_LITERAL {junk2($1,$2); $$ = xx_forward($3); } ; entry: entry_head assignment_list TOKEN_RBRACE { $$ = xx_token_entry( $1, $2); junk1($3); } | entry_head assignment_list TOKEN_COMMA opt_space TOKEN_RBRACE { $$ = xx_token_entry( $1, $2); junk3($3,$4,$5); } | entry_head TOKEN_RBRACE { $$ = xx_token_entry_empty($1) ; junk1($2) ; } ; entry_head: TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space key_name opt_space TOKEN_COMMA opt_space { $$ = xx_entry_head( $1, $5) ; junk6($2,$3,$4,$6,$7,$8) ; } | TOKEN_ENTRY opt_space TOKEN_LBRACE opt_space TOKEN_COMMA opt_space { $$ = xx_entry_head_nokey( $1) ; junk5($2,$3,$4,$5,$6) ; } ; key_name: TOKEN_KEY { $$ = xx_keyname_key( $1) ;} | TOKEN_ABBREV { $$ = xx_keyname_abbrev( $1) ; } ; include: TOKEN_INCLUDE opt_space TOKEN_LITERAL { $$ = xx_include( $3 ) ; junk2($1,$2) ; } ; preamble: TOKEN_PREAMBLE opt_space TOKEN_LBRACE opt_space value opt_space TOKEN_RBRACE { $$ = xx_preamble($5) ; junk6($1,$2,$3,$4,$6,$7) ; } ; string: TOKEN_STRING opt_space TOKEN_LBRACE opt_space assignment opt_space TOKEN_RBRACE { $$ = xx_string($5) ; junk6( $1, $2, $3, $4, $6, $7) ; } ; value: simple_value {$$ = xx_forward($1) ; } | value opt_space TOKEN_SHARP opt_space simple_value { $$ = xx_value( $1, $5) ; junk3( $2, $3, $4); } ; simple_value: TOKEN_VALUE { $$ = xx_simple_value($1); } | TOKEN_ABBREV { $$ = xx_expand_abbrev($1); } ; assignment_list: assignment { $$ = xx_assignement_list1($1); } | assignment_list TOKEN_COMMA opt_space assignment { $$ = xx_assignement_list2($1, $4); junk2($2,$3); } ; assignment: assignment_lhs opt_space TOKEN_EQUALS opt_space value opt_space { $$ = xx_assignement($1, $5); junk4($2, $3, $4, $6); } ; assignment_lhs: TOKEN_FIELD { $$ = xx_lhs_field( $1 ) ; } | TOKEN_ABBREV { $$ = xx_lhs_abbrev( $1 ); } ; opt_space: { $$ = xx_null() ; } | space { $$ = xx_forward($1) ;} ; space: single_space { $$ = xx_forward($1) ;} | space single_space { $$ = xx_forward($1); junk1($2) ; } ; single_space: TOKEN_SPACE { $$ = xx_space( $1 ) ; } | TOKEN_INLINE { $$ = xx_space_inline( $1 ) ; } | TOKEN_NEWLINE { $$ = xx_space_newline( $1 ) ; } ; %% /*}}} end of grammar */ /*{{{ functions borrowed from gram.y */ #ifdef Win32 static char * fixmode(const char *mode){ /* Rconnection can have a mode of 4 chars plus a null; we might * add one char */ static char fixedmode[6]; fixedmode[4] = '\0'; strncpy(fixedmode, mode, 4); if (!strpbrk(fixedmode, "bt")) { strcat(fixedmode, "t"); } return fixedmode; } #else #define fixmode(mode) (mode) #endif FILE * _fopen(const char *filename, const char *mode){ return(filename ? fopen(filename, fixmode(mode)) : NULL ); } /*}}}*/ /*{{{ yyerror */ void _yyerror(const char *s){ warning( "\n%s:%d:%d\n\t%s\n\tDropping the entry `%s` (starting at line %d) ", bibfile, line_number, col_number, s, currentKey, currentKeyLine ) ; /* indicates that we are recovering from an error */ recovering = 1 ; } /*}}}*/ /*{{{ yywarning */ static void yywarning(const char *s){ warning( "\n%s:%d:%d\n\t%s", bibfile, line_number, col_number, s ) ; } /*}}}*/ /*{{{ R interface */ /** * .Internal( "do_read_bib", file = file ) */ SEXP do_read_bib(SEXP args) { SEXP filename = CADR(args) ; const char* fname = CHAR(STRING_ELT(filename,0) ) ; bibfile = (char*)fname ; const char* encoding = CHAR(STRING_ELT( CADDR(args), 0 ) ); known_to_be_latin1 = known_to_be_utf8 = FALSE; if(streql(encoding, "latin1")) { known_to_be_latin1 = TRUE; } else if(streql(encoding, "UTF-8")) { known_to_be_utf8 = TRUE; } else if(!streql( encoding, "unknown") ){ warning( "encoding '%s' will be ignored", encoding ) ; } srcfile = CADDDR(args); FILE* fp ; if((fp = _fopen(R_ExpandFileName( fname ), "r")) == NULL){ error( "unable to open file to read", 0); } yyset_in( fp ) ; /* so that the lexer reads from the file */ #if YYDEBUG yydebug = 0 ; /* setting this to 1 gives a lot of messages */ #endif popping = 0; line_number = 1; col_number = 0; byte_number = 0; /* set up the data */ _PROTECT_WITH_INDEX( includes = NewList() , &INCLUDE_INDEX ) ; _PROTECT_WITH_INDEX( comments = NewList() , &COMMENT_INDEX ) ; _PROTECT_WITH_INDEX( strings = NewList() , &STRING_INDEX ) ; _PROTECT_WITH_INDEX( preamble = NewList() , &PREAMBLE_INDEX ) ; _PROTECT_WITH_INDEX( entries = NewList() , &ENTRIES_INDEX ) ; /* call the parser */ recovering = 0; /* int res = yyparse() ; */ yyparse() ; /* structure the data */ SEXP ans; if( isNull( CDR(entries) ) ){ PROTECT( ans = allocVector( VECSXP, 0) ) ; } else { PROTECT( ans = CDR(entries) ) ; } SEXP obj ; _PROTECT(obj = asVector( comments, 0 ) ); setAttrib( ans , install("comment") , obj ); _UNPROTECT_PTR( obj ) ; _PROTECT(obj = asVector( includes, 0 ) ); setAttrib( ans , install("include") , obj ); _UNPROTECT_PTR( obj ) ; _PROTECT(obj = asVector( strings , 1 ) ); setAttrib( ans , install("strings") , obj ); _UNPROTECT_PTR( obj ) ; _PROTECT(obj = asVector( preamble, 0 ) ); setAttrib( ans , install("preamble"), obj ); _UNPROTECT_PTR( obj ) ; _UNPROTECT_PTR( entries ) ; _UNPROTECT_PTR( ans ); fclose(fp); return ans ; } /*}}}*/ /*{{{ xx_* parser helpers */ /** * Object list with one object * * @param object the object */ static SEXP xx_object_list_1(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans, tmp ; _PROTECT( tmp = NewList() ) ; if( object == R_NilValue) { _PROTECT( ans = tmp ) ; } else{ _PROTECT( ans = GrowList( tmp, object) ) ; } _UNPROTECT_PTR( tmp) ; _UNPROTECT_PTR( object) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Adds an object to an object list * * @param */ static SEXP xx_object_list_2(SEXP list, SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; if( object == R_NilValue ){ _PROTECT( ans = list ); } else{ _PROTECT( ans = GrowList( list, object ) ); } _UNPROTECT_PTR( object ) ; _UNPROTECT_PTR( list ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * recognizes an object, adds it to the list of entries * * @param object object */ static SEXP xx_object(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = object ) ; _UNPROTECT_PTR( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Comment object * * @param object */ static SEXP xx_atobject_comment(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = R_NilValue ) ; recordComment( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Entry object * * @param object the entry object */ static SEXP xx_atobject_entry(SEXP object, YYLTYPE loc){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans, head, o, names; _PROTECT( head = getAttrib( object, install("head") ) ); int n = length( object ) ; _PROTECT( ans = allocVector( STRSXP, n) ) ; _PROTECT( names = allocVector( STRSXP, n) ) ; _PROTECT( o = object ) ; int i; for( i=0; i\n" ) ; #endif _UNPROTECT_PTR( ans ) ; _PROTECT( ans = R_NilValue ); return ans ; } /** * Include object * * @param object the include object */ static SEXP xx_atobject_include(SEXP object ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = R_NilValue ) ; recordInclude( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * A preamble object */ static SEXP xx_atobject_preamble(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = R_NilValue ) ; recordPreamble( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * string object */ static SEXP xx_atobject_string(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = R_NilValue ) ; recordString( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * actual entry object * * @param head the entry head * @param list the assignement list */ static SEXP xx_token_entry( SEXP head, SEXP list){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP data ; _PROTECT( data = CDR(list) ) ; setAttrib( data, install("head"), head) ; _UNPROTECT_PTR( list ) ; _UNPROTECT_PTR( head ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return data; } /** * actual entry object with no assignements * * @param head */ static SEXP xx_token_entry_empty(SEXP head){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = R_NilValue ) ; setAttrib( ans, install("head"), head) ; _UNPROTECT_PTR( head ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /** * entry head * * @param kind kind of entry * @param keyname the name of the entry */ static SEXP xx_entry_head( SEXP kind, SEXP keyname ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = allocVector( STRSXP, 2) ) ; SET_STRING_ELT( ans, 0, STRING_ELT(keyname, 0) ) ; SET_STRING_ELT( ans, 1, STRING_ELT(kind, 0) ) ; _UNPROTECT_PTR(kind) ; _UNPROTECT_PTR(keyname) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * entry head * * @param kind kind of entry */ static SEXP xx_entry_head_nokey( SEXP kind){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = allocVector( STRSXP, 2) ) ; SET_STRING_ELT( ans, 0, NA_STRING ) ; SET_STRING_ELT( ans, 1, STRING_ELT(kind, 0) ) ; _UNPROTECT_PTR(kind) ; warning( "\n%s:%d:%d\n\tno key for the entry at line %d", bibfile, line_number, col_number, currentKeyLine ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * sets the currentKey as the first element of the 'key' parameter * and returns currentKey */ char* set_current_key( SEXP key ){ // free currentKey if needed if( currentKey ) free( currentKey ) ; // grab the first element of key currentKey = ( length( key ) > 0 ) ? strdup( CHAR( STRING_ELT(key,0) ) ) : 0 ; return currentKey ; } /** * name of an entry * * @param key keyname */ static SEXP xx_keyname_key( SEXP key){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif currentKey = set_current_key( key ) ; currentKeyLine = line_number ; return key; } /** * name of an entry */ static SEXP xx_keyname_abbrev( SEXP abbrev){ SEXP res = xx_expand_abbrev( abbrev ) ; currentKey = set_current_key( abbrev ) ; currentKeyLine = line_number ; return res; } /** * "include" object * * @param object */ static SEXP xx_include( SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return object ; } /** * preamble object * * @param object preamble object */ static SEXP xx_preamble(SEXP value){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return value; } /** * string object * * @param object the assignement */ static SEXP xx_string(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return object ; } /** * value, paste( left, right , sep = "" ) * * @param */ static SEXP xx_value( SEXP left , SEXP right ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; const char* left_ = CHAR( STRING_ELT( left, 0) ) ; const char* right_ = CHAR( STRING_ELT( right, 0) ) ; int n_left = strlen( left_); int n_right = strlen( right_); int n = n_left + n_right ; char res[n] ; int i, j; for( i=0; i\n" ) ; #endif return ans ; } /** * creates a new assignement list * * @param object assignement object */ static SEXP xx_assignement_list1(SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans, tmp; _PROTECT( tmp = NewList( ) ) ; _PROTECT( ans = GrowList( tmp, object) ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans ; } /** * Augments an assignement list with a new assignement * * @param list assignement list * @param object new assignement */ static SEXP xx_assignement_list2(SEXP list, SEXP object){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans ; _PROTECT( ans = GrowList( list, object) ) ; _UNPROTECT_PTR( list ) ; _UNPROTECT_PTR( object ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /** * assignement * * @param lhs left side * @param value value */ static SEXP xx_assignement(SEXP lhs, SEXP value){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = value ) ; setAttrib( ans, install("names"), lhs ) ; _UNPROTECT_PTR( lhs ) ; _UNPROTECT_PTR( value ) ; #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /** * field lhs * * @param field */ static SEXP xx_lhs_field( SEXP field){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return field ; } static SEXP xx_lhs_abbrev( SEXP abbrev){ return xx_expand_abbrev( abbrev ) ; } static SEXP xx_space( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_space_inline( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_space_newline( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_forward( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return s ; } static SEXP xx_simple_value( SEXP s ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; /* all of what follows simply removes the " from the start and the end of the value, it might be better to do this in the lexer instead */ const char* data = CHAR( STRING_ELT( s, 0 ) ); int n = strlen(data); if( n >= 2) { char first = data[0]; char last = data[n-1]; if( first == '"' && last == '"' ){ _PROTECT( ans = allocVector( STRSXP, 1 ) ); if( n == 2 ){ SET_STRING_ELT( ans, 0, mkChar("") ) ; } else { char noquote[n-2] ; for( int i=1; i\n" ) ; #endif return ans ; } static SEXP xx_null( ){ #ifdef XXDEBUG Rprintf( "\n" ) ; #endif SEXP ans; _PROTECT( ans = R_NilValue ); #ifdef XXDEBUG Rprintf( "\n" ) ; #endif return ans; } /*}}}*/ /*{{{ various record functions */ static void recordInclude( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( includes, object ) ); _REPROTECT( includes = tmp, INCLUDE_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static void recordComment( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( comments, object ) ); _REPROTECT( comments = tmp, COMMENT_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static void recordString( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( strings, object ) ); _REPROTECT( strings = tmp, STRING_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static void recordPreamble( SEXP object ){ SEXP tmp ; _PROTECT( tmp = GrowList( preamble, object ) ); _REPROTECT( preamble = tmp, PREAMBLE_INDEX ) ; _UNPROTECT_PTR( tmp ) ; _UNPROTECT_PTR( object ) ; } static SEXP xx_expand_abbrev( SEXP abbrev ){ SEXP ans, tmp ; /* use the abbreviation name by default */ _PROTECT( ans = allocVector( STRSXP, 1 ) ) ; SET_STRING_ELT( ans, 0, STRING_ELT( abbrev, 0) ) ; _PROTECT( tmp = CDR(strings) ) ; int n = length( tmp ) ; const char * target = CHAR( STRING_ELT( abbrev, 0) ) ; SEXP item ; for(int i=0; i c( a = "aa", b = "bb" ) */ static SEXP asVector( SEXP x, int donames){ SEXP ans, names = R_NilValue ; SEXP tmp ; int n = length( CDR(x) ) ; _PROTECT( ans = allocVector( STRSXP, n) ) ; if( donames ){ _PROTECT( names = allocVector( STRSXP, n) ) ; } SEXP item; _PROTECT( tmp = CDR( x ) ); for( int i=0; i