├── .gitignore ├── README ├── bisonc++ ├── CLASSES ├── CLASSES.bobcat ├── INSTALL ├── INSTALL.im ├── README-0.98 ├── README.class-setup ├── README.flex ├── README.insertions ├── README.lookaheads ├── README.output ├── README.parser ├── README.polymorphic ├── README.polymorphic-technical ├── README.states ├── README.states-and-conflicts ├── TODO ├── VERSION ├── VERSION.h ├── atdollar │ ├── atdollar.h │ ├── atdollar.ih │ ├── atdollar1.cc │ ├── frame │ ├── operatorinsert.cc │ ├── setatpatterns.cc │ ├── setdollardollarpatterns.cc │ ├── setdollarpatterns.cc │ ├── setnumberpatterns.cc │ ├── setrefpatterns.cc │ ├── settagnr.cc │ ├── settagpatterns.cc │ └── stackelement.cc ├── bisonc++.xref ├── block │ ├── atdollar.cc │ ├── block.h │ ├── block.ih │ ├── clear.cc │ ├── close.cc │ ├── frame │ ├── open.cc │ ├── operatorinsert.cc │ └── opfuncharp.cc ├── build ├── changelog ├── documentation │ ├── demos │ │ ├── README │ │ ├── bison++Example.NEW │ │ │ ├── FlexLexer.h │ │ │ ├── Makefile │ │ │ ├── MyCompiler.cc │ │ │ ├── MyParser.h │ │ │ ├── MyParser.ih │ │ │ ├── MyParser.y │ │ │ ├── MyScanner.h │ │ │ ├── MyScanner.l │ │ │ ├── README │ │ │ ├── make │ │ │ ├── test.txt │ │ │ └── test2.txt │ │ ├── bison++Example.ORG │ │ │ ├── FlexLexer.h │ │ │ ├── Makefile │ │ │ ├── MyCompiler.cc │ │ │ ├── MyParser.y │ │ │ ├── MyScanner.l │ │ │ ├── test.txt │ │ │ └── test2.txt │ │ └── manual │ ├── html │ │ ├── bison.html │ │ ├── bison_1.html │ │ ├── bison_10.html │ │ ├── bison_11.html │ │ ├── bison_12.html │ │ ├── bison_13.html │ │ ├── bison_14.html │ │ ├── bison_15.html │ │ ├── bison_16.html │ │ ├── bison_2.html │ │ ├── bison_3.html │ │ ├── bison_4.html │ │ ├── bison_5.html │ │ ├── bison_6.html │ │ ├── bison_7.html │ │ ├── bison_8.html │ │ ├── bison_9.html │ │ ├── bison_abt.html │ │ ├── bison_ovr.html │ │ └── bison_toc.html │ ├── man │ │ ├── bisonc++.yo │ │ ├── bisonc++api.yo │ │ ├── bisonc++input.yo │ │ ├── calculator │ │ │ ├── README │ │ │ ├── build │ │ │ ├── main.cc │ │ │ ├── parser │ │ │ │ ├── grammar │ │ │ │ ├── parser.h │ │ │ │ ├── parser.ih │ │ │ │ └── parserbase.h │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── options.yodl │ │ └── seealso.yo │ ├── manual │ │ ├── algorithm.yo │ │ ├── algorithm │ │ │ ├── condep.yo │ │ │ ├── conflicts.yo │ │ │ ├── demos │ │ │ │ ├── Parser.h │ │ │ │ ├── Parser.ih │ │ │ │ ├── Parserbase.h │ │ │ │ ├── dangling │ │ │ │ ├── dangling.tab.c │ │ │ │ ├── mandayam │ │ │ │ ├── noshiftreduce │ │ │ │ ├── notpeculiar │ │ │ │ ├── peculiar │ │ │ │ ├── rr1 │ │ │ │ └── rr1.tab.c │ │ │ ├── determine.yo │ │ │ ├── example │ │ │ │ ├── Parser.h │ │ │ │ ├── demo.cc │ │ │ │ ├── grammar │ │ │ │ └── grammar.output │ │ │ ├── first.yo │ │ │ ├── howprec.yo │ │ │ ├── input.yo │ │ │ ├── intro.yo │ │ │ ├── lookahead.yo │ │ │ ├── lookaheads.yo │ │ │ ├── mysterious.yo │ │ │ ├── precdemos.yo │ │ │ ├── precedence.yo │ │ │ ├── pstates.yo │ │ │ ├── reduce.yo │ │ │ ├── ruleprec.yo │ │ │ ├── specifying.yo │ │ │ ├── states.yo │ │ │ ├── transition.yo │ │ │ └── whenprec.yo │ │ ├── bisonc++.yo │ │ ├── class.yo │ │ ├── class │ │ │ ├── anonymous.yo │ │ │ ├── features.yo │ │ │ ├── intro.yo │ │ │ ├── lex.yo │ │ │ ├── privdata.yo │ │ │ ├── privenum.yo │ │ │ ├── privmembers.yo │ │ │ └── public.yo │ │ ├── concepts.yo │ │ ├── concepts │ │ │ ├── actions.yo │ │ │ ├── formal.yo │ │ │ ├── intro.yo │ │ │ ├── languages.yo │ │ │ ├── layout.yo │ │ │ ├── output.yo │ │ │ ├── reentrant.yo │ │ │ ├── semantic.yo │ │ │ └── stages.yo │ │ ├── conditions.yo │ │ ├── conditions │ │ │ ├── gpl.yo │ │ │ └── intro.yo │ │ ├── demos │ │ │ ├── calc.yo │ │ │ ├── calc │ │ │ │ ├── build │ │ │ │ ├── main.cc │ │ │ │ ├── main.ih │ │ │ │ └── parser │ │ │ │ │ ├── Parser.ih │ │ │ │ │ ├── grammar │ │ │ │ │ ├── lex.cc │ │ │ │ │ └── parse.output │ │ │ ├── errorcalc │ │ │ │ ├── build │ │ │ │ ├── calc.cc │ │ │ │ ├── calc.h │ │ │ │ └── parser │ │ │ │ │ ├── Parser.h │ │ │ │ │ ├── Parser.ih │ │ │ │ │ ├── Parserbase.h │ │ │ │ │ ├── grammar │ │ │ │ │ ├── lex.cc │ │ │ │ │ └── parse.output │ │ │ ├── errors.yo │ │ │ ├── exercises.yo │ │ │ ├── intro.yo │ │ │ ├── mfbuild.yo │ │ │ ├── mfcalc.yo │ │ │ ├── mfcalc │ │ │ │ ├── build │ │ │ │ ├── main.cc │ │ │ │ ├── main.ih │ │ │ │ └── parser │ │ │ │ │ ├── Parser.h │ │ │ │ │ ├── Parser.ih │ │ │ │ │ ├── data.cc │ │ │ │ │ ├── grammar │ │ │ │ │ ├── grammar.rules │ │ │ │ │ ├── internalheader.ih │ │ │ │ │ ├── lex.cc │ │ │ │ │ ├── parse.output │ │ │ │ │ └── parser.header │ │ │ ├── mfdecl.yo │ │ │ ├── mfgrammar.yo │ │ │ ├── mflex.yo │ │ │ ├── mftables.yo │ │ │ ├── rpn.yo │ │ │ ├── rpn │ │ │ │ ├── build │ │ │ │ ├── index.html │ │ │ │ ├── index.yo │ │ │ │ ├── main.cc │ │ │ │ ├── main.ih │ │ │ │ └── parser │ │ │ │ │ ├── Parser.ih │ │ │ │ │ ├── grammar │ │ │ │ │ └── lex.cc │ │ │ ├── rpnconstruct.yo │ │ │ ├── rpndecl.yo │ │ │ ├── rpnerror.yo │ │ │ ├── rpnexpr.yo │ │ │ ├── rpngram.yo │ │ │ ├── rpninput.yo │ │ │ ├── rpnlex.yo │ │ │ ├── rpnline.yo │ │ │ ├── rpnmain.yo │ │ │ └── rpnparser.yo │ │ ├── directives │ │ │ ├── baseclass.yo │ │ │ ├── classhdr.yo │ │ │ ├── debug.yo │ │ │ ├── defaultactions.yo │ │ │ ├── errorverbose.yo │ │ │ ├── expect.yo │ │ │ ├── filenames.yo │ │ │ ├── flex.yo │ │ │ ├── imphdr.yo │ │ │ ├── improper.yo │ │ │ ├── include.yo │ │ │ ├── intro.yo │ │ │ ├── lines.yo │ │ │ ├── lneeded.yo │ │ │ ├── locstruct.yo │ │ │ ├── ltype.yo │ │ │ ├── namespace.yo │ │ │ ├── negative.yo │ │ │ ├── nonterms.yo │ │ │ ├── output.yo │ │ │ ├── parse.yo │ │ │ ├── parserclass.yo │ │ │ ├── polymorphic.yo │ │ │ ├── prec.yo │ │ │ ├── precedence.yo │ │ │ ├── preinclude.yo │ │ │ ├── print.yo │ │ │ ├── prompt.yo │ │ │ ├── required.yo │ │ │ ├── scanner.yo │ │ │ ├── scannerclassname.yo │ │ │ ├── scannermatchedtextfunction.yo │ │ │ ├── scannertokenfunction.yo │ │ │ ├── stackexpansion.yo │ │ │ ├── start.yo │ │ │ ├── stype.yo │ │ │ ├── tagmismatches.yo │ │ │ ├── targetdir.yo │ │ │ ├── threadsafe.yo │ │ │ ├── tokens.yo │ │ │ ├── union.yo │ │ │ └── weaktags.yo │ │ ├── error.yo │ │ ├── error │ │ │ ├── errordemo │ │ │ │ ├── input │ │ │ │ ├── main.cc │ │ │ │ └── parser │ │ │ │ │ ├── grammar │ │ │ │ │ ├── lex.cc │ │ │ │ │ ├── parser.h │ │ │ │ │ └── parser.ih │ │ │ ├── intro.yo │ │ │ ├── recovery.yo │ │ │ ├── semantical.yo │ │ │ └── syntactical.yo │ │ ├── examples.yo │ │ ├── grammar.yo │ │ ├── grammar │ │ │ ├── actions.yo │ │ │ ├── alternatives.yo │ │ │ ├── code.yo │ │ │ ├── delimseries.yo │ │ │ ├── essence │ │ │ │ └── demo.cc │ │ │ ├── gramcons.yo │ │ │ ├── intro.yo │ │ │ ├── midrule.yo │ │ │ ├── multiple.yo │ │ │ ├── nested.yo │ │ │ ├── optdelim.yo │ │ │ ├── optseries.yo │ │ │ ├── outline.yo │ │ │ ├── parser.yo │ │ │ ├── poly │ │ │ │ ├── README │ │ │ │ ├── build │ │ │ │ ├── icmconf │ │ │ │ ├── main.cc │ │ │ │ ├── main.ih │ │ │ │ ├── parser │ │ │ │ │ ├── grammar │ │ │ │ │ ├── intvalue.cc │ │ │ │ │ ├── parser.h │ │ │ │ │ ├── parser.ih │ │ │ │ │ └── process.cc │ │ │ │ └── scanner │ │ │ │ │ ├── lexer │ │ │ │ │ ├── scanner.h │ │ │ │ │ └── scanner.ih │ │ │ ├── polydollar.yo │ │ │ ├── polymorphic.yo │ │ │ ├── polymorphicdirective.yo │ │ │ ├── polymorphicshorthand.yo │ │ │ ├── polymorphictype.OBS │ │ │ ├── recursive.yo │ │ │ ├── scanner.yo │ │ │ ├── semantics.yo │ │ │ ├── series.yo │ │ │ ├── stypedollar.yo │ │ │ ├── stypeinterface.yo │ │ │ ├── stypeshorthand.yo │ │ │ ├── symbols.yo │ │ │ ├── syntax.yo │ │ │ ├── uniondollar.yo │ │ │ └── unionshorthand.yo │ │ ├── introduction.yo │ │ ├── invoking.yo │ │ ├── invoking │ │ │ ├── options.yo │ │ │ └── usage.yo │ │ ├── preamble.yo │ │ ├── underscores.yo │ │ ├── version.yo │ │ └── whatsnew.yo │ ├── regression │ │ ├── aho4.42 │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── aho4.46 │ │ │ ├── doc │ │ │ └── parser │ │ │ │ └── grammar │ │ ├── annotations │ │ │ ├── _a2x.h │ │ │ ├── _data.cc │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ │ ├── _display1.cc │ │ │ │ ├── _display2.cc │ │ │ │ ├── _done.cc │ │ │ │ ├── _reset.cc │ │ │ │ ├── bgram │ │ │ │ ├── grammar │ │ │ │ ├── parser.h │ │ │ │ └── parser.ih │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── calculator │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ │ ├── bgram │ │ │ │ ├── grammar │ │ │ │ ├── parser.h │ │ │ │ └── parser.ih │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── conflicts │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── danglingelse │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── duplicate │ │ │ └── parser │ │ │ │ └── grammar │ │ ├── error │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── fun │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ │ ├── _a2x.h │ │ │ │ ├── _angle.cc │ │ │ │ ├── _assign.cc │ │ │ │ ├── _binary.cc │ │ │ │ ├── _call.cc │ │ │ │ ├── _data.cc │ │ │ │ ├── _display.cc │ │ │ │ ├── _div0.cc │ │ │ │ ├── _error.cc │ │ │ │ ├── _error2.cc │ │ │ │ ├── _firstarg.cc │ │ │ │ ├── _help.cc │ │ │ │ ├── _identvalue.cc │ │ │ │ ├── _integral.cc │ │ │ │ ├── _list.cc │ │ │ │ ├── _lvalue.cc │ │ │ │ ├── _mathconst.cc │ │ │ │ ├── _newvalue.cc │ │ │ │ ├── _prompt.cc │ │ │ │ ├── _radians.cc │ │ │ │ ├── _setangletype.cc │ │ │ │ ├── _setdatatype.cc │ │ │ │ ├── _setfunction.cc │ │ │ │ ├── _showvarfun.cc │ │ │ │ ├── _storeident.cc │ │ │ │ ├── _unary.cc │ │ │ │ ├── _variable.cc │ │ │ │ ├── bgram │ │ │ │ ├── grammar │ │ │ │ ├── parser.h │ │ │ │ └── parser.ih │ │ │ ├── rulevalue │ │ │ │ ├── _as.cc │ │ │ │ ├── _copy.cc │ │ │ │ ├── _data.cc │ │ │ │ ├── _function.cc │ │ │ │ ├── _operatoraand.cc │ │ │ │ ├── _operatoradda.cc │ │ │ │ ├── _operatoradiv.cc │ │ │ │ ├── _operatoralshift.cc │ │ │ │ ├── _operatoramod.cc │ │ │ │ ├── _operatoramul.cc │ │ │ │ ├── _operatoraor.cc │ │ │ │ ├── _operatorarshift.cc │ │ │ │ ├── _operatorassign.cc │ │ │ │ ├── _operatorasub.cc │ │ │ │ ├── _operatoraxor.cc │ │ │ │ ├── _operatorinsert.cc │ │ │ │ ├── _operatornegate.cc │ │ │ │ ├── _rulevalue.h │ │ │ │ ├── _rulevalue.ih │ │ │ │ └── _rulevalue1.cc │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── icmake1 │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── icmake2 │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── location │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ │ ├── bgram │ │ │ │ ├── grammar │ │ │ │ └── parser.h │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── mandayam │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── naive │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ │ └── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ ├── nosentence │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── notused │ │ │ ├── doc │ │ │ └── parser │ │ │ │ └── grammar │ │ ├── polymorphic │ │ │ ├── base │ │ │ │ ├── base.h │ │ │ │ └── base.ih │ │ │ ├── dallas │ │ │ ├── dallas2 │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── enum │ │ │ │ ├── enum.h │ │ │ │ └── enum.ih │ │ │ ├── ident │ │ │ │ ├── ident.h │ │ │ │ └── ident.ih │ │ │ ├── input │ │ │ ├── main.ih │ │ │ ├── parser │ │ │ │ ├── grammar │ │ │ │ ├── parser.h │ │ │ │ ├── parser.ih │ │ │ │ └── preinclude.h │ │ │ ├── scanner │ │ │ │ ├── lexer │ │ │ │ ├── scanner.h │ │ │ │ └── scanner.ih │ │ │ └── semval │ │ │ │ └── semval.h │ │ ├── rr2 │ │ │ ├── doc │ │ │ └── parser │ │ │ │ ├── bgram │ │ │ │ └── grammar │ │ ├── run │ │ ├── runone │ │ └── simplecalc │ │ │ ├── demo.cc │ │ │ ├── doc │ │ │ ├── parser │ │ │ ├── bgram │ │ │ ├── grammar │ │ │ ├── parser.h │ │ │ └── parser.ih │ │ │ └── scanner │ │ │ ├── lexer │ │ │ ├── scanner.h │ │ │ └── scanner.ih │ └── usage │ │ └── usage.cc ├── element │ ├── destructor.cc │ ├── element.h │ ├── element.ih │ └── frame ├── enumsolution │ └── enumsolution.h ├── firstset │ ├── firstset.h │ ├── firstset.ih │ ├── firstset1.cc │ ├── frame │ ├── oinsert.cc │ ├── operatorplusis1.cc │ └── operatorplusis2.cc ├── generator │ ├── TODO │ ├── actioncases.cc │ ├── atclassname.cc │ ├── atelse.cc │ ├── atend.cc │ ├── atltype.cc │ ├── atmatchedtextfunction.cc │ ├── atnamespacedclassname.cc │ ├── attokenfunction.cc │ ├── baseclass.cc │ ├── baseclasscode.cc │ ├── baseclassheader.cc │ ├── bolat.cc │ ├── classh.cc │ ├── classheader.cc │ ├── classih.cc │ ├── conflicts.cc │ ├── data.cc │ ├── debug.cc │ ├── debugdecl.cc │ ├── debugfunctions.cc │ ├── debugincludes.cc │ ├── debuginit.cc │ ├── debuglookup.cc │ ├── errexisting.cc │ ├── errorverbose.cc │ ├── executeactioncases.cc │ ├── filename.cc │ ├── filter.cc │ ├── frame │ ├── generator.h │ ├── generator.ih │ ├── generator1.cc │ ├── grep.cc │ ├── idoftag.cc │ ├── ifinsertstype.cc │ ├── ifltype.cc │ ├── ifprinttokens.cc │ ├── implementationheader.cc │ ├── insert.cc │ ├── insert2.cc │ ├── key.cc │ ├── lex.cc │ ├── ltype.cc │ ├── ltypeclear.cc │ ├── ltypedata.cc │ ├── ltypepop.cc │ ├── ltypepush.cc │ ├── ltyperesize.cc │ ├── ltypestack.cc │ ├── namespaceclose.cc │ ├── namespaceopen.cc │ ├── namespaceuse.cc │ ├── parsefunction.cc │ ├── polyincludes.cc │ ├── polymorphic.cc │ ├── polymorphiccode.cc │ ├── polymorphicspecializations.cc │ ├── preincludes.cc │ ├── print.cc │ ├── prompt.cc │ ├── replace.cc │ ├── replaceatkey.cc │ ├── replacebaseflag.cc │ ├── scannerh.cc │ ├── scannerobject.cc │ ├── selectsymbolic.cc │ ├── staticdata.cc │ ├── stype.cc │ ├── tokens.cc │ └── warntagmismatches.cc ├── grammar │ ├── becomesderivable.cc │ ├── derivable.cc │ ├── derivesentence.cc │ ├── frame │ ├── grammar.h │ ├── grammar.ih │ └── isderivable.cc ├── grammars │ ├── conflict │ ├── empty │ ├── expressions │ ├── exprplus │ ├── grammar │ ├── grammar.p238 │ ├── grammar4.11 │ ├── grammar4.19 │ ├── grammar4.20 │ ├── grammar4.21 │ ├── ifelse │ ├── input │ ├── precedence │ └── small ├── icmake │ ├── adddir │ ├── backtick │ ├── clean │ ├── cuteoln │ ├── destinstall │ ├── findall │ ├── github │ ├── install │ ├── installer │ ├── log │ ├── logfile │ ├── logfiles │ ├── loginstall │ ├── loginstalled │ ├── logrecursive │ ├── logzip │ ├── manpage │ ├── manual │ ├── md │ ├── pathfile │ ├── remove │ ├── run │ ├── setopt │ ├── special │ └── uninstall ├── icmconf ├── item │ ├── beyonddotisnonterminal.cc │ ├── data.cc │ ├── firstbeyonddot.cc │ ├── frame │ ├── hasrightofdot.cc │ ├── insert.cc │ ├── item.h │ ├── item.ih │ ├── item0.cc │ ├── item1.cc │ ├── item2.cc │ ├── item3.cc │ ├── operatorequal.cc │ ├── plainitem.cc │ ├── pnrdotitem.cc │ └── transitsto.cc ├── lookaheadset │ ├── insert.cc │ ├── intersection.cc │ ├── lookaheadset.h │ ├── lookaheadset.ih │ ├── lookaheadset1.cc │ ├── lookaheadset2.cc │ ├── lookaheadset3.cc │ ├── operatorgreaterequal.cc │ ├── operatorinsert.cc │ ├── operatorplusis.cc │ ├── operatorplusis2.cc │ ├── operatorsubis.cc │ └── operatorsubis2.cc ├── main.cc ├── main.ih ├── next │ ├── addtokernel.cc │ ├── buildkernel.cc │ ├── checkremoved.cc │ ├── data.cc │ ├── frame │ ├── next.h │ ├── next.ih │ ├── next1.cc │ ├── next2.cc │ ├── removeshift.cc │ ├── solvebyassociation.cc │ ├── solvebyprecedence.cc │ ├── transition.cc │ └── transitionkernel.cc ├── nonterminal │ ├── data.cc │ ├── destructor.cc │ ├── frame │ ├── insname.cc │ ├── nonterminal.h │ ├── nonterminal.ih │ ├── nonterminal1.cc │ ├── setfirst.cc │ ├── undefined.cc │ ├── unused.cc │ └── v.cc ├── options │ ├── accept.cc │ ├── addincludequotes.cc │ ├── assign.cc │ ├── baseclassheadername.cc │ ├── cleandir.cc │ ├── data.cc │ ├── frame │ ├── instance.cc │ ├── isfirststypedef.cc │ ├── options.h │ ├── options.ih │ ├── options1.cc │ ├── setaccessorvariables.cc │ ├── setbasicstrings.cc │ ├── setbooleans.cc │ ├── setconstructorchecks.cc │ ├── setdefaultaction.cc │ ├── setlocationdecl.cc │ ├── setltype.cc │ ├── setopt.cc │ ├── setparsingoptions.cc │ ├── setpath2.4.04 │ ├── setpath2.cc │ ├── setpathstrings.cc │ ├── setpolymorphicdecl.cc │ ├── setprinttokens.cc │ ├── setquotedstrings.cc │ ├── setrequiredtokens.cc │ ├── setskeletons.cc │ ├── setstackexpansion.cc │ ├── setstype.cc │ ├── settagmismatches.cc │ ├── setuniondecl.cc │ ├── setverbosity.cc │ ├── showfilenames.cc │ ├── undelimit.cc │ ├── valueof.cc │ └── warnnonpolymorphic.cc ├── parseconstruction ├── parser │ ├── README.dollar │ ├── addpolymorphic.cc │ ├── blkassign.cc │ ├── blkassignw.cc │ ├── blkcheck.cc │ ├── blkcheckw.cc │ ├── blkdirect.cc │ ├── blkdirectw.cc │ ├── blkerr.cc │ ├── blknop.cc │ ├── blknopw.cc │ ├── blkstype.cc │ ├── blkstypew.cc │ ├── checkfield.cc │ ├── checkfirsttype.cc │ ├── cleanup.cc │ ├── data.cc │ ├── defaultpolymorphicaction.cc │ ├── definenonterminal.cc │ ├── definepathname.cc │ ├── defineterminal.cc │ ├── definetokenname.cc │ ├── driver │ │ ├── build │ │ ├── driver.cc │ │ └── driver.h │ ├── dval.cc │ ├── dvalmem.cc │ ├── dvalpar.cc │ ├── dvalpoly.cc │ ├── dvalpolymem.cc │ ├── dvalpolypar.cc │ ├── dvalpolyptr.cc │ ├── dvalpolyreplace.cc │ ├── dvalptr.cc │ ├── dvalrefunion.cc │ ├── dvalreplace.cc │ ├── dvalunion.cc │ ├── dvalunionmem.cc │ ├── dvalunionpar.cc │ ├── dvalunionptr.cc │ ├── dvalunionreplace.cc │ ├── errindextoolarge.cc │ ├── errnotag.cc │ ├── errnounionptr.cc │ ├── error.cc │ ├── existingtag.cc │ ├── expectrules.cc │ ├── extractindex.cc │ ├── extracttype.cc │ ├── frame │ ├── grammar │ ├── handleproductionelement.cc │ ├── handleproductionelements.cc │ ├── inc │ │ ├── directives │ │ ├── identifier │ │ ├── opt │ │ ├── rules │ │ └── typename │ ├── indextooffset.cc │ ├── installaction.cc │ ├── installdefaultaction.cc │ ├── loc.cc │ ├── locel.cc │ ├── multiplydefined.cc │ ├── nestedblock.cc │ ├── nexthiddenname.cc │ ├── openrule.cc │ ├── parse.cc │ ├── parser.h │ ├── parser.ih │ ├── parser1.cc │ ├── parserbase.h │ ├── predefine.cc │ ├── preheaders.h │ ├── requirenonterminal.cc │ ├── setpolymorphicdecl.cc │ ├── setprecedence.cc │ ├── setstart.cc │ ├── setuniondecl.cc │ ├── stdemsg.cc │ ├── stdwmsg.cc │ ├── substituteblock.cc │ ├── svs.cc │ ├── svselement.cc │ ├── svsmem.cc │ ├── svspoly.cc │ ├── svspolymem.cc │ ├── svspolyptr.cc │ ├── svspolyreplace.cc │ ├── svspolytag.cc │ ├── svspolytagmem.cc │ ├── svspolytagptr.cc │ ├── svspolytagreplace.cc │ ├── svsptr.cc │ ├── svsrefunion.cc │ ├── svsreplace.cc │ ├── svstagref.cc │ ├── svsunion.cc │ ├── svsunionmem.cc │ ├── svsunionptr.cc │ ├── svsunionreplace.cc │ ├── svsuniontag.cc │ ├── svsuniontagmem.cc │ ├── svsuniontagptr.cc │ ├── svsuniontagreplace.cc │ ├── typeindex.cc │ ├── updatedefaultactionlinenr.cc │ ├── usesymbol.cc │ ├── useterminal.cc │ ├── warnautotag.cc │ ├── warndefaultaction.cc │ ├── warnforcelsp.cc │ ├── warnmissingsemval.cc │ ├── warnnegativedollarindices.cc │ └── warnuntaggedvalue.cc ├── plainwarnings.cc ├── production │ ├── data.cc │ ├── frame │ ├── insertaction.cc │ ├── production.h │ ├── production.ih │ ├── production1.cc │ ├── setprecedence.cc │ ├── standard.cc │ ├── storeFilename.cc │ ├── unused.cc │ └── vectoridx.cc ├── rebis ├── required ├── rmreduction │ ├── frame │ ├── rmreduction.h │ ├── rmreduction.ih │ └── rmreduction1.cc ├── rmshift │ ├── frame │ ├── rmshift.h │ ├── rmshift.ih │ └── rmshift1.cc ├── rrconflict │ ├── comparereductions.cc │ ├── data.cc │ ├── frame │ ├── insert.cc │ ├── inspect.cc │ ├── removeconflicts.cc │ ├── rrconflict.h │ ├── rrconflict.ih │ ├── rrconflict1.cc │ ├── showconflicts.cc │ └── visitreduction.cc ├── rrdata │ ├── rrdata.h │ ├── rrdata.ih │ ├── rrdata1.cc │ └── setidx.cc ├── rules │ ├── addelement.cc │ ├── addproduction.cc │ ├── assignnonterminalnumbers.cc │ ├── augmentgrammar.cc │ ├── data.cc │ ├── determinefirst.cc │ ├── frame │ ├── insert1.cc │ ├── insert2.cc │ ├── newrule.cc │ ├── rules.h │ ├── rules.ih │ ├── sethiddenaction.cc │ ├── setnonterminaltypes.cc │ ├── setprecedence.cc │ ├── showfirst.cc │ ├── showrules.cc │ ├── showterminals.cc │ ├── showunusednonterminals.cc │ ├── showunusedrules.cc │ ├── showunusedterminals.cc │ ├── stype.cc │ ├── termtononterm.cc │ ├── updatedefaultactionlinenr.cc │ ├── updateprecedence.cc │ └── updateprecedences.cc ├── runtmp ├── scanner │ ├── assignment.cc │ ├── canonicalquote.cc │ ├── checkendofrawstring.cc │ ├── checkzeronumber.cc │ ├── driver │ │ ├── build │ │ ├── driver.cc │ │ ├── driver.h │ │ └── grammar │ ├── eoln.cc │ ├── escape.cc │ ├── frame │ ├── handlerawstring.cc │ ├── handlexstring.cc │ ├── hexadecimal.cc │ ├── lex.cc │ ├── lexer │ ├── multicharquote.cc │ ├── octal.cc │ ├── popstream.cc │ ├── returnquoted.cc │ ├── returntypespec.cc │ ├── scanner.h │ ├── scanner.ih │ ├── scanner1.cc │ ├── scannerbase.h │ ├── setlinenrs.cc │ └── settags.cc ├── skeletons.src │ ├── base │ │ ├── base1 │ │ ├── clearin │ │ ├── comment │ │ ├── debugfunctions │ │ ├── declarations │ │ ├── lex │ │ ├── lookup │ │ ├── pop │ │ ├── poptoken │ │ ├── push │ │ ├── pushtoken │ │ ├── redotoken │ │ ├── reduce │ │ ├── shift │ │ ├── startrecovery │ │ └── top │ ├── build │ ├── derived │ │ ├── errorrecovery │ │ ├── executeaction │ │ ├── nextcycle │ │ ├── nexttoken │ │ ├── parse │ │ ├── print │ │ └── tail │ └── hdr │ │ ├── abort │ │ ├── accept │ │ ├── baseclass │ │ ├── debug │ │ ├── error │ │ ├── includes │ │ ├── opbitand │ │ ├── opbitor │ │ ├── recovery │ │ ├── savedtoken │ │ ├── stacksize │ │ ├── state │ │ ├── tail │ │ ├── token │ │ └── vs ├── skeletons │ ├── bisonc++.cc │ ├── bisonc++.h │ ├── bisonc++.ih │ ├── bisonc++base.h │ ├── bisonc++polymorphic │ ├── bisonc++polymorphic.code │ ├── debugdecl.in │ ├── debugfunctions1.in │ ├── debugfunctions2.in │ ├── debugfunctions3.in │ ├── debugincludes.in │ ├── debuglookup.in │ ├── lex.in │ ├── ltype.in │ ├── ltypedata.in │ └── print.in ├── srconflict │ ├── data.cc │ ├── frame │ ├── handlesrconflict.cc │ ├── insert.cc │ ├── inspect.cc │ ├── processshiftreduceconflict.cc │ ├── removereductions.cc │ ├── removeshifts.cc │ ├── showconflicts.cc │ ├── srconflict.h │ ├── srconflict.ih │ ├── srconflict1.cc │ └── visitreduction.cc ├── state │ ├── addkernelitem.cc │ ├── addnext.cc │ ├── addproductions.cc │ ├── addstate.cc │ ├── allstates.cc │ ├── checkconflicts.cc │ ├── computelasets.cc │ ├── construct.cc │ ├── data.cc │ ├── define.cc │ ├── determinelasets.cc │ ├── distributelasetof.cc │ ├── findkernel.cc │ ├── frame │ ├── haskernel.cc │ ├── initialstate.cc │ ├── insertext.cc │ ├── insertstd.cc │ ├── inspecttransitions.cc │ ├── newstate.cc │ ├── nextfindfrom.cc │ ├── nexton.cc │ ├── nextstate.cc │ ├── nextterminal.cc │ ├── notreducible.cc │ ├── setitems.cc │ ├── state.h │ ├── state.ih │ ├── state1.cc │ └── summarizeactions.cc ├── stateitem │ ├── containskernelitem.cc │ ├── data.cc │ ├── enlargela.cc │ ├── frame │ ├── itemcontext.cc │ ├── plainitem.cc │ ├── stateitem.h │ ├── stateitem.ih │ ├── stateitem1.cc │ └── stateitem2.cc ├── statetype │ ├── data.cc │ ├── frame │ ├── statetype.h │ └── statetype.ih ├── symbol │ ├── destructor.cc │ ├── frame │ ├── symbol.h │ ├── symbol.ih │ └── symbol1.cc ├── symtab │ ├── frame │ ├── lookup.cc │ ├── symtab.h │ └── symtab.ih ├── terminal │ ├── compareprecedence.cc │ ├── data.cc │ ├── destructor.cc │ ├── frame │ ├── nameorvalue.cc │ ├── quotedname.cc │ ├── setunique.cc │ ├── setvalue.cc │ ├── terminal.h │ ├── terminal.ih │ ├── terminal1.cc │ ├── terminal2.cc │ ├── unused.cc │ └── valuequotedname.cc ├── usage.cc ├── version.cc └── writer │ ├── data.cc │ ├── frame │ ├── insert.cc │ ├── inserttoken.cc │ ├── nonterminalsymbol.cc │ ├── productioninfo.cc │ ├── productions.cc │ ├── reduction.cc │ ├── reductions.cc │ ├── reductionsymbol.cc │ ├── srtable.cc │ ├── srtables.cc │ ├── statesarray.cc │ ├── symbolicnames.cc │ ├── terminalsymbol.cc │ ├── transition.cc │ ├── transitions.cc │ ├── writer.h │ ├── writer.ih │ └── writer0.cc ├── excluded ├── parsergen └── sourcetar /.gitignore: -------------------------------------------------------------------------------- 1 | *.ih.gch 2 | self 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Bisonc++ is a parser generator like bison, but it generates C++ code 2 | 3 | Bisonc++'s repository has moved to https://gitlab.com/fbb-git/bisoncpp. 4 | and is not maintained at this location anymore. 5 | 6 | The project's web-page can be found at http://fbb-git.gitlab.io/bisoncpp/ 7 | -------------------------------------------------------------------------------- /bisonc++/CLASSES.bobcat: -------------------------------------------------------------------------------- 1 | align 2 | arg 3 | datetime 4 | exception 5 | indent 6 | mstream 7 | pattern 8 | ranger 9 | stat 10 | string 11 | table 12 | tablesupport 13 | -------------------------------------------------------------------------------- /bisonc++/README.lookaheads: -------------------------------------------------------------------------------- 1 | The algorithm that is used to compute the look-ahead sets of all items of all 2 | states of a grammar is described in chapter 7 (The Bisonc++ Parser Algorithm) 3 | of Bisonc++'s user mannual, as well as in the state/determinelasets.cc source 4 | file. Please refer to these documentation sources for further information 5 | about the LA sets computation algorithm. 6 | -------------------------------------------------------------------------------- /bisonc++/README.output: -------------------------------------------------------------------------------- 1 | Output to the xxx.output file by the --verbose or --construction flags are 2 | mostly handled from the State::allStates() function. This function calls 3 | State's operator<<, which is initialized by a pointer pointing to either 4 | 5 | insertStd, 6 | insertExt 7 | 8 | or 9 | 10 | skipInsertion. 11 | 12 | Inspect state/insertstd.cc for the standard insertion method and 13 | state/insertext.cc for the extensive insertion method. 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/README.polymorphic: -------------------------------------------------------------------------------- 1 | A short demo program is found in documentation/manual/grammar/poly/; 2 | A demo illustrating the way polymorphic semantic type assignment works is 3 | provided in documentation/manual/grammar/essence/demo.cc. 4 | -------------------------------------------------------------------------------- /bisonc++/TODO: -------------------------------------------------------------------------------- 1 | - %nonassoc should probably produce an error when %nonassoc operators are used 2 | repeatedly. 3 | -------------------------------------------------------------------------------- /bisonc++/VERSION: -------------------------------------------------------------------------------- 1 | #define VERSION "6.02.00" 2 | #define YEARS "2005-2018" 3 | -------------------------------------------------------------------------------- /bisonc++/VERSION.h: -------------------------------------------------------------------------------- 1 | #include "VERSION" 2 | SUBST(_CurVers_)(VERSION) 3 | SUBST(_CurYrs_)(YEARS) 4 | -------------------------------------------------------------------------------- /bisonc++/atdollar/atdollar.ih: -------------------------------------------------------------------------------- 1 | #include "atdollar.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/atdollar/frame: -------------------------------------------------------------------------------- 1 | #include "atdollar.ih" 2 | 3 | AtDollar:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/atdollar/setatpatterns.cc: -------------------------------------------------------------------------------- 1 | #include "atdollar.ih" 2 | 3 | void AtDollar::setAtPatterns() // text[0] == '@' 4 | { 5 | if (d_text[1] == '@') 6 | d_pattern = AA; 7 | else 8 | { 9 | d_pattern = An; 10 | d_nr = stol(d_text.substr(1)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/atdollar/settagnr.cc: -------------------------------------------------------------------------------- 1 | #include "atdollar.ih" 2 | 3 | void AtDollar::setTagNr(size_t begin) // idx beyond < 4 | { 5 | size_t end = d_text.find('>'); 6 | 7 | d_tag = d_text.substr(begin, end - begin); 8 | d_nr = stol(d_text.substr(end + 1)); 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/atdollar/stackelement.cc: -------------------------------------------------------------------------------- 1 | #include "atdollar.ih" 2 | 3 | bool AtDollar::stackElement() const 4 | { 5 | switch (d_pattern) 6 | { 7 | case AA: 8 | case DD: 9 | case refDD: 10 | case DDm: 11 | case DDp: 12 | case DDpar: 13 | return false; 14 | 15 | default: 16 | return true; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bisonc++/block/atdollar.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | void Block::atDollar(size_t lineNr, string const &text, bool assignment, 4 | bool refByScanner) 5 | { 6 | d_atDollar.push_back(AtDollar{length(), lineNr, text, refByScanner}); 7 | 8 | d_assignment |= assignment; 9 | 10 | append(text); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/block/block.ih: -------------------------------------------------------------------------------- 1 | #include "block.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/block/clear.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | void Block::clear() 4 | { 5 | erase(); 6 | d_atDollar.clear(); 7 | d_count = 0; 8 | d_assignment = false; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/block/close.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | bool Block::close() 4 | { 5 | *this += "}"; 6 | return --d_count == 0; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/block/frame: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | void Block::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/block/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | std::ostream &operator<<(std::ostream &out, Block const &blk) 4 | { 5 | out << '`' << static_cast(blk) << "'\n"; 6 | 7 | copy(blk.d_atDollar.rbegin(), blk.d_atDollar.rend(), 8 | ostream_iterator(out, "\n")); 9 | 10 | return out; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/block/opfuncharp.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | bool Block::operator()(string const &text) 4 | { 5 | if (d_count == 0) 6 | return false; 7 | 8 | *this += text; 9 | return true; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.NEW/MyCompiler.cc: -------------------------------------------------------------------------------- 1 | #include "MyParser.h" 2 | 3 | #include 4 | 5 | int main(int argc,char **argv) 6 | { 7 | MyParser aCompiler; 8 | int result = aCompiler.parse(); 9 | 10 | printf("Parsing result = %s\n", result ? "Error" : "OK"); 11 | return 0; 12 | }; 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.NEW/MyParser.ih: -------------------------------------------------------------------------------- 1 | // Include this file in the sources of the class MyParser. 2 | 3 | // $insert class.h 4 | #include "MyParser.h" 5 | 6 | // Add below here any includes etc. that are only 7 | // required for the compilation of MyParser's sources. 8 | 9 | 10 | 11 | // UN-comment the next using-declaration if you want to use 12 | // symbols from the namespace std without specifying std:: 13 | using namespace std; 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.NEW/MyScanner.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_MYSCANNER_H_ 2 | #define _INCLUDED_MYSCANNER_H_ 3 | 4 | #if ! defined(_SKIP_YYFLEXLEXER_) && ! defined(_SYSINC_FLEXLEXER_H_) 5 | #include 6 | #define _SYSINC_FLEXLEXER_H_ 7 | #endif 8 | 9 | class MyScanner: public yyFlexLexer 10 | { 11 | public: 12 | int yylex(); 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.NEW/make: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if [ "$1" == "clean" ] ; then 5 | rm -f parse.cc MyParserbase.h a.out 6 | else 7 | bisonc++ -V MyParser.y || exit 1 8 | 9 | flex -o MyScanner.cc MyScanner.l 10 | g++ -Wall *.cc 11 | fi 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.NEW/test.txt: -------------------------------------------------------------------------------- 1 | 1+2+3+4 2 | -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.NEW/test2.txt: -------------------------------------------------------------------------------- 1 | (TRUE OR FALSE) AND FALSE -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.ORG/FlexLexer.h: -------------------------------------------------------------------------------- 1 | ../bison++Example.NEW/FlexLexer.h -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.ORG/Makefile: -------------------------------------------------------------------------------- 1 | ../bison++Example.NEW/Makefile -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.ORG/test.txt: -------------------------------------------------------------------------------- 1 | ../bison++Example.NEW/test.txt -------------------------------------------------------------------------------- /bisonc++/documentation/demos/bison++Example.ORG/test2.txt: -------------------------------------------------------------------------------- 1 | ../bison++Example.NEW/test2.txt -------------------------------------------------------------------------------- /bisonc++/documentation/demos/manual: -------------------------------------------------------------------------------- 1 | ../manual/examples -------------------------------------------------------------------------------- /bisonc++/documentation/man/calculator/README: -------------------------------------------------------------------------------- 1 | Run `build clean' to cleanup, `build demo' to create the program. 2 | -------------------------------------------------------------------------------- /bisonc++/documentation/man/calculator/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $1 in 4 | (clean) 5 | rm -rf scanner/lex.cc scanner/scannerbase.h calculator parser/parse.* 6 | ;; 7 | (demo) 8 | cd parser 9 | bisonc++ grammar 10 | cd ../scanner 11 | flexc++ lexer 12 | cd .. 13 | g++ --std=c++11 -Wall -o calculator *.cc */*.cc 14 | ;; 15 | (*) 16 | echo "$0 [clean|demo] to clean or build the demo program" 17 | ;; 18 | esac 19 | -------------------------------------------------------------------------------- /bisonc++/documentation/man/calculator/main.cc: -------------------------------------------------------------------------------- 1 | #include "parser/parser.h" 2 | 3 | int main() 4 | { 5 | Parser calculator; 6 | return calculator.parse(); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/man/calculator/scanner/lexer: -------------------------------------------------------------------------------- 1 | ../../../regression/calculator/scanner/lexer -------------------------------------------------------------------------------- /bisonc++/documentation/man/calculator/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | 3 | #include "../parser/parserbase.h" 4 | 5 | // end of scanner.ih 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/man/options.yodl: -------------------------------------------------------------------------------- 1 | ../manual/invoking/options.yo -------------------------------------------------------------------------------- /bisonc++/documentation/man/seealso.yo: -------------------------------------------------------------------------------- 1 | bf(bison)(1), bf(bison++)(1), 2 | SYMBOLVALUE(manalso), 3 | bf(bison.info) (using texinfo), 4 | bf(flexc++)(1), 5 | bf(https://fbb-git.github.io/bisoncpp/) 6 | 7 | Lakos, J. (2001) bf(Large Scale C++ Software Design), Addison Wesley.nl() 8 | Aho, A.V., Sethi, R., Ullman, J.D. (1986) bf(Compilers), Addison Wesley. 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/demos/Parser.ih: -------------------------------------------------------------------------------- 1 | // Include this file in the sources of the class Parser. 2 | 3 | // $insert class.h 4 | #include "Parser.h" 5 | 6 | // Add below here any includes etc. that are only 7 | // required for the compilation of Parser's sources. 8 | 9 | 10 | 11 | // UN-comment the next using-declaration if you want to use 12 | // symbols from the namespace std without specifying std:: 13 | //using namespace std; 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/demos/dangling: -------------------------------------------------------------------------------- 1 | %token IF ELSE VAR 2 | 3 | %% 4 | 5 | stmt: 6 | VAR ';' 7 | | 8 | IF '(' VAR ')' stmt 9 | | 10 | IF '(' VAR ')' stmt ELSE stmt 11 | ; 12 | 13 | 14 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/demos/mandayam: -------------------------------------------------------------------------------- 1 | %debug 2 | 3 | %token ID 4 | 5 | %left '+' '-' 6 | %left '*' '/' 7 | %right UNARY 8 | 9 | %% 10 | 11 | expr: 12 | expr '+' term 13 | | expr '-' term 14 | | term 15 | ; 16 | 17 | term: 18 | term '*' primary 19 | | term '/' primary 20 | | primary 21 | ; 22 | 23 | primary: 24 | '-' expr %prec UNARY 25 | | '+' expr %prec UNARY 26 | | ID 27 | ; 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/demos/noshiftreduce: -------------------------------------------------------------------------------- 1 | %token ID 2 | %left '*' 3 | %right '-' 4 | 5 | %% 6 | 7 | term: 8 | term '*' term 9 | | 10 | ID 11 | | 12 | '-' term 13 | ; 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/demos/notpeculiar: -------------------------------------------------------------------------------- 1 | %token ID 2 | %left '-' 3 | %left '*' 4 | %right UNARY 5 | 6 | %% 7 | 8 | expr: 9 | expr '-' expr 10 | | 11 | expr '*' expr 12 | | 13 | '-' expr %prec UNARY 14 | | 15 | ID 16 | ; 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/demos/peculiar: -------------------------------------------------------------------------------- 1 | %token ID 2 | %left '-' 3 | %left '*' 4 | %right UNARY 5 | 6 | %% 7 | 8 | expr: 9 | expr '-' term 10 | | 11 | term 12 | ; 13 | 14 | term: 15 | term '*' factor 16 | | 17 | factor 18 | ; 19 | 20 | factor: 21 | '-' expr %prec UNARY 22 | | 23 | ID 24 | ; 25 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/example/demo.cc: -------------------------------------------------------------------------------- 1 | #include "Parser.h" 2 | 3 | int main() 4 | { 5 | Parser parser; 6 | 7 | parser.parse(); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/example/grammar: -------------------------------------------------------------------------------- 1 | %token NR 2 | 3 | %left '+' 4 | 5 | %% 6 | 7 | start: 8 | start expr 9 | | 10 | // empty 11 | ; 12 | 13 | expr: 14 | NR 15 | | 16 | expr '+' expr 17 | ; 18 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/algorithm/precedence.yo: -------------------------------------------------------------------------------- 1 | Shift/reduce conflicts are frequently encountered in grammars specifying rules 2 | of arithmetic expressions. Here shifting is not always the preferred 3 | resolution; the b() directives for operator precedence allow you to specify 4 | when to shift and when to reduce. How and when to do so is discussed next. 5 | 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/concepts/intro.yo: -------------------------------------------------------------------------------- 1 | This chapter introduces many of the basic concepts without which the details 2 | of b() do not make sense. If you do not already know how to use 3 | b(), bison++ or bison, it is advised to start by reading this chapter 4 | carefully. 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/conditions.yo: -------------------------------------------------------------------------------- 1 | includefile(conditions/intro.yo) 2 | 3 | sect(The `GNU General Public License' (GPL)) 4 | includefile(conditions/gpl.yo) 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/conditions/gpl.yo: -------------------------------------------------------------------------------- 1 | The text of the em(GNU General Public License) (GPL) is frequently found in 2 | files named tt(COPYING). On em(Debian) systems the GPL may be found in the 3 | file tt(/usr/share/common-licenses/GPL). 4 | 5 | The GPL is shown below: 6 | 7 | verbinclude(/usr/share/common-licenses/GPL) 8 | 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/conditions/intro.yo: -------------------------------------------------------------------------------- 1 | B() may be used according to the em(GNU General Public License) (GPL). In 2 | short, this implies that everybody is allowed to use tt(b()) and its generated 3 | software in any program he/she is developing. 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/calc/build: -------------------------------------------------------------------------------- 1 | ../rpn/build -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/calc/main.cc: -------------------------------------------------------------------------------- 1 | ../rpn/main.cc -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/calc/main.ih: -------------------------------------------------------------------------------- 1 | ../rpn/main.ih -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/calc/parser/lex.cc: -------------------------------------------------------------------------------- 1 | ../../rpn/parser/lex.cc -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/errorcalc/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $1 in 4 | (clean) 5 | rm parser/[pP]arse* calc 6 | ;; 7 | (calc) 8 | cd parser 9 | bisonc++ -V -l grammar 10 | 11 | cd .. 12 | g++ -Wall -o calc *.cc */*.cc 13 | ;; 14 | (*) 15 | echo "$0 [clean|calc] to clean or build the calc program" 16 | ;; 17 | esac 18 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/errorcalc/calc.cc: -------------------------------------------------------------------------------- 1 | /* 2 | calc.cc 3 | */ 4 | 5 | #include "calc.h" 6 | 7 | int main() 8 | { 9 | Parser parser; 10 | 11 | parser.parse(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/errorcalc/calc.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_CALC_H_ 2 | #define _INCLUDED_CALC_H_ 3 | 4 | #include 5 | 6 | #include "parser/Parser.h" 7 | 8 | using namespace std; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/errorcalc/parser/Parser.ih: -------------------------------------------------------------------------------- 1 | // Include this file in the sources of the class Parser. 2 | 3 | // $insert class.h 4 | #include "Parser.h" 5 | 6 | // Add below here any includes etc. that are only 7 | // required for the compilation of Parser's sources. 8 | 9 | 10 | 11 | // UN-comment the next using-declaration if you want to use 12 | // symbols from the namespace std without specifying std:: 13 | //using namespace std; 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/mfcalc/main.cc: -------------------------------------------------------------------------------- 1 | ../rpn/main.cc -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/mfcalc/main.ih: -------------------------------------------------------------------------------- 1 | ../rpn/main.ih -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/mfcalc/parser/internalheader.ih: -------------------------------------------------------------------------------- 1 | // Include this file in the sources of the class Parser. 2 | 3 | // $insert class.h 4 | #include "Parser.h" 5 | 6 | // Add below here any includes etc. that are only 7 | // required for the compilation of Parser's sources. 8 | #include 9 | 10 | // UN-comment the next using-declaration if you want to use 11 | // symbols from the namespace std without specifying std:: 12 | using namespace std; 13 | 14 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/mfgrammar.yo: -------------------------------------------------------------------------------- 1 | Here are the grammar rules for the multi-function calculator. Most of them are 2 | copied directly from tt(calc). Three rules, mentioning tt(VAR) or 3 | tt(FNCT), are new: 4 | verbinclude(mfcalc/parser/grammar.rules) 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/rpn.yo: -------------------------------------------------------------------------------- 1 | The first example is about a simple double-precision reverse polish notation 2 | calculator (a calculator using postfix operators). This example provides a 3 | good starting point, since operator precedence is not an issue. The second 4 | example illustrates how operator precedence is handled. 5 | 6 | All sources for this calculator are found in the 7 | url(demos/rpn/)(demos/rpn/index.html) directory. 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/rpn/index.yo: -------------------------------------------------------------------------------- 1 | mailto(f.b.brokken@rug.nl) 2 | 3 | notableofcontents() 4 | 5 | htmlbodyopt(text)(#27408B) 6 | htmlbodyopt(bgcolor)(#FFFAF0) 7 | 8 | affiliation() 9 | article(Overview of rpn files)()() 10 | 11 | itemization( 12 | it() lurl(build) 13 | it() lurl(main.cc) 14 | it() lurl(main.ih) 15 | it() lurl(parser/grammar) 16 | it() lurl(parser/lex.cc) 17 | it() lurl(parser/Parser.ih) 18 | ) 19 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/rpn/main.cc: -------------------------------------------------------------------------------- 1 | #include "main.ih" 2 | 3 | int main() 4 | { 5 | Parser parser; 6 | 7 | parser.parse(); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/rpn/main.ih: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_MAIN_H_ 2 | #define _INCLUDED_MAIN_H_ 3 | 4 | #include 5 | 6 | #include "parser/Parser.h" 7 | 8 | using namespace std; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/demos/rpnmain.yo: -------------------------------------------------------------------------------- 1 | In keeping with the spirit of this example, the calcuator's 2 | tt(main) function is a very small one. It 3 | constructs a parser object and then calls its parsing function to 4 | start the calculator: 5 | verbinclude(rpn/main.cc) 6 | 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/errorverbose.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%error-verbose) 2 | 3 | The parser's state stack is dumped to the standard error stream when an 4 | error is detected by the tt(parse) member function. After calling 5 | tt(error) the stack is dumped from the top of the stack (highest 6 | offset) down to its bottom (offset 0). Each stack element is prefixed by the 7 | stack element's index. 8 | 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/filenames.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%filenames) tt(filename) 2 | 3 | tt(Filename) is a generic filename, used for all header files generated 4 | by bic(). 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/flex.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%flex) nl() 2 | 3 | When provided, the scanner matched text function is called as 4 | tt(d_scanner.YYText()), and the scanner token function is called as 5 | tt(d_scanner.yylex()). This directive is only interpreted if the tt(%scanner) 6 | directive is also provided. 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/locstruct.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%locationstruct) tt(struct-definition) 2 | 3 | Defines the organization of the location-struct data type bf(LTYPE_). This 4 | struct should be specified analogously to the way the parser's stacktype is 5 | defined using bf(%union) (see below). The location struct type is named 6 | bf(LTYPE_). If neither bf(locationstruct) nor bf(LTYPE_) is specified, the 7 | default link(LTYPE_)(LSPNEEDED) struct is used. 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/parse.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%parsefun-source) tt(filename) 2 | 3 | tt(Filename) defines the name of the source file to contain the parser member 4 | function tt(parse). Defaults to tt(parse.cc). 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/print.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%print-tokens) 2 | 3 | The tt(%print-tokens) directive provides an implementation of the Parser 4 | class's tt(print_) function displaying the current token value and the text 5 | matched by the lexical scanner as received by the generated tt(parse) 6 | function. 7 | 8 | The tt(print_) function is also implemented if the tt(--print) 9 | command-line option is provided. 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/stackexpansion.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%stack-expansion) tt(size) 2 | 3 | Defines the number of elements to be added to the generated parser's semantic 4 | value stack when it must be enlarged. By default 10 elements are added to the 5 | stack. This option/directive is interpreted only once, and only if tt(size) at 6 | least equals the default stack expansion size of 10. 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/targetdir.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%target-directory) tt(pathname) 2 | 3 | tt(Pathname) defines the directory where generated files should be written. 4 | By default this is the directory where bic() is called. 5 | 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/directives/threadsafe.yo: -------------------------------------------------------------------------------- 1 | Syntax: bf(%thread-safe) 2 | 3 | Only used with polymorphic semantic values, and then only required when the 4 | same parser is used in multiple threads: it ensures that each thread's 5 | polymorphic code only accesses the errors counter (i.e., tt(d_nErrors_)) 6 | of its own parser. 7 | 8 | Instead of using the tt(%thread-safe) directive the tt(--thread-safe) option 9 | can also be used. 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/error.yo: -------------------------------------------------------------------------------- 1 | includefile(error/intro.yo) 2 | 3 | sect(Syntactic Error Recovery) 4 | includefile(error/syntactical.yo) 5 | 6 | subsect(Error Recovery) 7 | includefile(error/recovery.yo) 8 | 9 | sect(Semantic Error Recovery) 10 | includefile(error/semantical.yo) 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/error/errordemo/input: -------------------------------------------------------------------------------- 1 | a 2 | 3+a 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/error/errordemo/main.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "parser/parser.h" 6 | 7 | int main(int argc, char **argv) 8 | { 9 | Parser parser; 10 | 11 | parser.parse(); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/error/errordemo/parser/grammar: -------------------------------------------------------------------------------- 1 | %filenames parser 2 | %debug 3 | 4 | %token NR 5 | 6 | %left '+' 7 | 8 | %% 9 | 10 | start: 11 | start expr 12 | | 13 | // empty 14 | ; 15 | 16 | expr: 17 | error 18 | | 19 | NR 20 | | 21 | expr '+' expr 22 | ; 23 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/error/errordemo/parser/lex.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | int Parser::lex() 4 | { 5 | std::string word; 6 | 7 | std::cin >> word; 8 | if (std::cin.eof()) 9 | return 0; 10 | if (isdigit(word[0])) 11 | return NR; 12 | 13 | return word[0]; 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/gramcons.yo: -------------------------------------------------------------------------------- 1 | In the following sections several basic building blocks for writing grammars 2 | are presented in their prototypical forms. When these building blocks are 3 | used to write a grammar, the resulting grammar is usually accepted by 4 | b(). Moreover, these building blocks are frequently encountered in 5 | programming languages. When designing your own grammar, try to stick as 6 | closely as possible to the following basic forms. 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/poly/main.cc: -------------------------------------------------------------------------------- 1 | #include "main.ih" 2 | 3 | int main() 4 | { 5 | Parser parser; 6 | parser.parse(); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/poly/main.ih: -------------------------------------------------------------------------------- 1 | #include "parser/parser.h" 2 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/poly/parser/intvalue.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | int Parser::intValue() const 4 | { 5 | istringstream in(d_scanner.matched()); 6 | int ret; 7 | 8 | in >> ret; // succeeds, as lex() just returned 'NR' 9 | return ret; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/poly/parser/process.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::process(STYPE_ const &semVal) const 4 | { 5 | if (semVal.tag() == Tag_::INT) 6 | cout << "Saw an int-value: " << semVal.get() << '\n'; 7 | else 8 | cout << "Saw text: " << semVal.get() << '\n'; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/poly/scanner/lexer: -------------------------------------------------------------------------------- 1 | %interactive 2 | %filenames scanner 3 | 4 | %% 5 | 6 | [ \t]+ // skip white space 7 | 8 | [0-9]+ return Parser::INT; 9 | 10 | [a-zA-Z_][a-zA-Z0-9_]* return Parser::IDENTIFIER; 11 | 12 | .|\n return matched()[0]; 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/poly/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/parserbase.h" 3 | 4 | // end of scanner.hh 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/grammar/scanner.yo: -------------------------------------------------------------------------------- 1 | The scanner recognizes input patterns, and returns Parser tokens (e.g., 2 | Parser::INT) matching the recognized input. 3 | 4 | It is easily created by 5 | bf(flexc++)(1) processing the following simple specification file. 6 | verbinclude(poly/scanner/lexer) 7 | 8 | The reader may refer to bf(flexc++)(1) documentation for details about 9 | bf(flexc++)(1) specification files. 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/invoking.yo: -------------------------------------------------------------------------------- 1 | lsect(OPTIONS)(Bisonc++ options) 2 | includefile(invoking/options.yo) 3 | 4 | sect(Bisonc++ usage) 5 | includefile(invoking/usage.yo) 6 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/invoking/usage.yo: -------------------------------------------------------------------------------- 1 | When b() is called without any arguments it generates the following usage 2 | information: 3 | COMMENT(The usage file should be removed by cleanup, in order to make sure 4 | that it is created using the latest bisonc++ version) 5 | 6 | TYPEOUT( 7 | If a message about a failing NOEXPANDINCLUDE is shown, create the file 8 | `usage' in documentation/manual/invoking containing the latest usage info 9 | ) 10 | verbinclude(usage.txt) 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/manual/version.yo: -------------------------------------------------------------------------------- 1 | SUBST(DOCVERSION)(0.98.003) 2 | SUBST(YEARS)(2005) 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/aho4.42/doc: -------------------------------------------------------------------------------- 1 | This grammar, given by AHO et al as grammar 4.42 (p. 231), has 7 states, no 2 | shift-reduce or reduce-reduce conflict. 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/aho4.42/parser/bgram: -------------------------------------------------------------------------------- 1 | /* AHO et al, example 4.42 */ 2 | 3 | %token c d 4 | 5 | %% 6 | 7 | S: 8 | C C 9 | ; 10 | 11 | C: 12 | c C 13 | | 14 | d 15 | ; 16 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/aho4.42/parser/grammar: -------------------------------------------------------------------------------- 1 | /* AHO et al, example 4.42 */ 2 | 3 | %default-actions quiet 4 | %token c d 5 | 6 | %% 7 | 8 | S: 9 | C C 10 | ; 11 | 12 | C: 13 | c C 14 | | 15 | d 16 | ; 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/aho4.46/doc: -------------------------------------------------------------------------------- 1 | This grammar, given by AHO et al as grammar 4.46 (p. 241), has 10 states, no 2 | shift-reduce or reduce-reduce conflict. 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/aho4.46/parser/grammar: -------------------------------------------------------------------------------- 1 | /* AHO et al, example 4.46 */ 2 | 3 | %token i 4 | 5 | %% 6 | 7 | S: L '=' R ; 8 | 9 | S: R ; 10 | 11 | L: '*' R ; 12 | 13 | L: i ; 14 | 15 | R: L ; 16 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/_data.cc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/parser/_display1.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::display(int x) 4 | { 5 | cerr << "RPN: " << d_rpn.str() << endl; 6 | cerr << "int: " << x << endl; 7 | d_rpn.str(string()); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/parser/_display2.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::display(double x) 4 | { 5 | cerr << "RPN: " << d_rpn.str() << endl; 6 | cerr << "double: " << x << endl; 7 | d_rpn.str(string()); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/parser/_done.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::done() const 4 | { 5 | cout << "Good bye\n"; 6 | ACCEPT(); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/parser/_reset.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::reset() 4 | { 5 | d_rpn.clear(); 6 | d_rpn.str(string()); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/scanner/lexer: -------------------------------------------------------------------------------- 1 | %filenames scanner 2 | %interactive 3 | 4 | %% 5 | 6 | [ \t] ; 7 | [0-9]+ return Parser::INT; 8 | 9 | "."[0-9]* | 10 | [0-9]+("."[0-9]*)? return Parser::DOUBLE; 11 | 12 | .|\n return matched()[0]; 13 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/annotations/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | ../../simplecalc/scanner/scanner.ih -------------------------------------------------------------------------------- /bisonc++/documentation/regression/calculator/doc: -------------------------------------------------------------------------------- 1 | This is the regression installation of the calculator also found in 2 | documentation/man. The program implements a simple calculator, accepting unary 3 | and binary + and -, binary * and /, and nested expressions, using integral 4 | operands. 5 | 6 | To end the program, enter: q 7 | 8 | Errors are handled by skipping all information until the next end of line. 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/calculator/scanner/lexer: -------------------------------------------------------------------------------- 1 | %interactive 2 | %filenames scanner 3 | 4 | %% 5 | 6 | [ \t]+ // skip white space 7 | 8 | \n return Parser::EOLN; 9 | 10 | [0-9]+ return Parser::NUMBER; 11 | 12 | . return matched()[0]; 13 | 14 | 15 | %% 16 | 17 | 18 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/calculator/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/parserbase.h" 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/conflicts/parser/bgram: -------------------------------------------------------------------------------- 1 | %token i 2 | %% 3 | 4 | E: 5 | i 6 | | 7 | i 8 | | 9 | E '+' E 10 | | 11 | E '*' E 12 | ; 13 | 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/conflicts/parser/grammar: -------------------------------------------------------------------------------- 1 | %token i 2 | %default-actions quiet 3 | 4 | %% 5 | 6 | E: 7 | i 8 | | 9 | i 10 | | 11 | E '+' E 12 | | 13 | E '*' E 14 | ; 15 | 16 | 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/danglingelse/doc: -------------------------------------------------------------------------------- 1 | The well-known dangling-else problem. This grammar shows one S/R conflict, 2 | which is solved as SHIFT, using the default S/R conflict resolution method. 3 | 4 | By using %expect 1 the S/R warning can be prevented 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/danglingelse/parser/bgram: -------------------------------------------------------------------------------- 1 | %token EXPR ELSE 2 | 3 | %% 4 | 5 | stmnt: 6 | EXPR stmnt 7 | | 8 | EXPR stmnt ELSE stmnt 9 | | 10 | EXPR ';' 11 | ; 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/danglingelse/parser/grammar: -------------------------------------------------------------------------------- 1 | %token EXPR ELSE 2 | %default-actions quiet 3 | 4 | %% 5 | 6 | stmnt: 7 | EXPR stmnt 8 | | 9 | EXPR stmnt ELSE stmnt 10 | | 11 | EXPR ';' 12 | ; 13 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/duplicate/parser/grammar: -------------------------------------------------------------------------------- 1 | %token NR 2 | 3 | %% 4 | 5 | start: 6 | NR 7 | | 8 | NR 9 | ; 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/error/doc: -------------------------------------------------------------------------------- 1 | This example offers a demonstration of error-handling. 2 | 3 | Enter lines, each containing one integral value. Use ^C to end the program 4 | other line content should result in a `syntax error' 5 | blanks and tabs are ignored (and thus OK) 6 | 7 | An empty line, however, *will* result in a `syntax error' 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/error/parser/bgram: -------------------------------------------------------------------------------- 1 | 2 | %token NR 3 | 4 | %% 5 | 6 | lines: 7 | lines line 8 | | 9 | line 10 | ; 11 | 12 | line: 13 | NR '\n' 14 | | 15 | error '\n' 16 | ; 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/error/parser/grammar: -------------------------------------------------------------------------------- 1 | %default-actions quiet 2 | 3 | %scanner ../scanner/scanner.h 4 | %token NR 5 | %print-tokens 6 | 7 | %% 8 | 9 | lines: 10 | lines line 11 | | 12 | line 13 | ; 14 | 15 | line: 16 | NR '\n' 17 | { 18 | std::cout << " OK\n"; 19 | } 20 | | 21 | error '\n' 22 | { 23 | std::cout << " ERROR\n"; 24 | } 25 | ; 26 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/error/scanner/lexer: -------------------------------------------------------------------------------- 1 | %filenames scanner 2 | %interactive 3 | 4 | %% 5 | 6 | [ \t]+ // Often used: skip white space 7 | 8 | [0-9]+ return Parser::NR; 9 | 10 | .|\n return matched()[0]; 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/error/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/Parserbase.h" 3 | 4 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/doc: -------------------------------------------------------------------------------- 1 | A more complex calculator offering types (char, int, double) and functions. 2 | Expressions and commands must be entered on lines. 3 | 4 | Compiling this program may take a little while. 5 | 6 | To end the program, enter: quit 7 | 8 | When the program has started the command help 9 | will provide an overview of its possibilities. 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_a2x.h: -------------------------------------------------------------------------------- 1 | ../../annotations/_a2x.h -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_angle.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | double Parser::angle(double radians) // convert radians to angle type 4 | { 5 | return 6 | d_angleType == RADIANS ? radians : 7 | d_angleType == DEG360 ? 180 / M_PI * radians : 8 | 200 / M_PI * radians; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_display.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::display(RuleValue const &e) 4 | { 5 | if (!d_error) 6 | cout << rvalue(e) << '\n'; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_div0.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::div0(RuleValue const &vl, RuleValue const &vr) 4 | { 5 | error( 6 | abs(vl.asDouble()) > 1e100 * abs(vr.asDouble()), 7 | "Number too large" 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_error.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::error() 4 | { 5 | if (!d_error) 6 | cout << "At " << d_scanner.matched() << ": error in expression.\n" 7 | "(" << static_cast(d_scanner.matched()[0]) << ")\n"; 8 | d_error = true; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_error2.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::error(bool ifTrue, char const *msg) 4 | { 5 | if (d_error || not ifTrue) 6 | return; 7 | 8 | d_error = true; 9 | cout << msg << '\n'; 10 | ERROR(); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_firstarg.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | RuleValue Parser::firstArg(RuleValue &rv) 4 | { 5 | return RuleValue(new vector(1, rv)); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_integral.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::integral(RuleValue const &v1) 4 | { 5 | error 6 | ( 7 | v1.tag() != RuleValue::CHAR && v1.tag() != RuleValue::INT, 8 | "Non-integral operand on integral operator" 9 | ); 10 | } 11 | 12 | void Parser::integral(RuleValue const &v1, RuleValue const &v2) 13 | { 14 | integral(v1); 15 | integral(v2); 16 | } 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_list.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::list() 4 | { 5 | if (!d_symtab.size()) 6 | cout << "No variables\n"; 7 | else 8 | for_each(d_symtab.begin(), d_symtab.end(), ShowVar(d_value)); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_lvalue.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | RuleValue &Parser::lvalue(RuleValue &e) 4 | { 5 | return e.tag() == RuleValue::VARIABLE ? 6 | d_value[e.varIdx()] 7 | : 8 | e; 9 | } 10 | 11 | RuleValue const &Parser::rvalue(RuleValue const &e) const 12 | { 13 | return e.tag() == RuleValue::VARIABLE ? 14 | d_value[e.varIdx()] 15 | : 16 | e; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_mathconst.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | RuleValue Parser::mathConst() 4 | { 5 | string c = d_scanner.matched(); 6 | 7 | return RuleValue( 8 | c == "E" ? M_E : 9 | M_PI 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_prompt.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::prompt() 4 | { 5 | cout << "? " << flush; 6 | d_error = false; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_radians.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | double Parser::radians(double angle) // convert angles to radians 4 | { 5 | return 6 | d_angleType == RADIANS ? angle : 7 | d_angleType == DEG360 ? M_PI / 180 * angle : 8 | M_PI / 200 * angle; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_setdatatype.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | RuleValue Parser::setDataType() 4 | { 5 | string type = d_scanner.matched(); 6 | return 7 | type == "char" ? RuleValue(RuleValue::CHAR) : 8 | type == "int" ? RuleValue(RuleValue::INT) : 9 | /* double */ RuleValue(RuleValue::DOUBLE); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_showvarfun.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::ShowVar::operator()(SymbolMap::value_type &v) 4 | { 5 | cout << v.first << ": " << d_value[v.second] << 6 | " (" << d_value[v.second].tagName() << ")" << endl; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/parser/_storeident.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::storeIdent() 4 | { 5 | d_lastIdent = d_scanner.matched(); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_copy.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | void RuleValue::copy(RuleValue const &other) 4 | { 5 | d_tag = other.d_tag; 6 | if (d_tag != ARG_VECTOR) 7 | d_value = other.d_value; 8 | else 9 | d_value.args = new std::vector(*other.d_value.args); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_data.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | char const *RuleValue::s_tagName[] = 4 | { 5 | "error", // something failed. 6 | "char", 7 | "int", 8 | "double", 9 | "variable", 10 | "function", 11 | "argsector", 12 | }; 13 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_function.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue::Function::Function(double (*ptr)(double), Type t) 4 | : 5 | d_type(t), 6 | d_arity(1) 7 | { 8 | d_ptr.unary = ptr; 9 | } 10 | 11 | RuleValue::Function::Function(double (*ptr)(double, double)) 12 | : 13 | d_type(DOUBLE_IN_DOUBLE_OUT), 14 | d_arity(2) 15 | { 16 | d_ptr.binary = ptr; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoraand.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | // Here, the parser makes sure that we're already using integral values 4 | 5 | RuleValue &RuleValue::operator&=(RuleValue const &other) 6 | { 7 | d_value.i = asInt() & other.asInt(); 8 | d_tag = INT; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoradda.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue &RuleValue::operator+=(RuleValue const &other) 4 | { 5 | if (d_tag == DOUBLE || other.d_tag == DOUBLE) 6 | { 7 | d_value.d = asDouble() + other.asDouble(); 8 | d_tag = DOUBLE; 9 | } 10 | else 11 | { 12 | d_value.i = asInt() + other.asInt(); 13 | d_tag = INT; 14 | } 15 | return *this; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoradiv.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue &RuleValue::operator/=(RuleValue const &other) 4 | { 5 | if (d_tag == DOUBLE || other.d_tag == DOUBLE) 6 | { 7 | d_value.d = asDouble() / other.asDouble(); 8 | d_tag = DOUBLE; 9 | } 10 | else 11 | { 12 | d_value.i = asInt() / other.asInt(); 13 | d_tag = INT; 14 | } 15 | return *this; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoralshift.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | // Here, the parser makes sure that we're already using integral values 4 | 5 | RuleValue &RuleValue::operator<<=(RuleValue const &other) 6 | { 7 | d_value.i = asInt() << other.asInt(); 8 | d_tag = INT; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoramod.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | // Here, the parser makes sure that we're already using integral values 4 | 5 | RuleValue &RuleValue::operator%=(RuleValue const &other) 6 | { 7 | d_value.i = asInt() % other.asInt(); 8 | d_tag = INT; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoramul.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue &RuleValue::operator*=(RuleValue const &other) 4 | { 5 | if (d_tag == DOUBLE || other.d_tag == DOUBLE) 6 | { 7 | d_value.d = asDouble() * other.asDouble(); 8 | d_tag = DOUBLE; 9 | } 10 | else 11 | { 12 | d_value.i = asInt() * other.asInt(); 13 | d_tag = INT; 14 | } 15 | return *this; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoraor.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | // Here, the parser makes sure that we're already using integral values 4 | 5 | RuleValue &RuleValue::operator|=(RuleValue const &other) 6 | { 7 | d_value.i = asInt() | other.asInt(); 8 | d_tag = INT; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatorarshift.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | // Here, the parser makes sure that we're already using integral values 4 | 5 | RuleValue &RuleValue::operator>>=(RuleValue const &other) 6 | { 7 | d_value.i = asInt() >> other.asInt(); 8 | d_tag = INT; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatorassign.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue &RuleValue::operator=(RuleValue const &other) 4 | { 5 | if (this != &other) 6 | { 7 | destroy(); 8 | copy(other); 9 | } 10 | return *this; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatorasub.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue &RuleValue::operator-=(RuleValue const &other) 4 | { 5 | if (d_tag == DOUBLE || other.d_tag == DOUBLE) 6 | { 7 | d_value.d = asDouble() - other.asDouble(); 8 | d_tag = DOUBLE; 9 | } 10 | else 11 | { 12 | d_value.i = asInt() - other.asInt(); 13 | d_tag = INT; 14 | } 15 | return *this; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatoraxor.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | // Here, the parser makes sure that we're already using integral values 4 | 5 | RuleValue &RuleValue::operator^=(RuleValue const &other) 6 | { 7 | d_value.i = asInt() ^ other.asInt(); 8 | d_tag = INT; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | namespace std 4 | { 5 | ostream &operator<<(ostream &out, RuleValue const &t) 6 | { 7 | switch (t.tag()) 8 | { 9 | case RuleValue::CHAR: 10 | return out << t.asChar(); 11 | 12 | case RuleValue::INT: 13 | return out << t.asInt(); 14 | 15 | default: 16 | return out << t.asDouble(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_operatornegate.cc: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.ih" 2 | 3 | RuleValue RuleValue::operator-() const 4 | { 5 | switch (d_tag) 6 | { 7 | case CHAR: 8 | return RuleValue(-asChar()); 9 | 10 | case INT: 11 | return RuleValue(-asInt()); 12 | 13 | default: 14 | return RuleValue(-asDouble()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/rulevalue/_rulevalue.ih: -------------------------------------------------------------------------------- 1 | #include "_rulevalue.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/fun/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/parserbase.h" 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/icmake1/doc: -------------------------------------------------------------------------------- 1 | A highly reduced grammar derived from icmake V 7.00's grammar producing 2 | spurious RR conflicts with bisonc++ before version 1.5.0 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/icmake1/parser/bgram: -------------------------------------------------------------------------------- 1 | %token X 2 | 3 | %% 4 | 5 | run: 6 | one 7 | | 8 | two X 9 | ; 10 | 11 | one: 12 | ; 13 | 14 | two: 15 | one 16 | ; 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/icmake1/parser/grammar: -------------------------------------------------------------------------------- 1 | %token X 2 | %default-actions quiet 3 | 4 | %% 5 | 6 | run: 7 | one 8 | | 9 | two X 10 | ; 11 | 12 | one: 13 | ; 14 | 15 | two: 16 | one 17 | ; 18 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/icmake2/doc: -------------------------------------------------------------------------------- 1 | The full icmake V 7.00 grammar, on which bisonc++ before V 1.5.0 choked. 2 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/location/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "../parser/Parserbase.h" 2 | #include "scanner.h" 3 | 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/naive/doc: -------------------------------------------------------------------------------- 1 | This is a parser for a simple series of ;-separated integral numbers. Any 2 | error input is skipped until the next ;-token, after which another number is 3 | expected. 4 | 5 | To end the program, press ctrl-d 6 | 7 | To view the parser's debugging output, start the program with an argument, 8 | e.g., demo x 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/naive/parser/bgram: -------------------------------------------------------------------------------- 1 | 2 | %token NR 3 | 4 | %% 5 | 6 | lines: 7 | lines expr ';' 8 | | 9 | /* empty */ 10 | ; 11 | 12 | expr: 13 | NR 14 | | 15 | error 16 | ; 17 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/naive/parser/grammar: -------------------------------------------------------------------------------- 1 | %default-actions quiet 2 | %scanner ../scanner/scanner.h 3 | 4 | %token NR 5 | 6 | %% 7 | 8 | lines: 9 | lines expr ';' 10 | | 11 | // empty 12 | ; 13 | 14 | expr: 15 | NR 16 | { 17 | std::cout << d_scanner.matched() << '\n'; 18 | } 19 | | 20 | error 21 | { 22 | std::cout << "oops...\n"; 23 | } 24 | ; 25 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/naive/scanner/lexer: -------------------------------------------------------------------------------- 1 | %interactive 2 | %filenames scanner 3 | 4 | %% 5 | 6 | [ \t]+ // Often used: skip white space 7 | \n // same 8 | 9 | [0-9]+ return Parser::NR; 10 | 11 | . return matched()[0]; 12 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/naive/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/Parserbase.h" 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/nosentence/doc: -------------------------------------------------------------------------------- 1 | This grammar has a single left-recursive rule, so no rule reduces to 2 | `start'. Consequently, no sentences can be derived from this grammar. 3 | Here is its sole production rule: 4 | 5 | start: 6 | NR start 7 | ; 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/nosentence/parser/bgram: -------------------------------------------------------------------------------- 1 | %token NR 2 | 3 | %% 4 | 5 | start: 6 | NR start 7 | ; 8 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/nosentence/parser/grammar: -------------------------------------------------------------------------------- 1 | %token NR 2 | %default-actions quiet 3 | 4 | %% 5 | 6 | start: 7 | NR start 8 | ; 9 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/notused/doc: -------------------------------------------------------------------------------- 1 | This grammar contains 2 unused non-terminals and 2 unused terminal 2 | symbols. 3 | 4 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/notused/parser/grammar: -------------------------------------------------------------------------------- 1 | %token TOKEN_ONE TOKEN_TWO 2 | 3 | %% 4 | 5 | start: 6 | one 7 | | 8 | '+' 9 | ; 10 | 11 | one: 12 | '-' 13 | {} 14 | ; 15 | 16 | unused_one: 17 | TOKEN_ONE 18 | ; 19 | 20 | unused_two: 21 | TOKEN_TWO 22 | ; 23 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/base/base.ih: -------------------------------------------------------------------------------- 1 | #include "base.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/doc: -------------------------------------------------------------------------------- 1 | This is the original example resulting from a discussion I had with 2 | Dallas A. Clement about polymorphic semantic values. The program creates a 3 | simple parser that can be run as follows: 4 | demo < input 5 | When run as 6 | demo x < input 7 | debug output is shown, including selected semantic values on the semantic 8 | value stack. 9 | 10 | Also: see the files `dallas' and `dallas2' 11 | 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/enum/enum.ih: -------------------------------------------------------------------------------- 1 | #include "enum.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/ident/ident.ih: -------------------------------------------------------------------------------- 1 | #include "ident.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/input: -------------------------------------------------------------------------------- 1 | const abc j = xyz; 2 | 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/main.ih: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "semval/semval.h" 7 | #include "ident/ident.h" 8 | #include "enum/enum.h" 9 | 10 | #include "parser/parser.h" 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/parser/preinclude.h: -------------------------------------------------------------------------------- 1 | #include "../enum/enum.h" 2 | #include "../ident/ident.h" 3 | #include "../semval/semval.h" 4 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/polymorphic/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "../parser/parserbase.h" 2 | #include "scanner.h" 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/rr2/doc: -------------------------------------------------------------------------------- 1 | This grammar was produced by several of my students during my 2005-2006 C++ 2 | course. Bisonc++ V 0.98 did not properly recognize its two RR conflicts. 3 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/rr2/parser/bgram: -------------------------------------------------------------------------------- 1 | %token DELIM TEXT 2 | 3 | %% 4 | 5 | line: 6 | line 7 | mstring 8 | | 9 | /* empty */ 10 | ; 11 | 12 | mstring: 13 | mstring 14 | atom 15 | | 16 | atom 17 | ; 18 | 19 | atom: 20 | opt_delimiter 21 | TEXT 22 | ; 23 | 24 | opt_delimiter: 25 | opt_delimiter 26 | DELIM 27 | | 28 | /* empty */ 29 | ; 30 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/rr2/parser/grammar: -------------------------------------------------------------------------------- 1 | %token DELIM TEXT 2 | %default-actions quiet 3 | 4 | %% 5 | 6 | line: 7 | line 8 | mstring 9 | | 10 | /* empty */ 11 | ; 12 | 13 | mstring: 14 | mstring 15 | atom 16 | | 17 | atom 18 | ; 19 | 20 | atom: 21 | opt_delimiter 22 | TEXT 23 | ; 24 | 25 | opt_delimiter: 26 | opt_delimiter 27 | DELIM 28 | | 29 | /* empty */ 30 | ; 31 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/simplecalc/doc: -------------------------------------------------------------------------------- 1 | This simple calculator adds two integral values. Each expression must be 2 | terminated by =, for example: 3 | 4 | 3 + 5 = 5 | 6 | To end the program, enter q 7 | 8 | Error recovery is available. When making a syntax error the parser allows you 9 | to enter another expression -------------------------------------------------------------------------------- /bisonc++/documentation/regression/simplecalc/scanner/lexer: -------------------------------------------------------------------------------- 1 | %interactive 2 | %filenames scanner 3 | 4 | %% 5 | 6 | [[:space:]]+ // skip white space 7 | 8 | [0-9]+ return Parser::NUMBER; 9 | 10 | . return matched()[0]; 11 | -------------------------------------------------------------------------------- /bisonc++/documentation/regression/simplecalc/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/parserbase.h" 3 | 4 | -------------------------------------------------------------------------------- /bisonc++/documentation/usage/usage.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | #include "../../VERSION" 7 | 8 | char version[] = VERSION; 9 | char year[] = YEARS; 10 | 11 | #define _INCLUDED_BISONCPP_H_ 12 | #include "../../usage.cc" 13 | 14 | int main() 15 | { 16 | usage("bisonc++"); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /bisonc++/element/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "element.ih" 2 | 3 | Element::~Element() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/element/element.ih: -------------------------------------------------------------------------------- 1 | #include "element.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/element/frame: -------------------------------------------------------------------------------- 1 | #include "element.ih" 2 | 3 | Element:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/enumsolution/enumsolution.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_ENUMSOLUTION_ 2 | #define _INCLUDED_ENUMSOLUTION_ 3 | 4 | namespace Enum 5 | { 6 | enum Solution 7 | { 8 | UNDECIDED, 9 | SHIFT, 10 | REDUCE, 11 | }; 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /bisonc++/firstset/firstset.ih: -------------------------------------------------------------------------------- 1 | #include "firstset.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/firstset/firstset1.cc: -------------------------------------------------------------------------------- 1 | #include "firstset.ih" 2 | 3 | FirstSet::FirstSet(Element const *terminal) 4 | : 5 | std::set(&terminal, &terminal + 1), 6 | d_epsilon(false) 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/firstset/frame: -------------------------------------------------------------------------------- 1 | #include "firstset.ih" 2 | 3 | FirstSet::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/firstset/oinsert.cc: -------------------------------------------------------------------------------- 1 | #include "firstset.ih" 2 | 3 | 4 | ostream &FirstSet::insert(ostream &out) const 5 | { 6 | out << "{ "; 7 | // passing Element const * values 8 | copy(begin(), end(), ostream_iterator(out, " ")); 9 | 10 | if (d_epsilon) 11 | out << " "; 12 | 13 | out << "}"; 14 | 15 | return out; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/firstset/operatorplusis1.cc: -------------------------------------------------------------------------------- 1 | #include "firstset.ih" 2 | 3 | FirstSet &FirstSet::operator+=(FirstSet const &other) 4 | { 5 | *this += other.set(); 6 | d_epsilon |= other.d_epsilon; 7 | return *this; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/firstset/operatorplusis2.cc: -------------------------------------------------------------------------------- 1 | #include "firstset.ih" 2 | 3 | FirstSet &FirstSet::operator+=(std::set const &terminalSet) 4 | { 5 | Baseclass::insert(terminalSet.begin(), terminalSet.end()); 6 | 7 | return *this; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/generator/TODO: -------------------------------------------------------------------------------- 1 | @else 2 | @ 3 | 4 | 5 | 6 | 7 | Replace unordered_map by linear_map 8 | -------------------------------------------------------------------------------- /bisonc++/generator/atclassname.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | std::string const &Generator::atClassname() const 4 | { 5 | return d_options.className(); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/atelse.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::atElse(bool &accept) const 4 | { 5 | accept = not accept; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/atend.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::atEnd(bool &accept) const 4 | { 5 | accept = true; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/atltype.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | std::string const &Generator::atLtype() const 4 | { 5 | return d_options.ltype(); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/atmatchedtextfunction.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | std::string const &Generator::atMatchedTextFunction() const 4 | { 5 | return d_matchedTextFunction; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/atnamespacedclassname.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | std::string const &Generator::atNameSpacedClassname() const 4 | { 5 | return d_nameSpacedClassname; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/attokenfunction.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | std::string const &Generator::atTokenFunction() const 4 | { 5 | return d_tokenFunction; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/baseclass.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::baseClass(ostream &out) const 4 | { 5 | key(out); 6 | out << "#include \"" << filename(d_options.baseClassHeader()) << "\"\n"; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/generator/baseclasscode.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::baseClassCode(ostream &out) const 4 | { 5 | key(out); 6 | 7 | out << "d_requiredTokens_(" << d_options.requiredTokens() << ")\n" 8 | "{\n"; 9 | 10 | if (d_options.polymorphic()) 11 | out << " Meta_::t_nErrors = &d_nErrors_;\n"; 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/generator/bolat.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::bolAt(string &line, bool &accept) const 4 | { 5 | auto iter = find(line, 0, s_atBol); 6 | 7 | if (iter != s_atBol.end()) 8 | (this->*iter->function)(accept); 9 | else 10 | wmsg << "Ignoring unsupported `" << line << "' in .in file" << endl; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/generator/classh.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::classH(ostream &out) const 4 | { 5 | key(out); 6 | out << "#include \"" << filename(d_options.classHeader()) << "\"\n"; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/generator/classih.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::classIH(ostream &out) const 4 | { 5 | key(out); 6 | out << "#include \"" << 7 | filename(d_options.implementationHeader()) << "\"\n"; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/generator/debugdecl.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::debugDecl(std::ostream &out) const 4 | { 5 | if (!d_genDebug && !d_printTokens) 6 | return; 7 | 8 | key(out); 9 | 10 | insert(out, 8, "debugdecl.in"); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/generator/debugincludes.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::debugIncludes(ostream &out) const 4 | { 5 | bool verbose = d_arg.option(0, "error-verbose"); 6 | 7 | if (!d_genDebug && !verbose && !d_printTokens) 8 | return; 9 | 10 | key(out); 11 | 12 | insert(out, 0, "debugincludes.in"); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/generator/debuginit.cc: -------------------------------------------------------------------------------- 1 | //#include "generator.ih" 2 | // 3 | //void Generator::debugInit(ostream &out) const 4 | //{ 5 | //// key(out); 6 | //// out << "d_debug_(" << boolalpha << d_debug << "),\n"; 7 | //} 8 | -------------------------------------------------------------------------------- /bisonc++/generator/debuglookup.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::debugLookup(std::ostream &out) const 4 | { 5 | if (!d_genDebug) 6 | return; 7 | 8 | key(out); 9 | 10 | insert(out, 4, "debuglookup.in"); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/generator/errorverbose.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::errorVerbose(ostream &out) const 4 | { 5 | if (!d_arg.option(0, "error-verbose")) 6 | return; 7 | 8 | key(out); 9 | out << "errorVerbose_();\n"; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/generator/executeactioncases.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::executeActionCases(ostream &out) const 4 | { 5 | if (!d_genDebug) 6 | return; 7 | 8 | key(out); 9 | 10 | out << R"( 11 | if (d_actionCases_) 12 | s_out_ << "executeAction case " << production << '\n' << dflush_; 13 | )"; 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/generator/filename.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | string Generator::filename(std::string const &path) 4 | { 5 | size_t idx = path.rfind('/'); 6 | 7 | string ret(idx == string::npos ? path : path.substr(idx + 1)); 8 | 9 | return ret; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/generator/frame: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | Generator::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/generator/grep.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | bool Generator::grep(string const &fileName, string const ®ex) const 4 | { 5 | ifstream in(fileName); 6 | Pattern pattern(regex); 7 | string line; 8 | 9 | while (getline(in, line)) 10 | { 11 | if (pattern << line) 12 | return true; 13 | } 14 | 15 | return false; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/generator/idoftag.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::idOfTag(ostream &out) const 4 | { 5 | key(out); 6 | 7 | if (d_options.tagMismatches().value == Options::ON) 8 | { 9 | out << "char const *idOfTag_[] = {\n"; 10 | for (auto const &poly: d_polymorphic) 11 | out << " \"" << poly.first << "\",\n"; 12 | out << " \"\"\n" 13 | "};\n"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/generator/ifinsertstype.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ifInsertStype(bool &accept) const 4 | { 5 | accept = d_arg.option(0, "insert-stype"); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/ifltype.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ifLtype(bool &accept) const 4 | { 5 | accept = not d_options.ltype().empty(); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/ifprinttokens.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ifPrintTokens(bool &accept) const 4 | { 5 | accept = d_arg.option(0, "printtokens"); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/generator/key.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::key(ostream &out) const 4 | { 5 | out << setw(d_indent) << "" << "// $insert " << d_key << '\n' << 6 | setw(d_indent) << "" << flush; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/generator/lex.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lex(ostream &out) const 4 | { 5 | key(out); 6 | 7 | if (d_printTokens || not d_options.implementationHeader().empty()) 8 | insert(out, 0, "lex.in"); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/generator/ltype.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltype(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | insert(out, 4, "ltype.in"); 11 | } 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /bisonc++/generator/ltypeclear.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltypeClear(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << "d_locationStack.clear();\n"; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/generator/ltypedata.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltypeData(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | insert(out, 8, "ltypedata.in"); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/generator/ltypepop.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltypePop(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << "d_lsp = &d_locationStack[d_stackIdx];\n"; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/generator/ltypepush.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltypePush(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << "*(d_lsp = &d_locationStack[d_stackIdx]) = d_loc_;\n"; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/generator/ltyperesize.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltypeResize(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << "d_locationStack.resize(newSize);\n"; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/generator/ltypestack.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ltypeStack(ostream &out) const 4 | { 5 | if (!d_options.lspNeeded()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << " std::vector d_locationStack;\n" 11 | " LTYPE_ *d_lsp;\n"; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /bisonc++/generator/namespaceclose.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::namespaceClose(std::ostream &out) const 4 | { 5 | if (d_nameSpace.empty()) 6 | return; 7 | 8 | key(out); 9 | out << "}\n"; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/generator/namespaceopen.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::namespaceOpen(std::ostream &out) const 4 | { 5 | if (d_nameSpace.size()) 6 | { 7 | key(out); 8 | out << "namespace " << d_nameSpace << "\n" 9 | "{\n"; 10 | } 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /bisonc++/generator/namespaceuse.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::namespaceUse(std::ostream &out) const 4 | { 5 | if (d_nameSpace.empty()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << 11 | " // UN-comment the next using-declaration if you want to use\n" 12 | " // symbols from the namespace " << d_nameSpace << 13 | " without specifying " << d_nameSpace << "::\n" 14 | "//using namespace " << d_nameSpace << ";\n"; 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/generator/polyincludes.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::polyIncludes(ostream &out) const 4 | { 5 | if (not d_options.polymorphic()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << "#include \n"; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/generator/preincludes.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::preIncludes(std::ostream &out) const 4 | { 5 | bool preInclude = not d_options.preInclude().empty(); 6 | bool polymorphic = d_options.polymorphic(); 7 | 8 | if (not preInclude && not polymorphic) 9 | return; 10 | 11 | key(out); 12 | 13 | if (preInclude) 14 | out << "#include " << d_options.preInclude() << '\n'; 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/generator/print.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::print(ostream &out) const 4 | { 5 | key(out); 6 | 7 | // Reserved_::UNDETERMINED_ is also used in writer/symbolicnames.cc 8 | 9 | if (d_printTokens) 10 | insert(out, 4, "print.in"); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/generator/replace.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::replace(string &str, char ch, string const &replacement) 4 | { 5 | size_t pos = 0; 6 | 7 | while (true) 8 | { 9 | pos = str.find(pos, ch); 10 | if (pos == string::npos) 11 | return; 12 | str.replace(pos, 1, replacement); 13 | pos += replacement.length(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/generator/replaceatkey.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::replaceAtKey(string &line, size_t pos) const 4 | { 5 | for (auto &atKey: s_at) 6 | { 7 | if (line.find(atKey.key, pos) == pos) 8 | { 9 | line.replace(pos, atKey.size, (this->*atKey.function)()); 10 | return; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/generator/replacebaseflag.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::replaceBaseFlag(string &line) const 4 | { 5 | size_t pos = line.length(); 6 | 7 | while ((pos = line.rfind(s_atFlag, pos)) != string::npos) // found \@ 8 | { 9 | auto iter = find(line, pos, s_at); 10 | 11 | if (iter != s_at.end()) 12 | line.replace(pos, iter->size, (this->*iter->function)()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/generator/scannerh.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::scannerH(ostream &out) const 4 | { 5 | if (d_options.scannerInclude().empty()) 6 | return; 7 | 8 | key(out); 9 | out << "#include " << d_options.scannerInclude() << '\n'; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/generator/scannerobject.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::scannerObject(ostream &out) const 4 | { 5 | if (d_options.scannerInclude().empty()) 6 | return; 7 | 8 | key(out); 9 | out << d_options.scannerClassName() << " d_scanner;\n"; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/generator/stype.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::stype(ostream &out) const 4 | { 5 | key(out); 6 | 7 | if (!d_options.stype().empty()) 8 | out << d_options.stype() << '\n'; 9 | else 10 | out << "typedef int STYPE_;\n"; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/grammar/derivesentence.cc: -------------------------------------------------------------------------------- 1 | #include "grammar.ih" 2 | 3 | // Sentences are derived from the states following the Shift-Reduce algorithm 4 | // trying all alternative routes until the final state is somehow reached. 5 | 6 | void Grammar::deriveSentence() 7 | { 8 | if (!derivable(Rules::startSymbol())) 9 | fmsg << 10 | "Grammar's start symbol `" << Rules::startSymbol() << 11 | "' does not derive any sentence" << noid; 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/grammar/frame: -------------------------------------------------------------------------------- 1 | #include "grammar.ih" 2 | 3 | Grammar::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/grammar/grammar.ih: -------------------------------------------------------------------------------- 1 | #include "grammar.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "../rules/rules.h" 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | -------------------------------------------------------------------------------- /bisonc++/grammars/conflict: -------------------------------------------------------------------------------- 1 | %token i 2 | %% 3 | 4 | E: 5 | i 6 | | 7 | i 8 | | 9 | E '+' E 10 | | 11 | E '*' E 12 | ; 13 | 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/grammars/empty: -------------------------------------------------------------------------------- 1 | %% 2 | 3 | S: 4 | S I 5 | | 6 | ; 7 | 8 | I: 9 | 'a' 10 | | 11 | ; 12 | -------------------------------------------------------------------------------- /bisonc++/grammars/exprplus: -------------------------------------------------------------------------------- 1 | %e 2 2 | E: E-E 3 | E: -E 4 | E: n 5 | -------------------------------------------------------------------------------- /bisonc++/grammars/grammar: -------------------------------------------------------------------------------- 1 | %scanner scanner/scanner.h 2 | %token i 3 | 4 | %% 5 | 6 | S: 7 | L '=' R 8 | | 9 | R 10 | { 11 | cout << "Hello world\n"; 12 | } 13 | ; 14 | 15 | L: 16 | '*' R 17 | | 18 | i 19 | ; 20 | 21 | R: 22 | L 23 | ; 24 | 25 | -------------------------------------------------------------------------------- /bisonc++/grammars/grammar.p238: -------------------------------------------------------------------------------- 1 | %% 2 | 3 | S: 4 | 'a' A 'd' 5 | | 6 | 'b' B 'd' 7 | | 8 | 'a' B 'e' 9 | | 10 | 'b' A 'e' 11 | ; 12 | 13 | A: 14 | 'c' 15 | ; 16 | 17 | B: 18 | 'c' 19 | ; 20 | 21 | 22 | -------------------------------------------------------------------------------- /bisonc++/grammars/grammar4.11: -------------------------------------------------------------------------------- 1 | E: TD 2 | D: +TD 3 | D: 4 | T: FS 5 | S: *FS 6 | S: 7 | F: (E) 8 | F: i 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/grammars/grammar4.19: -------------------------------------------------------------------------------- 1 | E: E+T 2 | E: T 3 | T: T*F 4 | T: F 5 | F: (E) 6 | F: i 7 | -------------------------------------------------------------------------------- /bisonc++/grammars/grammar4.20: -------------------------------------------------------------------------------- 1 | %token i 2 | 3 | %% 4 | S: 5 | L '=' R 6 | | 7 | R 8 | ; 9 | 10 | L: 11 | '*' R 12 | | 13 | i 14 | ; 15 | 16 | R: 17 | L 18 | ; -------------------------------------------------------------------------------- /bisonc++/grammars/grammar4.21: -------------------------------------------------------------------------------- 1 | S: CC 2 | C: cC 3 | C: d 4 | -------------------------------------------------------------------------------- /bisonc++/grammars/ifelse: -------------------------------------------------------------------------------- 1 | %token i e a 2 | %% 3 | 4 | S: 5 | i S e S 6 | | 7 | i S 8 | | 9 | a 10 | ; 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/grammars/input: -------------------------------------------------------------------------------- 1 | %token NR 2 | %left '+' 3 | // %left '*' 4 | 5 | %% 6 | 7 | expr: 8 | expr '+' expr 9 | { 10 | $$ = $1 + $3; 11 | } 12 | //| 13 | // expr '*' expr 14 | // { 15 | // $$ = $1 * $3; 16 | // } 17 | | 18 | // {} 19 | NR 20 | ; 21 | -------------------------------------------------------------------------------- /bisonc++/grammars/precedence: -------------------------------------------------------------------------------- 1 | %token NR 2 | %left '+' '-' 3 | %left '*' '/' 4 | %right UMIN 5 | 6 | %% 7 | 8 | expr: 9 | expr '+' expr 10 | | 11 | expr '-' expr 12 | | 13 | expr '*' expr 14 | | 15 | expr '/' expr 16 | | 17 | '(' expr ')' 18 | | 19 | NR 20 | | 21 | '-' expr %prec UMIN 22 | ; 23 | -------------------------------------------------------------------------------- /bisonc++/grammars/small: -------------------------------------------------------------------------------- 1 | %token NR IDENT 2 | 3 | %% 4 | 5 | lines: 6 | lines line 7 | | 8 | ; 9 | 10 | line: 11 | content 12 | '\n' 13 | ; 14 | 15 | content: 16 | expr 17 | | 18 | error 19 | | 20 | ; 21 | 22 | expr: 23 | NR 24 | | 25 | IDENT 26 | ; 27 | -------------------------------------------------------------------------------- /bisonc++/icmake/backtick: -------------------------------------------------------------------------------- 1 | list backtick(string arg) 2 | { 3 | list ret; 4 | 5 | echo(OFF); 6 | ret = `arg`; 7 | echo(g_echo); 8 | return ret; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/icmake/cuteoln: -------------------------------------------------------------------------------- 1 | string cutEoln(string text) 2 | { 3 | return resize(text, strlen(text) - 1); 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/icmake/github: -------------------------------------------------------------------------------- 1 | void github() 2 | { 3 | run("cp -r release.yo tmp/manhtml/*.html tmp/manual " "../../wip"); 4 | run("cp changelog ../../wip/changelog.txt"); 5 | exit(0); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/icmake/installer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -eq 0 ] ; then 4 | echo destination path, ending in /, must be provided 5 | exit 0 6 | fi 7 | 8 | for src in `find -mindepth 1 -type d` # create missing target dirs 9 | do 10 | [ ! -e $1$src ] && mkdir -p $1$src 11 | done 12 | 13 | for file in `find -type f -or -type l` 14 | do 15 | cp -d --preserve=timestamps $file $1$file 16 | done 17 | 18 | -------------------------------------------------------------------------------- /bisonc++/icmake/log: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find tmp/install/$1 -type f -exec md5sum "{}" \; | 4 | sed 's|tmp/install/'$1'|'$2'|' >> $3 5 | find tmp/install/$1 -type l -exec printf "link %s\n" "{}" \; | 6 | sed 's|tmp/install/'$1'|'$2'|' >> $3 7 | find tmp/install/$1 -type d -exec printf "dir %s\n" "{}" \; | 8 | sed 's|tmp/install/'$1'|'$2'|' >> $3 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/icmake/logfile: -------------------------------------------------------------------------------- 1 | void logFile(string srcdir, string src, string destdir, string dest) 2 | { 3 | chdir(g_cwd); 4 | md(destdir); 5 | 6 | // copy srdir/src to destdir/dest, where destdir also contains the 7 | // topic-icentifier (e.g., b in tmp/install/b) 8 | 9 | run("cp " + srcdir + "/" + src + " " + destdir + "/" + dest); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/icmake/logfiles: -------------------------------------------------------------------------------- 1 | void logFiles(string source, string dest) 2 | { 3 | list files; 4 | int idx; 5 | 6 | echo(OFF); 7 | files = `"(chdir " + source + ";find ./ -type f)"`; 8 | 9 | for (idx = listlen(files); idx--; ) 10 | log(dest + "/" + files[idx]); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/icmake/loginstalled: -------------------------------------------------------------------------------- 1 | void logInstalled(string dest, string section) 2 | { 3 | if (g_logPath != "") 4 | { 5 | chdir(g_cwd); 6 | 7 | // The log-script is a bash script writing the log-info of 8 | // files, links and dirs to g_logpath 9 | // Files to install are under tmp/install/section. 10 | // 11 | backtick("icmake/log " + section + " " + dest + " " + g_logPath); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/icmake/pathfile: -------------------------------------------------------------------------------- 1 | list path_file(string path) 2 | { 3 | list ret; 4 | int len; 5 | int idx; 6 | 7 | for (len = strlen(path), idx = len; idx--; ) 8 | { 9 | if (path[idx] == "/") 10 | { 11 | ret = 12 | (list)substr(path, 0, idx) + (list)substr(path, idx + 1, len); 13 | return ret; 14 | } 15 | } 16 | 17 | ret = (list)"" + (list)path; 18 | return ret; 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /bisonc++/icmake/run: -------------------------------------------------------------------------------- 1 | void run(string cmd) 2 | { 3 | if (g_echo == OFF) 4 | cmd += "> /dev/null 2>&1"; 5 | 6 | system(0, cmd); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /bisonc++/icmake/setopt: -------------------------------------------------------------------------------- 1 | string setOpt(string install_im, string envvar) 2 | { 3 | list optvar; 4 | string ret; 5 | 6 | optvar = getenv(envvar); 7 | 8 | if (optvar[0] == "1") 9 | ret = optvar[1]; 10 | else 11 | ret = install_im; 12 | 13 | return ret; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /bisonc++/icmake/special: -------------------------------------------------------------------------------- 1 | void special() 2 | { 3 | if ("INSTALL.im" newer "options/SKEL") 4 | run("echo \"#define _Skel_ \\\"" SKEL + "\\\"\" > options/SKEL"); 5 | 6 | if (! exists("release.yo") || "VERSION" newer "release.yo") 7 | { 8 | system("touch version.cc"); 9 | run("gcc -E VERSION.h | grep -v '#' | sed 's/\\\"//g' > " 10 | "release.yo"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/icmake/uninstall: -------------------------------------------------------------------------------- 1 | void uninstall(string logfile) 2 | { 3 | int idx; 4 | list entry; 5 | string dir; 6 | list line; 7 | 8 | if (!exists(logfile)) 9 | { 10 | printf("installation log file " + logfile + " not found\n"); 11 | exit(0); 12 | } 13 | 14 | run("icmake/remove " + logfile + " " + (string)g_echo); 15 | 16 | exit(0); 17 | } 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /bisonc++/item/beyonddotisnonterminal.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | Symbol const *Item::beyondDotIsNonTerminal() const 4 | { 5 | if (d_dot < d_production->size()) 6 | { 7 | Symbol const &symbol = (*d_production)[d_dot]; 8 | if (symbol.isNonTerminal()) 9 | return &symbol; 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/item/data.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | ostream &(Item::*Item::s_insertPtr)(ostream &out) const = &Item::plainItem; 4 | -------------------------------------------------------------------------------- /bisonc++/item/frame: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | Item:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/item/hasrightofdot.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | bool Item::hasRightOfDot(Symbol const &symbol) const 4 | { 5 | return 6 | d_dot < d_production->size() // dot position before the end 7 | && // and 8 | d_production->rhs(d_dot) == &symbol; // symbol is at the . position 9 | } 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/item/item.ih: -------------------------------------------------------------------------------- 1 | #include "item.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../firstset/firstset.h" 9 | #include "../nonterminal/nonterminal.h" 10 | 11 | using namespace std; 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/item/item0.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | Item::Item() 4 | : 5 | d_production(0), 6 | d_dot(0) // In this item we haven't as yet seen any part of the 7 | // production rule. 8 | {} 9 | -------------------------------------------------------------------------------- /bisonc++/item/item1.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | Item::Item(Production const *start) 4 | : 5 | d_production(start), 6 | d_dot(0) // In this item we haven't as yet seen any part of the 7 | // production rule. 8 | { 9 | d_production->used(); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/item/item2.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | Item::Item(Item const *item, size_t dot) 4 | : 5 | d_production(item->d_production), 6 | d_dot(dot) 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/item/item3.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | Item::Item(Production const *production, size_t dot) 4 | : 5 | d_production(production), 6 | d_dot(dot) 7 | { 8 | d_production->used(); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/item/operatorequal.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | // `smaller' for the rule ptr means: pointing to an earlier 4 | // element in the rules-map. 5 | 6 | bool Item::operator==(Item const &other) const 7 | { 8 | return 9 | d_dot == other.d_dot 10 | && 11 | d_production == other.d_production; 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/item/plainitem.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | ostream &Item::plainItem(ostream &out) const 4 | { 5 | Production const *prod = production(); 6 | 7 | if (!prod) 8 | return out; 9 | 10 | out << prod->nr() << ": "; 11 | 12 | return insert(out, prod); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/item/pnrdotitem.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | std::ostream &Item::pNrDotItem(std::ostream &out) const 4 | { 5 | Production const *prod = production(); 6 | 7 | if (!prod) 8 | return out; 9 | 10 | out << "[P" << prod->nr() << " " << dot() << "] "; 11 | 12 | return insert(out, prod); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/item/transitsto.cc: -------------------------------------------------------------------------------- 1 | #include "item.ih" 2 | 3 | // return true if the current item is the predecessor of 4 | // the next item. So, their rules are identical, but 5 | // the current item's dot position is one lower than the 6 | // the next item's dot position. 7 | 8 | bool Item::transitsTo(Item const &next) const 9 | { 10 | return 11 | d_dot + 1 == next.d_dot 12 | && 13 | d_production == next.d_production; 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/insert.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | ostream &LookaheadSet::insert(ostream &out) const 4 | { 5 | out << "{ "; 6 | 7 | copy(begin(), end(), ostream_iterator(out, " ")); 8 | 9 | if (d_EOF == e_withEOF) 10 | out << " "; 11 | 12 | out << "}"; 13 | 14 | return out; 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/lookaheadset.ih: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "../rules/rules.h" 7 | 8 | using namespace std; 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/lookaheadset1.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | LookaheadSet::LookaheadSet(EndStatus eof) 4 | : 5 | d_EOF(eof) 6 | {} 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/lookaheadset2.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | LookaheadSet::LookaheadSet(FirstSet const &firstSet) 4 | : 5 | FirstSet(firstSet), 6 | d_EOF(e_withoutEOF) 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/lookaheadset3.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | LookaheadSet::LookaheadSet(LookaheadSet const &other) 4 | : 5 | FirstSet(other), 6 | d_EOF(other.d_EOF) 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/operatorgreaterequal.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | // Return true if all elements in `other' are already in *this 4 | 5 | bool LookaheadSet::operator>=(LookaheadSet const &other) const 6 | { 7 | return (hasEpsilon() || !other.hasEpsilon()) 8 | && 9 | (d_EOF == e_withEOF || other.d_EOF == e_withoutEOF) 10 | && 11 | includes(begin(), end(), other.begin(), other.end()); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | ostream &operator<<(ostream &out, LookaheadSet const &lookaheadSet) 4 | { 5 | return lookaheadSet.insert(out); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/operatorplusis.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | LookaheadSet &LookaheadSet::operator+=(LookaheadSet const &other) 4 | { 5 | *reinterpret_cast(this) += other; 6 | 7 | if (other.d_EOF == e_withEOF) 8 | d_EOF = e_withEOF; 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/operatorplusis2.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | LookaheadSet &LookaheadSet::operator+=(FirstSet const &firstSet) 4 | { 5 | *reinterpret_cast(this) += firstSet; 6 | return *this; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/lookaheadset/operatorsubis2.cc: -------------------------------------------------------------------------------- 1 | #include "lookaheadset.ih" 2 | 3 | LookaheadSet &LookaheadSet::operator-=(Symbol const *symbol) 4 | { 5 | if (symbol == Rules::eofTerminal()) 6 | d_EOF = e_withoutEOF; 7 | else 8 | reinterpret_cast(this)->erase(symbol); 9 | 10 | return *this; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/next/buildkernel.cc: -------------------------------------------------------------------------------- 1 | #include "next.ih" 2 | 3 | void Next::buildKernel(Item::Vector *kernel, 4 | StateItem::Vector const &stateItem) 5 | { 6 | for (size_t idx = 0; idx < d_kernel.size(); ++idx) 7 | kernel->push_back(stateItem[d_kernel[idx]].item().incDot()); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/next/checkremoved.cc: -------------------------------------------------------------------------------- 1 | #include "next.ih" 2 | 3 | void Next::checkRemoved(ostream &out) const 4 | { 5 | if (d_symbol != 0) 6 | out << ": "; 7 | else // symbols may be removed by the SRConflict 8 | { // resolution process. 9 | if (d_forced) 10 | out << " (AUTO REMOVED by S/R resolution): "; 11 | else 12 | out << " (removed by precedence): "; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/next/data.cc: -------------------------------------------------------------------------------- 1 | #include "next.ih" 2 | 3 | ostream &(Next::*Next::s_insertPtr)(ostream &out) const = &Next::transition; 4 | -------------------------------------------------------------------------------- /bisonc++/next/frame: -------------------------------------------------------------------------------- 1 | #include "next.ih" 2 | 3 | Next:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/next/next.ih: -------------------------------------------------------------------------------- 1 | #include "next.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../nonterminal/nonterminal.h" 8 | 9 | using namespace std; 10 | 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/next/next1.cc: -------------------------------------------------------------------------------- 1 | #include "next.ih" 2 | 3 | Next::Next() 4 | : 5 | d_symbol(0), 6 | d_removed(0), 7 | d_forced(false), 8 | d_next(string::npos), 9 | d_stateType(StateType::NORMAL) 10 | {} 11 | -------------------------------------------------------------------------------- /bisonc++/next/next2.cc: -------------------------------------------------------------------------------- 1 | #include "next.ih" 2 | 3 | Next::Next(Symbol const *symbol, size_t stateItemOffset) 4 | : 5 | d_symbol(symbol), 6 | d_removed(symbol), 7 | d_forced(false), 8 | d_next(string::npos), 9 | d_kernel(1, stateItemOffset), 10 | d_stateType(StateType::NORMAL) 11 | {} 12 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/data.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | size_t NonTerminal::s_counter; 4 | size_t NonTerminal::s_number; 5 | bool NonTerminal::s_unused; 6 | bool NonTerminal::s_undefined; 7 | 8 | ostream &(NonTerminal::*NonTerminal::s_insertPtr)(ostream &out) const = 9 | &NonTerminal::plainName; 10 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | NonTerminal::~NonTerminal() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/frame: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | NonTerminal:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/insname.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | std::ostream &NonTerminal::insName(std::ostream &out) const 4 | { 5 | std::string const &nName = name(); 6 | 7 | return out << " " << nName << left << 8 | setw(max(10 - static_cast(nName.length()), 1)) << ": "; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/nonterminal.ih: -------------------------------------------------------------------------------- 1 | #include "nonterminal.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | using namespace std; 9 | using namespace FBB; 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/nonterminal1.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | NonTerminal::NonTerminal(string const &name, string const &stype, Type type) 4 | : 5 | Symbol(name, type, stype) 6 | {} 7 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/undefined.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | void NonTerminal::undefined(NonTerminal const *nonTerminal) 4 | { 5 | if (nonTerminal->isUsed() && !nonTerminal->nProductions()) 6 | { 7 | s_undefined = true; 8 | emsg << "No production rules for non-terminal `" << 9 | nonTerminal->name() << '\'' << endl; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/unused.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | void NonTerminal::unused(NonTerminal const *nonTerminal) 4 | { 5 | if (!nonTerminal->isUsed()) 6 | { 7 | if (!s_unused) 8 | { 9 | wmsg << "Non-terminal symbol(s) not used in productions:" << endl; 10 | s_unused = true; 11 | } 12 | wmsg << " " << nonTerminal << endl; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/nonterminal/v.cc: -------------------------------------------------------------------------------- 1 | #include "nonterminal.ih" 2 | 3 | size_t NonTerminal::v_value() const 4 | { 5 | return d_nr; 6 | } 7 | 8 | FirstSet const &NonTerminal::v_firstSet() const 9 | { 10 | return d_first; 11 | } 12 | 13 | std::ostream &NonTerminal::insert(std::ostream &out) const 14 | { 15 | return (this->*NonTerminal::s_insertPtr)(out); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /bisonc++/options/accept.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | std::string const &Options::accept(PathType pathType, char const *declTxt) 4 | { 5 | if (pathType == FILENAME && d_matched->find('/') != string::npos) 6 | emsg << '`' << declTxt << "' directive: no path names" << endl; 7 | 8 | return *d_matched; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/options/addincludequotes.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::addIncludeQuotes(string &target) 4 | { 5 | if 6 | ( 7 | target.size() // target specified 8 | && 9 | target.find_first_of("<\"") != 0 // but no initial quotes 10 | ) 11 | target.insert(0, 1, '"') += '"'; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /bisonc++/options/assign.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::assign(std::string *target, PathType pathType, 4 | char const *declTxt) 5 | { 6 | if (target->empty()) 7 | { 8 | d_warnOptions.insert(declTxt); 9 | *target = accept(pathType, declTxt); 10 | } 11 | else 12 | emsg << "%" << declTxt << " multiply specified" << endl; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/options/baseclassheadername.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | std::string Options::baseclassHeaderName() const 4 | { 5 | size_t pos = d_baseClassHeader.rfind('/'); 6 | return pos == string::npos ? 7 | d_baseClassHeader 8 | : 9 | d_baseClassHeader.substr(pos + 1); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/options/cleandir.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::cleanDir(string &dir, bool append) 4 | { 5 | dir = undelimit(dir); 6 | 7 | if (append && *dir.rbegin() != '/') 8 | dir += '/'; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/options/frame: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | Options:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/options/instance.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | Options &Options::instance() 4 | { 5 | if (s_options == 0) 6 | s_options = new Options(); 7 | 8 | return *s_options; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/options/isfirststypedef.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | bool Options::isFirstStypeDefinition() const 4 | { 5 | if (d_stackDecl.empty()) 6 | return true; 7 | 8 | emsg << "Only one of %polymorphic, %stype, or %union can be specified" << 9 | endl; 10 | 11 | return false; 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/options/options.ih: -------------------------------------------------------------------------------- 1 | #include "options.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Global 9 | { 10 | void plainWarnings(); 11 | } 12 | 13 | using namespace std; 14 | using namespace FBB; 15 | -------------------------------------------------------------------------------- /bisonc++/options/options1.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | Options::Options() 4 | : 5 | d_arg(Arg::instance()), 6 | d_verboseName("(not requested)") 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/options/setconstructorchecks.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setConstructorChecks(string const &request, 4 | string const &filename, size_t lineNr) 5 | { 6 | Value value = valueOf(request, ON, OFF); // default ON, OFF also OK 7 | 8 | d_constructorChecks = OptInfo{value, filename, lineNr}; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/options/setlocationdecl.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | // copy the location declaration into `d_locationDecl' as the 4 | // definition of LSTYPE. 5 | 6 | void Options::setLocationDecl(std::string const &block) 7 | { 8 | if (!d_locationDecl.empty()) 9 | emsg << "%location-struct or %ltype multiply specified" << endl; 10 | else 11 | { 12 | d_locationDecl = "struct LTYPE_\n" + block += ";\n"; 13 | d_lspNeeded = true; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/options/setltype.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setLtype() 4 | { 5 | if (d_locationDecl.size()) 6 | emsg << "%location-struct or %ltype multiply declared" << endl; 7 | else if (d_matched->find(';') != string::npos) 8 | emsg << "`;' in %ltype type-definition `" << *d_matched << 9 | '\'' << endl; 10 | else 11 | d_locationDecl = "typedef " + *d_matched += " LTYPE_;\n"; 12 | } 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /bisonc++/options/setopt.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setOpt(string *destVar, 4 | char const *option, string const &defaultSpec) 5 | { 6 | string str; 7 | 8 | d_arg.option(&str, option); 9 | 10 | if (not str.empty()) 11 | { 12 | d_warnOptions.insert(option); 13 | *destVar = undelimit(str); 14 | } 15 | else if (destVar->empty()) 16 | *destVar = defaultSpec; 17 | } 18 | -------------------------------------------------------------------------------- /bisonc++/options/setparsingoptions.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setParsingOptions() 4 | { 5 | string value; 6 | 7 | if (d_arg.option(&value, 'd')) 8 | setDefaultAction(value, "", 0); 9 | 10 | if (d_arg.option(&value, "tag-mismatches")) 11 | setTagMismatches(value, "", 0); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/options/setpolymorphicdecl.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | // define the polymorphic semantic value type, embedded in a shared_ptr 4 | 5 | void Options::setPolymorphicDecl() 6 | { 7 | if (isFirstStypeDefinition()) 8 | d_stackDecl = " typedef Meta_::SType STYPE_;\n"; 9 | 10 | d_polymorphic = true; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/options/setprinttokens.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setPrintTokens() 4 | { 5 | d_printTokens = true; 6 | d_warnOptions.insert("print-tokens"); 7 | } 8 | 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/options/setquotedstrings.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setQuotedStrings() 4 | { 5 | d_arg.option(&d_preInclude, 'H'); 6 | addIncludeQuotes(d_preInclude); 7 | 8 | d_arg.option(&d_scannerInclude, 's'); 9 | addIncludeQuotes(d_scannerInclude); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/options/setrequiredtokens.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setRequiredTokens(size_t nRequiredTokens) 4 | { 5 | if (d_requiredTokens != 0) 6 | emsg << "%required-tokens multiply specified " << endl; 7 | else 8 | d_requiredTokens = nRequiredTokens; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/options/setstackexpansion.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setStackExpansion(size_t stackExpansion) 4 | { 5 | if (d_stackExpansion != 0) 6 | return; 7 | 8 | if (stackExpansion >= s_defaultStackExpansion) 9 | d_stackExpansion = stackExpansion; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/options/setstype.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setStype() 4 | { 5 | if (not isFirstStypeDefinition()) 6 | return; 7 | 8 | if (d_matched->find(';') == string::npos) 9 | d_stackDecl = "typedef " + *d_matched + " STYPE_;\n"; 10 | else 11 | emsg << "`;' in %stype type-definition `" << *d_matched << '\'' << 12 | endl; 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/options/settagmismatches.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | // Resulting values: ON, OFF 4 | void Options::setTagMismatches(string const &request, 5 | string const &filename, size_t lineNr) 6 | { 7 | Value value = valueOf(request, ON, ~WARN); 8 | // the mask turns WARN into ON 9 | if (value == QUIET) 10 | value = OFF; 11 | 12 | d_tagMismatches = OptInfo{value, filename, lineNr}; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/options/setuniondecl.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | // copy the union declaration into ostringstream `union_decl' as the 4 | // definition of LSTYPE. 5 | 6 | void Options::setUnionDecl(std::string const &block) 7 | { 8 | if (isFirstStypeDefinition()) 9 | d_stackDecl = "union STYPE_\n" + block + ";\n"; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/options/setverbosity.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setVerbosity() 4 | { 5 | if 6 | ( 7 | d_arg.option('V') || d_arg.option(0, "construction") 8 | || 9 | d_arg.option(0, "own-debug") 10 | ) 11 | { // determine the output filename 12 | (d_verboseName = d_arg[0]) += ".output"; 13 | imsg.reset(d_verboseName); 14 | } 15 | else 16 | imsg.off(); // suppress verbose messages 17 | } 18 | -------------------------------------------------------------------------------- /bisonc++/options/valueof.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | // static 4 | 5 | Options::Value Options::valueOf(string const &key, Value byDefault, 6 | unsigned mask) 7 | { 8 | auto entry = s_value.find(String::lc(key)); 9 | 10 | if (entry == s_value.end()) 11 | return byDefault; 12 | 13 | Value ret = entry->second; 14 | 15 | return ret & mask ? ret : byDefault; 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/parser/blkassign.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // unused ruleType is required when initializing s_defaultAction in data.cc 4 | 5 | void Parser::blkAssign([[maybe_unused]] string const &ruleType, 6 | Production const &prod) 7 | { 8 | installDefaultAction( 9 | prod, 10 | svsElement(prod.size(), 1) + ".get()" 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/parser/blkassignw.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::blkAssignW(string const &ruleType, Production const &prod) 4 | { 5 | wmsg << '`' << &prod << 6 | "': installed $$ = $1.get() action block" << endl; 7 | 8 | blkAssign(ruleType, prod); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/blkcheck.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::blkCheck(string const &ruleType, Production const &prod) 4 | { 5 | (this->* 6 | ( 7 | ruleType == prod[0].sType() ? 8 | &Parser::blkAssign 9 | : 10 | &Parser::blkErr 11 | ) 12 | )(ruleType, prod); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/parser/blkcheckw.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::blkCheckW(string const &ruleType, Production const &prod) 4 | { 5 | (this->* 6 | ( 7 | ruleType == prod[0].sType() ? 8 | &Parser::blkAssignW 9 | : 10 | &Parser::blkErr 11 | ) 12 | )(ruleType, prod); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/parser/blkdirect.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // unused ruleType is required when initializing s_defaultAction in data.cc 4 | 5 | void Parser::blkDirect([[maybe_unused]] string const &ruleType, 6 | Production const &prod) 7 | { 8 | installDefaultAction(prod, svsElement(prod.size(), 1) ); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/blkdirectw.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::blkDirectW(string const &ruleType, Production const &prod) 4 | { 5 | wmsg << '`' << &prod << 6 | "': installed $$ = $1 action block" << endl; 7 | 8 | blkDirect(ruleType, prod); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/blkerr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::blkErr(string const &ruleType, Production const &prod) 4 | { 5 | emsg << '`' << &prod << "': type conflict ($$: " << 6 | nameOf(ruleType) << ", $1: " << nameOf(prod[0].sType()) << 7 | "): cannot auto-append default action `$$ = $1'" << endl; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/parser/blknop.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // unused parameters are required when initializing s_defaultAction in data.cc 4 | 5 | void Parser::blkNop([[maybe_unused]] string const &ruleType, 6 | [[maybe_unused]] Production const &prod) 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/parser/blknopw.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // unused ruleType is required when initializing s_defaultAction in data.cc 4 | 5 | void Parser::blkNopW([[maybe_unused]] string const &ruleType, 6 | Production const &prod) 7 | { 8 | wmsg << '`' << &prod << 9 | "': no default action block was installed" << endl; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/blkstype.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // unused ruleType is required when initializing s_defaultAction in data.cc 4 | 5 | void Parser::blkSTYPE([[maybe_unused]] string const &ruleType, 6 | Production const &prod) 7 | { 8 | installDefaultAction(prod, s_stype + "{}"); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/blkstypew.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::blkSTYPEW(string const &ruleType, Production const &prod) 4 | { 5 | wmsg << '`' << &prod << 6 | "': installed $$ = STYPE_{} action block" << endl; 7 | blkSTYPE(ruleType, prod); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/parser/definepathname.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::definePathname(string *target) 4 | { 5 | if (target->empty()) // assign only if not yet assigned 6 | *target = Options::undelimit(*target); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/definetokenname.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::defineTokenName(string const &name, bool hasValue) 4 | { 5 | defineTerminal(name, Symbol::SYMBOLIC_TERMINAL); 6 | 7 | if (hasValue) 8 | { 9 | wmsg << "deprecated use of explicit value: `" << name << 10 | ' ' << d_scanner.number() << '\'' << endl; 11 | d_rules.setLastTerminalValue(d_scanner.number()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/parser/driver/driver.cc: -------------------------------------------------------------------------------- 1 | /* 2 | driver.cc 3 | */ 4 | 5 | #include "driver.h" 6 | 7 | #include "../inputgrammar.h" 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | 12 | 13 | int main(int argc, char **argv, char **envp) 14 | { 15 | Arg &arg = Arg::initialize("", argc, argv); 16 | 17 | InputGrammar input; 18 | 19 | input.parse(); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /bisonc++/parser/driver/driver.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_DRIVER_H_ 2 | #define _INCLUDED_DRIVER_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace FBB 8 | { 9 | 10 | } 11 | 12 | using namespace std; 13 | using namespace FBB; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /bisonc++/parser/dval.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // _$$ 4 | bool Parser::dval(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return dvalReplace(nElements < 0 && atd.refByScanner(), block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalmem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$. 4 | bool Parser::dvalMem(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return dvalReplace(nElements < 0, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalpar.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$( 4 | bool Parser::dvalPar(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return dvalReplace(nElements < 0, block, atd, "("); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalpoly.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$ 4 | bool Parser::dvalPoly(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | // < 0 means: mid-rule action 7 | return dvalPolyReplace(nElements < 0, block, atd, ""); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalpolymem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$. 4 | bool Parser::dvalPolyMem(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return dvalPolyReplace(nElements < 0, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalpolyptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$-> 4 | bool Parser::dvalPolyPtr(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return dvalPolyReplace(nElements < 0, block, atd, "->"); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::dvalPtr(int nElements, Block &block, AtDollar const &atd) 4 | { 5 | return dvalReplace(nElements < 0, block, atd, "->"); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalrefunion.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // see parser.h about refByScanner for info why nElements < 0 4 | // returns true. 5 | 6 | // $$ 7 | bool Parser::dvalRefUnion(int nElements, Block &block, AtDollar const &atd) 8 | { 9 | return 10 | atd.refByScanner() ? 11 | dvalUnionReplace(nElements < 0, block, atd, "") 12 | : 13 | dvalReplace(false, block, atd, "") or nElements < 0; 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalunion.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$ 4 | bool Parser::dvalUnion(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return dvalUnionReplace(nElements < 0, block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalunionmem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$. 4 | bool Parser::dvalUnionMem(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return dvalUnionReplace(nElements < 0, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalunionpar.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$( 4 | bool Parser::dvalUnionPar(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return dvalReplace(nElements < 0, block, atd, "("); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/dvalunionptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $$-> 4 | bool Parser::dvalUnionPtr(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return dvalUnionReplace(nElements < 0, block, atd, "->"); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/errnotag.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // Unused parameters are required for the initialization of s_single in 4 | // data.cc 5 | 6 | bool Parser::errNoTag([[maybe_unused]] int nElements, 7 | [[maybe_unused]] Block &block, AtDollar const &atd) 8 | { 9 | stdEmsg(atd) << "the STYPE_ semantic value type does not support " 10 | "tags (`" << atd.text() << "')" << endl; 11 | 12 | return false; 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/parser/errnounionptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::errNoUnionPtr(AtDollar const &atd) 4 | { 5 | stdEmsg(atd) << "cannot use -> " "with plain union types" << endl; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/parser/existingtag.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::existingTag(AtDollar const &atd) const 4 | { 5 | if (d_polymorphic.find(atd.tag()) != d_polymorphic.end()) 6 | return true; 7 | 8 | stdEmsg(atd) << "tag `" << atd.tag() << "' not defined" << endl; 9 | return false; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/extractindex.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | size_t Parser::extractIndex(int *idx, size_t pos) 4 | { 5 | istringstream is(d_scanner.block().substr(pos)); 6 | 7 | is >> *idx; 8 | return is.tellg(); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/frame: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Parser::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/parser/inc/identifier: -------------------------------------------------------------------------------- 1 | identifier: 2 | IDENTIFIER 3 | { 4 | $$ = d_matched; 5 | } 6 | ; 7 | -------------------------------------------------------------------------------- /bisonc++/parser/inc/typename: -------------------------------------------------------------------------------- 1 | typename: 2 | '<' 3 | identifier 4 | '>' 5 | { 6 | checkField($2); // d_field = $2; 7 | } 8 | ; 9 | -------------------------------------------------------------------------------- /bisonc++/parser/installaction.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::installAction(Block &block) 4 | { 5 | // process the block for the last 6 | // production rule, having a given number 7 | // of elements. 8 | 9 | substituteBlock(d_rules.nElements(), block); 10 | d_rules.setAction(block); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/parser/loc.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // unused `nElements' is required when initializing s_union in data.cc 4 | 5 | bool Parser::loc([[maybe_unused]] int nElements, 6 | Block &block, AtDollar const &atd) 7 | { 8 | block.replace(atd.pos(), atd.length(), s_locationValue); 9 | warnForceLSP(atd.lineNr()); 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/parser/locel.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::locEl(int nElements, Block &block,AtDollar const &atd) 4 | { 5 | ostringstream os; 6 | os << s_locationValueStack << indexToOffset(atd.nr(), nElements) << ')'; 7 | 8 | block.replace(atd.pos(), atd.length(), os.str()); 9 | warnForceLSP(atd.lineNr()); 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/parser/multiplydefined.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::multiplyDefined(Symbol const *sp) 4 | { 5 | Terminal::inserter(&Terminal::plainName); 6 | NonTerminal::inserter(&NonTerminal::plainName); 7 | 8 | emsg << (sp->isTerminal() ? "Terminal " : "Nonterminal ") << 9 | sp << " multiply defined" << endl; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/nexthiddenname.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | string Parser::nextHiddenName() 4 | { 5 | s_hiddenName.clear(); 6 | s_hiddenName.str(""); 7 | s_hiddenName << "#" << setfill('0') << setw(4) << ++s_nHidden; 8 | 9 | return s_hiddenName.str(); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/predefine.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::predefine(Terminal const *terminal) 4 | { 5 | d_symtab.insert 6 | ( 7 | Symtab::value_type 8 | ( 9 | terminal->name(), 10 | d_rules.insert(const_cast(terminal), terminal->name()) 11 | ) 12 | ).first->second->used(); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/parser/preheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_PREHEADERS_H_ 2 | #define _INCLUDED_PREHEADERS_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "../rules/rules.h" 12 | #include "../symtab/symtab.h" 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /bisonc++/parser/setpolymorphicdecl.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::setPolymorphicDecl() 4 | { 5 | d_expect = "Polymorphic base class specifications"; 6 | d_options.setPolymorphicDecl(); 7 | d_semType = POLYMORPHIC; 8 | d_atDollar = &s_polymorphic; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/parser/setstart.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::setStart() 4 | { 5 | if (d_rules.startRule().size()) 6 | emsg << "%start multiply specified" << endl; 7 | else 8 | d_rules.setStartRule(d_matched); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/parser/stdemsg.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | ostream &Parser::stdEmsg(AtDollar const &atd) const 4 | { 5 | emsg.setLineNr(atd.lineNr()); 6 | emsg << "rule " << &d_rules.lastProduction() << ": "; 7 | return emsg; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/parser/stdwmsg.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | ostream &Parser::stdWmsg(AtDollar const &atd) const 4 | { 5 | wmsg.setLineNr(atd.lineNr()); 6 | wmsg << "rule " << &d_rules.lastProduction() << ": "; 7 | wmsg.setLineNr(atd.lineNr()); 8 | return wmsg; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/svs.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr _$nr $-nr _$-nr 4 | bool Parser::svs(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsReplace(nElements, block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svselement.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // note: 2nd arg. is the production rule's element NUMBER, not index. 4 | string Parser::svsElement(int nElements, int nr) const 5 | { 6 | ostringstream os; 7 | os << s_semanticValueStack << indexToOffset(nr, nElements) << ')'; 8 | 9 | return os.str(); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/svsmem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr. $-nr. 4 | bool Parser::svsMem(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return svsReplace(nElements, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspoly.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr _$nr $-nr _$-nr 4 | bool Parser::svsPoly(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsPolyReplace(nElements, block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspolymem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr. $-nr. 4 | bool Parser::svsPolyMem(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return svsPolyReplace(nElements, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspolyptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr. $-nr. 4 | bool Parser::svsPolyPtr(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return svsPolyReplace(nElements, block, atd, "->"); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspolytag.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $-nr 4 | bool Parser::svsPolyTag(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsPolyTagReplace(nElements, block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspolytagmem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $-nr. 4 | bool Parser::svsPolyTagMem(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsPolyTagReplace(nElements, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspolytagptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $-nr. 4 | bool Parser::svsPolyTagPtr(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsPolyTagReplace(nElements, block, atd, "->"); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svspolytagreplace.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::svsPolyTagReplace(int nElements, Block &block, 4 | AtDollar const &atd, char const *suffix) 5 | { 6 | if (existingTag(atd)) 7 | block.replace(atd.pos(), atd.length(), 8 | svsElement(nElements, atd.nr()) + 9 | ".get()" + suffix 10 | ); 11 | return false; 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/parser/svsptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::svsPtr(int nElements, Block &block,AtDollar const &atd) 4 | { 5 | return svsReplace(nElements, block, atd, "->"); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/parser/svsrefunion.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr _$nr $-nr _$-nr 4 | bool Parser::svsRefUnion(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return 7 | (this->* 8 | (atd.refByScanner() ? 9 | &Parser::svsUnionReplace 10 | : 11 | &Parser::svsReplace 12 | ) 13 | )(nElements, block, atd, ""); 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/parser/svsreplace.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::svsReplace(int nElements, Block &block,AtDollar const &atd, 4 | char const *suffix) 5 | { 6 | warnNegativeDollarIndices(atd); 7 | 8 | block.replace(atd.pos(), atd.length(), 9 | svsElement(nElements, atd.nr()) + suffix); 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/parser/svstagref.cc: -------------------------------------------------------------------------------- 1 | //#include "parser.ih" 2 | // 3 | //bool Parser::svsTagRef(int nElements, Block &block,AtDollar const &atd) 4 | //{ 5 | // return svsTagReplace(nElements, block, atd, ""); 6 | //} 7 | -------------------------------------------------------------------------------- /bisonc++/parser/svsunion.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr _$nr $-nr _$-nr 4 | bool Parser::svsUnion(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsUnionReplace(nElements, block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svsunionmem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr. $-nr. 4 | bool Parser::svsUnionMem(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return svsUnionReplace(nElements, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svsunionptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $nr-> $-nr-> 4 | bool Parser::svsUnionPtr(int nElements, Block &block, AtDollar const &atd) 5 | { 6 | return svsUnionReplace(nElements, block, atd, "->"); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svsuniontag.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $-nr 4 | bool Parser::svsUnionTag(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsUnionTagReplace(nElements, block, atd, ""); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svsuniontagmem.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $-nr. 4 | bool Parser::svsUnionTagMem(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsUnionTagReplace(nElements, block, atd, "."); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svsuniontagptr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // $-nr. 4 | bool Parser::svsUnionTagPtr(int nElements, Block &block,AtDollar const &atd) 5 | { 6 | return svsUnionTagReplace(nElements, block, atd, "->"); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/parser/svsuniontagreplace.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | bool Parser::svsUnionTagReplace(int nElements, Block &block,AtDollar 4 | const &atd, char const *suffix) 5 | { 6 | block.replace(atd.pos(), atd.length(), 7 | svsElement(nElements, atd.nr()) + "." + atd.tag() + suffix); 8 | 9 | return false; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/typeindex.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // static 4 | int Parser::typeIndex(string const &typeName) 5 | { 6 | return typeName.empty() ? 0 : 7 | typeName == s_stype ? 1 : 8 | 2; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/parser/updatedefaultactionlinenr.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::updateDefaultActionLineNr() 4 | { 5 | d_rules.updateDefaultActionLineNr(d_scanner.lineNr()); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/parser/usesymbol.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Symbol *Parser::useSymbol() 4 | { 5 | if (Symbol *sp = d_symtab.lookup(d_matched)) 6 | return sp; 7 | 8 | NonTerminal *np = new NonTerminal(d_matched); 9 | 10 | d_symtab.insert 11 | ( 12 | Symtab::value_type 13 | ( 14 | d_matched, 15 | d_rules.insert(np) 16 | ) 17 | ); 18 | 19 | return np; 20 | } 21 | -------------------------------------------------------------------------------- /bisonc++/parser/warnautotag.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | string Parser::warnAutoTag(bool midRule, AtDollar const &atd) const 4 | { 5 | string tag = productionTag(atd.nr()); // get the element's tag 6 | 7 | if (midRule and not tag.empty()) 8 | { 9 | stdWmsg(atd) << " auto " << s_autoTypeLabel[d_semType] << " `" << 10 | tag << "' ignored in mid-rule action" << endl; 11 | tag.clear(); 12 | } 13 | 14 | return tag; 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/parser/warndefaultaction.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | // static 4 | void Parser::warnDefaultAction(Production const &prod) 5 | { 6 | wmsg << '`' << &prod << 7 | "': installed $$ = STYPE_{} action block" << endl; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/parser/warnforcelsp.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::warnForceLSP(size_t lineNr) const 4 | { 5 | if (not d_options.lspNeeded()) 6 | { 7 | wmsg << "@ used at line " << lineNr << ": %lsp-needed forced" << 8 | endl; 9 | d_options.setLspNeeded(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/parser/warnmissingsemval.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::warnMissingSemval() const 4 | { 5 | string const &stype = d_rules.sType(); 6 | 7 | if (stype.empty() or d_options.tagMismatches().value != Options::ON) 8 | return; 9 | 10 | wmsg << "`rule " << &d_rules.lastProduction() << 11 | "': confirm action block returns a required " << 12 | stype << " value" << endl; 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/parser/warnnegativedollarindices.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::warnNegativeDollarIndices(AtDollar const &atd) const 4 | { 5 | if (d_negativeDollarIndicesOK || atd.nr() > 0) 6 | return; 7 | 8 | stdWmsg(atd) << "negative $-index used in action block `" << atd.text() << 9 | '\'' << endl; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/parser/warnuntaggedvalue.cc: -------------------------------------------------------------------------------- 1 | //#include "parser.ih" 2 | // 3 | //void Parser::warnUntaggedValue(AtDollar const &atd) const 4 | //{ 5 | // wmsg.setLineNr(atd.lineNr()); 6 | // wmsg << "rule " << &d_rules.lastProduction() << 7 | // ": using untagged semantic value `" << atd.text() << '\'' << endl; 8 | //} 9 | -------------------------------------------------------------------------------- /bisonc++/plainwarnings.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace Global 4 | { 5 | void plainWarnings() 6 | { 7 | FBB::wmsg.setTag("Warning"); 8 | FBB::wmsg.noLineNr(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/production/data.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | size_t Production::s_nr; 4 | bool Production::s_unused; 5 | 6 | Production const *Production::s_startProduction; 7 | 8 | vector Production::s_fileName; 9 | -------------------------------------------------------------------------------- /bisonc++/production/frame: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | Production::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/production/production.ih: -------------------------------------------------------------------------------- 1 | #include "production.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | using namespace FBB; 8 | 9 | -------------------------------------------------------------------------------- /bisonc++/production/production1.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | Production::Production(Symbol const *nonTerminal, size_t lineNr) 4 | : 5 | d_precedence(0), 6 | d_nonTerminal(nonTerminal), 7 | d_nr(++s_nr), 8 | d_used(false), 9 | d_lineNr(lineNr), 10 | d_nameIdx(s_fileName.size() - 1) 11 | {} 12 | -------------------------------------------------------------------------------- /bisonc++/production/setprecedence.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | void Production::setPrecedence(Terminal const *terminal) 4 | { 5 | d_precedence = terminal; 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/production/standard.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | std::ostream &Production::standard(std::ostream &out) const 4 | { 5 | out << d_nr << ": " << lhs(); 6 | 7 | if (d_precedence != 0) 8 | out << " (" << d_precedence << ')'; 9 | 10 | out << " -> "; 11 | 12 | if (size() == 0) 13 | out << " "; 14 | else 15 | { 16 | for (const_iterator sym = begin(); sym != end(); ++sym) 17 | out << ' ' << *sym; 18 | } 19 | 20 | return out; 21 | } 22 | -------------------------------------------------------------------------------- /bisonc++/production/storeFilename.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | void Production::storeFilename(string const &filename) 4 | { 5 | if 6 | ( 7 | find(s_fileName.begin(), s_fileName.end(), filename) 8 | == s_fileName.end() 9 | ) 10 | s_fileName.push_back(filename); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/production/unused.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | void Production::unused(Production const *production) 4 | { 5 | if (!production->d_used) 6 | { 7 | if (!s_unused) 8 | { 9 | wmsg << 10 | "Unused production rule(s):" << endl; 11 | s_unused = true; 12 | } 13 | wmsg << " " << production << endl; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/production/vectoridx.cc: -------------------------------------------------------------------------------- 1 | #include "production.ih" 2 | 3 | Symbol *Production::vectorIdx(size_t idx) const 4 | { 5 | return idx >= size() ? 0 : std::vector::operator[](idx); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/rmreduction/frame: -------------------------------------------------------------------------------- 1 | #include "rmreduction.ih" 2 | 3 | RmReduction:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/rmreduction/rmreduction.ih: -------------------------------------------------------------------------------- 1 | #include "rmreduction.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/rmreduction/rmreduction1.cc: -------------------------------------------------------------------------------- 1 | #include "rmreduction.ih" 2 | 3 | RmReduction::RmReduction(size_t idx, size_t next, Symbol const *symbol, 4 | bool forced) 5 | : 6 | d_idx(idx), 7 | d_next(next), 8 | d_symbol(symbol), 9 | d_forced(forced) 10 | {} 11 | -------------------------------------------------------------------------------- /bisonc++/rmshift/frame: -------------------------------------------------------------------------------- 1 | #include "rmshift.ih" 2 | 3 | RmShift:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/rmshift/rmshift.ih: -------------------------------------------------------------------------------- 1 | #include "rmshift.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/rmshift/rmshift1.cc: -------------------------------------------------------------------------------- 1 | #include "rmshift.ih" 2 | 3 | RmShift::RmShift(size_t idx, bool forced) 4 | : 5 | d_idx(idx), 6 | d_forced(forced) 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/data.cc: -------------------------------------------------------------------------------- 1 | #include "rrconflict.ih" 2 | 3 | size_t RRConflict::s_nConflicts; 4 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/frame: -------------------------------------------------------------------------------- 1 | #include "rrconflict.ih" 2 | 3 | RRConflict:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/inspect.cc: -------------------------------------------------------------------------------- 1 | #include "rrconflict.ih" 2 | 3 | void RRConflict::inspect() 4 | { 5 | for (unsigned first = 0; first < d_reducible.size(); ++first) 6 | visitReduction(first); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/removeconflicts.cc: -------------------------------------------------------------------------------- 1 | #include "rrconflict.ih" 2 | 3 | void RRConflict::removeConflicts(StateItem::Vector &itemVector) 4 | { 5 | for (auto &rm: d_rmReduction) 6 | StateItem::removeRRConflict(rm, itemVector); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/rrconflict.ih: -------------------------------------------------------------------------------- 1 | #include "rrconflict.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "../rules/rules.h" 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/rrconflict1.cc: -------------------------------------------------------------------------------- 1 | #include "rrconflict.ih" 2 | 3 | RRConflict::RRConflict(StateItem::Vector const &stateItem, 4 | vector const &reducible) 5 | : 6 | d_itemVector(stateItem), 7 | d_reducible(reducible) 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/rrconflict/visitreduction.cc: -------------------------------------------------------------------------------- 1 | #include "rrconflict.ih" 2 | 3 | void RRConflict::visitReduction(size_t first) 4 | { 5 | d_firstIdx = d_reducible[first]; 6 | d_firstLA = &d_itemVector[d_firstIdx].lookaheadSet(); 7 | 8 | // this MUST be second < d_reducible.size() !! 9 | for (size_t second = first + 1; second < d_reducible.size(); ++second) 10 | compareReductions(second); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/rrdata/rrdata.ih: -------------------------------------------------------------------------------- 1 | #include "rrdata.h" 2 | 3 | using namespace std; 4 | -------------------------------------------------------------------------------- /bisonc++/rrdata/rrdata1.cc: -------------------------------------------------------------------------------- 1 | #include "rrdata.ih" 2 | 3 | RRData::RRData(LookaheadSet laSet) 4 | : 5 | d_laSet(laSet), 6 | d_forced(false), 7 | d_kept(~0) 8 | {} 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/rrdata/setidx.cc: -------------------------------------------------------------------------------- 1 | #include "rrdata.ih" 2 | 3 | void RRData::setIdx(Keep keep, size_t first, size_t second) 4 | { 5 | if (keep == KEEP_FIRST) 6 | { 7 | d_idx = second; 8 | d_kept = first; 9 | } 10 | else 11 | { 12 | d_idx = first; 13 | d_kept = second; 14 | } 15 | 16 | d_forced = true; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bisonc++/rules/assignnonterminalnumbers.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::assignNonTerminalNumbers() 4 | { 5 | NonTerminal::setFirstNr(Terminal::maxValue() + 1); 6 | 7 | for_each(d_nonTerminal.begin(), d_nonTerminal.end(), 8 | &NonTerminal::setNr); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/rules/data.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | size_t Rules::s_lastLineNr; 4 | size_t Rules::s_nExpectedConflicts; 5 | size_t Rules::s_acceptProductionNr; 6 | 7 | Symbol *Rules::s_startSymbol; 8 | 9 | Terminal Rules::s_errorTerminal("error", "errTok_", 10 | Symbol::SYMBOLIC_TERMINAL); 11 | 12 | Terminal Rules::s_eofTerminal("EOF", "EOF_", Symbol::SYMBOLIC_TERMINAL); 13 | -------------------------------------------------------------------------------- /bisonc++/rules/frame: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | Rules::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/rules/insert1.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | Terminal *Rules::insert(Terminal *terminal, std::string const &literal) 4 | { 5 | d_terminal.push_back(terminal); 6 | 7 | if (terminal->name() != literal) 8 | d_terminal.back()->setLiteral(literal); 9 | 10 | return d_terminal.back(); 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/rules/insert2.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | NonTerminal *Rules::insert(NonTerminal *nonTerminal) 4 | { 5 | d_nonTerminal.push_back(nonTerminal); 6 | 7 | return d_nonTerminal.back(); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/rules/rules.ih: -------------------------------------------------------------------------------- 1 | #include "rules.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | using namespace FBB; 13 | 14 | inline bool Rules::isTerminal(Symbol const *symbol) 15 | { 16 | return symbol->isTerminal(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bisonc++/rules/setnonterminaltypes.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::setNonTerminalTypes() 4 | { 5 | for_each(d_nonTerminal.begin(), d_nonTerminal.end(), 6 | &NonTerminal::setNonTerminal); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/rules/showterminals.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::showTerminals() const 4 | { 5 | if (!imsg.isActive()) 6 | return; 7 | 8 | imsg.setTag(""); 9 | 10 | imsg << "\n" 11 | "Symbolic Terminal tokens:\n"; 12 | 13 | Terminal::inserter(&Terminal::valueQuotedName); 14 | 15 | copy(d_terminal.begin(), d_terminal.end(), 16 | ostream_iterator(imsg, "\n")); 17 | 18 | imsg << endl; 19 | } 20 | -------------------------------------------------------------------------------- /bisonc++/rules/showunusedrules.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::showUnusedRules() const 4 | { 5 | Terminal::inserter(&Terminal::plainName); 6 | 7 | for_each(d_production.begin(), d_production.end(), &Production::unused); 8 | 9 | if (Production::notUsed()) 10 | imsg << endl; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/rules/showunusedterminals.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::showUnusedTerminals() const 4 | { 5 | Terminal::inserter(&Terminal::valueQuotedName); 6 | 7 | for_each(d_terminal.begin(), d_terminal.end(), &Terminal::unused); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/rules/stype.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | namespace { 4 | string const ret; 5 | } 6 | 7 | string const &Rules::sType(size_t idx) const 8 | { 9 | size_t size = d_currentProduction->size(); 10 | 11 | return 12 | (idx && idx <= size) ? 13 | (*d_currentProduction)[idx - 1].sType() 14 | : 15 | ret; 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /bisonc++/rules/termtononterm.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::termToNonterm(Symbol *term, Symbol *nonTerm) 4 | { 5 | d_terminal.erase(find(d_terminal.begin(), d_terminal.end(), term)); 6 | 7 | for (auto pPtr: d_production) 8 | Production::termToNonterm(pPtr, term, nonTerm); 9 | 10 | delete term; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/rules/updatedefaultactionlinenr.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::updateDefaultActionLineNr(size_t lineNr) 4 | { 5 | if (d_defaultAction && d_currentProduction) 6 | { 7 | d_currentProduction->setBlockLineNr(lineNr); 8 | d_defaultAction = false; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/rules/updateprecedences.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | // The precedence of a production rule is defined either explicitly (using 4 | // %prec) or it is defined as the priority setting of the rule's first 5 | // terminal token. If none is found the production rule has a default 6 | // priority. 7 | 8 | void Rules::updatePrecedences() 9 | { 10 | for (auto production: d_production) 11 | updatePrecedence(production); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/runtmp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PRE=`dirname $0` 4 | 5 | if [ $# == 0 ] 6 | then 7 | echo " 8 | Provide arguments to $PRE/tmp/bin/bisonc++. 9 | The skeletons in ${PRE}/skeletons are used. 10 | " 11 | exit 1 12 | fi 13 | 14 | ${PRE}/tmp/bin/bisonc++ -S ${PRE}/skeletons $* 15 | -------------------------------------------------------------------------------- /bisonc++/scanner/assignment.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::assignment() 4 | { 5 | d_block.atDollar(lineNr(), "_" + d_matched.substr(0, length() - 1), 6 | d_matched[1] == '$', // saw '$$ =', so $$-assignment 7 | true); // ref. by the scanner 8 | push(" ="); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/scanner/canonicalquote.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | string const &Scanner::canonicalQuote() 4 | { 5 | ostringstream oss; 6 | oss << "'\\x" << setfill('0') << setw(2) << 7 | hex << d_number << "'"; 8 | return d_canonicalQuote = oss.str(); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/scanner/checkendofrawstring.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::checkEndOfRawString() 4 | { 5 | if (matched().rfind(d_rawString) == length() - d_rawString.length()) 6 | begin(StartCondition_::block); 7 | 8 | more(); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/scanner/checkzeronumber.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::checkZeroNumber() 4 | { 5 | if (d_number == 0) 6 | emsg << "Quoted constant " << d_matched << " equals zero" << endl; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/scanner/driver/driver.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDED_DRIVER_H_ 2 | #define _INCLUDED_DRIVER_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../scanner.h" 9 | 10 | namespace FBB 11 | {} 12 | 13 | using namespace std; 14 | using namespace FBB; 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /bisonc++/scanner/eoln.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::eoln() 4 | { 5 | begin(StartCondition_::INITIAL); 6 | setLineNrs(); 7 | return '\n'; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/scanner/frame: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/scanner/handlerawstring.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::rawString() 4 | { 5 | d_rawString = matched(); 6 | d_rawString.erase(0, 1); // rm the R 7 | 8 | d_rawString.front() = ')'; // end sentinel is )IDENTIFIER" 9 | d_rawString.back() = '"'; 10 | 11 | more(); 12 | begin(StartCondition_::rawstring); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/scanner/hexadecimal.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::hexadecimal() 4 | { 5 | istringstream istr(d_matched.substr(3)); 6 | istr >> hex >> d_number; 7 | 8 | checkZeroNumber(); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/scanner/multicharquote.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::multiCharQuote() 4 | { 5 | emsg << "multiple characters in quoted constant " << d_matched << endl; 6 | d_number = 0; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/scanner/octal.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::octal() 4 | { 5 | istringstream istr(d_matched.substr(2)); 6 | istr >> oct >> d_number; 7 | 8 | if (d_number > 0xff) 9 | emsg << "Quoted constant " << d_matched << " exceeds 0177" << endl; 10 | else 11 | checkZeroNumber(); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/scanner/popstream.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::popStream() 4 | { 5 | bool ret = ScannerBase::popStream(); 6 | d_inclusionDepth -= ret; 7 | setTags(); 8 | return ret; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /bisonc++/scanner/returntypespec.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::returnTypeSpec() 4 | { 5 | string trimmed = String::trim(matched()); 6 | 7 | push(trimmed.back()); // return '%' or ';' for renewed scanning 8 | 9 | trimmed.resize(trimmed.length() - 1); 10 | 11 | setMatched(String::trim(trimmed)); 12 | 13 | begin(StartCondition_::INITIAL); 14 | 15 | leave(Parser::IDENTIFIER); 16 | } 17 | -------------------------------------------------------------------------------- /bisonc++/scanner/scanner1.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner::Scanner(std::string const &infile) 4 | : 5 | ScannerBase(infile, ""), 6 | d_include(false), 7 | d_matched(matched()), 8 | d_inclusionDepth(1) 9 | { 10 | memset(d_commentChar, 0, 2); 11 | 12 | setTags(); 13 | 14 | Arg &arg = Arg::instance(); 15 | 16 | string value; 17 | if (arg.option(&value, "max-inclusion-depth")) 18 | d_maxDepth = stoul(value); 19 | else 20 | d_maxDepth = 10; 21 | } 22 | -------------------------------------------------------------------------------- /bisonc++/scanner/setlinenrs.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::setLineNrs() const 4 | { 5 | emsg.setLineNr(lineNr()); 6 | fmsg.setLineNr(lineNr()); 7 | imsg.setLineNr(lineNr()); 8 | wmsg.setLineNr(lineNr()); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/scanner/settags.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::setTags() const 4 | { 5 | emsg.setTag(filename() + ": error"); 6 | fmsg.setTag(filename() + ": fatal"); 7 | imsg.setTag(filename() + " (info)"); 8 | wmsg.setTag(filename() + ": warning"); 9 | setLineNrs(); 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/base1: -------------------------------------------------------------------------------- 1 | \@Base::\@Base() 2 | : 3 | d_token(Reserved_::UNDETERMINED_), 4 | $insert 4 baseclasscode 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/clearin: -------------------------------------------------------------------------------- 1 | void \@Base::clearin_() 2 | { 3 | d_nErrors_ = 0; 4 | d_stackIdx = -1; 5 | d_stateStack.clear(); 6 | $insert 4 LTYPEclear 7 | d_token = Reserved_::UNDETERMINED_; 8 | d_next = TokenPair{ Reserved_::UNDETERMINED_, STYPE_{} }; 9 | d_recovery = false; 10 | d_acceptedTokens_ = d_requiredTokens_; 11 | d_val_ = STYPE_{}; 12 | 13 | push_(0); 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/debugfunctions: -------------------------------------------------------------------------------- 1 | $insert debugfunctions 2 | 3 | void \@Base::setDebug(bool mode) 4 | { 5 | d_actionCases_ = false; 6 | d_debug_ = mode; 7 | } 8 | 9 | void \@Base::setDebug(DebugMode_ mode) 10 | { 11 | d_actionCases_ = mode & ACTIONCASES; 12 | d_debug_ = mode & ON; 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/lex: -------------------------------------------------------------------------------- 1 | void \@Base::lex_(int token) 2 | { 3 | d_token = token; 4 | 5 | if (d_token <= 0) 6 | d_token = Reserved_::EOF_; 7 | 8 | d_terminalToken = true; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/poptoken: -------------------------------------------------------------------------------- 1 | void \@Base::popToken_() 2 | { 3 | d_token = d_next.first; 4 | d_val_ = std::move(d_next.second); 5 | 6 | d_next.first = Reserved_::UNDETERMINED_; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/pushtoken: -------------------------------------------------------------------------------- 1 | void \@Base::pushToken_(int token) 2 | { 3 | d_next = TokenPair{ d_token, std::move(d_val_) }; 4 | d_token = token; 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/redotoken: -------------------------------------------------------------------------------- 1 | void \@Base::redoToken_() 2 | { 3 | if (d_token != Reserved_::UNDETERMINED_) 4 | pushToken_(d_token); 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/reduce: -------------------------------------------------------------------------------- 1 | void \@Base::reduce_(int rule) 2 | { 3 | PI_ const &pi = s_productionInfo[rule]; 4 | 5 | d_token = pi.d_nonTerm; 6 | $insert 4 debug "rule " << (&pi - s_productionInfo) << ": pop " << pi.d_size << " elements. Next will be: [" << d_stateStack[d_stackIdx - pi.d_size].first << ", " << symbol_(d_token) << ']' 7 | pop_(pi.d_size); 8 | 9 | d_terminalToken = false; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/shift: -------------------------------------------------------------------------------- 1 | void \@Base::shift_(int action) 2 | { 3 | push_(action); 4 | popToken_(); // token processed 5 | 6 | if (d_recovery and d_terminalToken) 7 | { 8 | $insert 8 debug "ERROR RECOVERED: next state " << action 9 | d_recovery = false; 10 | d_acceptedTokens_ = 0; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/base/top: -------------------------------------------------------------------------------- 1 | inline size_t \@Base::top_() const 2 | { 3 | return d_stateStack[d_stackIdx].first; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/derived/print: -------------------------------------------------------------------------------- 1 | void \@::print_() 2 | { 3 | $insert print 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/derived/tail: -------------------------------------------------------------------------------- 1 | 2 | $insert namespace-close 3 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/abort: -------------------------------------------------------------------------------- 1 | inline void \@Base::ABORT() const 2 | { 3 | $insert 4 debug "ABORT(): Parsing unsuccessful" 4 | throw PARSE_ABORT_; 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/accept: -------------------------------------------------------------------------------- 1 | inline void \@Base::ACCEPT() const 2 | { 3 | $insert 4 debug "ACCEPT(): Parsing successful" 4 | throw PARSE_ACCEPT_; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/debug: -------------------------------------------------------------------------------- 1 | inline bool \@Base::debug() const 2 | { 3 | return d_debug_; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/error: -------------------------------------------------------------------------------- 1 | inline void \@Base::ERROR() const 2 | { 3 | $insert 4 debug "ERROR(): Forced error condition" 4 | throw UNEXPECTED_TOKEN_; 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/includes: -------------------------------------------------------------------------------- 1 | #ifndef \@$Base_h_included 2 | #define \@$Base_h_included 3 | 4 | #include 5 | #include 6 | #include 7 | $insert polyincludes 8 | $insert preincludes 9 | $insert debugincludes 10 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/opbitand: -------------------------------------------------------------------------------- 1 | inline \@Base::DebugMode_ operator&(\@Base::DebugMode_ lhs, 2 | \@Base::DebugMode_ rhs) 3 | { 4 | return static_cast<\@Base::DebugMode_>( 5 | static_cast(lhs) & rhs); 6 | } 7 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/opbitor: -------------------------------------------------------------------------------- 1 | inline \@Base::DebugMode_ operator|(\@Base::DebugMode_ lhs, 2 | \@Base::DebugMode_ rhs) 3 | { 4 | return static_cast<\@Base::DebugMode_>(static_cast(lhs) | rhs); 5 | }; 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/recovery: -------------------------------------------------------------------------------- 1 | inline bool \@Base::recovery_() const 2 | { 3 | return d_recovery; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/savedtoken: -------------------------------------------------------------------------------- 1 | inline int \@Base::savedToken_() const 2 | { 3 | return d_next.first; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/stacksize: -------------------------------------------------------------------------------- 1 | inline size_t \@Base::stackSize_() const 2 | { 3 | return d_stackIdx + 1; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/state: -------------------------------------------------------------------------------- 1 | inline size_t \@Base::state_() const 2 | { 3 | return d_state; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/tail: -------------------------------------------------------------------------------- 1 | // For convenience, when including ParserBase.h its symbols are available as 2 | // symbols in the class Parser, too. 3 | #define \@ \@Base 4 | 5 | $insert namespace-close 6 | 7 | #endif 8 | 9 | 10 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/token: -------------------------------------------------------------------------------- 1 | inline int \@Base::token_() const 2 | { 3 | return d_token; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons.src/hdr/vs: -------------------------------------------------------------------------------- 1 | inline \@Base::STYPE_ &\@Base::vs_(int idx) 2 | { 3 | return (d_vsp + idx)->second; 4 | } 5 | -------------------------------------------------------------------------------- /bisonc++/skeletons/bisonc++polymorphic.code: -------------------------------------------------------------------------------- 1 | $insert idoftag 2 | 3 | size_t const *s_nErrors_; 4 | 5 | Base::~Base() 6 | {} 7 | 8 | } // namespace Meta_ 9 | -------------------------------------------------------------------------------- /bisonc++/skeletons/debugdecl.in: -------------------------------------------------------------------------------- 1 | static std::ostringstream s_out_; 2 | 3 | std::string symbol_(int value) const; 4 | std::string stype_(char const *pre, STYPE_ const &semVal, 5 | char const *post = "") const; 6 | static std::ostream &dflush_(std::ostream &out); 7 | -------------------------------------------------------------------------------- /bisonc++/skeletons/debugincludes.in: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /bisonc++/skeletons/debuglookup.in: -------------------------------------------------------------------------------- 1 | if (d_debug_) 2 | { 3 | s_out_ << "encountered " << symbol_(token_()) << " in state " << 4 | state_() << ": "; 5 | 6 | if (action < 0) // a reduction was found 7 | s_out_ << ": reducing by rule " << -action; 8 | else if (action == 0) 9 | s_out_ << "ACCEPT"; 10 | else 11 | s_out_ << "next state: " << action; 12 | 13 | s_out_ << '\n' << dflush_; 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/skeletons/lex.in: -------------------------------------------------------------------------------- 1 | inline int \@::lex() 2 | { 3 | @printtokens 4 | print(); 5 | @end 6 | return \@tokenfunction; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/skeletons/ltype.in: -------------------------------------------------------------------------------- 1 | @ltype 2 | \@ltype 3 | @else 4 | struct LTYPE_ 5 | { 6 | int timestamp; 7 | int first_line; 8 | int first_column; 9 | int last_line; 10 | int last_column; 11 | char *text; 12 | }; 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/skeletons/ltypedata.in: -------------------------------------------------------------------------------- 1 | LTYPE_ d_loc_; 2 | 3 | LTYPE_ const &lsp_(int idx) const 4 | { 5 | return *(d_lsp + idx); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/skeletons/print.in: -------------------------------------------------------------------------------- 1 | std::cout << "Token: " << symbol_(token_()) << ", text: `"; 2 | if (token_() == Reserved_::UNDETERMINED_) 3 | std::cout << "'\n"; 4 | else 5 | std::cout << \@matchedtextfunction << "'\n"; 6 | -------------------------------------------------------------------------------- /bisonc++/srconflict/data.cc: -------------------------------------------------------------------------------- 1 | #include "srconflict.ih" 2 | 3 | size_t SRConflict::s_nConflicts; 4 | -------------------------------------------------------------------------------- /bisonc++/srconflict/frame: -------------------------------------------------------------------------------- 1 | #include "srconflict.ih" 2 | 3 | SRConflict:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/srconflict/inspect.cc: -------------------------------------------------------------------------------- 1 | #include "srconflict.ih" 2 | 3 | // Each reducible item index is passed to visitReduction() which handles an 4 | // observed S/R conflict. See README.states-and-conflicts for a description of 5 | // the conflict resolution process. 6 | 7 | // called fm: State::checkConflicts 8 | 9 | void SRConflict::inspect() 10 | { 11 | for (auto idx: d_reducible) 12 | visitReduction(idx); 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /bisonc++/srconflict/removereductions.cc: -------------------------------------------------------------------------------- 1 | #include "srconflict.ih" 2 | 3 | void SRConflict::removeReductions(StateItem::Vector &itemVector) 4 | { 5 | for (auto &rm: d_rmReduction) 6 | StateItem::removeReduction(rm, itemVector); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/srconflict/removeshifts.cc: -------------------------------------------------------------------------------- 1 | #include "srconflict.ih" 2 | 3 | size_t SRConflict::removeShifts(Next::Vector &nextVector) 4 | { 5 | size_t nRemoved = 0; 6 | 7 | for (auto &rmShift: d_rmShift) 8 | Next::removeShift(rmShift, nextVector, &nRemoved); 9 | 10 | return nRemoved; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/srconflict/srconflict.ih: -------------------------------------------------------------------------------- 1 | #include "srconflict.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "../enumsolution/enumsolution.h" 8 | #include "../rules/rules.h" 9 | 10 | using namespace std; 11 | using namespace FBB; 12 | 13 | -------------------------------------------------------------------------------- /bisonc++/srconflict/srconflict1.cc: -------------------------------------------------------------------------------- 1 | #include "srconflict.ih" 2 | 3 | SRConflict::SRConflict(Next::Vector const &nextVector, 4 | StateItem::Vector const &itemVector, 5 | std::vector const &reducible) 6 | : 7 | d_nextVector(nextVector), 8 | d_itemVector(itemVector), 9 | d_reducible(reducible) 10 | {} 11 | -------------------------------------------------------------------------------- /bisonc++/state/addkernelitem.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | void State::addKernelItem(StateItem const &stateItem) 4 | { 5 | d_itemVector.push_back(stateItem); 6 | ++d_nKernelItems; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/state/addstate.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | void State::addState(Item::Vector const &kernel) 4 | { 5 | State &state = newState(); 6 | 7 | for (auto &item: kernel) 8 | state.addKernelItem(StateItem(item)); 9 | } 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /bisonc++/state/construct.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | // the kernel item of the first state has already been set bij initialState(). 4 | 5 | // setItems adds the items implied by the kernel item(s), and transitions to 6 | // the next states. 7 | 8 | void State::construct() 9 | { 10 | setItems(); 11 | 12 | for (auto &next: d_nextVector) 13 | nextState(next); 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/state/data.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | vector State::s_state; 4 | 5 | State *State::s_acceptState; 6 | 7 | ostream &(State::*State::s_insert)(ostream &out) const; 8 | -------------------------------------------------------------------------------- /bisonc++/state/frame: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/state/initialstate.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | void State::initialState() 4 | { 5 | // construct the initial state. Start with S' -> . S 6 | // The start rule is obtained from Production::start() 7 | 8 | State &state = newState(); 9 | 10 | // Add the start production to the StateItem::Vector 11 | 12 | state.addKernelItem(StateItem(Item(Production::start()))); 13 | 14 | state.d_itemVector[0].setLA(LookaheadSet(LookaheadSet::e_withEOF)); 15 | } 16 | -------------------------------------------------------------------------------- /bisonc++/state/newstate.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State &State::newState() 4 | { 5 | State *ret = new State(s_state.size()); 6 | s_state.push_back(ret); 7 | return *ret; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/state/nextfindfrom.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | Next::ConstIter State::nextFind(Symbol const *symbol) const 4 | { 5 | return find_if( 6 | d_nextVector.begin(), d_nextVector.end(), 7 | [=](Next const &next) 8 | { 9 | return next.hasSymbol(symbol); 10 | } 11 | ); 12 | // FnWrap::unary(Next::hasSymbol, symbol)); 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/state/nexton.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | size_t State::nextOn(Symbol const *symbol) const 4 | { 5 | Next::ConstIter iter = nextFind(symbol); 6 | 7 | return iter == d_nextVector.end() ? string::npos : iter->next(); 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/state/nextterminal.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | Symbol const *State::nextTerminal(size_t *idxPtr) const 4 | { 5 | size_t idx = *idxPtr; 6 | 7 | while (idx < d_nextVector.size()) 8 | { 9 | Symbol const *ret = d_nextVector[idx].symbol(); 10 | if (ret->isTerminal()) 11 | { 12 | *idxPtr = idx; 13 | return ret; 14 | } 15 | ++idx; 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /bisonc++/state/state1.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State(size_t idx) 4 | : 5 | d_nKernelItems(0), 6 | d_nTransitions(0), 7 | d_nReductions(0), 8 | d_defaultReducible(string::npos), 9 | d_maxLAsize(0), 10 | d_summedLAsize(0), 11 | d_idx(idx), 12 | d_nTerminalTransitions(0), 13 | d_srConflict(d_nextVector, d_itemVector, d_reducible), 14 | d_rrConflict(d_itemVector, d_reducible), 15 | d_stateType(StateType::NORMAL) 16 | {} 17 | -------------------------------------------------------------------------------- /bisonc++/stateitem/containskernelitem.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | bool StateItem::containsKernelItem(Item const &searchItem, 4 | size_t nKernelItems, Vector const &vector) 5 | { 6 | for (size_t idx = 0; idx != nKernelItems; ++idx) 7 | if (searchItem == vector[idx].d_item) 8 | return true; 9 | 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/stateitem/data.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | ostream &(StateItem::*StateItem::s_insertPtr)(ostream &out) const = 4 | &StateItem::plainItem; 5 | -------------------------------------------------------------------------------- /bisonc++/stateitem/enlargela.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | bool StateItem::enlargeLA(LookaheadSet const &parentLA) 4 | { 5 | if (d_LA >= parentLA) // no additions needed 6 | return false; 7 | 8 | d_LA += parentLA; // enlarge the LA set 9 | 10 | return true; 11 | } 12 | -------------------------------------------------------------------------------- /bisonc++/stateitem/frame: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | StateItem::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/stateitem/itemcontext.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | // Produces: 4 | // item - LA - next-index 5 | 6 | ostream &StateItem::itemContext(ostream &out) const 7 | { 8 | return out << d_item << " " << d_LA << " " << 9 | static_cast(d_nextIdx); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/stateitem/plainitem.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | ostream &StateItem::plainItem(ostream &out) const 4 | { 5 | return out << d_item; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/stateitem/stateitem.ih: -------------------------------------------------------------------------------- 1 | #include "stateitem.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | -------------------------------------------------------------------------------- /bisonc++/stateitem/stateitem1.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | StateItem::StateItem() 4 | : 5 | d_nextIdx(string::npos) 6 | {} 7 | -------------------------------------------------------------------------------- /bisonc++/stateitem/stateitem2.cc: -------------------------------------------------------------------------------- 1 | #include "stateitem.ih" 2 | 3 | StateItem::StateItem(Item const &item) 4 | : 5 | d_item(item), 6 | d_nextIdx(string::npos) 7 | {} 8 | -------------------------------------------------------------------------------- /bisonc++/statetype/frame: -------------------------------------------------------------------------------- 1 | #include "statetype.ih" 2 | 3 | StateType::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/statetype/statetype.ih: -------------------------------------------------------------------------------- 1 | #include "statetype.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/symbol/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "symbol.ih" 2 | 3 | Symbol::~Symbol() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/symbol/frame: -------------------------------------------------------------------------------- 1 | #include "symbol.ih" 2 | 3 | Symbol::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/symbol/symbol.ih: -------------------------------------------------------------------------------- 1 | #include "symbol.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/symbol/symbol1.cc: -------------------------------------------------------------------------------- 1 | #include "symbol.ih" 2 | 3 | Symbol::Symbol(string const &name, Type type, string const &stype) 4 | : 5 | d_name(name), 6 | d_stype(stype), 7 | d_type(type), 8 | d_used(false) 9 | {} 10 | -------------------------------------------------------------------------------- /bisonc++/symtab/frame: -------------------------------------------------------------------------------- 1 | #include "symtab.ih" 2 | 3 | Symtab::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/symtab/lookup.cc: -------------------------------------------------------------------------------- 1 | #include "symtab.ih" 2 | 3 | Symbol *Symtab::lookup(std::string const &symbol) 4 | { 5 | iterator it = find(symbol); 6 | 7 | return it == end() ? 0 : it->second; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/symtab/symtab.ih: -------------------------------------------------------------------------------- 1 | #include "symtab.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /bisonc++/terminal/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | Terminal::~Terminal() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/terminal/frame: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | Terminal::() const 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/terminal/nameorvalue.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | ostream &Terminal::nameOrValue(ostream &out) const 4 | { 5 | if (isReserved()) 6 | return out << d_readableLiteral; 7 | 8 | return out << setw(3) << value(); 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/terminal/quotedname.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | namespace { 4 | char const *quotes[][2] = 5 | { 6 | {"`", ""}, 7 | {"'", ""} 8 | }; 9 | } 10 | 11 | ostream &Terminal::quotedName(ostream &out) const 12 | { 13 | size_t qIdx = (d_readableLiteral[0] == '\''); 14 | 15 | return out << quotes[0][qIdx] << d_readableLiteral << quotes[1][qIdx]; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /bisonc++/terminal/setunique.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | bool Terminal::setUnique(size_t value) 4 | { 5 | if (s_valueSet.count(value)) 6 | return false; // value already used 7 | 8 | s_valueSet.insert(value); 9 | return true; 10 | } 11 | -------------------------------------------------------------------------------- /bisonc++/terminal/setvalue.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | void Terminal::setValue(size_t value) 4 | { 5 | if (!setUnique(value)) 6 | emsg << "Value " << value << " of token " << this << 7 | " multiply assigned " << endl; 8 | 9 | s_valueSet.erase(d_value); 10 | s_value = value + 1; 11 | 12 | d_value = value; 13 | } 14 | -------------------------------------------------------------------------------- /bisonc++/terminal/terminal.ih: -------------------------------------------------------------------------------- 1 | #include "terminal.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | 12 | -------------------------------------------------------------------------------- /bisonc++/terminal/unused.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | void Terminal::unused(Terminal const *terminal) 4 | { 5 | static bool header = false; 6 | 7 | if (!terminal->isUsed()) 8 | { 9 | if (!header) 10 | { 11 | wmsg << "Terminal symbol(s) not used in productions:" << endl; 12 | header = true; 13 | } 14 | 15 | wmsg << terminal << endl; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bisonc++/terminal/valuequotedname.cc: -------------------------------------------------------------------------------- 1 | #include "terminal.ih" 2 | 3 | std::ostream &Terminal::valueQuotedName(std::ostream &out) const 4 | { 5 | if (isReserved()) 6 | return out << " " << name(); 7 | 8 | return out << " " << setw(3) << value() << ": " << d_readableLiteral; 9 | } 10 | -------------------------------------------------------------------------------- /bisonc++/version.cc: -------------------------------------------------------------------------------- 1 | #include "main.ih" 2 | #include "VERSION" 3 | 4 | char version[] = VERSION; 5 | char year[] = YEARS; 6 | 7 | -------------------------------------------------------------------------------- /bisonc++/writer/data.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | char const *Writer::s_threadConst = ""; 4 | -------------------------------------------------------------------------------- /bisonc++/writer/frame: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | Writer:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /bisonc++/writer/insert.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::insert(Terminal::ConstVector const &tokens) const 4 | { 5 | *d_out << "\n" 6 | " // Symbolic tokens:\n" 7 | " enum Tokens_\n" 8 | " {\n"; 9 | 10 | size_t lastTokenValue = 0; 11 | 12 | for (auto token: tokens) 13 | insertToken(token, lastTokenValue, *d_out); 14 | 15 | *d_out << " };\n" 16 | "\n"; 17 | } 18 | -------------------------------------------------------------------------------- /bisonc++/writer/inserttoken.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::insertToken(Terminal const *token, size_t &lastTokenValue, 4 | std::ostream &out) 5 | { 6 | out << " " << token; 7 | 8 | if (token->value() != ++lastTokenValue) 9 | { 10 | lastTokenValue = token->value(); 11 | out << " = " << lastTokenValue; 12 | } 13 | out << ",\n"; 14 | } 15 | -------------------------------------------------------------------------------- /bisonc++/writer/nonterminalsymbol.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::nonTerminalSymbol(NonTerminal const *nonTerminal, ostream &out) 4 | { 5 | out << " SMapVal(" << nonTerminal->value() << ", \"" << 6 | nonTerminal << "\"),\n"; 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/writer/productioninfo.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::productionInfo(Production const *production, ostream &out) 4 | { 5 | NonTerminal const *np = NonTerminal::downcast(production->lhs()); 6 | out << " {" << np->value() << ", " << 7 | production->size() << "}, // " << production << '\n'; 8 | } 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /bisonc++/writer/reduction.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::reduction(Table &table, StateItem const &stateItem) 4 | { 5 | size_t ruleNr = stateItem.nr(); 6 | 7 | for (auto sym: stateItem.lookaheadSet()) 8 | reductionSymbol(sym, ruleNr, table); 9 | 10 | if (stateItem.lookaheadSet().hasEOF()) 11 | reductionSymbol(Rules::eofTerminal(), ruleNr, table); 12 | } 13 | -------------------------------------------------------------------------------- /bisonc++/writer/reductions.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::reductions(Table &table, State const &state) 4 | { 5 | for 6 | ( 7 | size_t idx = 0, 8 | defaultReduction = state.defaultReduction(), 9 | nReductions = state.reductions(); 10 | idx != nReductions; 11 | ++idx 12 | ) 13 | { 14 | if (idx != defaultReduction) 15 | reduction(table, *state.reduction(idx)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /bisonc++/writer/terminalsymbol.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::terminalSymbol(Terminal const *terminal, ostream &out) 4 | { 5 | if (terminal->isSymbolic() && !terminal->isReserved()) 6 | out << " SMapVal(" << terminal->value() << ", \"" << 7 | terminal << "\"),\n"; 8 | } 9 | -------------------------------------------------------------------------------- /bisonc++/writer/transitions.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | void Writer::transitions(Table &table, Next::Vector const &next) 4 | { 5 | for (auto &element: next) 6 | transition(element, table); 7 | } 8 | -------------------------------------------------------------------------------- /bisonc++/writer/writer.ih: -------------------------------------------------------------------------------- 1 | #include "writer.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "../symbol/symbol.h" 10 | #include "../terminal/terminal.h" 11 | #include "../nonterminal/nonterminal.h" 12 | #include "../lookaheadset/lookaheadset.h" 13 | #include "../stateitem/stateitem.h" 14 | #include "../state/state.h" 15 | #include "../rules/rules.h" 16 | 17 | using namespace std; 18 | using namespace FBB; 19 | 20 | -------------------------------------------------------------------------------- /bisonc++/writer/writer0.cc: -------------------------------------------------------------------------------- 1 | #include "writer.ih" 2 | 3 | Writer::Writer(std::string const &baseclass, Rules const &rules) 4 | : 5 | d_out(0), 6 | d_baseclass(baseclass), 7 | d_rules(rules) 8 | { 9 | if (Arg::instance().option(0, "thread-safe")) 10 | s_threadConst = "const "; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /excluded: -------------------------------------------------------------------------------- 1 | tmp 2 | self 3 | documentation/manual/examples/rpn/index.yo 4 | --------------------------------------------------------------------------------