├── .gitignore ├── README ├── excluded ├── flexc++ ├── CLASSES ├── INSTALL ├── INSTALL.im ├── README.class-setup ├── README.flexc++-self ├── README.flexc++.output ├── README.lookahead ├── README.newgrammar ├── README.options ├── TODO ├── VERSION ├── VERSION.h ├── block │ ├── block.h │ ├── block.ih │ ├── clear.cc │ ├── close.cc │ ├── frame │ ├── open.cc │ └── operatorplusis.cc ├── build ├── changelog ├── charclass │ ├── addchars.cc │ ├── addrange.cc │ ├── append.cc │ ├── charclass.h │ ├── charclass.ih │ ├── charclass1.cc │ ├── charclass3.cc │ ├── chars.cc │ ├── difference.cc │ ├── driver │ │ ├── build │ │ └── driver.cc │ ├── frame │ ├── handleminusandescape.cc │ ├── inspect.cc │ ├── inversedrange.cc │ ├── ispredefined.cc │ ├── negate1.cc │ ├── negate2.cc │ ├── operatorinsert.cc │ ├── predefined.cc │ ├── predefinedafter.cc │ ├── predefinedbefore.cc │ ├── rangeafterrange.cc │ ├── rangestring.cc │ ├── replace.cc │ ├── set.cc │ ├── str.cc │ ├── tagminuses.cc │ ├── unite.cc │ └── validrange.cc ├── charrange │ ├── charrange.h │ ├── charrange.ih │ ├── data.cc │ ├── frame │ ├── negate.cc │ └── predefined.cc ├── dfa │ ├── README │ ├── README.computetailcounts │ ├── README.tailcounts │ ├── build.cc │ ├── data.cc │ ├── dfa.h │ ├── dfa.ih │ ├── dfa1.cc │ ├── frame │ ├── inspectrows.cc │ ├── keepuniquerows.cc │ ├── operatorinsert.cc │ ├── setverbose.cc │ └── shrinkdfa.cc ├── dfarow │ ├── README │ ├── dfarow.h │ ├── dfarow.ih │ ├── dfarow1.cc │ ├── frame │ ├── insertinto.xx │ ├── operatorequal.cc │ ├── operatorinsert.cc │ ├── sametransits.cc │ ├── setfinal.cc │ ├── tabulate.cc │ ├── tabulatefinals.cc │ ├── tabulatetransitions.cc │ ├── transit.cc │ ├── transitions.cc │ └── uniquemap.cc ├── dfas │ ├── build.cc │ ├── destructor.cc │ ├── dfas.h │ ├── dfas.ih │ ├── dfas1.cc │ ├── find.cc │ ├── frame │ ├── operatorinsert.cc │ ├── removerules.cc │ └── warnnonviable.cc ├── documentation │ ├── lop[dutch].txt │ ├── man │ │ ├── directives │ │ ├── flexc++.yo │ │ ├── flexc++api.yo │ │ ├── flexc++input.yo │ │ ├── generic.yo │ │ ├── include │ │ │ ├── header.yo │ │ │ ├── trailer.yo │ │ │ └── underscores.yo │ │ ├── input.yo │ │ ├── interactive.yo │ │ ├── options │ │ ├── rules.yo │ │ ├── scanner.h.yo │ │ ├── scannerbase.h.yo │ │ └── streamswitching.yo │ └── manual │ │ ├── 2oo6 │ │ ├── Makefile │ │ ├── differences │ │ ├── comment.yo │ │ ├── definitions.yo │ │ ├── files.yo │ │ ├── format.yo │ │ ├── intro.yo │ │ ├── members.yo │ │ ├── multiple.yo │ │ ├── patterns.yo │ │ ├── rules.yo │ │ └── usercode.yo │ │ ├── f.tgz │ │ ├── files │ │ ├── intro.yo │ │ └── multiple.yo │ │ ├── flexc++.yo │ │ ├── images │ │ ├── NFA1.jpg │ │ ├── NFA2.jpg │ │ ├── concatfig.jpg │ │ ├── cpttailcounts.jpg │ │ ├── dfa.jpg │ │ ├── dfa1.jpg │ │ ├── dfarow.jpg │ │ ├── dfas.jpg │ │ ├── fig18.jpg │ │ ├── fig29.jpg │ │ ├── fig30.jpg │ │ ├── incaccept.jpg │ │ ├── inputwrapping.jpg │ │ ├── lopdata.jpg │ │ ├── lopprocedure.jpg │ │ ├── molds │ │ │ ├── 2jpg │ │ │ ├── NFA1.odp │ │ │ ├── NFA1.pdf │ │ │ ├── NFA2.odp │ │ │ ├── NFA2.pdf │ │ │ ├── concatfig.odp │ │ │ ├── concatfig.pdf │ │ │ ├── cpttailcounts.odp │ │ │ ├── cpttailcounts.pdf │ │ │ ├── dfa.odp │ │ │ ├── dfa.pdf │ │ │ ├── dfa1.odp │ │ │ ├── dfa1.pdf │ │ │ ├── dfarow.odp │ │ │ ├── dfarow.pdf │ │ │ ├── dfas.odp │ │ │ ├── dfas.pdf │ │ │ ├── fig18.odp │ │ │ ├── fig18.pdf │ │ │ ├── fig29.odp │ │ │ ├── fig29.pdf │ │ │ ├── fig30.odp │ │ │ ├── fig30.pdf │ │ │ ├── figure.odp │ │ │ ├── generator.odp │ │ │ ├── incaccept.odp │ │ │ ├── incaccept.pdf │ │ │ ├── inputwrapping.odp │ │ │ ├── inputwrapping.pdf │ │ │ ├── lopdata.odp │ │ │ ├── lopdata.pdf │ │ │ ├── lopprocedure.odp │ │ │ ├── lopprocedure.pdf │ │ │ ├── pattern.odp │ │ │ ├── pattern.pdf │ │ │ ├── patternvalplain.odp │ │ │ ├── patternvalplain.pdf │ │ │ ├── ranges.odp │ │ │ ├── ranges.pdf │ │ │ ├── rule.odp │ │ │ ├── rule.pdf │ │ │ ├── rules.odp │ │ │ ├── rules.pdf │ │ │ ├── rules.svg │ │ │ ├── setlopblocks.odp │ │ │ ├── setlopblocks.pdf │ │ │ ├── state.odp │ │ │ ├── state.pdf │ │ │ ├── statecat.odp │ │ │ ├── statecat.pdf │ │ │ ├── states.odp │ │ │ ├── states.pdf │ │ │ ├── tailcount.odp │ │ │ └── tailcount.pdf │ │ ├── pattern.jpg │ │ ├── patternvalplain.jpg │ │ ├── ranges.jpg │ │ ├── rule.jpg │ │ ├── rules.jpg │ │ ├── rules2.jpg │ │ ├── setlopblocks.jpg │ │ ├── state.jpg │ │ ├── statecat.jpg │ │ ├── states.jpg │ │ └── tailcount.jpg │ │ ├── input │ │ ├── illustrationwrap.yo │ │ ├── intro.yo │ │ ├── miniscanners.yo │ │ ├── scanner │ │ │ ├── lexer │ │ │ ├── main.cc │ │ │ └── minimain.cc │ │ ├── scannerstreambuf.yo │ │ └── wrapping.yo │ │ ├── intro │ │ ├── demos │ │ │ ├── mainforoutputtinglexer.cc │ │ │ ├── mainforsimplelexer.cc │ │ │ ├── simpleignoringlexer │ │ │ ├── simplelexer │ │ │ └── simpleoutputtinglexer │ │ ├── flexc++.yo │ │ ├── interactive.yo │ │ ├── intro.yo │ │ ├── options.yo │ │ └── simple.yo │ │ ├── lexer │ │ ├── actions.yo │ │ ├── comment.yo │ │ ├── definitions.yo │ │ ├── directives.yo │ │ ├── input.yo │ │ ├── intro.yo │ │ ├── members.yo │ │ ├── notation.yo │ │ ├── patterns.yo │ │ ├── rules.yo │ │ └── startconditions.yo │ │ ├── preamble.yo │ │ └── technical │ │ ├── abbaabba.yo │ │ ├── addlopscs.yo │ │ ├── addrules.yo │ │ ├── blocks.yo │ │ ├── bolrules.yo │ │ ├── charclass.yo │ │ ├── developernotes.yo │ │ ├── dfa.yo │ │ ├── dfabuild.yo │ │ ├── dfarow.yo │ │ ├── dfas.yo │ │ ├── finac.txt │ │ ├── gencode.yo │ │ ├── gendfas.yo │ │ ├── interval.yo │ │ ├── intro.yo │ │ ├── keepunique.yo │ │ ├── lop.yo │ │ ├── lopexamples.yo │ │ ├── lopparser.yo │ │ ├── loppatterns.yo │ │ ├── lopproblem.yo │ │ ├── loprules.yo │ │ ├── lopruntime.yo │ │ ├── lopscs.yo │ │ ├── nonviable.yo │ │ ├── notations.yo │ │ ├── parser.yo │ │ ├── pattern.yo │ │ ├── ranges.yo │ │ ├── rangetable.yo │ │ ├── reflex.yo │ │ ├── rules.yo │ │ ├── ruletocall.yo │ │ ├── runtime.yo │ │ ├── semantic.yo │ │ ├── startconditions.yo │ │ ├── state.yo │ │ └── states.yo ├── flexc++.xref ├── flextypes │ └── flextypes.h ├── generator │ ├── actions.cc │ ├── baseclassh.cc │ ├── baseclassheader.cc │ ├── baseincludes.cc │ ├── casecheck.cc │ ├── classh.cc │ ├── classhead.cc │ ├── classheader.cc │ ├── classih.cc │ ├── conflicts.cc │ ├── construction.cc │ ├── data.cc │ ├── debug.cc │ ├── debugdecl.cc │ ├── debugfunctions.cc │ ├── debugtest.cc │ ├── declarations.cc │ ├── dfa.cc │ ├── dfabases.cc │ ├── dfarow.cc │ ├── dfarules.cc │ ├── dfas.cc │ ├── dfatransitions.cc │ ├── errexisting.cc │ ├── filename.cc │ ├── filter.cc │ ├── frame │ ├── generator.h │ ├── generator.ih │ ├── generator1.cc │ ├── getlop.cc │ ├── grep.cc │ ├── implementationheader.cc │ ├── inlinelexfunction.cc │ ├── inputimplementation.cc │ ├── inputinterface.cc │ ├── insert.cc │ ├── insertsstream.cc │ ├── interactivedecl.cc │ ├── interactiveinit.cc │ ├── interactivelex.cc │ ├── key.cc │ ├── lexfunctiondecl.cc │ ├── lexsource.cc │ ├── lop1.cc │ ├── lop2.cc │ ├── lop3.cc │ ├── lop4.cc │ ├── lopf.cc │ ├── lopimplementation.cc │ ├── namespaceclose.cc │ ├── namespaceopen.cc │ ├── namespaceuse.cc │ ├── outdfabase.cc │ ├── print.cc │ ├── ranges.cc │ ├── ruleaction.cc │ ├── scannerconstructors.cc │ ├── startconddecl.cc │ ├── startcondenum.cc │ ├── startcondimpl.cc │ └── startcondinfo.cc ├── icmake │ ├── adddir │ ├── backtick │ ├── clean │ ├── cuteoln │ ├── findall │ ├── github │ ├── install │ ├── installer │ ├── log │ ├── logfile │ ├── loginstall │ ├── logzip │ ├── manpage │ ├── manual │ ├── md │ ├── pathfile │ ├── remove │ ├── run │ ├── setopt │ ├── special │ └── uninstall ├── icmconf ├── interval │ ├── exact.cc │ ├── frame │ ├── interval.h │ ├── interval.ih │ ├── lowerbound.cc │ └── range.cc ├── main.cc ├── main.ih ├── newgrammar ├── options │ ├── accept.cc │ ├── assign.cc │ ├── baseclassheadername.cc │ ├── classheadername.cc │ ├── data.cc │ ├── frame │ ├── implementationheadername.cc │ ├── instance.cc │ ├── operatorfun1.cc │ ├── operatorfun2.cc │ ├── options.h │ ├── options.ih │ ├── options1.cc │ ├── setaccessorvariables.cc │ ├── setclassname.cc │ ├── setfilenames.cc │ ├── setlexfunctionname.cc │ ├── setnamespaceidentifier.cc │ ├── setoptionpath.cc │ ├── setparserinfo.cc │ ├── setpathstrings.cc │ ├── setstartconditionname.cc │ ├── showfilenames.cc │ └── textof.cc ├── parser │ ├── README.grammar │ ├── addlopstartconditions.cc │ ├── addrule.cc │ ├── assignblock.cc │ ├── block.cc │ ├── boln.cc │ ├── cleanup.cc │ ├── data.cc │ ├── dollar.cc │ ├── eolndollar.cc │ ├── error.cc │ ├── frame │ ├── grammar │ ├── inc │ │ ├── action │ │ ├── characterclass │ │ ├── combichars │ │ ├── directives │ │ ├── mscompound │ │ ├── msspec │ │ ├── options │ │ ├── optmsrule │ │ ├── regexoreof │ │ ├── reset │ │ └── rules │ ├── interval.cc │ ├── lex.cc │ ├── lookahead.cc │ ├── parse.cc │ ├── parser.h │ ├── parser.ih │ ├── parser1.cc │ ├── parserbase.h │ ├── preinclude.h │ ├── print.cc │ ├── quotes.cc │ ├── rawstring.cc │ └── reset.cc ├── pattern │ ├── alternatives.cc │ ├── canbeempty.cc │ ├── characterclass.cc │ ├── concatenate.cc │ ├── copy.cc │ ├── copypattern1.cc │ ├── copypattern2.cc │ ├── dot.cc │ ├── duplicate.cc │ ├── duppattern.cc │ ├── empty.cc │ ├── eof.cc │ ├── escape.cc │ ├── frame │ ├── interval.cc │ ├── join.cc │ ├── jumptoend.cc │ ├── operatorassign.cc │ ├── optionalpatterns.cc │ ├── optrepeatlastpattern.cc │ ├── pattern.h │ ├── pattern.ih │ ├── pattern1.cc │ ├── pattern2.cc │ ├── pattern3.cc │ ├── plus.cc │ ├── quantifier.cc │ ├── questionmark.cc │ ├── rawtext.cc │ └── star.cc ├── ranges │ ├── README │ ├── add.cc │ ├── add3.cc │ ├── charsettoranges.cc │ ├── chcollision.cc │ ├── collision.cc │ ├── countranges.cc │ ├── destructor.cc │ ├── determinesubsets.cc │ ├── driver │ │ └── main.cc │ ├── finalizestate.cc │ ├── finalizestates.cc │ ├── frame │ ├── inspectstate.cc │ ├── operatorassign.cc │ ├── operatorassign2.cc │ ├── operatorinsert.cc │ ├── outchar.cc │ ├── ranges.h │ ├── ranges.ih │ ├── ranges1.cc │ ├── ranges2.cc │ ├── ranges3.cc │ ├── reassign.cc │ ├── subsetcount.cc │ └── update.cc ├── rawtest │ ├── CLASSES │ ├── build │ ├── icmconf │ ├── in │ ├── main.cc │ ├── main.ih │ ├── scanner │ │ ├── data.cc │ │ ├── execute.cc │ │ ├── frame │ │ ├── lex.cc │ │ ├── scanner.h │ │ ├── scanner.ih │ │ └── scanner1.cc │ └── scannerbase │ │ ├── callexecute.cc │ │ ├── chartomatchbuffer.cc │ │ ├── frame │ │ ├── handleacceptstate.cc │ │ ├── input.cc │ │ ├── lookup.cc │ │ ├── next.cc │ │ ├── nextstate.cc │ │ ├── nothandledcharacter.cc │ │ ├── reject.cc │ │ ├── rejectreturn.cc │ │ ├── reread.cc │ │ ├── reset.cc │ │ ├── retain.cc │ │ ├── rulematched.cc │ │ ├── savelookahead.cc │ │ ├── scannerbase.h │ │ ├── scannerbase.ih │ │ ├── scannerbase1.cc │ │ ├── selectrule.cc │ │ ├── setheadsizeonce.cc │ │ └── updateheadsize.cc ├── reconstruction │ ├── CLASSES │ ├── VERSION │ ├── icmconf │ ├── input │ ├── main.cc │ ├── main.ih │ ├── parser │ │ ├── block.cc │ │ ├── frame │ │ ├── grammar │ │ ├── grammar.output │ │ ├── inc │ │ │ ├── directives │ │ │ ├── messages │ │ │ ├── options │ │ │ ├── rules │ │ │ └── rulessection2 │ │ ├── parse.cc │ │ ├── parser.h │ │ ├── parser.ih │ │ ├── parser1.cc │ │ ├── parserbase.h │ │ └── preinclude.h │ ├── run │ ├── scanner.h │ ├── scanner.ih │ ├── scanner │ │ ├── adddefinition.cc │ │ ├── block.cc │ │ ├── frame │ │ ├── lex.cc │ │ ├── lexer │ │ ├── maybeswitchstream.cc │ │ ├── newdefinition.cc │ │ ├── newscanner │ │ ├── out │ │ ├── popsc.cc │ │ ├── popstream.cc │ │ ├── push.cc │ │ ├── pushnameexpansion.cc │ │ ├── scanner.h │ │ ├── scanner.ih │ │ ├── scanner1.cc │ │ ├── scannerbase.h │ │ ├── setlinetags.cc │ │ └── switchtoinitial.cc │ └── scannerbase.h ├── reflex ├── regression │ ├── README │ ├── i01 │ ├── i02 │ ├── i03 │ ├── i04 │ ├── i05 │ ├── i06 │ ├── i07 │ ├── i08 │ ├── i09 │ ├── i10 │ ├── i11 │ ├── i12 │ ├── i13 │ ├── i14 │ ├── i15 │ ├── i16 │ ├── i17 │ ├── i18 │ ├── i19 │ ├── i4a │ ├── main.cc │ ├── main.ih │ ├── p01 │ ├── p02 │ ├── p03 │ ├── p04 │ ├── p05 │ ├── p06 │ ├── p07 │ ├── p08 │ ├── p09 │ ├── p10 │ ├── p11 │ ├── p12 │ ├── p13 │ ├── p14 │ ├── p15 │ ├── p16 │ ├── p17 │ ├── p18 │ ├── p19 │ ├── preamble │ ├── run │ ├── scanner.h │ └── scanner.ih ├── required ├── rule │ ├── frame │ ├── noaction.cc │ ├── operatorinsert.cc │ ├── rule.h │ ├── rule.ih │ ├── rule1.cc │ └── setstates.cc ├── rules │ ├── add.cc │ ├── addcatchall.cc │ ├── frame │ ├── handlefixedtailloprule.cc │ ├── handleloprule.cc │ ├── handleloprules.cc │ ├── noactions.cc │ ├── operatorinsert.cc │ ├── processcatchallrule.cc │ ├── rulefromfinalstate.cc │ ├── rules.h │ ├── rules.ih │ ├── rules1.cc │ ├── setlopblocks.cc │ └── setrule.cc ├── scanner │ ├── adddefinition.cc │ ├── allownullmatches.cc │ ├── endofrawstring.cc │ ├── frame │ ├── handlecharafterblanks.cc │ ├── handledquote.cc │ ├── handleeolncomment.cc │ ├── handlemulti.cc │ ├── handleopenbracket.cc │ ├── handlerawstring.cc │ ├── handlestdcomment.cc │ ├── insertedcatchall.cc │ ├── lex.cc │ ├── lexer │ ├── maybeswitchstream.cc │ ├── moreinput.cc │ ├── newdefinition.cc │ ├── newscanner │ ├── plex.cc │ ├── popsc.cc │ ├── popstream.cc │ ├── push.cc │ ├── pushnameexpansion.cc │ ├── rawstringcontents.cc │ ├── scanner.h │ ├── scanner.ih │ ├── scanner1.cc │ ├── scannerbase.h │ ├── secondsectiondelimiter.cc │ ├── setcasesensitive.cc │ ├── setlinetags.cc │ └── switchtoinitial.cc ├── skeletons │ ├── flexc++.cc │ ├── flexc++.h │ ├── flexc++.ih │ └── flexc++base.h ├── startconditions │ ├── activate.cc │ ├── add2.cc │ ├── addsc.cc │ ├── define.cc │ ├── frame │ ├── operatorinsert.cc │ ├── remove.cc │ ├── startconditions.h │ ├── startconditions.ih │ ├── startconditions1.cc │ └── useall.cc ├── state │ ├── README │ ├── contains.cc │ ├── dup.cc │ ├── frame │ ├── operatorinsert.cc │ ├── state.h │ ├── state.ih │ ├── state1.cc │ ├── state2.cc │ ├── state3.cc │ ├── state4.cc │ ├── state5.cc │ └── state6.cc ├── statedata │ ├── destructor.cc │ ├── frame │ ├── statedata.h │ ├── statedata.ih │ ├── statedata1.cc │ └── vclone.cc ├── states │ ├── collect.cc │ ├── eclosure.cc │ ├── frame │ ├── next.cc │ ├── next2.cc │ ├── next3.cc │ ├── operatorinsert.cc │ ├── states.h │ ├── states.ih │ └── states1.cc ├── statestring │ ├── frame │ ├── statestring.h │ ├── statestring.ih │ ├── statestring1.cc │ └── vclone.cc ├── templates │ └── templates.h ├── testpatterns ├── usage.cc └── version.cc └── sourcetar /.gitignore: -------------------------------------------------------------------------------- 1 | *.ih.gch 2 | self 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Flexc++ was designed after `flex'. Flexc++ offers as compared to flex's C++ 2 | option a cleaner class-design. 3 | 4 | Flexc++'s repository has moved to https://gitlab.com/fbb-git/flexcpp 5 | and is not maintained at this location anymore. 6 | 7 | The project's web-page can be found at http://fbb-git.gitlab.io/flexcpp/ 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /excluded: -------------------------------------------------------------------------------- 1 | o 2 | f.tgz 3 | rawtest 4 | regression 5 | *.odp 6 | *.svg 7 | README.flexc++.output 8 | README.lookahead 9 | README.options 10 | newscanner 11 | reconstruction 12 | grammar.output 13 | reflex 14 | README.flexc++-self 15 | self 16 | test 17 | out 18 | i 19 | u 20 | -------------------------------------------------------------------------------- /flexc++/README.lookahead: -------------------------------------------------------------------------------- 1 | Look-ahead operator handling 2 | ============================ 3 | 4 | See section `Patterns using the lookahead operator' in flexc++'s manual. 5 | 6 | There's also a brief (Dutch) description in documentation/lop[Dutch].txt 7 | -------------------------------------------------------------------------------- /flexc++/README.newgrammar: -------------------------------------------------------------------------------- 1 | If the parser (grammar specification) must be modified follow these steps: 2 | 3 | 1. modify the grammar specification 4 | 2. in parser/ run bisonc++ grammar 5 | This creates a new parserbase.h 6 | 3. in scanner/ run flexc++ lexer 7 | This creates a new scanner, using the definitions in 8 | ../parser/parserbase.h 9 | 4. touch scanner/a parser/a 10 | To recompile the full scanner and parser classes 11 | 5. build program 12 | 13 | 6. reflex 14 | To verify that the new flexc++ (= tmp/bin/binary) can recreate itself 15 | 16 | The first 5 steps were implemented in the newly added script ./newgrammar. 17 | -------------------------------------------------------------------------------- /flexc++/README.options: -------------------------------------------------------------------------------- 1 | How to add options/declarations to the program using an Options class 2 | 3 | 1. Options 4 | ========== 5 | 6 | 1. add the option to longOptions and/or the option list in Arg::initialize 7 | 8 | 9 | 2. Declarations 10 | -------------------------------------------------------------------------------- /flexc++/TODO: -------------------------------------------------------------------------------- 1 | To fix: Rule line numers refer to the next line if the rule has no action 2 | block 3 | 4 | -------------------------------------------------------------------------------- /flexc++/VERSION: -------------------------------------------------------------------------------- 1 | #define VERSION "2.07.00" 2 | #define YEARS "2008-2018" 3 | -------------------------------------------------------------------------------- /flexc++/VERSION.h: -------------------------------------------------------------------------------- 1 | #include "VERSION" 2 | SUBST(_CurVers_)(VERSION) 3 | SUBST(_CurYrs_)(YEARS) 4 | -------------------------------------------------------------------------------- /flexc++/block/block.ih: -------------------------------------------------------------------------------- 1 | #include "block.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | using namespace FBB; 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /flexc++/block/clear.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | void Block::clear() 4 | { 5 | d_str.erase(); 6 | d_level = 0; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/block/close.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | bool Block::close() 4 | { 5 | size_t lastUsedPos = d_str.find_last_not_of(' '); 6 | 7 | if (lastUsedPos + 4 <= d_str.length()) 8 | d_str.resize(d_str.length() - 4); 9 | 10 | if (--d_level != 0) 11 | d_str += '}'; 12 | 13 | return d_level; 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/block/frame: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | Block:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/block/open.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | void Block::open(size_t lineno, string const &filename) 4 | { 5 | if (d_level) // existing block ? 6 | d_str += '{'; // add open curly bracket to the block's code 7 | else 8 | { // assign line if no braces were open yet 9 | clear(); 10 | d_line = lineno; 11 | d_filename = filename; 12 | } 13 | 14 | ++d_level; // here, as clear() will reset d_level 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/block/operatorplusis.cc: -------------------------------------------------------------------------------- 1 | #include "block.ih" 2 | 3 | void Block::operator+=(string const &text) 4 | { 5 | if (text[0] == '\n') 6 | d_str += '\n'; 7 | else 8 | d_str += text == " " ? text : String::trim(text); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /flexc++/charclass/addchars.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::addChars(std::set &dest, size_t begin, size_t end) const 4 | { 5 | dest.insert(d_str.begin() + begin, d_str.begin() + end); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/charclass/addrange.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::addRange(std::set &dest, size_t idx) const 4 | { 5 | for ( 6 | size_t begin = static_cast(d_str[idx - 1]), 7 | end = static_cast(d_str[idx + 1]) + 1; 8 | begin != end; 9 | ++begin 10 | ) 11 | dest.insert(begin); 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/charclass/append.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::append(vector const &strings) 4 | { 5 | for (auto &str: strings) 6 | { 7 | if (str[0] == 'p') 8 | { 9 | if (d_type.back().second != PREDEF) 10 | d_type.push_back({d_str.length(), PREDEF}); 11 | } 12 | else 13 | { 14 | if (d_type.back().second != CHAR) 15 | d_type.push_back({d_str.length(), CHAR}); 16 | } 17 | d_str.append(str.begin() + 1, str.end()); // add all but the 1st 18 | } 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /flexc++/charclass/charclass.ih: -------------------------------------------------------------------------------- 1 | #include "charclass.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include "../charrange/charrange.h" 10 | 11 | using namespace std; 12 | using namespace FBB; 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /flexc++/charclass/charclass1.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | CharClass::CharClass() 4 | : 5 | d_type(1, {0, CHAR}) 6 | {} 7 | -------------------------------------------------------------------------------- /flexc++/charclass/charclass3.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | CharClass::CharClass(string const &chars, size_t skip) 4 | : 5 | d_str(skip == 0 ? chars : chars.substr(skip)), 6 | d_type(1, {0, CHAR}) 7 | {} 8 | -------------------------------------------------------------------------------- /flexc++/charclass/chars.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | string CharClass::chars(string const &matched) 4 | { 5 | string ret(string(1, 'c') + matched); 6 | 7 | return ret; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/charclass/difference.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | CharClass CharClass::difference(CharClass &lhs, CharClass &rhs) 4 | { 5 | std::set const &lset = lhs.set(); 6 | std::set const &rset = rhs.set(); 7 | 8 | CharClass ret; 9 | ret.d_state = FINAL; 10 | 11 | set_difference(lset.begin(), lset.end(), rset.begin(), rset.end(), 12 | back_inserter(ret.d_str)); 13 | 14 | return ret; 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/charclass/driver/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $1 in 4 | (b) 5 | g++ --std=c++0x -o driver driver.cc \ 6 | -lflexc++ -lbobcat -L../../ -s 7 | ;; 8 | (*) 9 | echo $0 b links to bobcat built by 'build libraries all' 10 | rm -f driver 11 | ;; 12 | esac 13 | 14 | -------------------------------------------------------------------------------- /flexc++/charclass/driver/driver.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../charclass.h" 5 | 6 | using namespace std; 7 | 8 | int main(int argc, char **argv) 9 | { 10 | while (true) 11 | { 12 | cout << "Enter chars do define a set, [ starts named. " 13 | "Return to signal 'done'\n"; 14 | string str; 15 | getline(cin, str); 16 | if (str.empty()) 17 | break; 18 | cout << "Entered: `" << str << "'\n"; 19 | spSemVal sp = str[0] == '[' ? CharClass::predefined(str) : 20 | CharClass::escape(str); 21 | cout << '`' << dynamic_cast(*sp).str() << "'\n"; 22 | } 23 | } 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /flexc++/charclass/frame: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | CharClass:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/charclass/handleminusandescape.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::handleMinusAndEscape() 4 | { 5 | if (d_state == RAW) 6 | d_type.push_back({d_str.length(), END}); 7 | 8 | for ( 9 | auto begin = d_type.begin(), end = d_type.end(); 10 | begin != end; 11 | ++begin 12 | ) 13 | inspect(begin); 14 | 15 | if (d_tag.size() && d_tag.front() == 0) // 1st char is not a range op. 16 | d_tag.erase(d_tag.begin()); 17 | 18 | // last char is not a range op. 19 | if (d_tag.size() && d_tag.back() == d_str.length() - 1) 20 | d_tag.pop_back(); 21 | } 22 | -------------------------------------------------------------------------------- /flexc++/charclass/inversedrange.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | bool CharClass::inversedRange(size_t idx) const 4 | { 5 | if 6 | ( // first char must be <= last ch. 7 | static_cast(d_str[idx - 1]) 8 | > 9 | static_cast(d_str[idx + 1]) 10 | ) 11 | { 12 | emsg << "lllegal range: `" << rangeString(idx) << '\'' << endl; 13 | return true; 14 | } 15 | 16 | return false; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/charclass/ispredefined.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | bool CharClass::isPredefined(size_t idx) const 4 | { 5 | return find_if(d_type.begin(), d_type.end(), 6 | [&](std::pair const &pair) 7 | { 8 | return pair.second == PREDEF && pair.first == idx; 9 | } 10 | ) != d_type.end(); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /flexc++/charclass/negate1.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::negate() 4 | { 5 | d_str = CharRange::negate(str()); 6 | d_state = NEGATED; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/charclass/negate2.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::negate(vector const &strings) 4 | { 5 | append(strings); 6 | negate(); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/charclass/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | std::ostream &operator<<(std::ostream &out, CharClass const &cc) 4 | { 5 | bool onlyPrintable = true; 6 | 7 | for (char ch: cc.d_str) 8 | { 9 | if (isprint(ch)) 10 | out << ch; 11 | else 12 | onlyPrintable = false; 13 | } 14 | if (onlyPrintable) 15 | return out; 16 | 17 | out << " #"; 18 | for (char ch: cc.d_str) 19 | { 20 | if (not isprint(ch)) 21 | out << '#' << (int)ch; 22 | } 23 | return out; 24 | } 25 | -------------------------------------------------------------------------------- /flexc++/charclass/predefined.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | string CharClass::predefined(string const &predef) 4 | { 5 | string ret(string(1, 'p') + CharRange::predefined(predef)); 6 | 7 | return ret; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/charclass/predefinedafter.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | bool CharClass::predefinedAfter(size_t idx) const 4 | { 5 | if (isPredefined(idx + 1)) // predefined range beyond '-' ? 6 | { 7 | emsg << "predefined set cannot follow '-'" << endl; 8 | return true; 9 | } 10 | 11 | return false; 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/charclass/predefinedbefore.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | bool CharClass::predefinedBefore(size_t idx) const 4 | { 5 | if (isPredefined(idx - 1)) // predefined range before '-' ? 6 | { 7 | emsg << "'-' cannot follow predefined set" << endl; 8 | return true; 9 | } 10 | 11 | return false; 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/charclass/rangeafterrange.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | bool CharClass::rangeAfterRange(TagIter iter) const 4 | { 5 | if 6 | ( 7 | iter + 1 != d_tag.end() // another - exists 8 | && 9 | *iter + 2 == *(iter + 1) // saw 'a-b-': illegal pattern 10 | ) 11 | { 12 | emsg << "range '-' cannot follow range `" << 13 | rangeString(*iter) << '\'' << endl; 14 | return true; 15 | } 16 | 17 | return false; 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/charclass/rangestring.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | string CharClass::rangeString(size_t idx) const 4 | { 5 | string ret; 6 | 7 | char ch = d_str[idx - 1]; 8 | 9 | if (isprint(ch)) 10 | ret = ch; 11 | else 12 | ret = "(int)" + to_string(static_cast(ch)); 13 | 14 | ret += '-'; 15 | 16 | ch = d_str[idx + 1]; 17 | 18 | if (isprint(ch)) 19 | ret += ch; 20 | else 21 | ret += "(int)" + to_string(static_cast(ch)); 22 | 23 | return ret; 24 | } 25 | -------------------------------------------------------------------------------- /flexc++/charclass/replace.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::replace(string newStr, TypeVector::iterator iter, size_t end) 4 | { 5 | size_t orgLen = end - iter->first; 6 | 7 | if (orgLen == newStr.length()) 8 | return; 9 | 10 | d_str.replace(iter->first, orgLen, newStr); // replace the original str 11 | // by the unescaped str. 12 | 13 | size_t reduction = orgLen - newStr.length(); 14 | 15 | for (++iter; iter != d_type.end(); ++iter) 16 | iter->first -= reduction; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/charclass/str.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | string const &CharClass::str() 4 | { 5 | if (d_state != FINAL) 6 | { 7 | std::set const &tmp = set(); 8 | d_str.assign(tmp.begin(), tmp.end()); 9 | d_state = FINAL; 10 | } 11 | return d_str; 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/charclass/tagminuses.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | void CharClass::tagMinuses(size_t offset, string const &str, size_t from) 4 | { 5 | while ((from = str.find('-', from)) != string::npos) 6 | d_tag.push_back(offset + from++); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/charclass/unite.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | CharClass CharClass::unite(CharClass &lhs, CharClass &rhs) 4 | { 5 | std::set const &lset = lhs.set(); 6 | std::set const &rset = rhs.set(); 7 | 8 | CharClass ret; 9 | ret.d_state = FINAL; 10 | 11 | set_union(lset.begin(), lset.end(), rset.begin(), rset.end(), 12 | back_inserter(ret.d_str)); 13 | 14 | return ret; 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/charclass/validrange.cc: -------------------------------------------------------------------------------- 1 | #include "charclass.ih" 2 | 3 | // got a pattern 'a-b', idx at '-' 4 | bool CharClass::validRange(TagIter iter) const 5 | { 6 | return not 7 | ( 8 | predefinedBefore(*iter) || predefinedAfter(*iter) || 9 | rangeAfterRange(iter) || inversedRange(*iter) 10 | ); 11 | } 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /flexc++/charrange/charrange.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_CHARRANGE_ 2 | #define INCLUDED_CHARRANGE_ 3 | 4 | #include 5 | #include 6 | 7 | class CharRange 8 | { 9 | struct AllString; 10 | 11 | static FBB::LinearMap s_hash; 12 | static FBB::LinearMap s_funHash; 13 | static std::string s_all; 14 | 15 | public: 16 | static std::string const &predefined(std::string const &className); 17 | static std::string negate(std::string const &str); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /flexc++/charrange/charrange.ih: -------------------------------------------------------------------------------- 1 | #include "charrange.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "../flextypes/flextypes.h" 9 | 10 | using namespace std; 11 | using namespace FBB; 12 | 13 | struct CharRange::AllString: public string 14 | { 15 | AllString() 16 | : 17 | string(Iterator::min(), Iterator::max()) 18 | { 19 | *this += *Iterator::max(); 20 | }; 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /flexc++/charrange/frame: -------------------------------------------------------------------------------- 1 | #include "charrange.ih" 2 | 3 | CharRange:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/charrange/negate.cc: -------------------------------------------------------------------------------- 1 | #include "charrange.ih" 2 | 3 | string CharRange::negate(string const &str) 4 | { 5 | string ret(FlexTypes::NCHARS, 0); 6 | 7 | auto end = set_difference(s_all.begin(), s_all.end(), 8 | str.begin(), str.end(), 9 | ret.begin()); 10 | 11 | ret.resize(end - ret.begin()); 12 | 13 | return ret; 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/dfa/README: -------------------------------------------------------------------------------- 1 | This is the DFA class, defining a Flexc++'s dfa matrix. One DFA matrix is 2 | built for every start state. 3 | 4 | The constructor receives the Rules and a vector of rule-numbers to use. 5 | 6 | The initial start condition is determined, considing of the start states of 7 | the DFA's rules. 8 | 9 | the eClosure (ASU, par. 3.6, 10 | p. 118) of the initial states of the active rules. 11 | -------------------------------------------------------------------------------- /flexc++/dfa/data.cc: -------------------------------------------------------------------------------- 1 | #include "dfa.ih" 2 | 3 | Mstream DFA::s_verbose; 4 | -------------------------------------------------------------------------------- /flexc++/dfa/dfa.ih: -------------------------------------------------------------------------------- 1 | #include "dfa.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "../rules/rules.h" 14 | #include "../states/states.h" 15 | #include "../ranges/ranges.h" 16 | #include "../options/options.h" 17 | 18 | using namespace std; 19 | using namespace FBB; 20 | 21 | // return the index of the DFA row containing 'nextRow' 22 | inline size_t DFA::available(DFARow const &nextRow) 23 | { 24 | return find(d_row.begin(), d_row.end(), nextRow) - d_row.begin(); 25 | } 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /flexc++/dfa/dfa1.cc: -------------------------------------------------------------------------------- 1 | #include "dfa.ih" 2 | 3 | DFA::DFA(Ranges &ranges, Rules &rules, States &states) 4 | : 5 | d_ranges(&ranges), 6 | d_rules(&rules), 7 | d_states(&states), 8 | d_stateSet(1), 9 | d_usedRanges(ranges.nRanges()) 10 | { 11 | if (not Options::instance().verbose()) 12 | s_verbose.off(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/dfa/frame: -------------------------------------------------------------------------------- 1 | #include "dfa.ih" 2 | 3 | DFA:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/dfa/keepuniquerows.cc: -------------------------------------------------------------------------------- 1 | #include "dfa.ih" 2 | 3 | void DFA::keepUniqueRows() 4 | { 5 | std::vector unique; 6 | 7 | inspectRows(unique); 8 | 9 | if (unique.back() == unique.size() - 1) 10 | return; 11 | 12 | s_verbose << "UNIQUE: "; 13 | if (s_verbose) 14 | copy(unique.begin(), unique.end(), 15 | ostream_iterator(s_verbose, ",")); 16 | s_verbose << '\n'; 17 | 18 | for (auto &row: d_row) 19 | row.uniqueMap(unique); 20 | 21 | shrinkDFA(unique); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /flexc++/dfa/setverbose.cc: -------------------------------------------------------------------------------- 1 | #include "dfa.ih" 2 | 3 | void DFA::setVerbose(bool on) 4 | { 5 | if (on) 6 | s_verbose.on(); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /flexc++/dfarow/dfarow.ih: -------------------------------------------------------------------------------- 1 | #include "dfarow.h" 2 | 3 | //#include //TMP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include "../templates/templates.h" 12 | 13 | using namespace std; 14 | using namespace FBB; 15 | 16 | inline void DFARow::translate(MapValue &transition, vector const &xlat) 17 | { 18 | transition.second = xlat[transition.second]; 19 | } 20 | 21 | inline bool DFARow::stateOfRule(size_t state, vector const &haystack) 22 | { 23 | return find(haystack.begin(), haystack.end(), state) != haystack.end(); 24 | } 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /flexc++/dfarow/dfarow1.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | DFARow::DFARow(Rules &rules, 4 | States &states, StateSetVector &stateSets, 5 | size_t thisRowIdx, size_t nRanges, vector *usedR) 6 | : 7 | d_finalRule(max(), max()), 8 | d_thisIdx(thisRowIdx), 9 | 10 | d_states(&states), 11 | d_stateSets(&stateSets), 12 | d_rules(&rules), 13 | d_nRanges(nRanges), 14 | d_usedRanges(usedR) 15 | {} 16 | -------------------------------------------------------------------------------- /flexc++/dfarow/frame: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | DFARow:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/dfarow/insertinto.xx: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | // put this function into dfarow.h to make the insertion operator available. 4 | // 5 | inline std::ostream &operator<<(std::ostream &out, DFARow const &row) 6 | { 7 | return row.insertInto(out); 8 | } 9 | 10 | 11 | std::ostream &DFARow::insertInto(std::ostream &out) const 12 | { 13 | out << "Row " << d_thisIdx << '\n'; 14 | for (auto &el: d_map) 15 | out << " on " << el.first << " to row " << el.second << '\n'; 16 | out << "final rule for " << d_finalRule.first << ", " << 17 | d_finalRule.second << '\n'; 18 | return out; 19 | } 20 | -------------------------------------------------------------------------------- /flexc++/dfarow/operatorequal.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | bool DFARow::operator==(DFARow const &rhs) const 4 | { 5 | return d_finalRule == rhs.d_finalRule && sameTransits(d_map, rhs.d_map); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/dfarow/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | Table &operator<<(Table &table, DFARow const &row) 4 | { 5 | row.tabulate(table); 6 | return table; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/dfarow/setfinal.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | void DFARow::setFinal(size_t ruleIdx) 4 | { 5 | size_t *target = 6 | (*d_rules)[ruleIdx].bol() ? 7 | &d_finalRule.second 8 | : 9 | &d_finalRule.first; 10 | 11 | if (ruleIdx < *target) 12 | *target = ruleIdx; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/dfarow/tabulate.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | void DFARow::tabulate(Table &table) const 4 | { 5 | tabulateTransitions(table); 6 | tabulateFinals(table); 7 | } 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /flexc++/dfarow/tabulatefinals.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | void DFARow::tabulateFinals(Table &table) const 4 | { 5 | size_t first = d_finalRule.first; 6 | size_t second = d_finalRule.second; 7 | 8 | ostringstream out; 9 | 10 | if (first != max()) 11 | { 12 | out << d_finalRule.first; 13 | if (second != max()) 14 | out << ','; 15 | } 16 | 17 | if (second != max()) 18 | out << second; 19 | 20 | table << out.str(); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /flexc++/dfarow/tabulatetransitions.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | void DFARow::tabulateTransitions(Table &table) const 4 | { 5 | // only display the ranges that are used 6 | for (size_t idx = 0; idx != d_nRanges; ++idx) 7 | { 8 | if (not (*d_usedRanges)[idx]) 9 | continue; 10 | 11 | auto iter = d_map.find(idx); 12 | if (iter == d_map.end()) 13 | table << ' '; 14 | else 15 | table << iter->second; 16 | } 17 | } 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /flexc++/dfarow/uniquemap.cc: -------------------------------------------------------------------------------- 1 | #include "dfarow.ih" 2 | 3 | void DFARow::uniqueMap(vector const &xlat) 4 | { 5 | for (auto &transition: d_map) 6 | translate(transition, xlat); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /flexc++/dfas/build.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | void DFAs::build() 4 | { 5 | size_t scIndex = 0; 6 | for (auto &sc: d_rules) 7 | { 8 | d_rules.checkUserSC(scIndex++); 9 | 10 | d_dfa.push_back( 11 | {sc.first, new DFA(d_ranges, d_rules, d_states)} ); 12 | 13 | // calls DFA::build 14 | d_dfa.back().second->build(sc.first, sc.second.rules()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/dfas/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | DFAs::~DFAs() 4 | { 5 | for (auto &pair: d_dfa) 6 | delete pair.second; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/dfas/dfas.ih: -------------------------------------------------------------------------------- 1 | #include "dfas.h" 2 | 3 | //#include //TMP 4 | 5 | #include 6 | #include 7 | 8 | #include "../dfa/dfa.h" 9 | 10 | using namespace std; 11 | using namespace FBB; 12 | -------------------------------------------------------------------------------- /flexc++/dfas/dfas1.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | DFAs::DFAs(Rules &rules, States &states, Ranges &ranges) 4 | : 5 | d_rules(rules), 6 | d_states(states), 7 | d_ranges(ranges) 8 | {} 9 | -------------------------------------------------------------------------------- /flexc++/dfas/find.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | DFAs::DFAInfo::const_iterator DFAs::find(std::string const &key) const 4 | { 5 | return find_if( 6 | d_dfa.begin(), d_dfa.end(), 7 | [&](Pair const &pair) 8 | { 9 | return pair.first == key; 10 | } 11 | ); 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /flexc++/dfas/frame: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | DFAs:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/dfas/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | ostream &operator<<(ostream &out, DFAs const &dfas) 4 | { 5 | for (auto &dfaInfo: dfas.d_dfa) 6 | out << "DFA for " << dfaInfo.first << '\n' << *dfaInfo.second; 7 | 8 | return out; 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/dfas/removerules.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | void DFAs::removeRules(DFA const &dfa, set &nonViable) const 4 | { 5 | for (auto &row: dfa.rows()) 6 | { 7 | auto &final = row.final(); 8 | nonViable.erase(final.first); 9 | nonViable.erase(final.second); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/dfas/warnnonviable.cc: -------------------------------------------------------------------------------- 1 | #include "dfas.ih" 2 | 3 | void DFAs::warnNonViable() const 4 | { 5 | set nonViable( 6 | Iterator(0), 7 | Iterator(d_rules.nUserRules()) 8 | ); 9 | 10 | for (auto &dfaInfo: d_dfa) 11 | { 12 | if (isdigit(dfaInfo.first[0])) 13 | break; 14 | 15 | removeRules(*dfaInfo.second, nonViable); 16 | } 17 | 18 | for(size_t rule: nonViable) 19 | wmsg << "Rule " << rule << " (" << d_rules[rule].source() << ": " << 20 | d_rules[rule].lineNr() << ") is never matched" << endl; 21 | } 22 | -------------------------------------------------------------------------------- /flexc++/documentation/man/directives: -------------------------------------------------------------------------------- 1 | ../manual/lexer/directives.yo -------------------------------------------------------------------------------- /flexc++/documentation/man/include/trailer.yo: -------------------------------------------------------------------------------- 1 | 2 | manpagesection(COPYRIGHT) 3 | This is free software, distributed under the terms of the 4 | GNU General Public License (GPL). 5 | 6 | manpageauthor() 7 | Frank B. Brokken (bf(f.b.brokken@rug.nl)),nl() 8 | Jean-Paul van Oosten (bf(j.p.van.oosten@rug.nl)),nl() 9 | Richard Berendsen (bf(richardberendsen@xs4all.nl)) (until 2010).nl() 10 | 11 | 12 | -------------------------------------------------------------------------------- /flexc++/documentation/man/options: -------------------------------------------------------------------------------- 1 | ../manual/intro/options.yo -------------------------------------------------------------------------------- /flexc++/documentation/manual/2oo6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | (cd ../..; build manual) 4 | yodl2html --live-data=ok flexc++ || exit 1 5 | 6 | [ $# -eq 0 ] || exit 0 7 | 8 | cp flexc++.html index.html 9 | 10 | scp *.html oosix:/var/www/icce.rug/gitman/ 11 | scp images/*.jpg oosix:/var/www/icce.rug/gitman/images/ 12 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | all: flexc++.pdf flexc++.html 4 | 5 | clean: 6 | rm flexc++*.html flexc++.{aux,latex,log,pdf,toc} 7 | 8 | flexc++.html: *.yo 9 | yodl2html flexc++ 10 | 11 | flexc++.pdf: *.yo 12 | yodl2latex flexc++ 13 | pdflatex flexc++.latex 14 | pdflatex flexc++.latex 15 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/comment.yo: -------------------------------------------------------------------------------- 1 | Flc() supports traditional bf(C) and bf(C++) style end-of-line comment. Flc() 2 | handles comment more flexible than tt(flex). Cf. section ref(comments) for 3 | details. 4 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/definitions.yo: -------------------------------------------------------------------------------- 1 | 2 | itemization( 3 | nosupport(tt(%top) block, copies code to top of yylex.cc.) 4 | (Define macros or include files.) 5 | (Include header files in Scanner.ih.) 6 | 7 | nosupport(Indented text or tt(`%{ ... %}') blocks copied verbatim to 8 | yylex.cc) 9 | (Can be used for helper code) 10 | (Use member functions and/or data members of the tt(Scanner) class.) 11 | 12 | nosupport(An unindented c-comment (tt(`/* ... */')) is copied to yylex.cc) 13 | (Commenting helper code.) 14 | (Comment outside of actions is ignored, and is considered part of 15 | flc()'s input file.) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/files.yo: -------------------------------------------------------------------------------- 1 | While bf(flex)(1) only generates a file tt(lex.yy.cc), flc() generates several 2 | files: several header files and a source file. By default flc() generates a 3 | class header file (tt(Scanner.h)), and internal header file (tt(Scanner.ih)), 4 | a base class header file (tt(Scannerbase.h)), and the file tt(lex.cc) 5 | containing the implementation of the required members of the tt(class 6 | Scanner). tt(Scannerbase.h) and tt(lex.cc) should not be edited: they are 7 | overwritten whenever flc() is invoked. The other files (tt(Scanner.h) and 8 | tt(Scanner.ih)) are generated only once, and can thereafter be modified by the 9 | user (e.g., to add members to the tt(Scanner) class). 10 | 11 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/intro.yo: -------------------------------------------------------------------------------- 1 | Although flc() tries to be as compatible as possible with bf(flex)(1), there 2 | are some noteworthy differences. This chapter provides a quick overview for 3 | the users already familiar with flex. 4 | 5 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/multiple.yo: -------------------------------------------------------------------------------- 1 | Multiple input files can easily be handled by flc(). See section 2 | ref(multiplestreams) for details. 3 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/patterns.yo: -------------------------------------------------------------------------------- 1 | Not all patterns supported by bf(flex)(1) are supported by flc(). Notably, 2 | flc() does not yet support certain flags in regular expressions, like the flag 3 | to define case-insensitive regular expressions, or the flag allowing white 4 | space in regular expressions. 5 | 6 | Another minor difference is that named patterns, defined in the definion 7 | section, cannot be used if they contain the lookahead operator (`/'). This is 8 | the result of the way name expansions are handled by flc(). Flc() handles name 9 | expansions as a parenthesized regular expression (a group). Since groups may 10 | occur any number of times in a regular expression but a lookahead operator 11 | only once, the look-ahead operator is not accepted in a named pattern. 12 | 13 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/differences/usercode.yo: -------------------------------------------------------------------------------- 1 | itemization( 2 | nosupport(The entire last section is copied to yylex.cc verbatim) 3 | (defining companion routines) 4 | (define member functions in scanner class) 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/f.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/f.tgz -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/NFA1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/NFA1.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/NFA2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/NFA2.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/concatfig.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/concatfig.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/cpttailcounts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/cpttailcounts.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/dfa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/dfa.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/dfa1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/dfa1.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/dfarow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/dfarow.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/dfas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/dfas.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/fig18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/fig18.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/fig29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/fig29.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/fig30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/fig30.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/incaccept.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/incaccept.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/inputwrapping.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/inputwrapping.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/lopdata.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/lopdata.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/lopprocedure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/lopprocedure.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/2jpg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | convert -trim $1.pdf ../$1.jpg 4 | 5 | if [ -e ../$1-0.jpg ] 6 | then 7 | mv ../$1-0.jpg ../$1.jpg 8 | rm ../$1-1.jpg 9 | fi 10 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/NFA1.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/NFA1.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/NFA1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/NFA1.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/NFA2.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/NFA2.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/NFA2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/NFA2.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/concatfig.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/concatfig.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/concatfig.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/concatfig.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/cpttailcounts.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/cpttailcounts.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/cpttailcounts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/cpttailcounts.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfa.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfa.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfa.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfa.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfa1.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfa1.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfa1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfa1.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfarow.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfarow.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfarow.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfarow.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfas.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfas.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/dfas.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/dfas.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/fig18.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/fig18.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/fig18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/fig18.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/fig29.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/fig29.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/fig29.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/fig29.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/fig30.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/fig30.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/fig30.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/fig30.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/figure.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/figure.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/generator.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/generator.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/incaccept.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/incaccept.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/incaccept.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/incaccept.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/inputwrapping.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/inputwrapping.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/inputwrapping.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/inputwrapping.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/lopdata.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/lopdata.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/lopdata.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/lopdata.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/lopprocedure.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/lopprocedure.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/lopprocedure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/lopprocedure.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/pattern.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/pattern.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/pattern.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/pattern.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/patternvalplain.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/patternvalplain.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/patternvalplain.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/patternvalplain.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/ranges.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/ranges.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/ranges.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/ranges.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/rule.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/rule.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/rule.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/rule.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/rules.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/rules.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/rules.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/rules.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/setlopblocks.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/setlopblocks.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/setlopblocks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/setlopblocks.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/state.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/state.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/state.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/state.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/statecat.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/statecat.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/statecat.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/statecat.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/states.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/states.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/states.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/states.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/tailcount.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/tailcount.odp -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/molds/tailcount.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/molds/tailcount.pdf -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/pattern.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/patternvalplain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/patternvalplain.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/ranges.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/ranges.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/rule.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/rule.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/rules.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/rules.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/rules2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/rules2.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/setlopblocks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/setlopblocks.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/state.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/state.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/statecat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/statecat.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/states.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/states.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/images/tailcount.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbb-git/flexcpp/2de6b90d79d930152f767bf0117a8d2b26a11e12/flexc++/documentation/manual/images/tailcount.jpg -------------------------------------------------------------------------------- /flexc++/documentation/manual/input/scanner/lexer: -------------------------------------------------------------------------------- 1 | %filenames scanner 2 | 3 | %% 4 | 5 | [ \t\n]+ // skip white space chars. 6 | [0-9]+ return NUMBER; 7 | [[:alpha:]_][[:alpha:][:digit:]_]* return IDENTIFIER; 8 | [][] return SIGNAL; 9 | . return matched()[0]; 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/intro/demos/mainforoutputtinglexer.cc: -------------------------------------------------------------------------------- 1 | #include "Scanner.h" 2 | 3 | int main() 4 | { 5 | Scanner scanner; 6 | scanner.lex(); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/intro/demos/mainforsimplelexer.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Scanner.h" 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | Scanner scanner; 9 | while (scanner.lex()) 10 | cout << "[Identifier: " << scanner.matched() << "]"; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/intro/demos/simpleignoringlexer: -------------------------------------------------------------------------------- 1 | %% 2 | [_a-zA-Z][_a-zA-Z0-9]* return 1; 3 | .|\n // ignore 4 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/intro/demos/simplelexer: -------------------------------------------------------------------------------- 1 | %% 2 | [_a-zA-Z][_a-zA-Z0-9]* return 1; 3 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/intro/demos/simpleoutputtinglexer: -------------------------------------------------------------------------------- 1 | %% 2 | [_a-zA-Z][_a-zA-Z0-9]* { 3 | std::cout << "[Identifier: " << matched() << "]\n"; 4 | } 5 | .|\n // ignore 6 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/lexer/comment.yo: -------------------------------------------------------------------------------- 1 | Comment may be used almost everywhere in flc()'s input file. 2 | Both traditional bf(C)-style multi-line comment (i.e., tt(/* ... */)) and 3 | bf(C++) style end-of-line comment (i.e., tt(// ...)) can be used. Indentation 4 | is optional. 5 | 6 | When comment is encountered outside of an action, flc() discards the comment, 7 | while all comment provided in the contect of actions are copied verbatim to 8 | the generated source file. 9 | 10 | Comment cannot be used when defining named regular expressions in the 11 | definitions section. 12 | 13 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/lexer/intro.yo: -------------------------------------------------------------------------------- 1 | The flc() input file consists of two sections, separated by a line containing 2 | `tt(%%)'. The section above tt(%%) contains option specifications and 3 | definitions; the section below tt(%%) contains the regular expressions (and 4 | their (optional) actions). The general layout of flc()'s input file, 5 | therefore, looks like this: 6 | 7 | verb( 8 | definitions 9 | %% 10 | rules 11 | ) 12 | 13 | Optionally, a final line containing `tt(%%)' may follow the rules. The 14 | following sections cover the `definitions' and `rules' sections. 15 | 16 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/lexer/notation.yo: -------------------------------------------------------------------------------- 1 | Instead of using a mini scanner compound statement, it is also 2 | possible to define rules using explicit start condition specifications 3 | (cf. section ref(patterns). Here is the tt(string) start condition once again, 4 | now using explicit start condition specifications: 5 | verb( 6 | %x string 7 | 8 | %% 9 | 10 | \" { 11 | more(); 12 | begin(StartCondition_::string); 13 | } 14 | \" { 15 | begin(StartCondition_::INITIAL); 16 | return Token::STRING; 17 | } 18 | \\.|. more(); 19 | ) 20 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/lexer/rules.yo: -------------------------------------------------------------------------------- 1 | The rules section of the flc() input file contains rules of the 2 | form: 3 | 4 | verb(pattern action) 5 | 6 | em(Action) is optional, and is separated from em(pattern) by spaces and/or 7 | tabs. It consists of a single-line bf(C++)-statement, or it consists of a 8 | compound statement that may span several lines. 9 | 10 | Alternatively, an action may consist of a vertical bar (`|'). A vertical bar 11 | indicates that em(pattern) uses the same action as the next rule. 12 | 13 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/technical/blocks.yo: -------------------------------------------------------------------------------- 1 | The block of bf(C++) code is simply parsed from the first tt({) until the 2 | final matching tt(}), acknowledging comment, strings and character constants. 3 | 4 | The scanner merely recognizes the beginning of an action (block), returning 5 | tt(Parser::BLOCK) from its tt(handleCharAfterBlanks) member. Then, 6 | tt(Parser::block) calls tt(Scanner::lex()) until it observes the end of the 7 | action statement or block. 8 | 9 | The parser stores the block's content in its tt(d_block) member for later 10 | processing by tt(Rules::add). 11 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/technical/interval.yo: -------------------------------------------------------------------------------- 1 | The class tt(Interval) is a simple support class defining the lower and upper 2 | bounds of an interval as tt(size_t) values. It uses tt(std::string) conversion 3 | functions to convert values stored in text format in tt(std::string) arguments 4 | to tt(size_t) values. 5 | 6 | The class defines two tt(size_t) values (tt(d_lower) and tt(d_upper)) and 7 | several factory members as well as members to access tt(d_lower) and 8 | tt(d_upper)'s values. 9 | -------------------------------------------------------------------------------- /flexc++/documentation/manual/technical/notations.yo: -------------------------------------------------------------------------------- 1 | itemization( 2 | itt(BOL): Begin-of-line. 3 | itt(LOP): the lookahead operator (tt(/)). 4 | itt(RE): A regular expression. 5 | itt(F): A final state. 6 | itt(x[y]): at state tt(x) an empty transition to state tt(y) is allowed. 7 | See figure ref(NFA1FIG). 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /flexc++/generator/baseclassh.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::baseClassH(ostream &out) const 4 | { 5 | key(out); 6 | out << "#include \"" << 7 | filename(d_options.baseclassHeaderName()) << "\"\n"; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/generator/baseclassheader.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | // Writing a base class header may be prevented by the --no-baseclass-header 4 | // option. Otherwise, it's rewritten each time flexc++ is called to process a 5 | // grammar. There should be no need for using the --no-baseclass-header 6 | // option, as all additional functionality can be defined in the 7 | // scanner's class header. 8 | 9 | void Generator::baseclassHeader() const 10 | { 11 | if (d_options("no-baseclass-header")) 12 | return; 13 | 14 | ofstream out; 15 | ifstream in; 16 | 17 | Exception::open(in, d_options.baseclassSkeleton()); 18 | Exception::open(out, d_options.baseclassHeaderPath()); 19 | 20 | filter(in, out); 21 | } 22 | -------------------------------------------------------------------------------- /flexc++/generator/baseincludes.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::baseIncludes(ostream &out) const 4 | { 5 | bool interactive = d_options.interactive(); 6 | bool caseSensitive = d_options.caseSensitive(); 7 | 8 | if (interactive || not caseSensitive) 9 | key(out); 10 | 11 | if (interactive) 12 | out << "#include \n"; 13 | 14 | if (not caseSensitive) 15 | out << "#include \n"; 16 | 17 | if (!d_debug) 18 | return; 19 | 20 | if (!interactive) 21 | { 22 | key(out); 23 | out << "#include \n"; 24 | } 25 | 26 | out << "#include \n" 27 | "#include \n"; 28 | } 29 | -------------------------------------------------------------------------------- /flexc++/generator/casecheck.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::caseCheck(ostream &out) const 4 | { 5 | if (d_options.caseSensitive()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << 11 | " ch = tolower(ch);\n" 12 | "\n"; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/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.classHeaderName()) << "\"\n"; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/generator/classhead.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::classHead(ostream &out) const 4 | { 5 | key(out); 6 | 7 | std::string const &name = d_options.className(); 8 | 9 | out << 10 | "class " << name << ": public " << name << "Base\n" 11 | "{\n" 12 | " public:\n" 13 | " explicit " << name << "(std::istream &in = std::cin,\n" 14 | " std::ostream &out = std::cout);\n"; 15 | 16 | if (not d_options.interactive()) 17 | out << 18 | "\n" 19 | " " << name << "(std::string const &infile, " 20 | "std::string const &outfile);\n"; 21 | } 22 | -------------------------------------------------------------------------------- /flexc++/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.implementationHeaderName()) << "\"\n"; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/generator/construction.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::construction(States const &states) 4 | { 5 | if (not d_options('K')) 6 | return; 7 | 8 | ofstream out; 9 | 10 | Exception::open(out, d_options.constructionPath()); 11 | 12 | out << "RANGES:\n" << 13 | d_ranges << "\n" 14 | "\n" 15 | "RULES:\n" << 16 | d_rules << "\n" 17 | "\n" 18 | "STATES:\n" 19 | << states << "\n" 20 | "\n" << 21 | d_dfas << '\n'; 22 | } 23 | -------------------------------------------------------------------------------- /flexc++/generator/debug.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | // see also: insert.cc 4 | 5 | void Generator::debug(ostream &out) const 6 | { 7 | if (not debugTest()) 8 | return; 9 | 10 | key(out); 11 | 12 | out << indent << "if (s_debug_)\n" << 13 | indent << " " << flush; 14 | 15 | if (*d_line.rbegin() != '+') 16 | out << "s_out_ << " << d_line << " << \"\\n\" << dflush_;\n"; 17 | else 18 | { 19 | d_line.resize(d_line.length() - 1); 20 | out << "s_out_ << " << d_line << ";\n"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /flexc++/generator/debugdecl.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::debugDecl(std::ostream &out) const 4 | { 5 | if (not debugCodeRequired()) 6 | return; 7 | 8 | key(out); 9 | out << 10 | " static bool s_debug_;\n" 11 | " static std::ostringstream s_out_;\n" 12 | " static std::ostream &dflush_(std::ostream &out);\n" 13 | " private:\n"; 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/generator/debugtest.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | bool Generator::debugTest() const 4 | { 5 | return d_debug || (d_field == "R" && d_options('R')); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/generator/dfa.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | // Generate a DFA in the lex.cc file. 4 | 5 | void Generator::dfa(DFAs::Pair const &dfaPair, ostream &out, 6 | vector &startStates, 7 | vector &dfaOffsets) 8 | { 9 | out << " // " << dfaPair.first << '\n'; // name of the DFA is shown 10 | startStates.push_back(dfaPair.first); 11 | dfaOffsets.push_back(*(dfaOffsets.rbegin()) + dfaPair.second->size()); 12 | 13 | size_t index = 0; 14 | for (auto &row: *dfaPair.second) 15 | dfaRow(row, index, out); // write the DFA's rows 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/generator/dfabases.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::DFAbases(ostream &out) const 4 | { 5 | string const &className = d_options.className(); 6 | 7 | out << "\n" 8 | "int const (*" << className << "Base::s_dfaBase_[])[" << 9 | dfaCols() << "] =\n" 10 | "{\n"; 11 | 12 | transform(d_startStates.begin(), d_startStates.end(), 13 | d_dfaIndices.begin(), 14 | ostream_iterator(out, "\n"), outDFAbase); 15 | 16 | out << "};\n"; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/generator/dfarow.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | // show one row of a DFA 4 | void Generator::dfaRow(DFARow const &row, size_t &index, ostream &out) 5 | { 6 | out << " {"; 7 | 8 | dfaTransitions(row, out); // show the transitions 9 | 10 | out << " "; // extra space to separate states from 11 | // the rules 12 | 13 | dfaRules(row, out); // show the rules, matched in this state 14 | 15 | out << "}, // " << index++ << '\n'; 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/generator/dfarules.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::dfaRules(DFARow const &row, ostream &out) 4 | { 5 | auto final = row.final(); 6 | 7 | out << 8 | setw(3) << 9 | (final.first != max() ? 10 | static_cast(final.first) : -1) << ',' << 11 | setw(3) << 12 | (final.second != max() ? 13 | static_cast(final.second) : -1); 14 | } 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /flexc++/generator/dfas.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::dfas(ostream &out) const 4 | { 5 | string const &className = d_options.className(); 6 | 7 | out << 8 | "int const " << className << "Base::s_dfa_[][" << dfaCols() << "] =\n" 9 | "{\n"; 10 | 11 | // write the DFAs: INITIAL is first, because FBB::LinearMap is used. 12 | for(auto &dfaPair: d_dfas) 13 | dfa(dfaPair, out, d_startStates, d_dfaIndices); 14 | 15 | out << "};\n"; 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/generator/dfatransitions.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::dfaTransitions(DFARow const &row, ostream &out) 4 | { 5 | for (size_t idx = 0, end = row.size(); idx != end; ) 6 | { 7 | auto iter = row.map().find(idx); 8 | if (iter == row.map().end()) 9 | out << "-1,"; 10 | else 11 | out << setw(2) << iter->second << ','; 12 | 13 | if (++idx % 20 == 0) 14 | out << "\n" 15 | " "; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /flexc++/generator/errexisting.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | bool Generator::errExisting(string const &fileName, string const &option, 4 | string const &pattern) const 5 | { 6 | if (not d_options.specified(option)) 7 | return false; 8 | 9 | if (not grep(fileName, pattern)) 10 | { 11 | emsg << '`' << fileName << "' exists, option/directive `" << 12 | option << "' specification conflict" << endl; 13 | return true; 14 | } 15 | 16 | return false; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/generator/frame: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | Generator:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/generator/generator1.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | Generator::Generator(Rules const &rules, Ranges const &ranges, 4 | DFAs const & dfas) 5 | : 6 | d_options(Options::instance()), 7 | d_rules(rules), 8 | d_ranges(ranges), 9 | d_dfas(dfas), 10 | d_lopUsed(rules.hasLOPrules()), 11 | d_dfaIndices(1, 0) 12 | { 13 | d_baseclassScope = d_options.className() + "Base::"; 14 | d_lineDirectives = d_options.lines(); 15 | d_debug = d_options.debug(); 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/generator/getlop.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::getLOP(ostream &out) const 4 | { 5 | out << 6 | "size_t " << d_baseclassScope << R"(getLOP() 7 | { 8 | size_t ch = d_lopIter == d_lopEnd ? as(AT_EOF) : *d_lopIter++; 9 | )"; 10 | 11 | if (d_debug) 12 | out << 13 | R"raw( 14 | if (s_debug_) 15 | { 16 | s_out_ << "getLOP() returns "; 17 | if (isprint(ch)) 18 | s_out_ << '`' << as(ch) << '\''; 19 | else 20 | s_out_ << "(int)" << as(ch); 21 | s_out_ << '\n' << dflush_; 22 | } 23 | )raw"; 24 | 25 | out << R"( 26 | return ch; 27 | } 28 | )"; 29 | 30 | } // getLOP 31 | -------------------------------------------------------------------------------- /flexc++/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 | FBB::Pattern pattern(regex); 7 | string line; 8 | 9 | while (getline(in, line)) 10 | { 11 | if (pattern << line) 12 | return true; 13 | } 14 | return false; 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/generator/implementationheader.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | // All members of the parser class should include the implementation header as 4 | // the only #included file. The implementation header should perform all 5 | // required preprocessor actions for the compilation of the Parser's class 6 | // members 7 | 8 | void Generator::implementationHeader() const 9 | { 10 | string const &implementationHeader = d_options.implementationHeaderPath(); 11 | 12 | if (Stat(implementationHeader)) 13 | return; 14 | 15 | ofstream out; 16 | ifstream in; 17 | 18 | Exception::open(in, d_options.implementationSkeleton()); 19 | Exception::open(out, implementationHeader); 20 | 21 | filter(in, out); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /flexc++/generator/inlinelexfunction.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::inlineLexFunction(std::ostream &out) const 4 | { 5 | if (not d_options.interactive()) 6 | { 7 | key(out); 8 | 9 | out << 10 | "inline int " << d_options.className() << "::" << 11 | d_options.lexFunctionName() << "()\n" 12 | "{\n" 13 | " return lex_();\n" 14 | "}\n"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/generator/insertsstream.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::insertSstream(ostream &out) const 4 | { 5 | key(out); 6 | 7 | out << "#include \n"; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/generator/interactivedecl.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::interactiveDecl(ostream &out) const 4 | { 5 | key(out); 6 | 7 | if (d_options.interactive()) 8 | out << " bool interactiveLine();\n"; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /flexc++/generator/interactiveinit.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::interactiveInit(ostream &out) const 4 | { 5 | key(out); 6 | 7 | if (!d_options.interactive()) 8 | out << 9 | " d_in(0),\n" 10 | " d_input(new std::istream(in.rdbuf())),\n"; 11 | else 12 | out << 13 | " d_in(&in),\n" 14 | " d_line(new std::istringstream()),\n" 15 | " d_input(new std::istream(d_line->rdbuf())),\n"; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /flexc++/generator/key.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::key(ostream &out) const 4 | { 5 | out << indent << "// $insert " << d_key << '\n'; 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/generator/lexfunctiondecl.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lexFunctionDecl(std::ostream &out) const 4 | { 5 | key(out); 6 | out << indent << "int " << d_options.lexFunctionName() << "();\n"; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/generator/lexsource.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lexSource() const 4 | { 5 | ifstream in; 6 | ofstream out; 7 | 8 | Exception::open(in, d_options.lexSkeleton()); 9 | Exception::open(out, d_options.lexSourcePath()); 10 | 11 | filter(in, out); 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/generator/lop2.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lop2(ostream &out) const 4 | { 5 | out << 6 | "void " << d_baseclassScope << R"(lop2_() // matched the tail 7 | { 8 | d_lopEnd = d_lopTail; // read the head 9 | d_lopIter = d_lopMatched.begin(); 10 | )"; 11 | 12 | if (d_debug) 13 | out << 14 | R"( 15 | if (s_debug_) 16 | s_out_ << "lop2_ matched tail `" << d_matched << "\'\n" << dflush_; 17 | )"; 18 | 19 | out << 20 | R"( 21 | begin(SC(d_startCondition + 1)); // switch to the head-matching 22 | } // SC 23 | )"; 24 | 25 | } // lop2 26 | -------------------------------------------------------------------------------- /flexc++/generator/lop3.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lop3(ostream &out) const 4 | { 5 | out << 6 | "inline void " << d_baseclassScope << R"(lop3_() // catch-all handler 7 | { 8 | d_lopIter = --d_lopTail; // increase the tail, try again 9 | )"; 10 | 11 | if (d_debug) 12 | out << 13 | R"( 14 | if (s_debug_) 15 | s_out_ << "lop3_: trying to match tail `" << 16 | std::string(d_lopIter, d_lopEnd) << "'\n" << dflush_; 17 | )"; 18 | 19 | out << 20 | "}\n"; 21 | 22 | } // lop3 23 | -------------------------------------------------------------------------------- /flexc++/generator/lopf.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lopf(ostream &out) const 4 | { 5 | out << 6 | "void " << d_baseclassScope << R"(lopf_(size_t tail) 7 | { 8 | tail = length() - tail; 9 | push(d_matched.substr(tail, std::string::npos)); 10 | d_matched.resize(tail); 11 | d_atBOL = length() && d_matched.back() == '\n'; 12 | } 13 | )"; 14 | 15 | } // lopf 16 | -------------------------------------------------------------------------------- /flexc++/generator/lopimplementation.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::lopImplementation(ostream &out) const 4 | { 5 | if (not d_lopUsed) 6 | return; 7 | 8 | key(out); 9 | 10 | if (d_rules.hasFixedTailLOPrules()) 11 | lopf(out); 12 | 13 | if (d_rules.hasVariableTailLOPrules()) 14 | { 15 | lop1(out); 16 | lop2(out); 17 | lop3(out); 18 | lop4(out); 19 | 20 | getLOP(out); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /flexc++/generator/namespaceclose.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::namespaceClose(std::ostream &out) const 4 | { 5 | if (d_options.nameSpace().empty()) 6 | return; 7 | 8 | key(out); 9 | out << "}\n"; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/generator/namespaceopen.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::namespaceOpen(std::ostream &out) const 4 | { 5 | if (not d_options.nameSpace().empty()) 6 | { 7 | key(out); 8 | out << "namespace " << d_options.nameSpace() << "\n" 9 | "{\n"; 10 | } 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /flexc++/generator/namespaceuse.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::namespaceUse(ostream &out) const 4 | { 5 | if (d_options.nameSpace().empty()) 6 | return; 7 | 8 | key(out); 9 | out << 10 | " // UN-comment the next using-declaration if you want to use\n" 11 | " // symbols from the namespace " << d_options.nameSpace() << 12 | " without prefixing " << d_options.nameSpace() << "::\n" 13 | "//using namespace " << d_options.nameSpace() << ";\n"; 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/generator/outdfabase.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | string Generator::outDFAbase([[maybe_unused]] string const &startState, 4 | size_t offset) 5 | { 6 | string ret = " s_dfa_ + " + to_string(offset) + ","; 7 | return ret; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/generator/print.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::print(ostream &out) const 4 | { 5 | if (!d_options.print()) 6 | return; 7 | 8 | key(out); 9 | 10 | out << 11 | " std::cout << \"Token: \" << d_token_;\n" 12 | " if (isprint(d_token_))\n" 13 | " std::cout << \" (`\" << " 14 | "static_cast(d_token_) << \"')\";\n" 15 | " std::cout << \", matched: `\" << d_matched << \"'\\n\";\n"; 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/generator/ranges.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::ranges(ostream &out) const 4 | { 5 | string const &className = d_options.className(); 6 | 7 | out << 8 | "size_t const " << className << "Base::s_ranges_[] =\n" 9 | "{"; 10 | 11 | size_t const *charRange = d_ranges.alphabet(); 12 | for (size_t begin = 0; begin != 256; ++begin) 13 | { 14 | if (begin % 25 == 0) 15 | out << "\n" 16 | " "; 17 | out << setw(2) << *charRange++ << ','; 18 | } 19 | 20 | out << "\n" 21 | "};\n"; 22 | } 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /flexc++/generator/scannerconstructors.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::scannerConstructors(ostream &out) const 4 | { 5 | key(out); 6 | 7 | std::string const &name = d_options.className(); 8 | 9 | out << 10 | "inline " << name << "::" << name << 11 | "(std::istream &in, std::ostream &out)\n" 12 | ":\n" 13 | " " << name << "Base(in, out)\n" 14 | "{}\n"; 15 | 16 | if (not d_options.interactive()) 17 | out << 18 | "\n" 19 | "inline " << name << "::" << name << "(std::string const &infile," 20 | " std::string const &outfile)\n" 21 | ":\n" 22 | " " << name << "Base(infile, outfile)\n" 23 | "{}\n"; 24 | } 25 | -------------------------------------------------------------------------------- /flexc++/generator/startconddecl.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::startCondDecl(ostream &out) const 4 | { 5 | key(out); 6 | 7 | string const &scName = d_options.startConditionName(); 8 | 9 | // inserted in flexc++base.h 10 | out << 11 | " " << scName << " startCondition() const; // current start condition\n" 12 | " void begin(" << scName << " startCondition);\n" 13 | "\n" 14 | "private:\n" 15 | " static " << scName << " constexpr SC(int sc);\n" 16 | " static int constexpr SC(" << scName << " sc);\n"; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/generator/startcondenum.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::startCondEnum(ostream &out) const 4 | { 5 | key(out); 6 | 7 | out << indent << "enum class " << d_options.startConditionName() << "{\n"; 8 | 9 | for (auto it = d_rules.begin(), end = d_rules.endUserSC(); it != end; ++it) 10 | out << indent << " " << it->first << ",\n"; 11 | 12 | out << indent << "};\n"; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/generator/startcondinfo.cc: -------------------------------------------------------------------------------- 1 | #include "generator.ih" 2 | 3 | void Generator::startCondInfo(ostream &out) const 4 | { 5 | key(out); 6 | 7 | string const &scName = d_options.startConditionName(); 8 | 9 | // inserted in flexc++.cc 10 | 11 | out << 12 | " // s_dfa_ contains the rows of *all* DFAs ordered by start state. " 13 | "The\n" 14 | " // enum class " << scName << "is defined in the baseclass header.\n" 15 | " // " << scName << "::INITIAL is always 0. " 16 | "Each entry defines the row to\n"; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/icmake/adddir: -------------------------------------------------------------------------------- 1 | list addDir(list dir, string entry) 2 | { 3 | list ret; 4 | int idx; 5 | int keep = 1; 6 | string elem; 7 | 8 | for (idx = listlen(dir); idx--; ) 9 | { 10 | elem = dir[idx]; 11 | 12 | if (strfind(entry, elem) != -1) // entry contains dir, ignore dir 13 | ret += (list)entry; 14 | else if (strfind(elem, entry) != -1) // dir contains entry 15 | { 16 | ret += (list)elem; 17 | keep = 0; 18 | } 19 | else // new unique entry, keep dir[idx] 20 | ret += (list)elem; 21 | } 22 | 23 | if (keep) 24 | ret += (list)entry; 25 | 26 | return ret; 27 | } 28 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/icmake/cuteoln: -------------------------------------------------------------------------------- 1 | string cutEoln(string text) 2 | { 3 | int len; 4 | 5 | len = strlen(text) - 1; 6 | if (text[len] == "\n") 7 | text = substr(text, 0, len); 8 | return text; 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/icmake/findall: -------------------------------------------------------------------------------- 1 | // assuming we're in g_cwd, all entries of type 'type' matching source/pattern 2 | // are returned w/o final \n 3 | 4 | list findAll(string type, string source, string pattern) 5 | { 6 | string cmd; 7 | list entries; 8 | list ret; 9 | int idx; 10 | 11 | chdir(source); 12 | 13 | cmd = "find ./ -mindepth 1 -maxdepth 1 -type " + type; 14 | 15 | if (pattern != "") 16 | pattern = "-name '" + pattern + "'"; 17 | 18 | entries = backtick(cmd + " " + pattern + " -printf \"%f\\n\""); 19 | 20 | for (idx = listlen(entries); idx--; ) 21 | ret += (list)cutEoln(entries[idx]); 22 | 23 | chdir(g_cwd); 24 | 25 | return ret; 26 | } 27 | -------------------------------------------------------------------------------- /flexc++/icmake/github: -------------------------------------------------------------------------------- 1 | void github() 2 | { 3 | run("cp -r release.yo tmp/manhtml tmp/manual ../../wip"); 4 | run("cp changelog ../../wip/changelog.txt"); 5 | exit(0); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/icmake/log: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find tmp/install -type f -exec md5sum "{}" \; | 4 | sed 's|tmp/install|'$1'|' > $2 5 | find tmp/install -type l -exec printf "link %s\n" "{}" \; | 6 | sed 's|tmp/install|'$1'|' >> $2 7 | find tmp/install -type d -exec printf "dir %s\n" "{}" \; | 8 | sed 's|tmp/install|'$1'|' >> $2 9 | 10 | -------------------------------------------------------------------------------- /flexc++/icmake/logfile: -------------------------------------------------------------------------------- 1 | void logFile(string srcdir, string src, string destdir, string dest) 2 | { 3 | chdir(g_cwd); 4 | md(destdir); 5 | 6 | run("cp " + srcdir + "/" + src + " " + destdir + "/" + dest); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/icmake/manpage: -------------------------------------------------------------------------------- 1 | 2 | void _manpage(string dest, string manpage, string source) 3 | { 4 | run("yodl2man -o " + dest + manpage + " " + source); 5 | run("yodl2html " 6 | "-o ../../tmp/manhtml/" + manpage + ".html " + source); 7 | } 8 | 9 | void manpage() 10 | { 11 | md("tmp/man tmp/manhtml"); 12 | 13 | chdir("documentation/man"); 14 | 15 | _manpage("../../tmp/man/", PROGRAM ".1", PROGRAM ".yo"); 16 | _manpage("../../tmp/man/", PROGRAM "api.3", PROGRAM "api.yo"); 17 | _manpage("../../tmp/man/", PROGRAM "input.7", PROGRAM "input.yo"); 18 | 19 | 20 | exit(0); 21 | } 22 | -------------------------------------------------------------------------------- /flexc++/icmake/manual: -------------------------------------------------------------------------------- 1 | void manual() 2 | { 3 | list files; 4 | string file; 5 | string cwd; 6 | int idx; 7 | string compiler; 8 | 9 | compiler = setOpt(CXX, "CXX"); 10 | 11 | cwd = chdir("."); 12 | 13 | md("tmp/manual/images"); 14 | 15 | chdir("documentation"); 16 | 17 | chdir("manual"); 18 | 19 | run("yodl2html -l3 " PROGRAM ".yo"); 20 | run("mv *.html ../../tmp/manual"); 21 | run("cp -r images/*.jpg ../../tmp/manual/images"); 22 | 23 | exit(0); 24 | } 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /flexc++/icmake/md: -------------------------------------------------------------------------------- 1 | // md: target should be a series of blank-delimited directories to be created 2 | // If an element is a whildcard, the directory will always be created, 3 | // using mkdir -p. 4 | // 5 | // uses: run() 6 | 7 | void md(string target) 8 | { 9 | int idx; 10 | list paths; 11 | string dir; 12 | 13 | if (!exists(target)) 14 | run("mkdir -p " + target); 15 | else if (((int)stat(target)[0] & S_IFDIR) == 0) 16 | { 17 | printf(target + " exists, but is not a directory\n"); 18 | exit(1); 19 | } 20 | } 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/icmake/special: -------------------------------------------------------------------------------- 1 | string g_skel; 2 | 3 | void special() 4 | { 5 | g_skel = setOpt(SKEL, "SKEL"); 6 | 7 | if ("INSTALL.im" newer "options/SKEL") 8 | run("echo \"#define _Skel_ \\\"" + g_skel + "\\\"\" > options/SKEL"); 9 | 10 | if (! exists("release.yo") || "VERSION" newer "release.yo") 11 | { 12 | system("touch version.cc"); 13 | run("gcc -E VERSION.h | grep -v '#' | sed 's/\\\"//g' > " 14 | "release.yo"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/interval/exact.cc: -------------------------------------------------------------------------------- 1 | #include "interval.ih" 2 | 3 | Interval Interval::exact(std::string const &text) 4 | { 5 | size_t value = stoul(text); 6 | 7 | Interval ret(value, value); 8 | return ret; 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/interval/frame: -------------------------------------------------------------------------------- 1 | #include "interval.ih" 2 | 3 | Interval:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/interval/interval.ih: -------------------------------------------------------------------------------- 1 | #include "interval.h" 2 | 3 | #include 4 | #include "../templates/templates.h" 5 | 6 | using namespace std; 7 | 8 | -------------------------------------------------------------------------------- /flexc++/interval/lowerbound.cc: -------------------------------------------------------------------------------- 1 | #include "interval.ih" 2 | 3 | Interval Interval::lowerBound(std::string const &lower) 4 | { 5 | Interval ret(stoul(lower), max()); 6 | return ret; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/interval/range.cc: -------------------------------------------------------------------------------- 1 | #include "interval.ih" 2 | 3 | Interval Interval::range(string const &lower, string const &upper) 4 | { 5 | Interval ret {stoul(lower), stoul(upper)}; 6 | return ret; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/main.ih: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include "options/options.h" 9 | #include "states/states.h" 10 | #include "rules/rules.h" 11 | #include "parser/parser.h" 12 | #include "ranges/ranges.h" 13 | #include "dfas/dfas.h" 14 | #include "dfa/dfa.h" 15 | #include "generator/generator.h" 16 | 17 | extern char version[]; 18 | extern char year[]; 19 | 20 | void usage(std::string const &progname); 21 | 22 | using namespace std; 23 | using namespace FBB; 24 | -------------------------------------------------------------------------------- /flexc++/newgrammar: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd parser 4 | bisonc++ grammar 5 | touch a 6 | rm -f parser.ih.gch 7 | 8 | cd ../scanner 9 | flexc++ lexer 10 | touch a 11 | rm -f scanner.ih.gch 12 | 13 | cd .. 14 | build program 15 | -------------------------------------------------------------------------------- /flexc++/options/accept.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::accept(string const &text, 4 | PathType pathType, char const *declTxt) 5 | { 6 | if (pathType == FILENAME && text.find('/') != string::npos) 7 | emsg << '`' << declTxt << "' option/directive: no path names" << endl; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/options/assign.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::assign(TextType textType, std::string *target, 4 | PathType pathType, char const *declTxt) 5 | { 6 | if (not target->empty()) 7 | emsg << "%" << declTxt << " multiply specified" << endl; 8 | else 9 | { 10 | s_warnOptions.insert(declTxt); 11 | accept(*target = textOf(textType), pathType, declTxt); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /flexc++/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 | -------------------------------------------------------------------------------- /flexc++/options/classheadername.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | std::string Options::classHeaderName() const 4 | { 5 | size_t pos = d_classHeader.rfind('/'); 6 | 7 | return pos == string::npos ? 8 | d_classHeader 9 | : 10 | d_classHeader.substr(pos + 1); 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/options/data.cc: -------------------------------------------------------------------------------- 1 | // Recompile this file if the skeleton locations in INSTALL.im change 2 | 3 | #include "options.ih" 4 | #include "SKEL" 5 | 6 | char Options::s_defaultSkeletonDirectory[] = _Skel_; 7 | char Options::s_defaultLexFunctionName[] = "lex"; 8 | char Options::s_defaultClassName[] = "Scanner"; 9 | char Options::s_defaultStartConditionName[] = "StartCondition_"; 10 | 11 | void (*Options::s_regexCall)(char const *funName) = Options::nop; 12 | 13 | set Options::s_warnOptions; 14 | 15 | Options *Options::s_options = 0; 16 | 17 | -------------------------------------------------------------------------------- /flexc++/options/frame: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | Options:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/options/implementationheadername.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | std::string Options::implementationHeaderName() const 4 | { 5 | size_t pos = d_implementationHeader.rfind('/'); 6 | 7 | return pos == string::npos ? 8 | d_implementationHeader 9 | : 10 | d_implementationHeader.substr(pos + 1); 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/options/instance.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | Options &Options::instance() 4 | { 5 | if (s_options == 0) 6 | s_options = new Options(); 7 | // yes, it exists until the program ends 8 | // and memory is claimed back by the 9 | // operaring system 10 | return *s_options; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/options/operatorfun1.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | bool Options::operator()(int opt) const 4 | { 5 | return d_arg.option(opt); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/options/operatorfun2.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | bool Options::operator()(char const *opt) const 4 | { 5 | return d_arg.option(0, opt); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/options/options.ih: -------------------------------------------------------------------------------- 1 | #include "options.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "SKEL" 10 | 11 | inline void Options::nop(char const *) 12 | {} 13 | 14 | using namespace std; 15 | using namespace FBB; 16 | 17 | 18 | #define FLEXCPPBASE_H "/flexc++base.h" 19 | #define FLEXCPP_H "/flexc++.h" 20 | #define FLEXCPP_IH "/flexc++.ih" 21 | #define FLEXCPP_CC "/flexc++.cc" 22 | 23 | -------------------------------------------------------------------------------- /flexc++/options/options1.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | Options::Options() 4 | : 5 | d_arg(Arg::instance()), 6 | d_infile(d_arg[0]), 7 | d_lines(not d_arg.option(0, "no-lines")), 8 | d_matchedRules(d_arg.option('R')), 9 | d_verbose(d_arg.option('V')), 10 | d_caseSensitive(not d_arg.option(0, "case-insensitive")), 11 | d_ownParser(d_arg.option('P')) 12 | { 13 | if (d_arg.option(0, "regex-calls")) 14 | s_regexCall = show; 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/options/setclassname.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setClassName(TextType textType) 4 | { 5 | if (d_className.size()) 6 | emsg << "%class-name multiply specified" << endl; 7 | else 8 | d_className = textOf(textType); 9 | 10 | s_warnOptions.insert("class-name"); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /flexc++/options/setfilenames.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setFilenames(TextType textType) 4 | { 5 | if (d_filenames.size()) 6 | emsg << "%filenames multiply specified" << endl; 7 | else 8 | d_filenames = textOf(textType); 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/options/setlexfunctionname.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setLexFunctionName(TextType textType) 4 | { 5 | if (d_lexFunctionName.size()) 6 | emsg << "%lex-function-name multiply specified" << endl; 7 | else 8 | d_lexFunctionName = textOf(textType); 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/options/setnamespaceidentifier.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setNameSpaceIdentifier() 4 | { 5 | for (int ch: d_nameSpace) 6 | { 7 | if (isalnum(ch) || ch == '_') 8 | d_nameSpaceIdentifier += ch; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/options/setparserinfo.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setParserInfo(string const &matched, string const &rawString) 4 | { 5 | d_matched = &matched; 6 | d_rawString = &rawString; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /flexc++/options/setstartconditionname.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | void Options::setStartConditionName(TextType textType) 4 | { 5 | if (d_startConditionName.size()) 6 | emsg << "%startcondition-name multiply specified" << endl; 7 | else 8 | d_startConditionName = textOf(textType); 9 | 10 | s_warnOptions.insert("startcondition-name"); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /flexc++/options/textof.cc: -------------------------------------------------------------------------------- 1 | #include "options.ih" 2 | 3 | string const &Options::textOf(TextType type) 4 | { 5 | switch (type) 6 | { 7 | case TextType::RAWSTRING: 8 | return *d_rawString; 9 | 10 | case TextType::STRING: 11 | if (d_matched->find('"') == 0 ) 12 | return d_undelimit = 13 | d_matched->substr(1, d_matched->size() - 2); 14 | [[fallthrough]] 15 | 16 | case TextType::IDENT: 17 | return *d_matched; 18 | 19 | default: // not reached, but added to prevent the 'control 20 | throw 1; // reaches the end of non-void function' warning. 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /flexc++/parser/assignblock.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::assignBlock() 4 | { 5 | d_rules.assignBlock(d_block); // assign the action block to all 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/parser/boln.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Pattern Parser::boln() 4 | { 5 | if (d_tokenCount <= 1) 6 | d_boln = true; 7 | else 8 | { 9 | if (not d_warnCarets) 10 | wmsg << "`^' inside regex loses its special meaning" << endl; 11 | d_warnCarets = true; 12 | } 13 | 14 | return rawText(d_warnCarets ? "^" : ""); 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/parser/cleanup.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::cleanup() 4 | { 5 | emsg.setTag("error"); 6 | 7 | wmsg.setTag("Warning"); 8 | wmsg.noLineNr(); 9 | 10 | d_options.setAccessorVariables(); 11 | 12 | // bisonc++ calls d_options.setVerbosity(); here 13 | 14 | d_options.setPathStrings(); 15 | 16 | if (int count = emsg.count()) // Terminate if parsing produced errors. 17 | { 18 | cout << "Error(s): " << count << '\n'; 19 | throw 1; 20 | } 21 | 22 | d_options.showFilenames(); 23 | // shows the verbosity-filename, otherwise 24 | // independent of the verbosity setting 25 | } 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /flexc++/parser/data.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | string Parser::s_lastMsg; 4 | int Parser::s_ignoreToken; 5 | 6 | -------------------------------------------------------------------------------- /flexc++/parser/dollar.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Pattern Parser::dollar() 4 | { 5 | if (not d_warnDollars) 6 | wmsg << "`$' inside regex loses its special meaning" << endl; 7 | d_warnDollars = true; 8 | 9 | return rawText("$"); 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/parser/eolndollar.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Pattern Parser::eolnDollar() 4 | { 5 | d_scanner.eolnDollar(); 6 | return rawText(""); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/parser/frame: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Parser:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/parser/inc/action: -------------------------------------------------------------------------------- 1 | // the scanner returns BLOCK if it encounters a non-blank character 2 | // on a line after ws, unless the character is a '|' 3 | // the block() member then processes the action block's tokens 4 | action: 5 | BLOCK 6 | { 7 | block(); // do not embed this elsewhere, as block() eats tokens 8 | } 9 | ; 10 | 11 | -------------------------------------------------------------------------------- /flexc++/parser/inc/combichars: -------------------------------------------------------------------------------- 1 | // elements may need to be split between _cc_element and _simple_regex 2 | // if their handling turns out to be special 3 | combi_chars: 4 | ',' 5 | | 6 | '=' 7 | | 8 | '-' 9 | | 10 | '\'' 11 | ; 12 | 13 | -------------------------------------------------------------------------------- /flexc++/parser/inc/msspec: -------------------------------------------------------------------------------- 1 | _ms_name: 2 | identifier 3 | { 4 | d_rules.addStartCondition($1); 5 | } 6 | ; 7 | 8 | _ms_name_list: 9 | _ms_name_list ',' _ms_name 10 | | 11 | _ms_name 12 | ; 13 | 14 | _ms_specs: 15 | '*' 16 | { // following <*> all mini scanners apply 17 | d_rules.useAll(); 18 | } 19 | | 20 | _ms_name_list 21 | ; 22 | 23 | _ms_angular: 24 | '<' 25 | { 26 | d_scanner.acceptMulti(); 27 | d_scanner.forceCaseSensitive(); 28 | } 29 | ; 30 | 31 | ms_spec: 32 | _ms_angular _ms_specs '>' 33 | { 34 | d_scanner.ignoreWS(); 35 | d_scanner.multiAsChar(); 36 | } 37 | ; 38 | 39 | 40 | -------------------------------------------------------------------------------- /flexc++/parser/inc/reset: -------------------------------------------------------------------------------- 1 | reset: 2 | { 3 | reset(); 4 | } 5 | ; 6 | 7 | -------------------------------------------------------------------------------- /flexc++/parser/inc/rules: -------------------------------------------------------------------------------- 1 | _rule_def: 2 | // only an empty line is OK 3 | | 4 | // recovery from errors is OK: continue at the next line 5 | error 6 | | 7 | optMs_rule 8 | | 9 | msCompound 10 | ; 11 | 12 | // each rule ends in a '\n' 13 | _rule: 14 | _rule_def '\n' reset 15 | // { 16 | // if (d_scanner.endOfInput()) 17 | // ACCEPT(); 18 | // } 19 | ; 20 | 21 | // there may be no rules 22 | // the scanner skips blanks, but returns '\n' 23 | rules: 24 | rules _rule 25 | | 26 | // empty 27 | ; 28 | 29 | -------------------------------------------------------------------------------- /flexc++/parser/interval.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Pattern Parser::interval(Pattern ®ex, Interval const &interval) 4 | { 5 | Options::regexCall("interval"); 6 | 7 | d_scanner.multiAsChar(); 8 | return Pattern::interval(d_states, regex, interval); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /flexc++/parser/lex.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | int Parser::lex() 4 | { 5 | print(); 6 | ++d_tokenCount; 7 | 8 | if (d_nlAtEOF) 9 | return 0; 10 | 11 | int token = d_scanner.pLex(); 12 | 13 | if (token == 0) 14 | { 15 | d_nlAtEOF = true; 16 | return '\n'; 17 | } 18 | 19 | return token; 20 | } 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /flexc++/parser/parser1.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Parser::Parser(Rules &rules, States &states) 4 | : 5 | d_options(Options::instance()), 6 | d_scanner(d_options.infile()), 7 | d_matched(d_scanner.matched()), 8 | d_block(0, ""), 9 | d_printTokens(d_options('T')), 10 | d_rules(rules), 11 | d_states(states) 12 | { 13 | d_options.setParserInfo(d_matched, d_rawStringContents); 14 | s_ignoreToken = token_(); // set by ParserBase to _UNDETERMINED 15 | // setDebug(d_options.debug()); // write debug code to the generated 16 | // lex.cc file 17 | setDebug(d_options.ownParserDebug()); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /flexc++/parser/preinclude.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PREINCLUDE_H_ 2 | #define INCLUDED_PREINCLUDE_H_ 3 | 4 | // #include "../spsemunion/spsemunion.h" 5 | 6 | #include "../charclass/charclass.h" 7 | #include "../interval/interval.h" 8 | #include "../pattern/pattern.h" 9 | #include "../flextypes/flextypes.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /flexc++/parser/print.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::print() 4 | { 5 | if (d_printTokens && token_() != s_ignoreToken) 6 | { 7 | std::cout << "Token: " << symbol_(token_()); 8 | 9 | if (isprint(token_()) || token_() > 0xff) 10 | std::cout << ", text: `" << d_matched << "'\n"; 11 | else 12 | std::cout << '\n'; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/parser/quotes.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Pattern Parser::quotes() 4 | { 5 | std::string &&str = String::unescape( 6 | d_matched.substr(1, d_scanner.length() - 2)); 7 | 8 | if (str.length() != 1) 9 | { 10 | d_doError = false; 11 | emsg << "Quoted character constants require one character" << endl; 12 | ERROR(); 13 | } 14 | 15 | return rawText(str); 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/parser/rawstring.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Parser::TextType Parser::rawString() 4 | { 5 | d_rawStringContents = d_scanner.rawStringContents(); 6 | return TextType::RAWSTRING; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/parser/reset.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | void Parser::reset() 4 | { 5 | s_lastMsg.clear(); 6 | d_parentheses = 0; 7 | d_usesLOP = false; 8 | d_boln = false; 9 | d_warnCarets = false; 10 | d_warnDollars = false; 11 | d_tokenCount = 0; 12 | d_scanner.multiAsChar(); 13 | d_scanner.setCaseSensitive(); 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/pattern/alternatives.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::alternatives(States &states, 4 | Pattern const &lhs, 5 | Pattern const &rhs) 6 | { 7 | Options::regexCall("alternatives"); 8 | 9 | Pair pair = states.next2(); 10 | states[pair.first] = State(EMPTY, lhs.begin(), rhs.begin()); 11 | 12 | states[lhs.end()] = State(EMPTY, pair.second, 0); 13 | states[rhs.end()] = State(EMPTY, pair.second, 0); 14 | 15 | Pattern ret(pair); 16 | 17 | if 18 | ( 19 | lhs.fixedLength() 20 | && rhs.fixedLength() 21 | && lhs.d_length == rhs.d_length 22 | ) 23 | ret.d_length = lhs.d_length; 24 | 25 | return ret; 26 | } 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /flexc++/pattern/canbeempty.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | bool Pattern::canBeEmpty(States const &states) const 4 | { 5 | return 6 | (fixedLength() && length() == 0) 7 | or 8 | empty(states, d_pair.first); 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/pattern/characterclass.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::characterClass(States &states, CharClass &charClass) 4 | { 5 | Pair pair = states.next2(); 6 | 7 | states[pair.first] = State(CHARSET, charClass.str(), pair.second); 8 | 9 | Pattern ret(pair); 10 | 11 | ret.d_length = not charClass.empty(); 12 | 13 | return ret; 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/pattern/concatenate.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | // States: 4 | // B1 -> E1 and B2 -> E2 5 | // becomes: 6 | // B1 -> (E1 = B2) -> E2 (B2 is assigned to E1) 7 | // B2 is returned to the State's free store. 8 | 9 | Pattern Pattern::concatenate(States &states, Pattern const &lhs, 10 | Pattern const &rhs) 11 | { 12 | Options::regexCall("concatenate"); 13 | 14 | states[lhs.end()] = states[rhs.begin()]; 15 | states.collect(rhs.begin()); 16 | 17 | Pattern ret({lhs.begin(), rhs.end()} ); 18 | 19 | if (lhs.fixedLength() && rhs.fixedLength()) 20 | ret.d_length = lhs.d_length + rhs.d_length; 21 | 22 | return ret; 23 | } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /flexc++/pattern/dot.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::dot(States &states) 4 | { 5 | CharClass charClass; 6 | charClass.append(vector(1, CharClass::predefined("."))); 7 | 8 | Pattern ret = characterClass(states, charClass); 9 | 10 | ret.d_length = 1; 11 | return ret; 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/pattern/duplicate.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | // Returns a Pattern which is a duplicate of the current pattern. It's a 4 | // self-supporting pattern, i.e., in the returned pattern all its next1/next2 5 | // links refer to the new pattern's states, and the StateData elements are 6 | // deep copies. 7 | 8 | Pattern Pattern::duplicate(States &states) const 9 | { 10 | Map map; 11 | map[0] = 0; // the end link remains as-is and is implicitly 12 | // available 13 | 14 | // the pair-indices of the new pattern are found in map[d_pair.first] 15 | // and map[d_pair.second]; 16 | 17 | dupPattern(map, states, d_pair.first); 18 | 19 | return Pattern(Pair(map[d_pair.first], map[d_pair.second])); 20 | } 21 | -------------------------------------------------------------------------------- /flexc++/pattern/empty.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | bool Pattern::empty(States const &states, size_t idx) 4 | { 5 | State const &state = states[idx]; 6 | 7 | switch (state.type()) 8 | { 9 | case EMPTY: 10 | return empty(states, state.next1()) || empty(states, state.next2()); 11 | 12 | case FINAL: 13 | return true; 14 | 15 | default: 16 | return false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/pattern/eof.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::eof(States &states) 4 | { 5 | Pair pair = states.next2(); 6 | 7 | states[pair.first] = State(EOF_, pair.second, 0); 8 | 9 | Pattern ret(pair); 10 | return ret; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/pattern/escape.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::escape(States &states, std::string const &ch) 4 | { 5 | Pair pair = states.next2(); 6 | 7 | states[pair.first] = 8 | State( 9 | static_cast(String::unescape(ch)[0]), 10 | pair.second 11 | ); 12 | 13 | Pattern ret(pair); 14 | ret.d_length = 1; 15 | return ret; 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/pattern/frame: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/pattern/join.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | void Pattern::join(States &states, Pattern &pattern, size_t upper, 4 | PairVector const &beginEnd) 5 | { 6 | Pattern next; 7 | 8 | for (size_t idx = 1; idx != upper; ++idx) 9 | { 10 | next.d_pair = beginEnd[idx]; 11 | pattern = concatenate(states, pattern, next); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/pattern/jumptoend.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | void Pattern::jumpToEnd(States &states, PairVector &beginEnd, 4 | size_t lower, size_t upper, Map &eject) 5 | { 6 | size_t exitState = beginEnd.back().second; // target state 7 | // for exit jumps 8 | 9 | for (size_t idx = lower; idx != upper; ++idx) // add connections to the 10 | { // exit-state 11 | states[eject[idx]] = State(EMPTY, beginEnd[idx].first, exitState); 12 | 13 | beginEnd[idx].first = eject[idx]; // new begin state 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/pattern/operatorassign.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern &Pattern::operator=(Pair const &pair) 4 | { 5 | d_pair = pair; 6 | d_lopData.reset(); 7 | return *this; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/pattern/optrepeatlastpattern.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::optRepeatLastPattern(States &states, 4 | Pattern &pattern, 5 | size_t lower, PairVector &beginEnd) 6 | { 7 | Pattern last(beginEnd.back()); 8 | 9 | // change the last pattern to pattern+ 10 | // update the begin- and end-indices 11 | beginEnd.back() = plus(states, last).d_pair; 12 | 13 | join(states, pattern, lower, beginEnd); 14 | 15 | Pattern ret( {pattern.begin(), pattern.end()} ); 16 | return ret; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/pattern/pattern.ih: -------------------------------------------------------------------------------- 1 | #include "pattern.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "../interval/interval.h" 11 | #include "../charclass/charclass.h" 12 | #include "../options/options.h" 13 | #include "../states/states.h" 14 | #include "../templates/templates.h" 15 | 16 | using namespace std; 17 | using namespace FBB; 18 | -------------------------------------------------------------------------------- /flexc++/pattern/pattern1.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern::Pattern(Pair const &pair) 4 | : 5 | d_pair(pair) 6 | {} 7 | -------------------------------------------------------------------------------- /flexc++/pattern/pattern2.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern::Pattern(States &states, Pattern const &lopLhs, Pattern const &lopRhs, 4 | size_t startCondition) 5 | : 6 | d_lopData(new LopData {startCondition, lopLhs.pair().second, 7 | lopLhs.duplicate(states) }), 8 | d_pair(concatenate(states, lopLhs, lopRhs).pair()) 9 | {} 10 | -------------------------------------------------------------------------------- /flexc++/pattern/pattern3.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | // This is a fixed-sized tail. 4 | 5 | Pattern::Pattern(States &states, size_t tailLength, 6 | Pattern const &lopLhs, Pattern const &lopRhs) 7 | : 8 | d_lopData(new LopData {tailLength, 0} ), 9 | d_pair(concatenate(states, lopLhs, lopRhs).pair()) 10 | {} 11 | -------------------------------------------------------------------------------- /flexc++/pattern/plus.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::plus(States &states, Pattern const &pattern) 4 | { 5 | Pair pair = states.next2(); // create new Start/Final states 6 | 7 | // pattern's end connects to pattern begin and the new FINAL state. 8 | states[pattern.end()] = State(EMPTY, pattern.begin(), pair.second); 9 | 10 | // Start state connects to the pattern's begin 11 | states[pair.first] = State(EMPTY, pattern.begin(), 0); 12 | 13 | Pattern ret(pair); 14 | 15 | return ret; 16 | } 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /flexc++/pattern/quantifier.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::quantifier(States &states, Pattern const &pat, 4 | size_t type) 5 | { 6 | Options::regexCall("quantifier"); 7 | 8 | Pattern ret; 9 | 10 | switch (type) 11 | { 12 | case '*': 13 | ret = star(states, pat); 14 | break; 15 | 16 | case '+': 17 | ret = plus(states, pat); 18 | break; 19 | 20 | case '?': 21 | ret = questionMark(states, pat); 22 | break; 23 | } 24 | 25 | return ret; 26 | } 27 | -------------------------------------------------------------------------------- /flexc++/pattern/questionmark.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::questionMark(States &states, Pattern const &pattern) 4 | { 5 | size_t idx = states.next(); // new start state 6 | 7 | // connect the new Start state with the pattern and FINAL 8 | states[idx] = State(EMPTY, pattern.begin(), pattern.end()); 9 | 10 | Pattern ret({idx, pattern.end()}); 11 | 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/pattern/star.cc: -------------------------------------------------------------------------------- 1 | #include "pattern.ih" 2 | 3 | Pattern Pattern::star(States &states, Pattern const &pattern) 4 | { 5 | Pair pair = states.next2(); // create new Start/Final states 6 | 7 | // pattern's end connects to pattern begin and the new FINAL state. 8 | states[pattern.end()] = State(EMPTY, pattern.begin(), pair.second); 9 | 10 | // new Start state connects to pattern begin + end 11 | states[pair.first] = State(EMPTY, pattern.begin(), pair.second); 12 | 13 | Pattern ret(pair); 14 | 15 | return ret; 16 | } 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /flexc++/ranges/add.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::add(string const &str) 4 | { 5 | size_t *next = new size_t[d_alphabetSize]; 6 | 7 | // initialize next values with d_alphabet 8 | copy(d_alphabet, d_alphabet + d_alphabetSize, next); 9 | 10 | // increment next counts for chars in str 11 | for (auto &ch: str) 12 | ++next[static_cast(ch)]; 13 | 14 | update(str, next); 15 | 16 | delete [] next; 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /flexc++/ranges/add3.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | namespace 4 | { 5 | string str; 6 | } 7 | 8 | void Ranges::add(size_t ch) 9 | { 10 | str = ch; 11 | add(str); 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/ranges/charsettoranges.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::charsetToRanges(StateData &data, size_t *ranges) 4 | { 5 | string const &str = data.str(); 6 | 7 | set rangeSet; // determine the ranges of the chars 8 | // used in the string 9 | for(auto ch: str) 10 | rangeSet.insert(ranges[static_cast(ch)]); 11 | 12 | string next; // create a new string 13 | copy(rangeSet.begin(), rangeSet.end(), inserter(next, next.end())); 14 | 15 | data.set(next); // assign the string of range-nrs 16 | // to the state 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/ranges/chcollision.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | bool Ranges::chCollision(unsigned char ch, unsigned char &pre, 4 | size_t const *next) 5 | { 6 | if (pre + 1 == ch) // in a range 7 | { 8 | pre = ch; 9 | return false; // report `no collision' 10 | } 11 | 12 | // no range, do the post-test for pre and the pre-test for ch 13 | return 14 | next[pre] == next[pre + 1] 15 | || 16 | next[ch - 1] == next[ch]; 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/ranges/countranges.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::countRanges(size_t &count, vector &ranges) 4 | { 5 | auto iter = find(ranges.begin(), ranges.end(), count); 6 | 7 | if (iter == ranges.end()) 8 | { 9 | ranges.push_back(count); 10 | count = ranges.size() - 1; 11 | return; 12 | } 13 | 14 | count = iter - ranges.begin(); 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/ranges/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges::~Ranges() 4 | { 5 | delete[] d_alphabet; 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/ranges/determinesubsets.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::determineSubsets() 4 | { 5 | for(auto &state: d_states) 6 | inspectState(state); 7 | 8 | // now convert counts to ranges. At each transition increment the range 9 | // nr. The initial range is 0 10 | 11 | size_t *begin = d_alphabet; 12 | size_t *end = d_alphabet + d_alphabetSize; 13 | size_t range = 0; 14 | while (begin != end) 15 | { 16 | size_t *last = find_if(begin, end, 17 | bind2nd(not_equal_to(), *begin)); 18 | fill(begin, last, range++); 19 | begin = last; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /flexc++/ranges/driver/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../usage.h" 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | string str; 11 | 12 | cout << "Enter text on lines, sorted chars or not\n"; 13 | 14 | Usage usage; 15 | 16 | while (getline(cin, str)) 17 | { 18 | usage.add(str); 19 | usage.display("Final counts:"); 20 | cout << "? "; 21 | } 22 | } 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /flexc++/ranges/finalizestate.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | // When BOL is encountered, increment the subsetcount. 4 | 5 | void Ranges::finalizeState(State &state) 6 | { 7 | switch (size_t type = state.type()) 8 | { 9 | case CHARSET: 10 | charsetToRanges(state.data(), d_alphabet); 11 | break; 12 | 13 | case EOF_: 14 | state.setType(d_eof); 15 | break; 16 | 17 | default: 18 | if (type < UNDETERMINED_) 19 | state.setType(d_alphabet[type]); 20 | break; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /flexc++/ranges/finalizestates.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | // All states are visited. 4 | // If a state holds a plain character it is changed to 5 | // its character range number. 6 | // If a state holds a set consisting of characters in n character ranges 7 | // then the ranges are changed to the set of character range numbers. 8 | // There is no need to insert new states. When character is inspected it 9 | // determine from the range whether there is a transition to another state or 10 | // not. 11 | 12 | void Ranges::finalizeStates() 13 | { 14 | // always use the <> range 15 | d_eof = d_nRanges == 0 ? ++d_nRanges : d_nRanges++; 16 | 17 | for(auto &state: d_states) 18 | finalizeState(state); 19 | } 20 | -------------------------------------------------------------------------------- /flexc++/ranges/frame: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/ranges/inspectstate.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::inspectState(State const &state) 4 | { 5 | size_t type = state.type(); 6 | 7 | if (type < UNDETERMINED_) 8 | add(type); 9 | else if (type == CHARSET) 10 | add(state.data().str()); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /flexc++/ranges/operatorassign.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges &Ranges::operator=(Ranges const &other) 4 | { 5 | Ranges tmp(other); 6 | swap(tmp); 7 | return *this; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/ranges/operatorassign2.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges &Ranges::operator=(Ranges &&r_tmp) 4 | { 5 | Ranges tmp(std::move(r_tmp)); 6 | swap(tmp); 7 | return *this; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/ranges/outchar.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::outChar(std::ostream &out, size_t idx) 4 | { 5 | out << setw(3) << idx; 6 | 7 | if (isprint(idx)) 8 | out << "('" << static_cast(idx) << "')"; 9 | else 10 | out << " "; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/ranges/ranges.ih: -------------------------------------------------------------------------------- 1 | #include "ranges.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "../states/states.h" 13 | #include "../statestring/statestring.h" 14 | 15 | using namespace std; 16 | -------------------------------------------------------------------------------- /flexc++/ranges/ranges1.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges::Ranges(States &states, size_t size) 4 | : 5 | d_alphabet(new size_t[size]), 6 | d_alphabetSize(size), 7 | d_nRanges(0), 8 | d_bol(0), 9 | d_eof(0), 10 | d_states(states) 11 | { 12 | fill(d_alphabet, d_alphabet + d_alphabetSize, 0); 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/ranges/ranges2.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges::Ranges(Ranges const &other) 4 | : 5 | d_alphabet(new size_t[other.d_alphabetSize]), 6 | d_alphabetSize(other.d_alphabetSize), 7 | d_nRanges(other.d_nRanges), 8 | d_states(other.d_states) 9 | { 10 | copy(other.d_alphabet, other.d_alphabet + d_alphabetSize, d_alphabet); 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/ranges/ranges3.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | Ranges::Ranges(Ranges &&tmp) 4 | : 5 | d_alphabet(tmp.d_alphabet), 6 | d_alphabetSize(tmp.d_alphabetSize), 7 | d_nRanges(tmp.d_nRanges), 8 | d_states(tmp.d_states) 9 | { 10 | tmp.d_alphabet = 0; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/ranges/reassign.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | // And individual element in the current d_alphabet array is replaced by 4 | // its index in the rangeNr vector 5 | 6 | void Ranges::reassign(size_t &count, vector &rangeNrs) 7 | { 8 | auto iter = find(rangeNrs.begin(), rangeNrs.end(), count); 9 | 10 | if (iter != rangeNrs.end()) 11 | count = iter - rangeNrs.begin(); 12 | else 13 | { 14 | count = rangeNrs.size(); 15 | rangeNrs.push_back(count); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/ranges/subsetcount.cc: -------------------------------------------------------------------------------- 1 | #include "ranges.ih" 2 | 3 | void Ranges::subsetCount() 4 | { 5 | d_nRanges = 0; 6 | 7 | size_t *begin = d_alphabet; 8 | size_t *end = d_alphabet + d_alphabetSize; 9 | while (begin != end) 10 | { 11 | ++d_nRanges; 12 | size_t *last = find_if(begin, end, 13 | bind2nd(not_equal_to(), *begin)); 14 | begin = last; 15 | } 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /flexc++/rawtest/CLASSES: -------------------------------------------------------------------------------- 1 | # This file contains the names of all subdirectories containing sources to 2 | # compile. Each directory should be specified on a line of its own. Initial 3 | # blanks are ok. Compilation is 1-level deep. 4 | 5 | # If a parser or scanner is used, (see icmconfig's USE_PARSER and USE_SCANNER 6 | # defines) then those directories are automatically included (although they 7 | # could be included here as well) 8 | 9 | # Lines starting with # or with // are ignored, as are empty lines. 10 | 11 | # sources in the current (i.e., this) directory are also compiled. 12 | 13 | scanner 14 | scannerbase 15 | -------------------------------------------------------------------------------- /flexc++/rawtest/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$1" == "clean" ] 4 | then 5 | icmbuild clean 6 | exit 0 7 | fi 8 | 9 | if [ ../tmp/bin/STATICS -nt main.cc ] 10 | then 11 | touch main.cc 12 | icmbuild clean 13 | fi 14 | 15 | icmbuild 16 | -------------------------------------------------------------------------------- /flexc++/rawtest/in: -------------------------------------------------------------------------------- 1 | hi 2 | aap 3 | one 4 | two 5 | -------------------------------------------------------------------------------- /flexc++/rawtest/main.ih: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "scanner/scanner.h" 7 | 8 | using namespace std; 9 | using namespace FBB; 10 | -------------------------------------------------------------------------------- /flexc++/rawtest/scanner/data.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | #include "../../tmp/bin/STATICS" 4 | -------------------------------------------------------------------------------- /flexc++/rawtest/scanner/execute.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::execute(bool *done) 4 | { 5 | switch (ruleIndex()) 6 | { 7 | #include "../../tmp/bin/ACTIONS" 8 | } 9 | *done = false; 10 | return -1; // irrelevant return due to true cycle 11 | } // in lookup 12 | -------------------------------------------------------------------------------- /flexc++/rawtest/scanner/frame: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/rawtest/scanner/scanner.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCANNER_H_ 2 | #define _SCANNER_H_ 3 | 4 | #include "../scannerbase/scannerbase.h" 5 | 6 | class Scanner: public ScannerBase 7 | { 8 | public: 9 | Scanner(); 10 | int lex(); 11 | private: 12 | int execute(bool *done); 13 | }; 14 | 15 | #endif 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /flexc++/rawtest/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | -------------------------------------------------------------------------------- /flexc++/rawtest/scanner/scanner1.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner::Scanner() 4 | //: 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/chartomatchbuffer.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::charToMatchBuffer() 4 | { 5 | if (plainChar()) 6 | d_match += d_char; 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/frame: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | ScannerBase:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/handleacceptstate.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::handleAcceptState() 4 | { 5 | switch (acceptStateType()) 6 | { 7 | default: // not an accept state 8 | break; 9 | 10 | case 'F': // Fixed Head Accept State 11 | setHeadSizeOnce(); 12 | break; 13 | 14 | case 'V': // Variable Head Accept State 15 | updateHeadSize(); 16 | break; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/input.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | int ScannerBase::input() 4 | { 5 | size_t ret; 6 | 7 | while (true) 8 | { 9 | ret = next(); 10 | if (ret == s_rangeOfEOF) 11 | return -1; 12 | if (ret != s_rangeOfBOL) 13 | return d_char; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/nothandledcharacter.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::notHandledChar() const 4 | { 5 | cerr << "NOT HANDLED: '" << d_char << "'\n"; // ECHO it to cerr 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/reject.cc: -------------------------------------------------------------------------------- 1 | // #include "scannerbase.ih" 2 | // 3 | // void ScannerBase::reject() 4 | // { 5 | // d_rejectFrom = d_fromState; 6 | // d_rejectTo = d_state; 7 | // 8 | // cerr << "REJECT: from state " << d_rejectFrom << " to state " << 9 | // d_rejectTo << endl; 10 | // 11 | // retain(0); 12 | // d_bol = false; 13 | // } 14 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/rejectreturn.cc: -------------------------------------------------------------------------------- 1 | // #include "scannerbase.ih" 2 | // 3 | // bool ScannerBase::rejectReturn() 4 | // { 5 | // // if (d_state == d_rejectTarget) 6 | // // { 7 | // //cerr << "REJECT!\n"; 8 | // // d_rejectTarget = -2; 9 | // // return true; 10 | // // } 11 | // 12 | // return false; 13 | // } 14 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/reread.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::reRead() 4 | { 5 | if (plainChar()) 6 | d_deque.push_front(d_char); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/reset.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::reset() 4 | { 5 | d_state = 0; 6 | 7 | if (d_more) 8 | d_more = false; 9 | else 10 | d_match.clear(); 11 | 12 | msg(1) << "\nResetting...\n"; 13 | 14 | for (size_t idx = s_acceptSize; idx--; ) 15 | d_accept[idx] = {-1, -1}; 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/retain.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::retain(size_t nChars) 4 | { 5 | if (d_match.size() <= nChars) 6 | return; 7 | 8 | string const &tail = d_match.substr(nChars); 9 | 10 | // push the LA text in front of the Q 11 | copy(tail.rbegin(), tail.rend(), front_inserter(d_deque)); 12 | 13 | d_match.resize(nChars); // keep the prefix 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/rulematched.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | bool ScannerBase::ruleMatched() 4 | { 5 | d_ruleIndex = selectRule(); 6 | 7 | if (d_ruleIndex == -1) 8 | return false; 9 | 10 | saveLookahead(); 11 | 12 | msg(2) << "FINAL state " << d_state << " for rule " << 13 | d_ruleIndex << '\n'; 14 | return true; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/savelookahead.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | // d_ruleIndex holds the index of the matched rule 4 | void ScannerBase::saveLookahead() 5 | { 6 | Accept &accept = d_accept[d_ruleIndex]; 7 | 8 | if (accept.headSize == -1) // nothing to save 9 | return; 10 | 11 | retain(accept.headSize); 12 | 13 | msg(1) << "LA size = " << accept.headSize << ": match = " << d_match << 14 | '\n'; 15 | 16 | d_bol = false; // prevent BOL from being returned 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/scannerbase.ih: -------------------------------------------------------------------------------- 1 | #include "scannerbase.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | ostream &msg(size_t level); 11 | 12 | inline bool ScannerBase::plainChar() const 13 | { 14 | return d_range < s_rangeOfEOF; 15 | } 16 | 17 | inline int ScannerBase::acceptRule() const 18 | { 19 | return d_dfa[d_state][s_acceptIdx]; 20 | } 21 | 22 | inline ScannerBase::Accept &ScannerBase::acceptRecord() 23 | { 24 | return d_accept[d_dfa[d_state][s_acceptIdx]]; 25 | } 26 | 27 | inline int ScannerBase::acceptStateType() const 28 | { 29 | return d_dfa[d_state][s_acceptIdx + 1]; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/scannerbase1.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | ScannerBase::ScannerBase() 4 | : 5 | d_dfa(s_dfa), // declared in DECLARE; initialize to INITIAL 6 | d_bol(s_rangeOfBOL), 7 | // d_char 8 | // d_state // by reset() 9 | // d_nextState 10 | // d_range 11 | d_more(false) 12 | { 13 | reset(); 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/setheadsizeonce.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::setHeadSizeOnce() 4 | { 5 | Accept &accept = acceptRecord(); 6 | 7 | msg(1) << "Rule " << acceptRule() << ": accept length at " << 8 | d_state << ": " << accept.headSize; 9 | 10 | if (accept.headSize == -1) 11 | accept.headSize = d_match.length(); 12 | 13 | msg(1) << " updated to " << accept.headSize << '\n'; 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/rawtest/scannerbase/updateheadsize.cc: -------------------------------------------------------------------------------- 1 | #include "scannerbase.ih" 2 | 3 | void ScannerBase::updateHeadSize() 4 | { 5 | Accept &accept = acceptRecord(); 6 | 7 | accept.headSize = accept.lastMatchSize; 8 | accept.lastMatchSize = d_match.length(); 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/reconstruction/CLASSES: -------------------------------------------------------------------------------- 1 | # This file contains the names of all subdirectories containing sources to 2 | # compile. Each directory should be specified on a line of its own. Initial 3 | # blanks are ok. Compilation is 1-level deep. 4 | 5 | # If a parser or scanner is used, (see icmconfig's USE_PARSER and USE_SCANNER 6 | # defines) then those directories are automatically included (although they 7 | # could be included here as well) 8 | 9 | # Lines starting with # or with // are ignored, as are empty lines. 10 | 11 | # sources in the current (i.e., this) directory are also compiled. 12 | 13 | -------------------------------------------------------------------------------- /flexc++/reconstruction/VERSION: -------------------------------------------------------------------------------- 1 | #define AUTHOR "" 2 | #define VERSION "0.00.00" 3 | #define YEARS "2012" 4 | -------------------------------------------------------------------------------- /flexc++/reconstruction/main.cc: -------------------------------------------------------------------------------- 1 | #include "main.ih" 2 | 3 | int main(int argc, char **argv) 4 | try 5 | { 6 | Parser parser(argc > 1); 7 | 8 | parser.setScannerDebug(argc > 2); 9 | 10 | parser.setDebug(argc > 3); 11 | 12 | parser.parse(); 13 | 14 | cout << "Parsing Status: " << parser.status() << '\n'; 15 | } 16 | catch (exception const &err) 17 | { 18 | cout << err.what() << '\n'; 19 | return 1; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /flexc++/reconstruction/main.ih: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "parser/parser.h" 6 | 7 | using namespace std; 8 | -------------------------------------------------------------------------------- /flexc++/reconstruction/parser/frame: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Parser:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/reconstruction/parser/parser.ih: -------------------------------------------------------------------------------- 1 | // Generated by Bisonc++ V2.09.04 on Mon, 16 Jan 2012 21:40:37 +0100 2 | 3 | // Include this file in the sources of the class Parser. 4 | 5 | // $insert class.h 6 | #include "parser.h" 7 | 8 | // Add below here any includes etc. that are only 9 | // required for the compilation of Parser's sources. 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | using namespace std; 16 | using namespace FBB; 17 | 18 | -------------------------------------------------------------------------------- /flexc++/reconstruction/parser/parser1.cc: -------------------------------------------------------------------------------- 1 | #include "parser.ih" 2 | 3 | Parser::Parser(bool doPrint) 4 | : 5 | d_print(doPrint) 6 | {} 7 | -------------------------------------------------------------------------------- /flexc++/reconstruction/parser/preinclude.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PREINCLUDE_H_ 2 | #define INCLUDED_PREINCLUDE_H_ 3 | 4 | //#include "../semval/semval.h" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /flexc++/reconstruction/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tmp/bin/binary $1 < input 4 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner.ih: -------------------------------------------------------------------------------- 1 | // Generated by Flexc++ V0.8.3 on Sat, 21 Jan 2012 15:47:47 +0100 2 | 3 | // $insert class_h 4 | #include "scanner.h" 5 | 6 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/adddefinition.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::addDefinition(string const &name, string const &def) 4 | { 5 | string namePattern = '{' + name + '}'; 6 | 7 | if (d_nameExpansion.find(namePattern) != d_nameExpansion.end()) 8 | emsg << "pattern '" << name << "' multiply defined" << endl; 9 | else 10 | { 11 | d_nameExpansion[namePattern] = '(' + String::trim(def) + ')'; 12 | cout << " DEFINING " << name << " AS: " << d_nameExpansion[namePattern] 13 | << '\n'; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/block.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::block() 4 | { 5 | // cout << " SCANNER::BLOCK SEES `" << matched() << "'\n"; 6 | 7 | accept(matched().find_first_not_of(" \t")); // remove initial blanks 8 | d_inBlock = true; 9 | return Parser::BLOCK; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/frame: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/maybeswitchstream.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::maybeSwitchStream() 4 | { 5 | string text = String::trim(matched().substr(sizeof("//include"))); 6 | 7 | if (text[0] == '"' && *text.rbegin() == '"') // "s around the name 8 | text = text.substr(1, text.length() - 2); // rm the "s 9 | 10 | else if (text.find_first_of(" \t") != string::npos) // blanks need "s 11 | { 12 | wmsg << '`' << matched() << "' considered comment" << endl; 13 | return; 14 | } 15 | 16 | cout << "SWITCHING TO STREAM " << text << '\n'; 17 | setLineTags(text); 18 | pushStream(text); 19 | } 20 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/newdefinition.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::newDefinition() 4 | { 5 | d_patternName.clear(); 6 | push(StartCondition_::line); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/newscanner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | flexc++-0.8.3 -S /usr/share/flexc++ --verbose lexer > out 4 | 5 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/popsc.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::popSc(int token) 4 | { 5 | if (not d_scStack.empty()) 6 | d_scStack.pop(); 7 | 8 | begin(d_scStack.empty() ? 9 | StartCondition_::INITIAL 10 | : 11 | d_scStack.top() 12 | ); 13 | 14 | cout << " POP-SC: RETURNING TO CONDITION " << 15 | (d_scStack.empty() ? 0 : (int)d_scStack.top()) << '\n'; 16 | 17 | return token; 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/popstream.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::popStream() 4 | { 5 | if (not ScannerBase::popStream()) 6 | return false; 7 | 8 | setLineTags(filename()); 9 | return true; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/push.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::push(StartCondition_ next) 4 | { 5 | d_scStack.push(next); 6 | begin(next); 7 | cout << " ENTERING CONDITION " << (int)next << '\n'; 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/pushnameexpansion.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::pushNameExpansion() 4 | { 5 | auto iter = d_nameExpansion.find(matched()); 6 | 7 | if (iter == d_nameExpansion.end()) 8 | fmsg << "Name expansion `" << matched() << "\' not found" << endl; 9 | 10 | push(iter->second); 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "../parser/parser.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | 12 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/scanner1.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner::Scanner(std::istream &in, std::ostream &out) 4 | : 5 | ScannerBase(in, out) 6 | { 7 | push(StartCondition_::pre); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/setlinetags.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::setLineTags(std::string const &filename) const 4 | { 5 | string tag = filename + ", line"; 6 | emsg.setLineTag(tag); 7 | wmsg.setLineTag(tag); 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/reconstruction/scanner/switchtoinitial.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::switchToINITIAL() 4 | { 5 | d_scStack = SCStack(); 6 | begin(StartCondition_::INITIAL); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/regression/i01: -------------------------------------------------------------------------------- 1 | aaab 2 | -------------------------------------------------------------------------------- /flexc++/regression/i02: -------------------------------------------------------------------------------- 1 | abc 2 | ab 3 | abb 4 | abc 5 | abbcc 6 | abbbccc 7 | -------------------------------------------------------------------------------- /flexc++/regression/i03: -------------------------------------------------------------------------------- 1 | y "hello world" 2 | x /* comment */ 3 | -------------------------------------------------------------------------------- /flexc++/regression/i04: -------------------------------------------------------------------------------- 1 | copying text 2 | #include "i4a" 3 | back at i4 4 | on multiple lines 5 | -------------------------------------------------------------------------------- /flexc++/regression/i05: -------------------------------------------------------------------------------- 1 | line with initial blanks 2 | line with trailing blanks 3 | line with initial and trailing blanks 4 | line without initial or trailing blanks 5 | -------------------------------------------------------------------------------- /flexc++/regression/i06: -------------------------------------------------------------------------------- 1 | a 2 | ab 3 | aab 4 | aaab 5 | aaaab 6 | -------------------------------------------------------------------------------- /flexc++/regression/i07: -------------------------------------------------------------------------------- 1 | a 2 | ab 3 | aab 4 | aaab 5 | aaaab 6 | -------------------------------------------------------------------------------- /flexc++/regression/i08: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | -------------------------------------------------------------------------------- /flexc++/regression/i09: -------------------------------------------------------------------------------- 1 | Aap 2 | noot 3 | aap 4 | Noot 5 | MIES 6 | -------------------------------------------------------------------------------- /flexc++/regression/i10: -------------------------------------------------------------------------------- 1 | //test 2 | //not test 3 | -------------------------------------------------------------------------------- /flexc++/regression/i11: -------------------------------------------------------------------------------- 1 | fu 2 | fu(x) 3 | 4 | -------------------------------------------------------------------------------- /flexc++/regression/i12: -------------------------------------------------------------------------------- 1 | 832 <0.000012> 2 | -------------------------------------------------------------------------------- /flexc++/regression/i13: -------------------------------------------------------------------------------- 1 | 2 | line 3 | -------------------------------------------------------------------------------- /flexc++/regression/i14: -------------------------------------------------------------------------------- 1 | b 2 | -------------------------------------------------------------------------------- /flexc++/regression/i15: -------------------------------------------------------------------------------- 1 | b 2 | ab 3 | aab 4 | aaab 5 | -------------------------------------------------------------------------------- /flexc++/regression/i16: -------------------------------------------------------------------------------- 1 | x 2 | -------------------------------------------------------------------------------- /flexc++/regression/i17: -------------------------------------------------------------------------------- 1 | x 2 | -------------------------------------------------------------------------------- /flexc++/regression/i18: -------------------------------------------------------------------------------- 1 | x 2 | -------------------------------------------------------------------------------- /flexc++/regression/i19: -------------------------------------------------------------------------------- 1 | a a 2 | -------------------------------------------------------------------------------- /flexc++/regression/i4a: -------------------------------------------------------------------------------- 1 | found in i4a 2 | several lines, until the last: 3 | this is the last line in `i4a' 4 | -------------------------------------------------------------------------------- /flexc++/regression/main.ih: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include "scanner.h" 7 | 8 | 9 | using namespace std; 10 | -------------------------------------------------------------------------------- /flexc++/regression/p01: -------------------------------------------------------------------------------- 1 | // The variable-head, fixed-tail LA pattern a+/aab 2 | %% 3 | a+/aab d_p = "a+/aab"; return 1; 4 | aab d_p = "aab"; return 2; 5 | 6 | [[:space:]]+ 7 | . d_p = "."; return -1; 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /flexc++/regression/p02: -------------------------------------------------------------------------------- 1 | // The variable-head, variable_tail LA pattern ab*/bc* 2 | // causing problems for flex 3 | %% 4 | ab*/bc* d_p = "ab*/bc*"; return 1; 5 | bc* d_p = "bc*"; return 2; 6 | c+ d_p = "c+"; return 3; 7 | 8 | [[:space:]]+ 9 | . d_p = "."; return -1; 10 | -------------------------------------------------------------------------------- /flexc++/regression/p03: -------------------------------------------------------------------------------- 1 | // Mini scanners grabbing strings, C-comment, and doing more() 2 | 3 | %x str 4 | %x com 5 | 6 | %% 7 | 8 | "/*" more(); begin(StartCondition_::com); 9 | .|\n more(); 10 | "*/" d_p = "/* ... */"; begin(StartCondition_::INITIAL); return 1; 11 | 12 | "\"" more(); begin(StartCondition_::str); 13 | "\"" d_p = "\" ... \""; more(); begin(StartCondition_::INITIAL); return 2; 14 | .|"\\". more(); 15 | 16 | [[:space:]]+ 17 | . 18 | 19 | -------------------------------------------------------------------------------- /flexc++/regression/p04: -------------------------------------------------------------------------------- 1 | // Using file switching through an #include directive, <>, more() 2 | // and aminiscanner 3 | 4 | %x inc eoln 5 | 6 | %% 7 | 8 | "#include"[ \t]+"\"" d_p = "\"#include\"[ \\t]+\"\\\""; begin(StartCondition_::inc); return 1; 9 | [^"]+"\"" d_p = "[^\"]+\"\\\"\""; begin(StartCondition_::INITIAL);pushStream(matched().substr(0, length()-1)); return 2; 10 | 11 | . more(); 12 | \n redo(1); begin(StartCondition_::eoln); return 4; 13 | 14 | [[:space:]]+ 15 | 16 | \n begin(StartCondition_::INITIAL); 17 | 18 | <> d_p = "<>"; return popStream() ? 7 : 0; 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /flexc++/regression/p05: -------------------------------------------------------------------------------- 1 | // Using ^, $, and //%nowarn to trim begin/end-of line blanks from input lines 2 | 3 | %% 4 | 5 | //%nowarn 6 | ^[ \t]* 7 | 8 | [ \t]+$ 9 | 10 | [^ \t\n](.*[^ \t\n])? return 2; 11 | \n return 3; 12 | -------------------------------------------------------------------------------- /flexc++/regression/p06: -------------------------------------------------------------------------------- 1 | // Using indeterminate head and tail length pattern a+/a+b 2 | // flex reports: `warning, dangerous trailing context' 3 | %% 4 | 5 | [[:space:]]+ 6 | 7 | a+/a+b d_p = "a+/a+b"; return 1; 8 | 9 | ab d_p = "ab"; return 2; 10 | 11 | . d_p = "."; return 3; 12 | -------------------------------------------------------------------------------- /flexc++/regression/p07: -------------------------------------------------------------------------------- 1 | // Using indeterminate head and tail length pattern a*/a+b 2 | // flex reports: `warning, dangerous trailing context' 3 | 4 | %% 5 | 6 | [[:space:]]+ 7 | 8 | ab d_p = "ab"; return 1; 9 | 10 | . d_p = "."; return 2; 11 | 12 | a*/a*b d_p = "a*/a*b"; return 3; 13 | 14 | -------------------------------------------------------------------------------- /flexc++/regression/p08: -------------------------------------------------------------------------------- 1 | // BOL patterns 2 | %% 3 | a\n/b d_p = "a\\n\\b"; return 1; 4 | 5 | ^b d_p = "^\\b"; return 2; 6 | b d_p = "b"; return 3; 7 | 8 | . d_p = "."; return 3; 9 | \n d_p = "\\n"; return 4; 10 | -------------------------------------------------------------------------------- /flexc++/regression/p09: -------------------------------------------------------------------------------- 1 | // case insensitive scanner 2 | %case-insensitive 3 | 4 | %% 5 | { 6 | aap return 1; 7 | } 8 | Noot return 2; 9 | //Aap // this rule can never be matched 10 | 11 | mies return 3; 12 | 13 | .|\n // ignore 14 | -------------------------------------------------------------------------------- /flexc++/regression/p10: -------------------------------------------------------------------------------- 1 | // raw string literals in patterns and actions 2 | %% 3 | ^R"(//test)" d_p = R"p(^R"(//test)")p"; return 1; 4 | R"label(//)label".* d_p = R"p(R"label(//)label".*)p"; return 2; 5 | 6 | -------------------------------------------------------------------------------- /flexc++/regression/p11: -------------------------------------------------------------------------------- 1 | // joren-bug, i11 returns 1, 2, 3, 3, 3 2 | ident [[:alpha:]]+ 3 | 4 | %% 5 | 6 | fu d_p = "fu"; return 1; 7 | {ident}/'(' d_p = "{ident}/'('"; return 2; 8 | . d_p = "."; return 3; 9 | -------------------------------------------------------------------------------- /flexc++/regression/p12: -------------------------------------------------------------------------------- 1 | // jurjen-bug, i12 returns 1 (matching 832) and 11 times 2. 2 | 3 | int [[:digit:]]+ 4 | 5 | %% 6 | 7 | {int}/(' '+'<'[0-9]+'.'[0-9]+'>'\n) d_p = "{int}/(' '+'<'[0-9]+'.'[0-9]+'>'\n)"; return 1; 8 | . d_p = "."; return 2; 9 | \n 10 | -------------------------------------------------------------------------------- /flexc++/regression/p13: -------------------------------------------------------------------------------- 1 | // lookahead full line contents 2 | 3 | %% 4 | 5 | \n 6 | 7 | //%nowarn 8 | .*$ d_p = ".*$"; return 1; 9 | 10 | -------------------------------------------------------------------------------- /flexc++/regression/p14: -------------------------------------------------------------------------------- 1 | // lookahead CONTINUOUS LOOP (intended behavior), do NOT run. Run p15 instead 2 | 3 | %% 4 | //%nowarn 5 | a*/b d_p = "a*/b"; return 1; 6 | 7 | \n 8 | 9 | -------------------------------------------------------------------------------- /flexc++/regression/p15: -------------------------------------------------------------------------------- 1 | // preventing lookahead continuous loop, returns 1, 2 sequences, ending at 1 2 | 3 | %% 4 | . d_p = ". single char"; return 1; 5 | //%nowarn 6 | a*/b d_p = "a*/b"; return 2; 7 | \n 8 | -------------------------------------------------------------------------------- /flexc++/regression/p16: -------------------------------------------------------------------------------- 1 | // Test handling lexer files w/o trailing \n. Program run-test not relevant 2 | 3 | %% 4 | . d_p = ". single char"; return 1; 5 | \n -------------------------------------------------------------------------------- /flexc++/regression/p17: -------------------------------------------------------------------------------- 1 | // Test handling lexer files w/o trailing \n. Program run-test not relevant 2 | 3 | %% 4 | \n 5 | . d_p = ". single char"; return 1; -------------------------------------------------------------------------------- /flexc++/regression/p18: -------------------------------------------------------------------------------- 1 | // Test handling lexer files w/o trailing \n. Program run-test not relevant 2 | 3 | %% 4 | \n 5 | . { 6 | d_p = ". single char"; 7 | return 1; 8 | } -------------------------------------------------------------------------------- /flexc++/regression/p19: -------------------------------------------------------------------------------- 1 | // Checking recognition of char-range 0: a \t must return 2 2 | 3 | %% 4 | a d_p = "a (single char)"; return 1; 5 | . d_p = ". (single char)"; return 2; 6 | \n d_p = "\\n (newline)"; return 3; 7 | -------------------------------------------------------------------------------- /flexc++/regression/preamble: -------------------------------------------------------------------------------- 1 | %skeleton-directory "../skeletons" 2 | %debug 3 | %filenames scanner 4 | -------------------------------------------------------------------------------- /flexc++/regression/scanner.ih: -------------------------------------------------------------------------------- 1 | // Generated by Flexc++ V0.98.00 on Fri, 11 May 2012 13:31:37 +0200 2 | 3 | // $insert class_h 4 | #include "scanner.h" 5 | 6 | -------------------------------------------------------------------------------- /flexc++/required: -------------------------------------------------------------------------------- 1 | This file lists non-standard software only, and applies to the version tagged 2 | with the version mentioned in the file VERSION. 3 | 4 | Standard utilities like cp, mv, sed, etc, etc, are not explicitly 5 | mentioned. Neither is the g++ compiler explicitly mentioned, but a fairly 6 | recent one is assumed. 7 | 8 | Required software for building Flexc++ 9 | -------------------------------------- 10 | 11 | libbobcat-dev (>= 4.01.00), 12 | 13 | 14 | To use the provided build-script: 15 | 16 | icmake (>= 8.00.04) 17 | 18 | To construct the manual and map-page: 19 | 20 | yodl (>= 3.06.0) 21 | -------------------------------------------------------------------------------- /flexc++/rule/frame: -------------------------------------------------------------------------------- 1 | #include "rule.ih" 2 | 3 | Rule:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/rule/noaction.cc: -------------------------------------------------------------------------------- 1 | #include "rule.ih" 2 | 3 | void Rule::noAction() 4 | { 5 | d_block.clear(); 6 | 7 | cerr << "block line nr was " << d_block.lineNr() << '\n'; 8 | d_block.setLineNr(d_block.lineNr() - 1); // didn't see a block, but 9 | // the \n following the regex 10 | // already has been read. 11 | cerr << "block line is was " << d_block.lineNr() << '\n'; 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/rule/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "rule.ih" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | ostream &operator<<(ostream &out, Rule const &rule) 8 | { 9 | out << " (" << rule.source() << " " << rule.lineNr() << 10 | "). Startstate " << setw(2) << rule.startState(); 11 | 12 | return out; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/rule/rule.ih: -------------------------------------------------------------------------------- 1 | #include "rule.h" 2 | 3 | #include "../states/states.h" 4 | 5 | #include //TMP 6 | 7 | using namespace std; 8 | 9 | -------------------------------------------------------------------------------- /flexc++/rule/rule1.cc: -------------------------------------------------------------------------------- 1 | #include "rule.ih" 2 | 3 | Rule::Rule([[maybe_unused]] States &states, bool bol, Pattern const &pattern, 4 | Block const &block, RuleType type) 5 | : 6 | d_pattern(pattern), 7 | d_block(block), 8 | d_bol(bol), 9 | d_type(type) 10 | {} 11 | 12 | -------------------------------------------------------------------------------- /flexc++/rules/add.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::add(bool bol, Pattern const &pattern, Block const &block, 4 | RuleType type) 5 | { 6 | size_t ruleIdx = d_rules.size(); // the index of the rule to add 7 | 8 | // now add the rule 9 | d_rules.push_back( { d_states, bol, pattern, block, type } ); 10 | 11 | Pair const &pair = d_rules.back().pair(); // the rule's begin/end states 12 | 13 | d_finalToRule[pair.second] = ruleIdx; // associate end-state to rule 14 | 15 | setRule(pair.first, ruleIdx); 16 | 17 | d_startConditions.add(ruleIdx); 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/rules/addcatchall.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::addCatchAll(size_t scIndex, size_t catchAllRuleIndex) 4 | { 5 | d_startConditions.activate(scIndex); 6 | 7 | addIndex(catchAllRuleIndex); 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /flexc++/rules/frame: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | Rules:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/rules/handlefixedtailloprule.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::handleFixedTailLopRule(Rule &rule) 4 | { 5 | auto const &block = rule.block(); 6 | auto const &pattern = rule.pattern(); 7 | 8 | // change the LOP rule's action into 9 | // calling lop_f, passing it the 10 | // lop's tail length 11 | Block workBlock(block.lineNr(), block.filename()); 12 | workBlock += "lopf_(" + to_string(pattern.lopTailLength()) + ");" ; 13 | workBlock += "\n"; // new line, and 14 | workBlock.addContents(block); // add the LOP rule's action block 15 | 16 | rule.assignBlock(workBlock); 17 | } 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /flexc++/rules/noactions.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::noActions() 4 | { 5 | for(auto &rule: ranger(d_rules.rbegin() + 1, d_rules.rend())) 6 | { 7 | if (not rule.orAction()) 8 | break; 9 | 10 | rule.noAction(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/rules/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | ostream &operator<<(ostream &out, Rules const &rules) 4 | { 5 | out << rules.startConditions() << '\n'; 6 | 7 | for (size_t idx = 0, end = rules.d_rules.size(); idx != end; ++idx) 8 | out << "rule " << setw(2) << idx << rules[idx] << '\n'; 9 | 10 | return out; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/rules/processcatchallrule.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::processCatchAllRule() 4 | { 5 | d_startConditions.remove(--d_nUserRules); 6 | d_catchAll = d_rules.back(); 7 | d_rules.pop_back(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /flexc++/rules/rulefromfinalstate.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | size_t Rules::ruleFromFinalState(size_t stateIdx) const 4 | { 5 | size_t rule = d_finalToRule.find(stateIdx)->second; 6 | 7 | auto iter = d_lopToRule.find(rule); 8 | 9 | return d_userSC && iter != d_lopToRule.end() ? 10 | iter->second 11 | : 12 | rule; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /flexc++/rules/rules.ih: -------------------------------------------------------------------------------- 1 | #include "rules.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "../states/states.h" 12 | #include "../pattern/pattern.h" 13 | 14 | using namespace std; 15 | using namespace FBB; 16 | -------------------------------------------------------------------------------- /flexc++/rules/rules1.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | Rules::Rules(States &states) 4 | : 5 | d_states(states) 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/rules/setrule.cc: -------------------------------------------------------------------------------- 1 | #include "rules.ih" 2 | 3 | void Rules::setRule(size_t stateIdx, size_t ruleIdx) 4 | { 5 | if (stateIdx == 0) // not a state 6 | return; 7 | 8 | State &state = d_states[stateIdx]; 9 | 10 | if (state.rule() == ruleIdx) // already set (next()s can jump back!) 11 | return; 12 | 13 | state.setRule(ruleIdx); 14 | 15 | setRule(state.next1(), ruleIdx); 16 | setRule(state.next2(), ruleIdx); 17 | } 18 | -------------------------------------------------------------------------------- /flexc++/scanner/adddefinition.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::addDefinition(string const &name, TextType textType) 4 | { 5 | string namePattern = '{' + name + '}'; 6 | 7 | string const &def = matched(); 8 | 9 | if (d_nameExpansion.find(namePattern) != d_nameExpansion.end()) 10 | emsg << "pattern '" << name << "' multiply defined" << endl; 11 | else 12 | d_nameExpansion[namePattern] = '(' + String::trim(def) + ')'; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/scanner/allownullmatches.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::allowNullMatches() 4 | { 5 | bool ret = d_allowNullMatches; 6 | d_allowNullMatches = false; 7 | return ret; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /flexc++/scanner/endofrawstring.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::endOfRawString() 4 | { 5 | if (matched().rfind(d_rawString) == length() - d_rawString.length()) 6 | return true; 7 | 8 | more(); 9 | return false; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/scanner/frame: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/scanner/handlecharafterblanks.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::handleCharAfterBlanks() 4 | { 5 | redo(1); 6 | 7 | if (d_inCharClass) 8 | return Parser::CHAR; 9 | 10 | if (d_inBlock) 11 | return ' '; 12 | 13 | d_inBlock = true; 14 | d_caseSensitive = true; 15 | return Parser::BLOCK; 16 | } 17 | -------------------------------------------------------------------------------- /flexc++/scanner/handledquote.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::handleDquote() 4 | { 5 | if (d_inCharClass) 6 | return true; 7 | 8 | more(); 9 | push(StartCondition_::string); 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/scanner/handleeolncomment.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::handleEOLNcomment() 4 | { 5 | if (not d_inCharClass) 6 | { 7 | if (matched() == "//%nowarn") 8 | d_allowNullMatches = true; 9 | return false; 10 | } 11 | 12 | accept(matched().find("//") + 2); // in char class: accept blanks + // 13 | return true; // and rescan the rest 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/scanner/handlemulti.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::handleMulti(int token) 4 | { 5 | if (d_inBlock || d_inCharClass || d_acceptMulti) 6 | return token; 7 | 8 | accept(1); 9 | return Parser::CHAR; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/scanner/handleopenbracket.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::handleOpenBracket() 4 | { 5 | if (startCondition() == StartCondition_::INITIAL) 6 | { 7 | if (d_inCharClass) 8 | return '['; 9 | 10 | d_inCharClass = true; 11 | } 12 | return Parser::CC_START; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /flexc++/scanner/handlerawstring.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::handleRawString() 4 | { 5 | if (d_inCharClass) 6 | { 7 | accept(1); 8 | return false; 9 | }; 10 | 11 | d_rawString = matched(); 12 | d_rawString.erase(0, 1); // rm the R 13 | 14 | d_rawString.front() = ')'; // end sentinel is )IDENTIFIER" 15 | d_rawString.back() = '"'; 16 | 17 | more(); 18 | push(StartCondition_::rawstring); 19 | return true; 20 | } 21 | -------------------------------------------------------------------------------- /flexc++/scanner/handlestdcomment.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::handleStdComment() 4 | { 5 | if (d_inCharClass) 6 | return true; 7 | 8 | push(StartCondition_::comment); 9 | return false; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/scanner/insertedcatchall.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::insertedCatchAll() 4 | { 5 | if (not d_catchAll.length()) // if no catch-all rule required 6 | return false; 7 | 8 | push(d_catchAll); 9 | d_catchAll.clear(); 10 | return true; 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/scanner/moreinput.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::moreInput() 4 | { 5 | if (popStream()) // first unwind any stacked files 6 | return true; 7 | 8 | // d_endOfInput = true; 9 | 10 | return insertedCatchAll(); 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/scanner/newdefinition.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::newDefinition() 4 | { 5 | push(StartCondition_::line); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /flexc++/scanner/newscanner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | flexc++ --verbose lexer > out && exit 0 4 | less out 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flexc++/scanner/plex.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::pLex() 4 | { 5 | int ret = lex(); 6 | 7 | if (not d_caseSensitive) 8 | setMatched(String::lc(matched())); 9 | 10 | emsg.setLineNr(lineNr()); 11 | wmsg.setLineNr(lineNr()); 12 | 13 | return ret; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /flexc++/scanner/popsc.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | int Scanner::popSc(int token) 4 | { 5 | if (not d_scStack.empty()) 6 | d_scStack.pop(); 7 | 8 | begin(d_scStack.empty() ? 9 | StartCondition_::INITIAL 10 | : 11 | d_scStack.top() 12 | ); 13 | 14 | return token; 15 | } 16 | -------------------------------------------------------------------------------- /flexc++/scanner/popstream.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::popStream() 4 | { 5 | if (not ScannerBase::popStream()) 6 | return false; 7 | 8 | setLineTags(filename()); 9 | return true; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/scanner/push.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::push(StartCondition_ next) 4 | { 5 | d_scStack.push(next); 6 | begin(next); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/scanner/pushnameexpansion.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::pushNameExpansion() 4 | { 5 | auto iter = d_nameExpansion.find(matched()); 6 | 7 | if (iter == d_nameExpansion.end()) 8 | fmsg << "Name expansion `" << matched() << "\' not found" << endl; 9 | 10 | push(iter->second); 11 | } 12 | -------------------------------------------------------------------------------- /flexc++/scanner/rawstringcontents.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | string Scanner::rawStringContents() const 4 | { 5 | // d_rawstring = )..." 6 | // raw string is: R"...( <-- contents --> )..." 7 | // so length - (2 x d_rawstring.length() + 1) is the 8 | // contents length 9 | 10 | return matched().substr( 11 | d_rawString.length() + 1, // + 1 for the R 12 | length() - ((d_rawString.length() << 1) + 1) 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /flexc++/scanner/scanner.ih: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "../parser/parser.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | using namespace FBB; 12 | 13 | inline int Scanner::handle(int token) const 14 | { 15 | return d_inCharClass ? Parser::IDENTIFIER : token; 16 | } 17 | 18 | inline int Scanner::openCC(int token) 19 | { 20 | d_inCharClass = true; 21 | return token; 22 | } 23 | 24 | inline int Scanner::closeCC(int token) 25 | { 26 | d_inCharClass = false; 27 | return token; 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /flexc++/scanner/scanner1.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | Scanner::Scanner(string const &fname) 4 | : 5 | ScannerBase(fname, "-"), 6 | d_inBlock(false), 7 | d_inCharClass(false), 8 | d_acceptMulti(true), 9 | d_caseSensitive(true) 10 | { 11 | setLineTags(fname); 12 | push(StartCondition_::pre); 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /flexc++/scanner/secondsectiondelimiter.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | bool Scanner::secondSectionDelimiter() 4 | { 5 | accept(0); 6 | return not insertedCatchAll(); // no catch all rule inserted, so a plain 7 | // second %% section delimiter was 8 | // encountered: end input processing. 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/scanner/setcasesensitive.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::setCaseSensitive() 4 | { 5 | d_caseSensitive = Options::instance().caseSensitive(); 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /flexc++/scanner/setlinetags.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::setLineTags(std::string const &filename) const 4 | { 5 | string tag = filename + ", line"; 6 | emsg.setLineTag(tag); 7 | wmsg.setLineTag(tag); 8 | } 9 | -------------------------------------------------------------------------------- /flexc++/scanner/switchtoinitial.cc: -------------------------------------------------------------------------------- 1 | #include "scanner.ih" 2 | 3 | void Scanner::switchToINITIAL() 4 | { 5 | d_scStack = SCStack(); 6 | begin(StartCondition_::INITIAL); 7 | } 8 | -------------------------------------------------------------------------------- /flexc++/skeletons/flexc++.ih: -------------------------------------------------------------------------------- 1 | $insert class_h 2 | 3 | $insert namespace-use 4 | -------------------------------------------------------------------------------- /flexc++/startconditions/activate.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | void StartConditions::activate(size_t index) 4 | { 5 | d_active = std::vector(1, 6 | &(d_sc.begin() + index)->second); 7 | } 8 | 9 | 10 | -------------------------------------------------------------------------------- /flexc++/startconditions/add2.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | void StartConditions::add(size_t ruleIdx) 4 | { 5 | if (not d_acceptRules) 6 | return; 7 | 8 | for (auto &sc: d_active) // add the rule to all active mini scanners 9 | sc->d_rules.push_back(ruleIdx); 10 | 11 | if (d_active.size()) // this rule is for specific mini scanners: 12 | return; // done 13 | // no mini scanners were explicitly mentioned: 14 | // add the rule to all inclusive mini scanners 15 | for (auto &element: d_sc) 16 | { 17 | if (element.second.d_type == INCLUSIVE) 18 | element.second.d_rules.push_back(ruleIdx); 19 | } 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /flexc++/startconditions/addsc.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | void StartConditions::addSC(string const &name) 4 | { 5 | auto iter = d_sc.find(name); 6 | 7 | if (iter == d_sc.end()) // done if the name isn't a startcondition 8 | { 9 | emsg << "cannot find start condition `" << name << '\'' << endl; 10 | return; 11 | } 12 | 13 | auto iterSC = find(d_active.begin(), d_active.end(), &iter->second); 14 | 15 | if (iterSC != d_active.end()) // done if this name was already specified 16 | { 17 | wmsg << "start condition `" << name << "' multiply specified" << endl; 18 | return; 19 | } 20 | 21 | // add this StartCondition to the active set 22 | d_active.push_back(&iter->second); 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /flexc++/startconditions/define.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | void StartConditions::define(string const &name) 4 | { 5 | if (not d_acceptRules) 6 | return; 7 | 8 | if (d_sc.find(name) != d_sc.end()) 9 | emsg << "start condition `" << name << "' multiply defined" << endl; 10 | else 11 | d_sc.insert( {name, StartCondition(d_type)} ); 12 | } 13 | -------------------------------------------------------------------------------- /flexc++/startconditions/frame: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | StartConditions:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/startconditions/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | ostream &operator<<(ostream &out, StartConditions const &startConditions) 4 | { 5 | for (auto &element: startConditions.d_sc) 6 | { 7 | out << "Rules active for `" << element.first << "':\n"; 8 | copy (element.second.d_rules.begin(), element.second.d_rules.end(), 9 | ostream_iterator(out, ", ")); 10 | out << '\n'; 11 | } 12 | return out; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/startconditions/remove.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | void StartConditions::remove(size_t ruleIndex) 4 | { 5 | for (auto &element: d_sc) 6 | { 7 | std::vector &rules = element.second.d_rules; 8 | auto iter = ::find(rules.begin(), rules.end(), ruleIndex); 9 | if (iter != rules.end()) 10 | rules.erase(iter); 11 | } 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /flexc++/startconditions/startconditions.ih: -------------------------------------------------------------------------------- 1 | #include "startconditions.h" 2 | 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | 12 | inline StartConditions::StartCondition::StartCondition(Type type) 13 | : 14 | d_type(type) 15 | {} 16 | 17 | //inline string const &StartConditions::strOf(SemVal const &nameVal) 18 | //{ 19 | // return SemVal::downCast(nameVal).str(); 20 | //} 21 | -------------------------------------------------------------------------------- /flexc++/startconditions/startconditions1.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | StartConditions::StartConditions() 4 | : 5 | d_sc( 6 | { 7 | {"INITIAL", StartCondition(INCLUSIVE) } 8 | } 9 | ) 10 | {} 11 | 12 | -------------------------------------------------------------------------------- /flexc++/startconditions/useall.cc: -------------------------------------------------------------------------------- 1 | #include "startconditions.ih" 2 | 3 | void StartConditions::useAll() 4 | { 5 | reset(); 6 | 7 | for(auto &mini: d_sc) 8 | d_active.push_back(&mini.second); 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/state/contains.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | bool State::contains(size_t rangeChar) const 4 | { 5 | return d_data->str().find(rangeChar) != string::npos; 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/state/dup.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | void State::dup(State const &src, size_t next1, size_t next2) 4 | { 5 | d_data.reset(src.data().dup()); 6 | d_data->set(next1, next2); 7 | 8 | d_type = src.d_type; 9 | d_rule = src.d_rule; 10 | } 11 | -------------------------------------------------------------------------------- /flexc++/state/frame: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/state/state.ih: -------------------------------------------------------------------------------- 1 | #include "state.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "../statestring/statestring.h" 7 | #include 8 | 9 | using namespace std; 10 | using namespace FBB; 11 | 12 | -------------------------------------------------------------------------------- /flexc++/state/state1.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State() 4 | : 5 | d_type(UNDETERMINED_), 6 | d_rule(-1) 7 | {} 8 | -------------------------------------------------------------------------------- /flexc++/state/state2.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State(size_t type) 4 | : 5 | d_type(type), 6 | d_rule(-1) 7 | {} 8 | -------------------------------------------------------------------------------- /flexc++/state/state3.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State(size_t type, StateData *data) 4 | : 5 | d_data(data), 6 | d_type(type), 7 | d_rule(-1) 8 | {} 9 | -------------------------------------------------------------------------------- /flexc++/state/state4.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State(size_t type, size_t next1, size_t next2) 4 | : 5 | State(type, new StateData(next1, next2)) 6 | {} 7 | -------------------------------------------------------------------------------- /flexc++/state/state5.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State(size_t type, string const &str, size_t next1, size_t next2) 4 | : 5 | State(type, new StateString(str, next1, next2)) 6 | {} 7 | -------------------------------------------------------------------------------- /flexc++/state/state6.cc: -------------------------------------------------------------------------------- 1 | #include "state.ih" 2 | 3 | State::State(unsigned char ch, size_t next1) 4 | : 5 | State(ch, new StateData(next1, 0)) 6 | {} 7 | 8 | -------------------------------------------------------------------------------- /flexc++/statedata/destructor.cc: -------------------------------------------------------------------------------- 1 | #include "statedata.ih" 2 | 3 | StateData::~StateData() 4 | {} 5 | -------------------------------------------------------------------------------- /flexc++/statedata/frame: -------------------------------------------------------------------------------- 1 | #include "statedata.ih" 2 | 3 | StateData:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/statedata/statedata.ih: -------------------------------------------------------------------------------- 1 | #include "statedata.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | -------------------------------------------------------------------------------- /flexc++/statedata/statedata1.cc: -------------------------------------------------------------------------------- 1 | #include "statedata.ih" 2 | 3 | StateData::StateData(size_t next1, size_t next2) 4 | : 5 | d_next1(next1), 6 | d_next2(next2) 7 | {} 8 | -------------------------------------------------------------------------------- /flexc++/statedata/vclone.cc: -------------------------------------------------------------------------------- 1 | #include "statedata.ih" 2 | 3 | StateData *StateData::v_clone() const 4 | { 5 | return new StateData(d_next1, d_next2); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/states/collect.cc: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | void States::collect(size_t idx) 4 | { 5 | d_state[idx].setType(UNDETERMINED_); 6 | return d_free.push_back(idx); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /flexc++/states/frame: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | States:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/states/next.cc: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | size_t States::next() 4 | { 5 | size_t ret; 6 | 7 | if (d_free.empty()) 8 | { 9 | ret = d_state.size(); 10 | d_state.resize(ret + 1); 11 | } 12 | else 13 | { 14 | ret = d_free.back(); 15 | d_free.pop_back(); 16 | } 17 | return ret; 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/states/next2.cc: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | States::Pair States::next2() 4 | { 5 | Pair ret {next(), next()}; 6 | d_state[ret.second] = State(FINAL, 0, 0); 7 | 8 | return ret; 9 | } 10 | -------------------------------------------------------------------------------- /flexc++/states/next3.cc: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | size_t *States::next(size_t nStates) 4 | { 5 | size_t *states = new size_t[nStates]; 6 | 7 | for (size_t idx = 0; idx != nStates; ++idx) 8 | states[idx] = next(); 9 | 10 | d_state[states[nStates - 1]] = State(FINAL, 0, 0); 11 | 12 | return states; 13 | } 14 | -------------------------------------------------------------------------------- /flexc++/states/operatorinsert.cc: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | #include 4 | #include 5 | 6 | ostream &operator<<(ostream &out, States const &states) 7 | { 8 | out << 9 | " E: EMPTY, F: FINAL, S: SET, : range\n" 10 | " NR TYPE F N1 N2 [range-indices]\n" 11 | "---------------------------------------------------\n"; 12 | for (size_t idx = 0, end = states.size(); idx != end; ++idx) 13 | { 14 | if (states[idx].type() != States::UNDETERMINED_) 15 | out << setw(3) << idx << ": " << states[idx] << '\n'; 16 | } 17 | return out; 18 | } 19 | -------------------------------------------------------------------------------- /flexc++/states/states.ih: -------------------------------------------------------------------------------- 1 | #include "states.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /flexc++/states/states1.cc: -------------------------------------------------------------------------------- 1 | #include "states.ih" 2 | 3 | States::States() 4 | : 5 | d_state(1) 6 | {} 7 | -------------------------------------------------------------------------------- /flexc++/statestring/frame: -------------------------------------------------------------------------------- 1 | #include "statestring.ih" 2 | 3 | StateString:: 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /flexc++/statestring/statestring.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_STATESTRING_ 2 | #define INCLUDED_STATESTRING_ 3 | 4 | #include "../statedata/statedata.h" 5 | 6 | class StateString: public StateData 7 | { 8 | std::string d_str; 9 | 10 | public: 11 | StateString(std::string const &str, size_t next1, size_t next2); 12 | 13 | private: 14 | virtual void v_set(std::string const &str); 15 | virtual std::string const &v_str() const; 16 | virtual StateData *v_clone() const; 17 | }; 18 | 19 | inline void StateString::v_set(std::string const &str) 20 | { 21 | d_str = str; 22 | } 23 | 24 | inline std::string const &StateString::v_str() const 25 | { 26 | return d_str; 27 | } 28 | 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /flexc++/statestring/statestring.ih: -------------------------------------------------------------------------------- 1 | #include "statestring.h" 2 | 3 | using namespace std; 4 | 5 | -------------------------------------------------------------------------------- /flexc++/statestring/statestring1.cc: -------------------------------------------------------------------------------- 1 | #include "statestring.ih" 2 | 3 | StateString::StateString(std::string const &str, size_t next1, size_t next2) 4 | : 5 | StateData(next1, next2), 6 | d_str(str) 7 | {} 8 | -------------------------------------------------------------------------------- /flexc++/statestring/vclone.cc: -------------------------------------------------------------------------------- 1 | #include "statestring.ih" 2 | 3 | StateData *StateString::v_clone() const 4 | { 5 | return new StateString(d_str, next1(), next2()); 6 | } 7 | -------------------------------------------------------------------------------- /flexc++/templates/templates.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_TEMPLATES_ 2 | #define INCLUDED_TEMPLATES_ 3 | 4 | #include 5 | 6 | template 7 | inline Type max() 8 | { 9 | return std::numeric_limits::max(); 10 | } 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /flexc++/testpatterns: -------------------------------------------------------------------------------- 1 | %% 2 | 3 | //P1: 4 | //a+/aab 5 | 6 | //P2: 7 | //a*/aaap 8 | 9 | //P3 10 | //a*/aaa 11 | 12 | //P4 13 | //(a|ab)+/(a|ba)+ 14 | 15 | //P5 16 | //(a|ab)*/(a|ba)* 17 | 18 | //P6 19 | //(a|ab)+/a(a|ba)+ 20 | 21 | //P7 22 | //a+/(a|ab)+ 23 | 24 | //P8 25 | //a*/a* 26 | 27 | //P9 28 | //a*/(ab)* 29 | 30 | //P10 31 | //a*b*/a* 32 | 33 | //P11 34 | //a*/aa+ 35 | 36 | -------------------------------------------------------------------------------- /flexc++/version.cc: -------------------------------------------------------------------------------- 1 | #include "main.ih" 2 | #include "VERSION" 3 | 4 | char version[] = VERSION; 5 | char year[] = YEARS; 6 | --------------------------------------------------------------------------------