\" for full help on a command. " ++
- "\n" ++
- "\n-- commands that change the state" ++
- "\n" ++
- "\ni, import: i File" ++
- "\n Reads a grammar from File and compiles it into a GF runtime grammar." ++
- "\n Files \"include\"d in File are read recursively, nubbing repetitions." ++
- "\n If a grammar with the same language name is already in the state," ++
- "\n it is overwritten - but only if compilation succeeds. " ++
- "\n The grammar parser depends on the file name suffix:" ++
- "\n .gf normal GF source" ++
- "\n .gfc canonical GF" ++
- "\n .gfr precompiled GF resource " ++
- "\n .gfcm multilingual canonical GF" ++
- "\n .gfe example-based grammar files (only with the -ex option)" ++
- "\n .gfwl multilingual word list (preprocessed to abs + cncs)" ++
- "\n .ebnf Extended BNF format" ++
- "\n .cf Context-free (BNF) format" ++
- "\n .trc TransferCore format" ++
- "\n options:" ++
- "\n -old old: parse in GF<2.0 format (not necessary)" ++
- "\n -v verbose: give lots of messages " ++
- "\n -s silent: don't give error messages" ++
- "\n -src from source: ignore precompiled gfc and gfr files" ++
- "\n -gfc from gfc: use compiled modules whenever they exist" ++
- "\n -retain retain operations: read resource modules (needed in comm cc) " ++
- "\n -nocf don't build old-style context-free grammar (default without HOAS)" ++
- "\n -docf do build old-style context-free grammar (default with HOAS)" ++
- "\n -nocheckcirc don't eliminate circular rules from CF " ++
- "\n -cflexer build an optimized parser with separate lexer trie" ++
- "\n -noemit do not emit code (default with old grammar format)" ++
- "\n -o do emit code (default with new grammar format)" ++
- "\n -ex preprocess .gfe files if needed" ++
- "\n -prob read probabilities from top grammar file (format --# prob Fun Double)" ++
- "\n -treebank read a treebank file to memory (xml format)" ++
- "\n flags:" ++
- "\n -abs set the name used for abstract syntax (with -old option)" ++
- "\n -cnc set the name used for concrete syntax (with -old option)" ++
- "\n -res set the name used for resource (with -old option)" ++
- "\n -path use the (colon-separated) search path to find modules" ++
- "\n -optimize select an optimization to override file-defined flags" ++
- "\n -conversion select parsing method (values strict|nondet)" ++
- "\n -probs read probabilities from file (format (--# prob) Fun Double)" ++
- "\n -preproc use a preprocessor on each source file" ++
- "\n -noparse read nonparsable functions from file (format --# noparse Funs) " ++
- "\n examples:" ++
- "\n i English.gf -- ordinary import of Concrete" ++
- "\n i -retain german/ParadigmsGer.gf -- import of Resource to test" ++
- "\n" ++
- "\nr, reload: r" ++
- "\n Executes the previous import (i) command." ++
- "\n " ++
- "\nrl, remove_language: rl Language" ++
- "\n Takes away the language from the state." ++
- "\n" ++
- "\ne, empty: e" ++
- "\n Takes away all languages and resets all global flags." ++
- "\n" ++
- "\nsf, set_flags: sf Flag*" ++
- "\n The values of the Flags are set for Language. If no language" ++
- "\n is specified, the flags are set globally." ++
- "\n examples:" ++
- "\n sf -nocpu -- stop showing CPU time" ++
- "\n sf -lang=Swe -- make Swe the default concrete" ++
- "\n" ++
- "\ns, strip: s" ++
- "\n Prune the state by removing source and resource modules." ++
- "\n" ++
- "\ndc, define_command Name Anything" ++
- "\n Add a new defined command. The Name must star with '%'. Later," ++
- "\n if 'Name X' is used, it is replaced by Anything where #1 is replaced" ++
- "\n by X. " ++
- "\n Restrictions: Currently at most one argument is possible, and a defined" ++
- "\n command cannot appear in a pipe. " ++
- "\n To see what definitions are in scope, use help -defs." ++
- "\n examples:" ++
- "\n dc %tnp p -cat=NP -lang=Eng #1 | l -lang=Swe -- translate NPs" ++
- "\n %tnp \"this man\" -- translate and parse" ++
- "\n" ++
- "\ndt, define_term Name Tree" ++
- "\n Add a constant for a tree. The constant can later be called by" ++
- "\n prefixing it with '$'. " ++
- "\n Restriction: These terms are not yet usable as a subterm. " ++
- "\n To see what definitions are in scope, use help -defs." ++
- "\n examples:" ++
- "\n p -cat=NP \"this man\" | dt tm -- define tm as parse result" ++
- "\n l -all $tm -- linearize tm in all forms" ++
- "\n" ++
- "\n-- commands that give information about the state" ++
- "\n" ++
- "\npg, print_grammar: pg" ++
- "\n Prints the actual grammar (overridden by the -lang=X flag)." ++
- "\n The -printer=X flag sets the format in which the grammar is" ++
- "\n written." ++
- "\n N.B. since grammars are compiled when imported, this command" ++
- "\n generally does not show the grammar in the same format as the" ++
- "\n source. In particular, the -printer=latex is not supported. " ++
- "\n Use the command tg -printer=latex File to print the source " ++
- "\n grammar in LaTeX." ++
- "\n options:" ++
- "\n -utf8 apply UTF8-encoding to the grammar" ++
- "\n flags: " ++
- "\n -printer" ++
- "\n -lang" ++
- "\n -startcat -- The start category of the generated grammar." ++
- "\n Only supported by some grammar printers." ++
- "\n examples:" ++
- "\n pg -printer=cf -- show the context-free skeleton" ++
- "\n" ++
- "\npm, print_multigrammar: pm" ++
- "\n Prints the current multilingual grammar in .gfcm form." ++
- "\n (Automatically executes the strip command (s) before doing this.)" ++
- "\n options:" ++
- "\n -utf8 apply UTF8 encoding to the tokens in the grammar" ++
- "\n -utf8id apply UTF8 encoding to the identifiers in the grammar" ++
- "\n examples:" ++
- "\n pm | wf Letter.gfcm -- print the grammar into the file Letter.gfcm" ++
- "\n pm -printer=graph | wf D.dot -- then do 'dot -Tps D.dot > D.ps'" ++
- "\n" ++
- "\nvg, visualize_graph: vg" ++
- "\n Show the dependency graph of multilingual grammar via dot and gv." ++
- "\n" ++
- "\npo, print_options: po" ++
- "\n Print what modules there are in the state. Also" ++
- "\n prints those flag values in the current state that differ from defaults." ++
- "\n" ++
- "\npl, print_languages: pl" ++
- "\n Prints the names of currently available languages." ++
- "\n" ++
- "\npi, print_info: pi Ident" ++
- "\n Prints information on the identifier." ++
- "\n" ++
- "\n-- commands that execute and show the session history" ++
- "\n" ++
- "\neh, execute_history: eh File" ++
- "\n Executes commands in the file." ++
- "\n" ++
- "\nph, print_history; ph" ++
- "\n Prints the commands issued during the GF session." ++
- "\n The result is readable by the eh command." ++
- "\n examples:" ++
- "\n ph | wf foo.hist\" -- save the history into a file" ++
- "\n" ++
- "\n-- linearization, parsing, translation, and computation" ++
- "\n" ++
- "\nl, linearize: l PattList? Tree" ++
- "\n Shows all linearization forms of Tree by the actual grammar" ++
- "\n (which is overridden by the -lang flag). " ++
- "\n The pattern list has the form [P, ... ,Q] where P,...,Q follow GF " ++
- "\n syntax for patterns. All those forms are generated that match with the" ++
- "\n pattern list. Too short lists are filled with variables in the end." ++
- "\n Only the -table flag is available if a pattern list is specified." ++
- "\n HINT: see GF language specification for the syntax of Pattern and Term." ++
- "\n You can also copy and past parsing results." ++
- "\n options: " ++
- "\n -struct bracketed form" ++
- "\n -table show parameters (not compatible with -record, -all)" ++
- "\n -record record, i.e. explicit GF concrete syntax term (not compatible with -table, -all)" ++
- "\n -all show all forms and variants (not compatible with -record, -table)" ++
- "\n -multi linearize to all languages (can be combined with the other options)" ++
- "\n flags:" ++
- "\n -lang linearize in this grammar" ++
- "\n -number give this number of forms at most" ++
- "\n -unlexer filter output through unlexer" ++
- "\n examples:" ++
- "\n l -lang=Swe -table -- show full inflection table in Swe" ++
- "\n" ++
- "\np, parse: p String" ++
- "\n Shows all Trees returned for String by the actual" ++
- "\n grammar (overridden by the -lang flag), in the category S (overridden" ++
- "\n by the -cat flag)." ++
- "\n options for batch input:" ++
- "\n -lines parse each line of input separately, ignoring empty lines" ++
- "\n -all as -lines, but also parse empty lines" ++
- "\n -prob rank results by probability" ++
- "\n -cut stop after first lexing result leading to parser success" ++
- "\n -fail show strings whose parse fails prefixed by #FAIL" ++
- "\n -ambiguous show strings that have more than one parse prefixed by #AMBIGUOUS" ++
- "\n options for selecting parsing method:" ++
- "\n -fcfg parse using a fast variant of MCFG (default is no HOAS in grammar)" ++
- "\n -old parse using an overgenerating CFG (default if HOAS in grammar)" ++
- "\n -cfg parse using a much less overgenerating CFG" ++
- "\n -mcfg parse using an even less overgenerating MCFG" ++
- "\n Note: the first time parsing with -cfg, -mcfg, and -fcfg may take a long time" ++
- "\n options that only work for the -old default parsing method:" ++
- "\n -n non-strict: tolerates morphological errors" ++
- "\n -ign ignore unknown words when parsing" ++
- "\n -raw return context-free terms in raw form" ++
- "\n -v verbose: give more information if parsing fails" ++
- "\n flags:" ++
- "\n -cat parse in this category" ++
- "\n -lang parse in this grammar" ++
- "\n -lexer filter input through this lexer" ++
- "\n -parser use this parsing strategy" ++
- "\n -number return this many results at most" ++
- "\n examples:" ++
- "\n p -cat=S -mcfg \"jag \228r gammal\" -- parse an S with the MCFG" ++
- "\n rf examples.txt | p -lines -- parse each non-empty line of the file" ++
- "\n" ++
- "\nat, apply_transfer: at (Module.Fun | Fun)" ++
- "\n Transfer a term using Fun from Module, or the topmost transfer" ++
- "\n module. Transfer modules are given in the .trc format. They are" ++
- "\n shown by the 'po' command." ++
- "\n flags:" ++
- "\n -lang typecheck the result in this lang instead of default lang" ++
- "\n examples:" ++
- "\n p -lang=Cncdecimal \"123\" | at num2bin | l -- convert dec to bin" ++
- "\n" ++
- "\ntb, tree_bank: tb" ++
- "\n Generate a multilingual treebank from a list of trees (default) or compare" ++
- "\n to an existing treebank." ++
- "\n options:" ++
- "\n -c compare to existing xml-formatted treebank" ++
- "\n -trees return the trees of the treebank" ++
- "\n -all show all linearization alternatives (branches and variants)" ++
- "\n -table show tables of linearizations with parameters" ++
- "\n -record show linearization records" ++
- "\n -xml wrap the treebank (or comparison results) with XML tags" ++
- "\n -mem write the treebank in memory instead of a file TODO" ++
- "\n examples:" ++
- "\n gr -cat=S -number=100 | tb -xml | wf tb.xml -- random treebank into file" ++
- "\n rf tb.xml | tb -c -- compare-test treebank from file" ++
- "\n rf old.xml | tb -trees | tb -xml -- create new treebank from old" ++
- "\n" ++
- "\nut, use_treebank: ut String" ++
- "\n Lookup a string in a treebank and return the resulting trees." ++
- "\n Use 'tb' to create a treebank and 'i -treebank' to read one from" ++
- "\n a file." ++
- "\n options:" ++
- "\n -assocs show all string-trees associations in the treebank" ++
- "\n -strings show all strings in the treebank" ++
- "\n -trees show all trees in the treebank" ++
- "\n -raw return the lookup result as string, without typechecking it" ++
- "\n flags:" ++
- "\n -treebank use this treebank (instead of the latest introduced one)" ++
- "\n examples:" ++
- "\n ut \"He adds this to that\" | l -multi -- use treebank lookup as parser in translation" ++
- "\n ut -assocs | grep \"ComplV2\" -- show all associations with ComplV2" ++
- "\n" ++
- "\ntt, test_tokenizer: tt String" ++
- "\n Show the token list sent to the parser when String is parsed." ++
- "\n HINT: can be useful when debugging the parser." ++
- "\n flags: " ++
- "\n -lexer use this lexer" ++
- "\n examples:" ++
- "\n tt -lexer=codelit \"2*(x + 3)\" -- a favourite lexer for program code" ++
- "\n" ++
- "\ng, grep: g String1 String2" ++
- "\n Grep the String1 in the String2. String2 is read line by line," ++
- "\n and only those lines that contain String1 are returned." ++
- "\n flags:" ++
- "\n -v return those lines that do not contain String1." ++
- "\n examples:" ++
- "\n pg -printer=cf | grep \"mother\" -- show cf rules with word mother" ++
- "\n" ++
- "\ncc, compute_concrete: cc Term" ++
- "\n Compute a term by concrete syntax definitions. Uses the topmost" ++
- "\n resource module (the last in listing by command po) to resolve " ++
- "\n constant names. " ++
- "\n N.B. You need the flag -retain when importing the grammar, if you want " ++
- "\n the oper definitions to be retained after compilation; otherwise this" ++
- "\n command does not expand oper constants." ++
- "\n N.B.' The resulting Term is not a term in the sense of abstract syntax," ++
- "\n and hence not a valid input to a Tree-demanding command." ++
- "\n flags:" ++
- "\n -table show output in a similar readable format as 'l -table'" ++
- "\n -res use another module than the topmost one" ++
- "\n examples:" ++
- "\n cc -res=ParadigmsFin (nLukko \"hyppy\") -- inflect \"hyppy\" with nLukko" ++
- "\n" ++
- "\nso, show_operations: so Type" ++
- "\n Show oper operations with the given value type. Uses the topmost " ++
- "\n resource module to resolve constant names. " ++
- "\n N.B. You need the flag -retain when importing the grammar, if you want " ++
- "\n the oper definitions to be retained after compilation; otherwise this" ++
- "\n command does not find any oper constants." ++
- "\n N.B.' The value type may not be defined in a supermodule of the" ++
- "\n topmost resource. In that case, use appropriate qualified name." ++
- "\n flags:" ++
- "\n -res use another module than the topmost one" ++
- "\n examples:" ++
- "\n so -res=ParadigmsFin ResourceFin.N -- show N-paradigms in ParadigmsFin" ++
- "\n" ++
- "\nt, translate: t Lang Lang String" ++
- "\n Parses String in Lang1 and linearizes the resulting Trees in Lang2." ++
- "\n flags:" ++
- "\n -cat" ++
- "\n -lexer" ++
- "\n -parser" ++
- "\n examples:" ++
- "\n t Eng Swe -cat=S \"every number is even or odd\"" ++
- "\n" ++
- "\ngr, generate_random: gr Tree?" ++
- "\n Generates a random Tree of a given category. If a Tree" ++
- "\n argument is given, the command completes the Tree with values to" ++
- "\n the metavariables in the tree. " ++
- "\n options:" ++
- "\n -prob use probabilities (works for nondep types only)" ++
- "\n -cf use a very fast method (works for nondep types only)" ++
- "\n flags:" ++
- "\n -cat generate in this category" ++
- "\n -lang use the abstract syntax of this grammar" ++
- "\n -number generate this number of trees (not impl. with Tree argument)" ++
- "\n -depth use this number of search steps at most" ++
- "\n examples:" ++
- "\n gr -cat=Query -- generate in category Query" ++
- "\n gr (PredVP ? (NegVG ?)) -- generate a random tree of this form" ++
- "\n gr -cat=S -tr | l -- gererate and linearize" ++
- "\n" ++
- "\ngt, generate_trees: gt Tree?" ++
- "\n Generates all trees up to a given depth. If the depth is large," ++
- "\n a small -alts is recommended. If a Tree argument is given, the" ++
- "\n command completes the Tree with values to the metavariables in" ++
- "\n the tree." ++
- "\n options:" ++
- "\n -metas also return trees that include metavariables" ++
- "\n -all generate all (can be infinitely many, lazily)" ++
- "\n -lin linearize result of -all (otherwise, use pipe to linearize)" ++
- "\n flags:" ++
- "\n -depth generate to this depth (default 3)" ++
- "\n -atoms take this number of atomic rules of each category (default unlimited)" ++
- "\n -alts take this number of alternatives at each branch (default unlimited)" ++
- "\n -cat generate in this category" ++
- "\n -nonub don't remove duplicates (faster, not effective with -mem)" ++
- "\n -mem use a memorizing algorithm (often faster, usually more memory-consuming)" ++
- "\n -lang use the abstract syntax of this grammar" ++
- "\n -number generate (at most) this number of trees (also works with -all)" ++
- "\n -noexpand don't expand these categories (comma-separated, e.g. -noexpand=V,CN)" ++
- "\n -doexpand only expand these categories (comma-separated, e.g. -doexpand=V,CN)" ++
- "\n examples:" ++
- "\n gt -depth=10 -cat=NP -- generate all NP's to depth 10 " ++
- "\n gt (PredVP ? (NegVG ?)) -- generate all trees of this form" ++
- "\n gt -cat=S -tr | l -- generate and linearize" ++
- "\n gt -noexpand=NP | l -mark=metacat -- the only NP is meta, linearized \"?0 +NP\"" ++
- "\n gt | l | p -lines -ambiguous | grep \"#AMBIGUOUS\" -- show ambiguous strings" ++
- "\n" ++
- "\nma, morphologically_analyse: ma String" ++
- "\n Runs morphological analysis on each word in String and displays" ++
- "\n the results line by line." ++
- "\n options:" ++
- "\n -short show analyses in bracketed words, instead of separate lines" ++
- "\n -status show just the work at success, prefixed with \"*\" at failure" ++
- "\n flags:" ++
- "\n -lang" ++
- "\n examples:" ++
- "\n wf Bible.txt | ma -short | wf Bible.tagged -- analyse the Bible" ++
- "\n" ++
- "\n" ++
- "\n-- elementary generation of Strings and Trees" ++
- "\n" ++
- "\nps, put_string: ps String" ++
- "\n Returns its argument String, like Unix echo." ++
- "\n HINT. The strength of ps comes from the possibility to receive the " ++
- "\n argument from a pipeline, and altering it by the -filter flag." ++
- "\n flags:" ++
- "\n -filter filter the result through this string processor " ++
- "\n -length cut the string after this number of characters" ++
- "\n examples:" ++
- "\n gr -cat=Letter | l | ps -filter=text -- random letter as text" ++
- "\n" ++
- "\npt, put_tree: pt Tree" ++
- "\n Returns its argument Tree, like a specialized Unix echo." ++
- "\n HINT. The strength of pt comes from the possibility to receive " ++
- "\n the argument from a pipeline, and altering it by the -transform flag." ++
- "\n flags:" ++
- "\n -transform transform the result by this term processor" ++
- "\n -number generate this number of terms at most" ++
- "\n examples:" ++
- "\n p \"zero is even\" | pt -transform=solve -- solve ?'s in parse result" ++
- "\n" ++
- "\n* st, show_tree: st Tree" ++
- "\n Prints the tree as a string. Unlike pt, this command cannot be" ++
- "\n used in a pipe to produce a tree, since its output is a string." ++
- "\n flags:" ++
- "\n -printer show the tree in a special format (-printer=xml supported)" ++
- "\n" ++
- "\nwt, wrap_tree: wt Fun" ++
- "\n Wraps the tree as the sole argument of Fun." ++
- "\n flags:" ++
- "\n -c compute the resulting new tree to normal form" ++
- "\n" ++
- "\nvt, visualize_tree: vt Tree" ++
- "\n Shows the abstract syntax tree via dot and gv (via temporary files" ++
- "\n grphtmp.dot, grphtmp.ps)." ++
- "\n flags:" ++
- "\n -c show categories only (no functions)" ++
- "\n -f show functions only (no categories)" ++
- "\n -g show as graph (sharing uses of the same function)" ++
- "\n -o just generate the .dot file" ++
- "\n examples:" ++
- "\n p \"hello world\" | vt -o | wf my.dot ;; ! open -a GraphViz my.dot" ++
- "\n -- This writes the parse tree into my.dot and opens the .dot file" ++
- "\n -- with another application without generating .ps." ++
- "\n" ++
- "\n-- subshells" ++
- "\n" ++
- "\nes, editing_session: es" ++
- "\n Opens an interactive editing session." ++
- "\n N.B. Exit from a Fudget session is to the Unix shell, not to GF. " ++
- "\n options:" ++
- "\n -f Fudget GUI (necessary for Unicode; only available in X Window System)" ++
- "\n" ++
- "\nts, translation_session: ts" ++
- "\n Translates input lines from any of the actual languages to all other ones." ++
- "\n To exit, type a full stop (.) alone on a line." ++
- "\n N.B. Exit from a Fudget session is to the Unix shell, not to GF. " ++
- "\n HINT: Set -parser and -lexer locally in each grammar." ++
- "\n options:" ++
- "\n -f Fudget GUI (necessary for Unicode; only available in X Windows)" ++
- "\n -lang prepend translation results with language names" ++
- "\n flags:" ++
- "\n -cat the parser category" ++
- "\n examples:" ++
- "\n ts -cat=Numeral -lang -- translate numerals, show language names" ++
- "\n" ++
- "\ntq, translation_quiz: tq Lang Lang" ++
- "\n Random-generates translation exercises from Lang1 to Lang2," ++
- "\n keeping score of success." ++
- "\n To interrupt, type a full stop (.) alone on a line." ++
- "\n HINT: Set -parser and -lexer locally in each grammar." ++
- "\n flags:" ++
- "\n -cat" ++
- "\n examples:" ++
- "\n tq -cat=NP TestResourceEng TestResourceSwe -- quiz for NPs" ++
- "\n" ++
- "\ntl, translation_list: tl Lang Lang" ++
- "\n Random-generates a list of ten translation exercises from Lang1" ++
- "\n to Lang2. The number can be changed by a flag." ++
- "\n HINT: use wf to save the exercises in a file." ++
- "\n flags:" ++
- "\n -cat" ++
- "\n -number" ++
- "\n examples:" ++
- "\n tl -cat=NP TestResourceEng TestResourceSwe -- quiz list for NPs" ++
- "\n" ++
- "\nmq, morphology_quiz: mq" ++
- "\n Random-generates morphological exercises," ++
- "\n keeping score of success." ++
- "\n To interrupt, type a full stop (.) alone on a line." ++
- "\n HINT: use printname judgements in your grammar to" ++
- "\n produce nice expressions for desired forms." ++
- "\n flags:" ++
- "\n -cat" ++
- "\n -lang" ++
- "\n examples:" ++
- "\n mq -cat=N -lang=TestResourceSwe -- quiz for Swedish nouns" ++
- "\n" ++
- "\nml, morphology_list: ml" ++
- "\n Random-generates a list of ten morphological exercises," ++
- "\n keeping score of success. The number can be changed with a flag." ++
- "\n HINT: use wf to save the exercises in a file." ++
- "\n flags:" ++
- "\n -cat" ++
- "\n -lang" ++
- "\n -number" ++
- "\n examples:" ++
- "\n ml -cat=N -lang=TestResourceSwe -- quiz list for Swedish nouns" ++
- "\n" ++
- "\n" ++
- "\n-- IO related commands" ++
- "\n" ++
- "\nrf, read_file: rf File" ++
- "\n Returns the contents of File as a String; error if File does not exist." ++
- "\n" ++
- "\nwf, write_file: wf File String" ++
- "\n Writes String into File; File is created if it does not exist." ++
- "\n N.B. the command overwrites File without a warning." ++
- "\n" ++
- "\naf, append_file: af File" ++
- "\n Writes String into the end of File; File is created if it does not exist." ++
- "\n" ++
- "\n* tg, transform_grammar: tg File" ++
- "\n Reads File, parses as a grammar, " ++
- "\n but instead of compiling further, prints it. " ++
- "\n The environment is not changed. When parsing the grammar, the same file" ++
- "\n name suffixes are supported as in the i command." ++
- "\n HINT: use this command to print the grammar in " ++
- "\n another format (the -printer flag); pipe it to wf to save this format." ++
- "\n flags:" ++
- "\n -printer (only -printer=latex supported currently)" ++
- "\n" ++
- "\n* cl, convert_latex: cl File" ++
- "\n Reads File, which is expected to be in LaTeX form." ++
- "\n Three environments are treated in special ways:" ++
- "\n \\begGF - \\end{verbatim}, which contains GF judgements," ++
- "\n \\begTGF - \\end{verbatim}, which contains a GF expression (displayed)" ++
- "\n \\begInTGF - \\end{verbatim}, which contains a GF expressions (inlined)." ++
- "\n Moreover, certain macros should be included in the file; you can" ++
- "\n get those macros by applying 'tg -printer=latex foo.gf' to any grammar" ++
- "\n foo.gf. Notice that the same File can be imported as a GF grammar," ++
- "\n consisting of all the judgements in \\begGF environments." ++
- "\n HINT: pipe with 'wf Foo.tex' to generate a new Latex file." ++
- "\n" ++
- "\nsa, speak_aloud: sa String" ++
- "\n Uses the Flite speech generator to produce speech for String." ++
- "\n Works for American English spelling. " ++
- "\n examples:" ++
- "\n h | sa -- listen to the list of commands" ++
- "\n gr -cat=S | l | sa -- generate a random sentence and speak it aloud" ++
- "\n" ++
- "\nsi, speech_input: si" ++
- "\n Uses an ATK speech recognizer to get speech input. " ++
- "\n flags:" ++
- "\n -lang: The grammar to use with the speech recognizer." ++
- "\n -cat: The grammar category to get input in." ++
- "\n -language: Use acoustic model and dictionary for this language." ++
- "\n -number: The number of utterances to recognize." ++
- "\n" ++
- "\nh, help: h Command?" ++
- "\n Displays the paragraph concerning the command from this help file." ++
- "\n Without the argument, shows the first lines of all paragraphs." ++
- "\n options" ++
- "\n -all show the whole help file" ++
- "\n -defs show user-defined commands and terms" ++
- "\n -FLAG show the values of FLAG (works for grammar-independent flags)" ++
- "\n examples:" ++
- "\n h print_grammar -- show all information on the pg command" ++
- "\n" ++
- "\nq, quit: q" ++
- "\n Exits GF." ++
- "\n HINT: you can use 'ph | wf history' to save your session." ++
- "\n" ++
- "\n!, system_command: ! String" ++
- "\n Issues a system command. No value is returned to GF." ++
- "\n example:" ++
- "\n ! ls" ++
- "\n" ++
- "\n?, system_command: ? String" ++
- "\n Issues a system command that receives its arguments from GF pipe" ++
- "\n and returns a value to GF." ++
- "\n example:" ++
- "\n h | ? 'wc -l' | p -cat=Num" ++
- "\n" ++
- "\n" ++
- "\n-- Flags. The availability of flags is defined separately for each command." ++
- "\n" ++
- "\n-cat, category in which parsing is performed." ++
- "\n The default is S." ++
- "\n" ++
- "\n-depth, the search depth in e.g. random generation." ++
- "\n The default depends on application." ++
- "\n" ++
- "\n-filter, operation performed on a string. The default is identity." ++
- "\n -filter=identity no change" ++
- "\n -filter=erase erase the text" ++
- "\n -filter=take100 show the first 100 characters" ++
- "\n -filter=length show the length of the string" ++
- "\n -filter=text format as text (punctuation, capitalization)" ++
- "\n -filter=code format as code (spacing, indentation)" ++
- "\n" ++
- "\n-lang, grammar used when executing a grammar-dependent command." ++
- "\n The default is the last-imported grammar." ++
- "\n" ++
- "\n-language, voice used by Festival as its --language flag in the sa command. " ++
- "\n The default is system-dependent. " ++
- "\n" ++
- "\n-length, the maximum number of characters shown of a string. " ++
- "\n The default is unlimited." ++
- "\n" ++
- "\n-lexer, tokenization transforming a string into lexical units for a parser." ++
- "\n The default is words." ++
- "\n -lexer=words tokens are separated by spaces or newlines" ++
- "\n -lexer=literals like words, but GF integer and string literals recognized" ++
- "\n -lexer=vars like words, but \"x\",\"x_...\",\"$...$\" as vars, \"?...\" as meta" ++
- "\n -lexer=chars each character is a token" ++
- "\n -lexer=code use Haskell's lex" ++
- "\n -lexer=codevars like code, but treat unknown words as variables, ?? as meta " ++
- "\n -lexer=textvars like text, but treat unknown words as variables, ?? as meta " ++
- "\n -lexer=text with conventions on punctuation and capital letters" ++
- "\n -lexer=codelit like code, but treat unknown words as string literals" ++
- "\n -lexer=textlit like text, but treat unknown words as string literals" ++
- "\n -lexer=codeC use a C-like lexer" ++
- "\n -lexer=ignore like literals, but ignore unknown words" ++
- "\n -lexer=subseqs like ignore, but then try all subsequences from longest" ++
- "\n" ++
- "\n-number, the maximum number of generated items in a list. " ++
- "\n The default is unlimited." ++
- "\n" ++
- "\n-optimize, optimization on generated code." ++
- "\n The default is share for concrete, none for resource modules." ++
- "\n Each of the flags can have the suffix _subs, which performs" ++
- "\n common subexpression elimination after the main optimization." ++
- "\n Thus, -optimize=all_subs is the most aggressive one. The _subs" ++
- "\n strategy only works in GFC, and applies therefore in concrete but" ++
- "\n not in resource modules." ++
- "\n -optimize=share share common branches in tables" ++
- "\n -optimize=parametrize first try parametrize then do share with the rest" ++
- "\n -optimize=values represent tables as courses-of-values" ++
- "\n -optimize=all first try parametrize then do values with the rest" ++
- "\n -optimize=none no optimization" ++
- "\n" ++
- "\n-parser, parsing strategy. The default is chart. If -cfg or -mcfg are" ++
- "\n selected, only bottomup and topdown are recognized." ++
- "\n -parser=chart bottom-up chart parsing" ++
- "\n -parser=bottomup a more up to date bottom-up strategy" ++
- "\n -parser=topdown top-down strategy" ++
- "\n -parser=old an old bottom-up chart parser" ++
- "\n" ++
- "\n-printer, format in which the grammar is printed. The default is" ++
- "\n gfc. Those marked with M are (only) available for pm, the rest" ++
- "\n for pg." ++
- "\n -printer=gfc GFC grammar" ++
- "\n -printer=gf GF grammar" ++
- "\n -printer=old old GF grammar" ++
- "\n -printer=cf context-free grammar, with profiles" ++
- "\n -printer=bnf context-free grammar, without profiles" ++
- "\n -printer=lbnf labelled context-free grammar for BNF Converter" ++
- "\n -printer=plbnf grammar for BNF Converter, with precedence levels" ++
- "\n *-printer=happy source file for Happy parser generator (use lbnf!)" ++
- "\n -printer=haskell abstract syntax in Haskell, with transl to/from GF" ++
- "\n -printer=haskell_gadt abstract syntax GADT in Haskell, with transl to/from GF" ++
- "\n -printer=morpho full-form lexicon, long format" ++
- "\n *-printer=latex LaTeX file (for the tg command)" ++
- "\n -printer=fullform full-form lexicon, short format" ++
- "\n *-printer=xml XML: DTD for the pg command, object for st" ++
- "\n -printer=old old GF: file readable by GF 1.2" ++
- "\n -printer=stat show some statistics of generated GFC" ++
- "\n -printer=probs show probabilities of all functions" ++
- "\n -printer=gsl Nuance GSL speech recognition grammar" ++
- "\n -printer=jsgf Java Speech Grammar Format" ++
- "\n -printer=jsgf_sisr_old Java Speech Grammar Format with semantic tags in " ++
- "\n SISR WD 20030401 format" ++
- "\n -printer=srgs_abnf SRGS ABNF format" ++
- "\n -printer=srgs_abnf_non_rec SRGS ABNF format, without any recursion." ++
- "\n -printer=srgs_abnf_sisr_old SRGS ABNF format, with semantic tags in" ++
- "\n SISR WD 20030401 format" ++
- "\n -printer=srgs_xml SRGS XML format" ++
- "\n -printer=srgs_xml_non_rec SRGS XML format, without any recursion." ++
- "\n -printer=srgs_xml_prob SRGS XML format, with weights" ++
- "\n -printer=srgs_xml_sisr_old SRGS XML format, with semantic tags in" ++
- "\n SISR WD 20030401 format" ++
- "\n -printer=vxml Generate a dialogue system in VoiceXML." ++
- "\n -printer=slf a finite automaton in the HTK SLF format" ++
- "\n -printer=slf_graphviz the same automaton as slf, but in Graphviz format" ++
- "\n -printer=slf_sub a finite automaton with sub-automata in the " ++
- "\n HTK SLF format" ++
- "\n -printer=slf_sub_graphviz the same automaton as slf_sub, but in " ++
- "\n Graphviz format" ++
- "\n -printer=fa_graphviz a finite automaton with labelled edges" ++
- "\n -printer=regular a regular grammar in a simple BNF" ++
- "\n -printer=unpar a gfc grammar with parameters eliminated" ++
- "\n -printer=functiongraph abstract syntax functions in 'dot' format" ++
- "\n -printer=typegraph abstract syntax categories in 'dot' format" ++
- "\n -printer=transfer Transfer language datatype (.tr file format)" ++
- "\n -printer=cfg-prolog M cfg in prolog format (also pg)" ++
- "\n -printer=gfc-prolog M gfc in prolog format (also pg)" ++
- "\n -printer=gfcm M gfcm file (default for pm)" ++
- "\n -printer=graph M module dependency graph in 'dot' (graphviz) format" ++
- "\n -printer=header M gfcm file with header (for GF embedded in Java)" ++
- "\n -printer=js M JavaScript type annotator and linearizer" ++
- "\n -printer=mcfg-prolog M mcfg in prolog format (also pg)" ++
- "\n -printer=missing M the missing linearizations of each concrete" ++
- "\n" ++
- "\n-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)" ++
- "\n" ++
- "\n-transform, transformation performed on a syntax tree. The default is identity." ++
- "\n -transform=identity no change" ++
- "\n -transform=compute compute by using definitions in the grammar" ++
- "\n -transform=nodup return the term only if it has no constants duplicated" ++
- "\n -transform=nodupatom return the term only if it has no atomic constants duplicated" ++
- "\n -transform=typecheck return the term only if it is type-correct" ++
- "\n -transform=solve solve metavariables as derived refinements" ++
- "\n -transform=context solve metavariables by unique refinements as variables" ++
- "\n -transform=delete replace the term by metavariable" ++
- "\n" ++
- "\n-unlexer, untokenization transforming linearization output into a string." ++
- "\n The default is unwords." ++
- "\n -unlexer=unwords space-separated token list (like unwords)" ++
- "\n -unlexer=text format as text: punctuation, capitals, paragraph " ++
- "\n -unlexer=code format as code (spacing, indentation)" ++
- "\n -unlexer=textlit like text, but remove string literal quotes" ++
- "\n -unlexer=codelit like code, but remove string literal quotes" ++
- "\n -unlexer=concat remove all spaces" ++
- "\n -unlexer=bind like identity, but bind at \"&+\"" ++
- "\n" ++
- "\n-mark, marking of parts of tree in linearization. The default is none." ++
- "\n -mark=metacat append \"+CAT\" to every metavariable, showing its category" ++
- "\n -mark=struct show tree structure with brackets" ++
- "\n -mark=java show tree structure with XML tags (used in gfeditor)" ++
- "\n" ++
- "\n-coding, Some grammars are in UTF-8, some in isolatin-1." ++
- "\n If the letters \228 (a-umlaut) and \246 (o-umlaut) look strange, either" ++
- "\n change your terminal to isolatin-1, or rewrite the grammar with" ++
- "\n 'pg -utf8'. For Windows you also may have to change your font to TrueType." ++
- "\n" ++
- "\n-- *: Commands and options marked with * are not currently implemented." ++
- []
diff --git a/src/GF/Shell/JGF.hs b/src/GF/Shell/JGF.hs
deleted file mode 100644
index 0ff678809..000000000
--- a/src/GF/Shell/JGF.hs
+++ /dev/null
@@ -1,89 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : JGF
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/06/03 22:44:36 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.13 $
---
--- GF editing session controlled by e.g. a Java program. AR 16\/11\/2001
------------------------------------------------------------------------------
-
-module GF.Shell.JGF where
-
-import GF.Data.Operations
-import GF.Infra.UseIO
-import GF.Text.Unicode
-
-import GF.API.IOGrammar
-import GF.Infra.Option
-import GF.Compile.ShellState
-import GF.UseGrammar.Session
-import GF.Shell.Commands
-import GF.Shell.CommandL
-import GF.Text.UTF8
-
-import Control.Monad (foldM)
-import System
-
-
-
--- GF editing session controlled by e.g. a Java program. AR 16/11/2001
-
--- | the Boolean is a temporary hack to have two parallel GUIs
-sessionLineJ :: Bool -> ShellState -> IO ()
-sessionLineJ isNew env = do
- putStrLnFlush $ initEditMsgJavaX env
- let env' = addGlobalOptions (options [sizeDisplay "short",beSilent]) env
- editLoopJnewX isNew env' (initSState)
-
--- | this is the real version, with XML
---
--- the Boolean is a temporary hack to have two parallel GUIs
-editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
-editLoopJnewX isNew env state = do
- mscs <- getCommandUTF (isCEnvUTF8 env state) ----
- let (ms,cs) = unzip mscs
- m = unlines ms --- ?
- if null cs
- then editLoopJnewX isNew env state
- else
- case cs of
- [CQuit] -> return ()
- _ -> do
- (env',state') <- foldM exec (env,state) cs
- let inits = initAndEditMsgJavaX isNew env' state' m
- let
- package = case last cs of
- CCEnvImport _ -> inits
- CCEnvEmptyAndImport _ -> inits
- CCEnvOpenTerm _ -> inits
- CCEnvOpenString _ -> inits
- CCEnvEmpty -> initEditMsgJavaX env'
- _ -> displaySStateJavaX isNew env' state' m
- putStrLnFlush package
- editLoopJnewX isNew env' state'
- where
- exec (env,state) c = do
- execCommand env c state
-
-welcome :: String
-welcome =
- "An experimental GF Editor for Java." ++
- "(c) Kristofer Johannisson, Janna Khegai, and Aarne Ranta 2002 under CNU GPL."
-
-initEditMsgJavaX :: CEnv -> String
-initEditMsgJavaX env = encodeUTF8 $ mkUnicode $ unlines $ tagXML "gfinit" $
- tagsXML "newcat" [["n" +++ cat] | (_,cat) <- newCatMenu env] ++
- tagXML "topic" [abstractName env] ++
- tagXML "language" [prLanguage langAbstract] ++
- concat [tagAttrXML "language" ("file",file) [prLanguage lang] |
- (file,lang) <- zip (allGrammarFileNames env) (allLanguages env)]
-
-
-initAndEditMsgJavaX :: Bool -> CEnv -> SState -> String -> String
-initAndEditMsgJavaX isNew env state m =
- initEditMsgJavaX env ++++ displaySStateJavaX isNew env state m
diff --git a/src/GF/Shell/PShell.hs b/src/GF/Shell/PShell.hs
deleted file mode 100644
index 68cb4d629..000000000
--- a/src/GF/Shell/PShell.hs
+++ /dev/null
@@ -1,174 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PShell
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/06 14:21:34 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.28 $
---
--- parsing GF shell commands. AR 11\/11\/2001
------------------------------------------------------------------------------
-
-module GF.Shell.PShell where
-
-import GF.Data.Operations
-import GF.Infra.UseIO
-import GF.Compile.ShellState
-import GF.Shell.ShellCommands
-import GF.Shell
-import GF.Infra.Option
-import GF.Compile.PGrammar (pzIdent, pTrm) --- (string2formsAndTerm)
-import GF.API
-import GF.System.Arch (fetchCommand)
-import GF.UseGrammar.Tokenize (wordsLits)
-
-import Data.Char (isDigit, isSpace)
-import System.IO.Error
-
--- parsing GF shell commands. AR 11/11/2001
-
--- | getting a sequence of command lines as input
-getCommandLines :: HState -> IO (String,[CommandLine])
-getCommandLines st = do
- s <- fetchCommand "> "
- return (s,pCommandLines st s)
-
-getCommandLinesBatch :: HState -> IO (String,[CommandLine])
-getCommandLinesBatch st = do
- s <- catch getLine (\e -> if isEOFError e then return "q" else ioError e)
- return $ (s,pCommandLines st s)
-
-pCommandLines :: HState -> String -> [CommandLine]
-pCommandLines st =
- map (pCommandLine st) . concatMap (chunks ";;" . wordsLits) . lines
-
--- | Remove single or double quotes around a string
-unquote :: String -> String
-unquote (x:xs@(_:_)) | x `elem` "\"'" && x == last xs = init xs
-unquote s = s
-
-pCommandLine :: HState -> [String] -> CommandLine
-pCommandLine st (c@('%':_):args) = pCommandLine st $ resolveShMacro st c args
-pCommandLine st (dc:c:def) | abbrevCommand dc == "dc" = ((CDefineCommand c def, noOptions),AUnit,[])
-pCommandLine st s = pFirst (chks s) where
- pFirst cos = case cos of
- (c,os,[a]) : cs -> ((c,os), a, pCont cs)
- _ -> ((CVoid,noOptions), AError "no parse", [])
- pCont cos = case cos of
- (c,os,_) : cs -> (c,os) : pCont cs
- _ -> []
- chks = map (pCommandOpt st) . chunks "|"
-
-pCommandOpt :: HState -> [String] -> (Command, Options, [CommandArg])
-pCommandOpt _ (w:ws) = let
- (os, co) = getOptions "-" ws
- (comm, args) = pCommand (abbrevCommand w:co)
- in
- (comm, os, args)
-pCommandOpt _ s = (CVoid, noOptions, [AError "no parse"])
-
-pInputString :: String -> [CommandArg]
-pInputString s = case s of
- ('"':_:_) | last s == '"' -> [AString (read s)]
- _ -> [AError "illegal string"]
-
--- | command @rl@ can be written @remove_language@ etc.
-abbrevCommand :: String -> String
-abbrevCommand = hds . words . map u2sp where
- u2sp c = if c=='_' then ' ' else c
- hds s = case s of
- [w@[_,_]] -> w
- _ -> map head s
-
-pCommand :: [String] -> (Command, [CommandArg])
-pCommand ws = case ws of
-
- "i" : f : [] -> aUnit (CImport (unquote f))
- "rl" : l : [] -> aUnit (CRemoveLanguage (language l))
- "e" : [] -> aUnit CEmptyState
- "cm" : a : [] -> aUnit (CChangeMain (Just (pzIdent a)))
- "cm" : [] -> aUnit (CChangeMain Nothing)
- "s" : [] -> aUnit CStripState
- "tg" : f : [] -> aUnit (CTransformGrammar f)
- "cl" : f : [] -> aUnit (CConvertLatex f)
-
- "ph" : [] -> aUnit CPrintHistory
- "dt" : f : t -> aTerm (CDefineTerm (unquote f)) t
-
- "l" : s -> aTermLi CLinearize s
-
- "p" : s -> aString CParse s
- "t" : i:o: s -> aString (CTranslate (language i) (language o)) s
- "gr" : [] -> aUnit CGenerateRandom
- "gr" : t -> aTerm CGenerateRandom t
- "gt" : [] -> aUnit CGenerateTrees
- "gt" : t -> aTerm CGenerateTrees t
- "pt" : s -> aTerm CPutTerm s
- "wt" : f : s -> aTerm (CWrapTerm (pzIdent f)) s
- "at" : f : s -> aTerm (CApplyTransfer (pmIdent f)) s
- "ma" : s -> aString CMorphoAnalyse s
- "tt" : s -> aString CTestTokenizer s
- "cc" : s -> aUnit $ CComputeConcrete $ unwords s
- "so" : s -> aUnit $ CShowOpers $ unwords s
- "tb" : [] -> aUnit CTreeBank
- "ut" : s -> aString CLookupTreebank s
-
- "tq" : i:o:[] -> aUnit (CTranslationQuiz (language i) (language o))
- "tl":i:o:[] -> aUnit (CTranslationList (language i) (language o))
- "mq" : [] -> aUnit CMorphoQuiz
- "ml" : [] -> aUnit CMorphoList
-
- "wf" : f : s -> aString (CWriteFile (unquote f)) s
- "af" : f : s -> aString (CAppendFile (unquote f)) s
- "rf" : f : [] -> aUnit (CReadFile (unquote f))
- "sa" : s -> aString CSpeakAloud s
- "si" : [] -> aUnit CSpeechInput
- "ps" : s -> aString CPutString s
- "st" : s -> aTerm CShowTerm s
- "!" : s -> aUnit (CSystemCommand (unwords s))
- "?" : s : x -> aString (CSystemCommand (unquote s)) x
- "sc" : s -> aUnit (CSystemCommand (unwords s))
- "g" : f : s -> aString (CGrep (unquote f)) s
-
- "sf" : l : [] -> aUnit (CSetLocalFlag (language l))
- "sf" : [] -> aUnit CSetFlag
-
- "pg" : [] -> aUnit CPrintGrammar
- "pi" : c : [] -> aUnit $ CPrintInformation (pzIdent c)
-
- "pj" : [] -> aUnit CPrintGramlet
- "pxs" : [] -> aUnit CPrintCanonXMLStruct
- "px" : [] -> aUnit CPrintCanonXML
- "pm" : [] -> aUnit CPrintMultiGrammar
- "vg" : [] -> aUnit CShowGrammarGraph
- "vt" : s -> aTerm CShowTreeGraph s
- "sg" : [] -> aUnit CPrintSourceGrammar
- "po" : [] -> aUnit CPrintGlobalOptions
- "pl" : [] -> aUnit CPrintLanguages
- "h" : c : [] -> aUnit $ CHelp (Just (abbrevCommand c))
- "h" : [] -> aUnit $ CHelp Nothing
-
- "q" : [] -> aImpure ICQuit
- "eh" : f : [] -> aImpure (ICExecuteHistory f)
- n : [] | all isDigit n -> aImpure (ICEarlierCommand (readIntArg n))
-
- "es" : [] -> aImpure ICEditSession
- "ts" : [] -> aImpure ICTranslateSession
- "r" : [] -> aImpure ICReload
- _ -> (CVoid, [])
-
- where
- aString c ss = (c, pInputString (unwords ss))
- aTerm c ss = (c, [ASTrm $ unwords ss]) ---- [ASTrms [s2t (unwords ss)]])
- aUnit c = (c, [AUnit])
- aImpure = aUnit . CImpure
-
- aTermLi c ss = (c [], [ASTrm $ unwords ss])
- ---- (c forms, [ASTrms [term]]) where
- ---- (forms,term) = ([], s2t (unwords ss)) ----string2formsAndTerm(unwords ss)
- pmIdent m = case span (/='.') m of
- (k,_:f) -> (Just (pzIdent k), pzIdent f)
- _ -> (Nothing,pzIdent m)
diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs
deleted file mode 100644
index 70238817b..000000000
--- a/src/GF/Shell/ShellCommands.hs
+++ /dev/null
@@ -1,246 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : ShellCommands
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/14 16:03:41 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.46 $
---
--- The datatype of shell commands and the list of their options.
------------------------------------------------------------------------------
-
-module GF.Shell.ShellCommands where
-
-import qualified GF.Infra.Ident as I
-import GF.Compile.ShellState
-import GF.UseGrammar.Custom
-import GF.Grammar.PrGrammar
-
-import GF.Infra.Option
-import GF.Data.Operations
-import GF.Infra.Modules
-
-import Data.Char (isDigit)
-import Control.Monad (mplus)
-
--- shell commands and their options
--- moved to separate module and added option check: AR 27/5/2004
---- TODO: single source for
---- (1) command interpreter (2) option check (3) help file
-
-data Command =
- CImport FilePath
- | CRemoveLanguage Language
- | CEmptyState
- | CChangeMain (Maybe I.Ident)
- | CStripState
- | CTransformGrammar FilePath
- | CConvertLatex FilePath
-
- | CDefineCommand String [String]
- | CDefineTerm String
-
- | CLinearize [()] ---- parameters
- | CParse
- | CTranslate Language Language
- | CGenerateRandom
- | CGenerateTrees
- | CTreeBank
- | CPutTerm
- | CWrapTerm I.Ident
- | CApplyTransfer (Maybe I.Ident, I.Ident)
- | CMorphoAnalyse
- | CTestTokenizer
- | CComputeConcrete String
- | CShowOpers String
-
- | CLookupTreebank
-
- | CTranslationQuiz Language Language
- | CTranslationList Language Language
- | CMorphoQuiz
- | CMorphoList
-
- | CReadFile FilePath
- | CWriteFile FilePath
- | CAppendFile FilePath
- | CSpeakAloud
- | CSpeechInput
- | CPutString
- | CShowTerm
- | CSystemCommand String
- | CGrep String
-
- | CSetFlag
- | CSetLocalFlag Language
-
- | CPrintGrammar
- | CPrintGlobalOptions
- | CPrintLanguages
- | CPrintInformation I.Ident
- | CPrintMultiGrammar
- | CPrintSourceGrammar
- | CShowGrammarGraph
- | CShowTreeGraph
- | CPrintGramlet
- | CPrintCanonXML
- | CPrintCanonXMLStruct
- | CPrintHistory
- | CHelp (Maybe String)
-
- | CImpure ImpureCommand
-
- | CVoid
-
--- to isolate the commands that are executed on top level
-data ImpureCommand =
- ICQuit
- | ICExecuteHistory FilePath
- | ICEarlierCommand Int
- | ICEditSession
- | ICTranslateSession
- | ICReload
-
-type CommandOpt = (Command, Options)
-
--- the top-level option warning action
-
-checkOptions :: ShellState -> (Command,Options) -> IO ()
-checkOptions sh (co, Opts opts) = do
- let (_,s) = errVal ([],"option check failed") $ mapErr check opts
- if (null s) then return ()
- else putStr "WARNING: " >> putStrLn s
- where
- check = isValidOption sh co
-
-isValidOption :: ShellState -> Command -> Option -> Err ()
-isValidOption st co op = case op of
- Opt (o,[]) ->
- testErr (elem o $ optsOf co) ("invalid option:" +++ prOpt op)
- Opt (o,[x]) -> do
- testErr (elem o (flagsOf co)) ("invalid flag:" +++ o)
- testValidFlag st co o x
- _ -> Bad $ "impossible option" +++ prOpt op
- where
- optsOf co = ("tr" :) $ fst $ optionsOfCommand co
- flagsOf co = snd $ optionsOfCommand co
-
-testValidFlag :: ShellState -> Command -> OptFunId -> String -> Err ()
-testValidFlag st co f x = case f of
- "cat" -> testIn (map prQIdent_ (allCategories st))
- "lang" -> testIn (map prt (allLanguages st))
- "transfer" -> testIn (map prt (allTransfers st))
- "res" -> testIn (map prt (allResources (srcModules st)))
- "number" -> testN
- "printer" -> case co of
- CPrintGrammar -> testInc customGrammarPrinter
- CPrintMultiGrammar -> testInc customMultiGrammarPrinter
- CSetFlag -> testInc customGrammarPrinter `mplus`
- testInc customMultiGrammarPrinter
- "lexer" -> testInc customTokenizer
- "unlexer" -> testInc customUntokenizer
- "depth" -> testN
- "rawtrees"-> testN
- "parser" -> testInc customParser
- -- hack for the -newer parsers: (to be changed in the future)
- -- `mplus` testIn (words "mcfg mcfg-bottomup mcfg-topdown cfg cfg-bottomup cfg-topdown bottomup topdown")
- -- if not(null x) && head x `elem` "mc" then return () else Bad ""
- "alts" -> testN
- "transform" -> testInc customTermCommand
- "filter" -> testInc customStringCommand
- "length" -> testN
- "optimize"-> testIn $ words "parametrize values all share none"
- "conversion" -> testIn $ words "strict nondet finite finite2 finite3 singletons finite-strict finite-singletons"
- _ -> return ()
- where
- testInc ci =
- let vs = snd (customInfo ci) in testIn vs
- testIn vs =
- if elem x vs
- then return ()
- else Bad ("flag:" +++ f +++ "invalid value:" +++ x ++++
- "possible values:" +++ unwords vs)
- testN =
- if all isDigit x
- then return ()
- else Bad ("flag:" +++ f +++ "invalid value:" +++ x ++++
- "expected integer")
-
-
-optionsOfCommand :: Command -> ([String],[String])
-optionsOfCommand co = case co of
- CSetFlag ->
- both "utf8 table struct record all multi"
- "cat lang lexer parser number depth rawtrees unlexer optimize path conversion printer"
- CImport _ ->
- both "old v s src make gfc retain docf nocf nocheckcirc cflexer noemit o make ex prob treebank"
- "abs cnc res path optimize conversion cat preproc probs noparse"
- CRemoveLanguage _ -> none
- CEmptyState -> none
- CStripState -> none
- CTransformGrammar _ -> flags "printer"
- CConvertLatex _ -> none
- CLinearize _ -> both "utf8 table struct record all multi" "lang number unlexer mark"
- CParse ->
- both "ambiguous fail cut new newer old overload cfg mcfg fcfg n ign raw v lines all prob"
- "cat lang lexer parser number rawtrees"
- CTranslate _ _ -> opts "cat lexer parser"
- CGenerateRandom -> both "cf prob" "cat lang number depth atoms noexpand doexpand"
- CGenerateTrees -> both "metas" "atoms depth alts cat lang number noexpand doexpand"
- CPutTerm -> flags "transform number"
- CTreeBank -> opts "c xml trees all table record"
- CLookupTreebank -> both "assocs raw strings trees" "treebank"
- CWrapTerm _ -> opts "c"
- CApplyTransfer _ -> flags "lang transfer"
- CMorphoAnalyse -> both "short status" "lang"
- CTestTokenizer -> flags "lexer"
- CComputeConcrete _ -> both "table" "res"
- CShowOpers _ -> flags "res"
-
- CTranslationQuiz _ _ -> flags "cat"
- CTranslationList _ _ -> flags "cat number"
- CMorphoQuiz -> flags "cat lang"
- CMorphoList -> flags "cat lang number"
-
- CReadFile _ -> none
- CWriteFile _ -> none
- CAppendFile _ -> none
- CSpeakAloud -> flags "language"
- CSpeechInput -> flags "lang cat language number"
-
- CPutString -> both "utf8" "filter length"
- CShowTerm -> flags "printer"
- CShowTreeGraph -> opts "c f g o"
- CSystemCommand _ -> none
- CGrep _ -> opts "v"
-
- CPrintGrammar -> both "utf8" "printer lang startcat"
- CPrintMultiGrammar -> both "utf8 utf8id" "printer"
- CPrintSourceGrammar -> both "utf8" "printer"
-
- CHelp _ -> opts "all alts atoms coding defs filter length lexer unlexer printer probs transform depth number cat"
-
- CImpure ICEditSession -> both "f" "file"
- CImpure ICTranslateSession -> both "f langs" "cat"
-
- _ -> none
-
-{-
- CSetLocalFlag Language
- CPrintGlobalOptions
- CPrintLanguages
- CPrintInformation I.Ident
- CPrintGramlet
- CPrintCanonXML
- CPrintCanonXMLStruct
- CPrintHistory
- CVoid
--}
- where
- flags fs = ([],words fs)
- opts fs = (words fs,[])
- both os fs = (words os,words fs)
- none = ([],[])
diff --git a/src/GF/Shell/SubShell.hs b/src/GF/Shell/SubShell.hs
deleted file mode 100644
index 5ef0459e5..000000000
--- a/src/GF/Shell/SubShell.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : SubShell
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:46:12 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.9 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Shell.SubShell where
-
-import GF.Data.Operations
-import GF.Infra.UseIO
-import GF.Compile.ShellState
-import GF.Infra.Option
-import GF.API
-
-import GF.Shell.CommandL
-import GF.System.ArchEdit
-
-import Data.List
-
--- AR 20/4/2000 -- 12/11/2001
-
-editSession :: Options -> ShellState -> IO ()
-editSession opts st
- | oElem makeFudget opts = fudlogueEdit font st'
- | otherwise = initEditLoop st' (return ())
- where
- st' = addGlobalOptions opts st
- font = maybe myUniFont mkOptFont $ getOptVal opts useFont
-
-myUniFont :: String
-myUniFont = "-mutt-clearlyu-medium-r-normal--0-0-100-100-p-0-iso10646-1"
-
-mkOptFont :: String -> String
-mkOptFont = id
-
-translateSession :: Options -> ShellState -> IO ()
-translateSession opts st = do
- let grs = allStateGrammars st
- cat = firstCatOpts opts (firstStateGrammar st)
- trans s = unlines $
- if oElem showLang opts then
- sort $ [l +++ ":" +++ s | (l,s) <- zip (map (prIdent . cncId) grs)
- (translateBetweenAll grs cat s)]
- else translateBetweenAll grs cat s
- translateLoop opts trans
-
-translateLoop :: Options -> (String -> String) -> IO ()
-translateLoop opts trans = do
- let fud = oElem makeFudget opts
- font = maybe myUniFont mkOptFont $ getOptVal opts useFont
- if fud then fudlogueWrite font trans else loopLine
- where
- loopLine = do
- putStrFlush "trans> "
- s <- getLine
- if s == "." then return () else do
- putStrLnFlush $ trans s
- loopLine
diff --git a/src/GF/Shell/TeachYourself.hs b/src/GF/Shell/TeachYourself.hs
deleted file mode 100644
index 7e5a8afe2..000000000
--- a/src/GF/Shell/TeachYourself.hs
+++ /dev/null
@@ -1,87 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : TeachYourself
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:46:13 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.7 $
---
--- translation and morphology quiz. AR 10\/5\/2000 -- 12\/4\/2002
------------------------------------------------------------------------------
-
-module GF.Shell.TeachYourself where
-
-import GF.Compile.ShellState
-import GF.API
-import GF.UseGrammar.Linear
-import GF.Grammar.PrGrammar
-
-import GF.Infra.Option
-import GF.System.Arch (myStdGen)
-import GF.Data.Operations
-import GF.Infra.UseIO
-
-import System.Random --- (randoms) --- bad import for hbc
-import System
-
--- translation and morphology quiz. AR 10/5/2000 -- 12/4/2002
-
-teachTranslation :: Options -> GFGrammar -> GFGrammar -> IO ()
-teachTranslation opts ig og = do
- tts <- transTrainList opts ig og infinity
- let qas = [ (q, mkAnswer as) | (q,as) <- tts]
- teachDialogue qas "Welcome to GF Translation Quiz."
-
-transTrainList ::
- Options -> GFGrammar -> GFGrammar -> Integer -> IO [(String,[String])]
-transTrainList opts ig og number = do
- ts <- randomTreesIO (addOption beSilent opts) ig (fromInteger number)
- return $ map mkOne $ ts
- where
- cat = firstCatOpts opts ig
- mkOne t = (norml (linearize ig t),map (norml . linearize og) (homonyms ig cat t))
-
-
-teachMorpho :: Options -> GFGrammar -> IO ()
-teachMorpho opts ig = useIOE () $ do
- tts <- morphoTrainList opts ig infinity
- let qas = [ (q, mkAnswer as) | (q,as) <- tts]
- ioeIO $ teachDialogue qas "Welcome to GF Morphology Quiz."
-
-morphoTrainList :: Options -> GFGrammar -> Integer -> IOE [(String,[String])]
-morphoTrainList opts ig number = do
- ts <- ioeIO $ randomTreesIO (addOption beSilent opts) ig (fromInteger number)
- gen <- ioeIO $ myStdGen (fromInteger number)
- mkOnes gen ts
- where
- mkOnes gen (t:ts) = do
- psss <- ioeErr $ allLinTables True gr cnc t
- let pss = concat $ map snd $ concat psss
- let (i,gen') = randomR (0, length pss - 1) gen
- (ps,ss) <- ioeErr $ pss !? i
- (_,ss0) <- ioeErr $ pss !? 0
- let bas = unwords ss0 --- concat $ take 1 ss0
- more <- mkOnes gen' ts
- return $ (bas +++ ":" +++ unwords (map prt_ ps), return (unwords ss)) : more
- mkOnes gen [] = return []
-
- gr = grammar ig
- cnc = cncId ig
-
--- | compare answer to the list of right answers, increase score and give feedback
-mkAnswer :: [String] -> String -> (Integer, String)
-mkAnswer as s = if (elem (norml s) as)
- then (1,"Yes.")
- else (0,"No, not" +++ s ++ ", but" ++++ unlines as)
-
-
-norml :: String -> String
-norml = unwords . words
-
--- | the maximal number of precompiled quiz problems
-infinity :: Integer
-infinity = 123
-
diff --git a/src/GF/Source/AbsGF.hs b/src/GF/Source/AbsGF.hs
deleted file mode 100644
index 63cc43006..000000000
--- a/src/GF/Source/AbsGF.hs
+++ /dev/null
@@ -1,306 +0,0 @@
-module GF.Source.AbsGF where
-
--- Haskell module generated by the BNF converter
-
-newtype LString = LString String deriving (Eq,Ord,Show)
-newtype PIdent = PIdent ((Int,Int),String) deriving (Eq,Ord,Show)
-data Grammar =
- Gr [ModDef]
- deriving (Eq,Ord,Show)
-
-data ModDef =
- MMain PIdent PIdent [ConcSpec]
- | MModule ComplMod ModType ModBody
- deriving (Eq,Ord,Show)
-
-data ConcSpec =
- ConcSpec PIdent ConcExp
- deriving (Eq,Ord,Show)
-
-data ConcExp =
- ConcExp PIdent [Transfer]
- deriving (Eq,Ord,Show)
-
-data Transfer =
- TransferIn Open
- | TransferOut Open
- deriving (Eq,Ord,Show)
-
-data ModType =
- MTAbstract PIdent
- | MTResource PIdent
- | MTInterface PIdent
- | MTConcrete PIdent PIdent
- | MTInstance PIdent PIdent
- | MTTransfer PIdent Open Open
- deriving (Eq,Ord,Show)
-
-data ModBody =
- MBody Extend Opens [TopDef]
- | MNoBody [Included]
- | MWith Included [Open]
- | MWithBody Included [Open] Opens [TopDef]
- | MWithE [Included] Included [Open]
- | MWithEBody [Included] Included [Open] Opens [TopDef]
- | MReuse PIdent
- | MUnion [Included]
- deriving (Eq,Ord,Show)
-
-data Extend =
- Ext [Included]
- | NoExt
- deriving (Eq,Ord,Show)
-
-data Opens =
- NoOpens
- | OpenIn [Open]
- deriving (Eq,Ord,Show)
-
-data Open =
- OName PIdent
- | OQualQO QualOpen PIdent
- | OQual QualOpen PIdent PIdent
- deriving (Eq,Ord,Show)
-
-data ComplMod =
- CMCompl
- | CMIncompl
- deriving (Eq,Ord,Show)
-
-data QualOpen =
- QOCompl
- | QOIncompl
- | QOInterface
- deriving (Eq,Ord,Show)
-
-data Included =
- IAll PIdent
- | ISome PIdent [PIdent]
- | IMinus PIdent [PIdent]
- deriving (Eq,Ord,Show)
-
-data Def =
- DDecl [Name] Exp
- | DDef [Name] Exp
- | DPatt Name [Patt] Exp
- | DFull [Name] Exp Exp
- deriving (Eq,Ord,Show)
-
-data TopDef =
- DefCat [CatDef]
- | DefFun [FunDef]
- | DefFunData [FunDef]
- | DefDef [Def]
- | DefData [DataDef]
- | DefTrans [Def]
- | DefPar [ParDef]
- | DefOper [Def]
- | DefLincat [PrintDef]
- | DefLindef [Def]
- | DefLin [Def]
- | DefPrintCat [PrintDef]
- | DefPrintFun [PrintDef]
- | DefFlag [FlagDef]
- | DefPrintOld [PrintDef]
- | DefLintype [Def]
- | DefPattern [Def]
- | DefPackage PIdent [TopDef]
- | DefVars [Def]
- | DefTokenizer PIdent
- deriving (Eq,Ord,Show)
-
-data CatDef =
- SimpleCatDef PIdent [DDecl]
- | ListCatDef PIdent [DDecl]
- | ListSizeCatDef PIdent [DDecl] Integer
- deriving (Eq,Ord,Show)
-
-data FunDef =
- FunDef [PIdent] Exp
- deriving (Eq,Ord,Show)
-
-data DataDef =
- DataDef PIdent [DataConstr]
- deriving (Eq,Ord,Show)
-
-data DataConstr =
- DataId PIdent
- | DataQId PIdent PIdent
- deriving (Eq,Ord,Show)
-
-data ParDef =
- ParDefDir PIdent [ParConstr]
- | ParDefIndir PIdent PIdent
- | ParDefAbs PIdent
- deriving (Eq,Ord,Show)
-
-data ParConstr =
- ParConstr PIdent [DDecl]
- deriving (Eq,Ord,Show)
-
-data PrintDef =
- PrintDef [Name] Exp
- deriving (Eq,Ord,Show)
-
-data FlagDef =
- FlagDef PIdent PIdent
- deriving (Eq,Ord,Show)
-
-data Name =
- IdentName PIdent
- | ListName PIdent
- deriving (Eq,Ord,Show)
-
-data LocDef =
- LDDecl [PIdent] Exp
- | LDDef [PIdent] Exp
- | LDFull [PIdent] Exp Exp
- deriving (Eq,Ord,Show)
-
-data Exp =
- EIdent PIdent
- | EConstr PIdent
- | ECons PIdent
- | ESort Sort
- | EString String
- | EInt Integer
- | EFloat Double
- | EMeta
- | EEmpty
- | EData
- | EList PIdent Exps
- | EStrings String
- | ERecord [LocDef]
- | ETuple [TupleComp]
- | EIndir PIdent
- | ETyped Exp Exp
- | EProj Exp Label
- | EQConstr PIdent PIdent
- | EQCons PIdent PIdent
- | EApp Exp Exp
- | ETable [Case]
- | ETTable Exp [Case]
- | EVTable Exp [Exp]
- | ECase Exp [Case]
- | EVariants [Exp]
- | EPre Exp [Altern]
- | EStrs [Exp]
- | EConAt PIdent Exp
- | EPatt Patt
- | EPattType Exp
- | ESelect Exp Exp
- | ETupTyp Exp Exp
- | EExtend Exp Exp
- | EGlue Exp Exp
- | EConcat Exp Exp
- | EAbstr [Bind] Exp
- | ECTable [Bind] Exp
- | EProd Decl Exp
- | ETType Exp Exp
- | ELet [LocDef] Exp
- | ELetb [LocDef] Exp
- | EWhere Exp [LocDef]
- | EEqs [Equation]
- | EExample Exp String
- | ELString LString
- | ELin PIdent
- deriving (Eq,Ord,Show)
-
-data Exps =
- NilExp
- | ConsExp Exp Exps
- deriving (Eq,Ord,Show)
-
-data Patt =
- PChar
- | PChars String
- | PMacro PIdent
- | PM PIdent PIdent
- | PW
- | PV PIdent
- | PCon PIdent
- | PQ PIdent PIdent
- | PInt Integer
- | PFloat Double
- | PStr String
- | PR [PattAss]
- | PTup [PattTupleComp]
- | PC PIdent [Patt]
- | PQC PIdent PIdent [Patt]
- | PDisj Patt Patt
- | PSeq Patt Patt
- | PRep Patt
- | PAs PIdent Patt
- | PNeg Patt
- deriving (Eq,Ord,Show)
-
-data PattAss =
- PA [PIdent] Patt
- deriving (Eq,Ord,Show)
-
-data Label =
- LIdent PIdent
- | LVar Integer
- deriving (Eq,Ord,Show)
-
-data Sort =
- Sort_Type
- | Sort_PType
- | Sort_Tok
- | Sort_Str
- | Sort_Strs
- deriving (Eq,Ord,Show)
-
-data Bind =
- BIdent PIdent
- | BWild
- deriving (Eq,Ord,Show)
-
-data Decl =
- DDec [Bind] Exp
- | DExp Exp
- deriving (Eq,Ord,Show)
-
-data TupleComp =
- TComp Exp
- deriving (Eq,Ord,Show)
-
-data PattTupleComp =
- PTComp Patt
- deriving (Eq,Ord,Show)
-
-data Case =
- Case Patt Exp
- deriving (Eq,Ord,Show)
-
-data Equation =
- Equ [Patt] Exp
- deriving (Eq,Ord,Show)
-
-data Altern =
- Alt Exp Exp
- deriving (Eq,Ord,Show)
-
-data DDecl =
- DDDec [Bind] Exp
- | DDExp Exp
- deriving (Eq,Ord,Show)
-
-data OldGrammar =
- OldGr Include [TopDef]
- deriving (Eq,Ord,Show)
-
-data Include =
- NoIncl
- | Incl [FileName]
- deriving (Eq,Ord,Show)
-
-data FileName =
- FString String
- | FIdent PIdent
- | FSlash FileName
- | FDot FileName
- | FMinus FileName
- | FAddId PIdent FileName
- deriving (Eq,Ord,Show)
-
diff --git a/src/GF/Source/ErrM.hs b/src/GF/Source/ErrM.hs
deleted file mode 100644
index 63840758e..000000000
--- a/src/GF/Source/ErrM.hs
+++ /dev/null
@@ -1,26 +0,0 @@
--- BNF Converter: Error Monad
--- Copyright (C) 2004 Author: Aarne Ranta
-
--- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
-module GF.Source.ErrM where
-
--- the Error monad: like Maybe type with error msgs
-
-import Control.Monad (MonadPlus(..), liftM)
-
-data Err a = Ok a | Bad String
- deriving (Read, Show, Eq, Ord)
-
-instance Monad Err where
- return = Ok
- fail = Bad
- Ok a >>= f = f a
- Bad s >>= f = Bad s
-
-instance Functor Err where
- fmap = liftM
-
-instance MonadPlus Err where
- mzero = Bad "Err.mzero"
- mplus (Bad _) y = y
- mplus x _ = x
diff --git a/src/GF/Source/GF.cf b/src/GF/Source/GF.cf
deleted file mode 100644
index 364550e6f..000000000
--- a/src/GF/Source/GF.cf
+++ /dev/null
@@ -1,370 +0,0 @@
--- AR 2/5/2003, 14-16 o'clock, Torino
-
--- 17/6/2007: marked with suffix --% those lines that are obsolete and
--- should not be included in documentation
-
-entrypoints Grammar, ModDef,
- OldGrammar, --%
- Exp ; -- let's see if more are needed
-
-comment "--" ;
-comment "{-" "-}" ;
-
--- the top-level grammar
-
-Gr. Grammar ::= [ModDef] ;
-
--- semicolon after module is permitted but not obligatory
-
-terminator ModDef "" ;
-_. ModDef ::= ModDef ";" ;
-
--- The $main$ multilingual grammar structure --%
-
-MMain. ModDef ::= "grammar" PIdent "=" "{" "abstract" "=" PIdent ";" [ConcSpec] "}" ;--%
-
-ConcSpec. ConcSpec ::= PIdent "=" ConcExp ;--%
-separator ConcSpec ";" ;--%
-
-ConcExp. ConcExp ::= PIdent [Transfer] ;--%
-
-separator Transfer "" ;--%
-TransferIn. Transfer ::= "(" "transfer" "in" Open ")" ; --%
-TransferOut. Transfer ::= "(" "transfer" "out" Open ")" ; --%
-
--- the module header
-
-MModule2. ModHeader ::= ComplMod ModType "=" ModHeaderBody ;
-
-MBody2. ModHeaderBody ::= Extend Opens ;
-MNoBody2. ModHeaderBody ::= [Included] ;
-MWith2. ModHeaderBody ::= Included "with" [Open] ;
-MWithBody2. ModHeaderBody ::= Included "with" [Open] "**" Opens ;
-MWithE2. ModHeaderBody ::= [Included] "**" Included "with" [Open] ;
-MWithEBody2. ModHeaderBody ::= [Included] "**" Included "with" [Open] "**" Opens ;
-
-MReuse2. ModHeaderBody ::= "reuse" PIdent ; --%
-MUnion2. ModHeaderBody ::= "union" [Included] ;--%
-
--- the individual modules
-
-MModule. ModDef ::= ComplMod ModType "=" ModBody ;
-
-MTAbstract. ModType ::= "abstract" PIdent ;
-MTResource. ModType ::= "resource" PIdent ;
-MTInterface. ModType ::= "interface" PIdent ;
-MTConcrete. ModType ::= "concrete" PIdent "of" PIdent ;
-MTInstance. ModType ::= "instance" PIdent "of" PIdent ;
-MTTransfer. ModType ::= "transfer" PIdent ":" Open "->" Open ;
-
-
-MBody. ModBody ::= Extend Opens "{" [TopDef] "}" ;
-MNoBody. ModBody ::= [Included] ;
-MWith. ModBody ::= Included "with" [Open] ;
-MWithBody. ModBody ::= Included "with" [Open] "**" Opens "{" [TopDef] "}" ;
-MWithE. ModBody ::= [Included] "**" Included "with" [Open] ;
-MWithEBody. ModBody ::= [Included] "**" Included "with" [Open] "**" Opens "{" [TopDef] "}" ;
-
-MReuse. ModBody ::= "reuse" PIdent ; --%
-MUnion. ModBody ::= "union" [Included] ;--%
-
-separator TopDef "" ;
-
-Ext. Extend ::= [Included] "**" ;
-NoExt. Extend ::= ;
-
-separator Open "," ;
-NoOpens. Opens ::= ;
-OpenIn. Opens ::= "open" [Open] "in" ;
-
-OName. Open ::= PIdent ;
-OQualQO. Open ::= "(" QualOpen PIdent ")" ;
-OQual. Open ::= "(" QualOpen PIdent "=" PIdent ")" ;
-
-CMCompl. ComplMod ::= ;
-CMIncompl. ComplMod ::= "incomplete" ;
-
-QOCompl. QualOpen ::= ;
-QOIncompl. QualOpen ::= "incomplete" ;--%
-QOInterface. QualOpen ::= "interface" ;--%
-
-separator Included "," ;
-
-IAll. Included ::= PIdent ;
-ISome. Included ::= PIdent "[" [PIdent] "]" ;
-IMinus. Included ::= PIdent "-" "[" [PIdent] "]" ;
-
--- definitions after the $oper$ keywords
-
-DDecl. Def ::= [Name] ":" Exp ;
-DDef. Def ::= [Name] "=" Exp ;
-DPatt. Def ::= Name [Patt] "=" Exp ; -- non-empty pattern list
-DFull. Def ::= [Name] ":" Exp "=" Exp ;
-
--- top-level definitions
-
-DefCat. TopDef ::= "cat" [CatDef] ;
-DefFun. TopDef ::= "fun" [FunDef] ;
-DefFunData.TopDef ::= "data" [FunDef] ;
-DefDef. TopDef ::= "def" [Def] ;
-DefData. TopDef ::= "data" [DataDef] ;
-
-DefTrans. TopDef ::= "transfer" [Def] ;--%
-
-DefPar. TopDef ::= "param" [ParDef] ;
-DefOper. TopDef ::= "oper" [Def] ;
-
-DefLincat. TopDef ::= "lincat" [PrintDef] ;
-DefLindef. TopDef ::= "lindef" [Def] ;
-DefLin. TopDef ::= "lin" [Def] ;
-
-DefPrintCat. TopDef ::= "printname" "cat" [PrintDef] ;
-DefPrintFun. TopDef ::= "printname" "fun" [PrintDef] ;
-DefFlag. TopDef ::= "flags" [FlagDef] ;
-
-SimpleCatDef. CatDef ::= PIdent [DDecl] ;
-ListCatDef. CatDef ::= "[" PIdent [DDecl] "]" ;
-ListSizeCatDef. CatDef ::= "[" PIdent [DDecl] "]" "{" Integer "}" ;
-
-FunDef. FunDef ::= [PIdent] ":" Exp ;
-
-DataDef. DataDef ::= PIdent "=" [DataConstr] ;
-DataId. DataConstr ::= PIdent ;
-DataQId. DataConstr ::= PIdent "." PIdent ;
-separator DataConstr "|" ;
-
-
-ParDefDir. ParDef ::= PIdent "=" [ParConstr] ;
-ParDefIndir. ParDef ::= PIdent "=" "(" "in" PIdent ")" ;
-ParDefAbs. ParDef ::= PIdent ;
-
-ParConstr. ParConstr ::= PIdent [DDecl] ;
-
-PrintDef. PrintDef ::= [Name] "=" Exp ;
-
-FlagDef. FlagDef ::= PIdent "=" PIdent ;
-
-terminator nonempty Def ";" ;
-terminator nonempty CatDef ";" ;
-terminator nonempty FunDef ";" ;
-terminator nonempty DataDef ";" ;
-terminator nonempty ParDef ";" ;
-
-terminator nonempty PrintDef ";" ;
-terminator nonempty FlagDef ";" ;
-
-separator ParConstr "|" ;
-
-separator nonempty PIdent "," ;
-
--- names of categories and functions in definition LHS
-
-IdentName. Name ::= PIdent ;
-ListName. Name ::= "[" PIdent "]" ;
-
-separator nonempty Name "," ;
-
--- definitions in records and $let$ expressions
-
-LDDecl. LocDef ::= [PIdent] ":" Exp ;
-LDDef. LocDef ::= [PIdent] "=" Exp ;
-LDFull. LocDef ::= [PIdent] ":" Exp "=" Exp ;
-
-separator LocDef ";" ;
-
--- terms and types
-
-EIdent. Exp6 ::= PIdent ;
-EConstr. Exp6 ::= "{" PIdent "}" ;--%
-ECons. Exp6 ::= "%" PIdent "%" ;--%
-ESort. Exp6 ::= Sort ;
-EString. Exp6 ::= String ;
-EInt. Exp6 ::= Integer ;
-EFloat. Exp6 ::= Double ;
-EMeta. Exp6 ::= "?" ;
-EEmpty. Exp6 ::= "[" "]" ;
-EData. Exp6 ::= "data" ;
-EList. Exp6 ::= "[" PIdent Exps "]" ;
-EStrings. Exp6 ::= "[" String "]" ;
-ERecord. Exp6 ::= "{" [LocDef] "}" ; -- !
-ETuple. Exp6 ::= "<" [TupleComp] ">" ; --- needed for separator ","
-EIndir. Exp6 ::= "(" "in" PIdent ")" ; -- indirection, used in judgements --%
-ETyped. Exp6 ::= "<" Exp ":" Exp ">" ; -- typing, used for annotations
-
-EProj. Exp5 ::= Exp5 "." Label ;
-EQConstr. Exp5 ::= "{" PIdent "." PIdent "}" ; -- qualified constructor --%
-EQCons. Exp5 ::= "%" PIdent "." PIdent ; -- qualified constant --%
-
-EApp. Exp4 ::= Exp4 Exp5 ;
-ETable. Exp4 ::= "table" "{" [Case] "}" ;
-ETTable. Exp4 ::= "table" Exp6 "{" [Case] "}" ;
-EVTable. Exp4 ::= "table" Exp6 "[" [Exp] "]" ;
-ECase. Exp4 ::= "case" Exp "of" "{" [Case] "}" ;
-EVariants. Exp4 ::= "variants" "{" [Exp] "}" ;
---- EPreCase. Exp4 ::= "pre" "{" [Case] "}" ;
-EPre. Exp4 ::= "pre" "{" Exp ";" [Altern] "}" ;
-EStrs. Exp4 ::= "strs" "{" [Exp] "}" ;
-EConAt. Exp4 ::= PIdent "@" Exp6 ; --%
-
-EPatt. Exp4 ::= "#" Patt2 ;
-EPattType. Exp4 ::= "pattern" Exp5 ;
-
-ESelect. Exp3 ::= Exp3 "!" Exp4 ;
-ETupTyp. Exp3 ::= Exp3 "*" Exp4 ;
-EExtend. Exp3 ::= Exp3 "**" Exp4 ;
-
-EGlue. Exp1 ::= Exp2 "+" Exp1 ;
-
-EConcat. Exp ::= Exp1 "++" Exp ;
-
-EAbstr. Exp ::= "\\" [Bind] "->" Exp ;
-ECTable. Exp ::= "\\""\\" [Bind] "=>" Exp ;
-EProd. Exp ::= Decl "->" Exp ;
-ETType. Exp ::= Exp3 "=>" Exp ; -- these are thus right associative
-ELet. Exp ::= "let" "{" [LocDef] "}" "in" Exp ;
-ELetb. Exp ::= "let" [LocDef] "in" Exp ;
-EWhere. Exp ::= Exp3 "where" "{" [LocDef] "}" ;
-EEqs. Exp ::= "fn" "{" [Equation] "}" ; --%
-
-EExample. Exp ::= "in" Exp5 String ;
-
-coercions Exp 6 ;
-
-separator Exp ";" ; -- in variants
-
--- list of arguments to category
-NilExp. Exps ::= ;
-ConsExp. Exps ::= Exp6 Exps ; -- Exp6 to force parantheses
-
--- patterns
-
-PChar. Patt2 ::= "?" ;
-PChars. Patt2 ::= "[" String "]" ;
-PMacro. Patt2 ::= "#" PIdent ;
-PM. Patt2 ::= "#" PIdent "." PIdent ;
-PW. Patt2 ::= "_" ;
-PV. Patt2 ::= PIdent ;
-PCon. Patt2 ::= "{" PIdent "}" ; --%
-PQ. Patt2 ::= PIdent "." PIdent ;
-PInt. Patt2 ::= Integer ;
-PFloat. Patt2 ::= Double ;
-PStr. Patt2 ::= String ;
-PR. Patt2 ::= "{" [PattAss] "}" ;
-PTup. Patt2 ::= "<" [PattTupleComp] ">" ;
-PC. Patt1 ::= PIdent [Patt] ;
-PQC. Patt1 ::= PIdent "." PIdent [Patt] ;
-PDisj. Patt ::= Patt "|" Patt1 ;
-PSeq. Patt ::= Patt "+" Patt1 ;
-PRep. Patt1 ::= Patt2 "*" ;
-PAs. Patt1 ::= PIdent "@" Patt2 ;
-PNeg. Patt1 ::= "-" Patt2 ;
-
-coercions Patt 2 ;
-
-PA. PattAss ::= [PIdent] "=" Patt ;
-
--- labels
-
-LIdent. Label ::= PIdent ;
-LVar. Label ::= "$" Integer ;
-
--- basic types
-
-rules Sort ::=
- "Type"
- | "PType"
- | "Tok" --%
- | "Str"
- | "Strs" ;
-
-separator PattAss ";" ;
-
--- this is explicit to force higher precedence level on rhs
-(:[]). [Patt] ::= Patt2 ;
-(:). [Patt] ::= Patt2 [Patt] ;
-
-
--- binds in lambdas and lin rules
-
-BIdent. Bind ::= PIdent ;
-BWild. Bind ::= "_" ;
-
-separator Bind "," ;
-
-
--- declarations in function types
-
-DDec. Decl ::= "(" [Bind] ":" Exp ")" ;
-DExp. Decl ::= Exp4 ; -- can thus be an application
-
--- tuple component (term or pattern)
-
-TComp. TupleComp ::= Exp ;
-PTComp. PattTupleComp ::= Patt ;
-
-separator TupleComp "," ;
-separator PattTupleComp "," ;
-
--- case branches
-
-Case. Case ::= Patt "=>" Exp ;
-
-separator nonempty Case ";" ;
-
--- cases in abstract syntax --%
-
-Equ. Equation ::= [Patt] "->" Exp ; --%
-
-separator Equation ";" ; --%
-
--- prefix alternatives
-
-Alt. Altern ::= Exp "/" Exp ;
-
-separator Altern ";" ;
-
--- in a context, higher precedence is required than in function types
-
-DDDec. DDecl ::= "(" [Bind] ":" Exp ")" ;
-DDExp. DDecl ::= Exp6 ; -- can thus *not* be an application
-
-separator DDecl "" ;
-
-
--------------------------------------- --%
-
--- for backward compatibility --%
-
-OldGr. OldGrammar ::= Include [TopDef] ; --%
-
-NoIncl. Include ::= ; --%
-Incl. Include ::= "include" [FileName] ; --%
-
-FString. FileName ::= String ; --%
-
-terminator nonempty FileName ";" ; --%
-
-FIdent. FileName ::= PIdent ; --%
-FSlash. FileName ::= "/" FileName ; --%
-FDot. FileName ::= "." FileName ; --%
-FMinus. FileName ::= "-" FileName ; --%
-FAddId. FileName ::= PIdent FileName ; --%
-
-token LString '\'' (char - '\'')* '\'' ; --%
-ELString. Exp6 ::= LString ; --%
-ELin. Exp4 ::= "Lin" PIdent ; --%
-
-DefPrintOld. TopDef ::= "printname" [PrintDef] ; --%
-DefLintype. TopDef ::= "lintype" [Def] ; --%
-DefPattern. TopDef ::= "pattern" [Def] ; --%
-
--- deprecated packages are attempted to be interpreted --%
-DefPackage. TopDef ::= "package" PIdent "=" "{" [TopDef] "}" ";" ; --%
-
--- these two are just ignored after parsing --%
-DefVars. TopDef ::= "var" [Def] ; --%
-DefTokenizer. TopDef ::= "tokenizer" PIdent ";" ; --%
-
--- identifiers
-
-position token PIdent ('_' | letter) (letter | digit | '_' | '\'')* ;
diff --git a/src/GF/Source/GrammarToSource.hs b/src/GF/Source/GrammarToSource.hs
deleted file mode 100644
index 6d48e4ced..000000000
--- a/src/GF/Source/GrammarToSource.hs
+++ /dev/null
@@ -1,259 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GrammarToSource
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/04 11:05:07 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.23 $
---
--- From internal source syntax to BNFC-generated (used for printing).
------------------------------------------------------------------------------
-
-module GF.Source.GrammarToSource ( trGrammar,
- trModule,
- trAnyDef,
- trLabel,
- trt, tri, trp
- ) where
-
-import GF.Data.Operations
-import GF.Grammar.Grammar
-import GF.Infra.Modules
-import GF.Infra.Option
-import qualified GF.Source.AbsGF as P
-import GF.Infra.Ident
-
--- | AR 13\/5\/2003
---
--- translate internal to parsable and printable source
-trGrammar :: SourceGrammar -> P.Grammar
-trGrammar (MGrammar ms) = P.Gr (map trModule ms) -- no includes
-
-trModule :: (Ident,SourceModInfo) -> P.ModDef
-trModule (i,mo) = case mo of
- ModMod m -> P.MModule compl typ body where
- compl = case mstatus m of
- MSIncomplete -> P.CMIncompl
- _ -> P.CMCompl
- i' = tri i
- typ = case typeOfModule mo of
- MTResource -> P.MTResource i'
- MTAbstract -> P.MTAbstract i'
- MTConcrete a -> P.MTConcrete i' (tri a)
- MTTransfer a b -> P.MTTransfer i' (trOpen a) (trOpen b)
- MTInstance a -> P.MTInstance i' (tri a)
- MTInterface -> P.MTInterface i'
- body = P.MBody
- (trExtends (extend m))
- (mkOpens (map trOpen (opens m)))
- (mkTopDefs (concatMap trAnyDef (tree2list (jments m)) ++ map trFlag (flags m)))
-
-trExtends :: [(Ident,MInclude Ident)] -> P.Extend
-trExtends [] = P.NoExt
-trExtends es = (P.Ext $ map tre es) where
- tre (i,c) = case c of
- MIAll -> P.IAll (tri i)
- MIOnly is -> P.ISome (tri i) (map tri is)
- MIExcept is -> P.IMinus (tri i) (map tri is)
-
----- this has to be completed with other mtys
-forName (MTConcrete a) = tri a
-
-trOpen :: OpenSpec Ident -> P.Open
-trOpen o = case o of
- OSimple OQNormal i -> P.OName (tri i)
- OSimple q i -> P.OQualQO (trQualOpen q) (tri i)
- OQualif q i j -> P.OQual (trQualOpen q) (tri i) (tri j)
-
-trQualOpen q = case q of
- OQNormal -> P.QOCompl
- OQIncomplete -> P.QOIncompl
- OQInterface -> P.QOInterface
-
-
-mkOpens ds = if null ds then P.NoOpens else P.OpenIn ds
-mkTopDefs ds = ds
-
-trAnyDef :: (Ident,Info) -> [P.TopDef]
-trAnyDef (i,info) = let i' = tri i in case info of
- AbsCat (Yes co) pd -> [P.DefCat [P.SimpleCatDef i' (map trDecl co)]]
- AbsFun (Yes ty) (Yes EData) -> [P.DefFunData [P.FunDef [i'] (trt ty)]]
- AbsFun (Yes ty) pt -> [P.DefFun [P.FunDef [i'] (trt ty)]] ++ case pt of
- Yes t -> [P.DefDef [P.DDef [mkName i'] (trt t)]]
- _ -> []
- AbsFun (May b) _ -> [P.DefFun [P.FunDef [i'] (P.EIndir (tri b))]]
- ---- don't destroy definitions!
- AbsTrans f -> [P.DefTrans [P.DDef [mkName i'] (trt f)]]
-
- ResOper pty ptr -> [P.DefOper [trDef i' pty ptr]]
- ResParam pp -> [P.DefPar [case pp of
- Yes (ps,_) -> P.ParDefDir i' [P.ParConstr (tri c) (map trDecl co) | (c,co) <- ps]
- May b -> P.ParDefIndir i' $ tri b
- _ -> P.ParDefAbs i']]
-
- ResOverload tysts ->
- [P.DefOper [P.DDef [mkName i'] (
- P.EApp (P.EIdent $ tri $ identC "overload")
- (P.ERecord [P.LDFull [i'] (trt ty) (trt fu) | (ty,fu) <- tysts]))]]
-
- CncCat (Yes ty) Nope _ ->
- [P.DefLincat [P.PrintDef [mkName i'] (trt ty)]]
- CncCat pty ptr ppr ->
- [P.DefLindef [trDef i' pty ptr]] ++
- [P.DefPrintCat [P.PrintDef [mkName i'] (trt pr)] | Yes pr <- [ppr]]
- CncFun _ ptr ppr ->
- [P.DefLin [trDef i' nope ptr]] ++
- [P.DefPrintFun [P.PrintDef [mkName i'] (trt pr)] | Yes pr <- [ppr]]
-{-
- ---- encoding of AnyInd without changing syntax. AR 20/9/2007
- AnyInd s b ->
- [P.DefOper [P.DDef [mkName i]
- (P.EApp (P.EInt (if s then 1 else 0)) (P.EIdent (tri b)))]]
--}
- _ -> []
-
-
-trDef :: P.PIdent -> Perh Type -> Perh Term -> P.Def
-trDef i pty ptr = case (pty,ptr) of
- (Nope, Nope) -> P.DDef [mkName i] (P.EMeta) ---
- (_, Nope) -> P.DDecl [mkName i] (trPerh pty)
- (Nope, _ ) -> P.DDef [mkName i] (trPerh ptr)
- (_, _ ) -> P.DFull [mkName i] (trPerh pty) (trPerh ptr)
-
-trPerh p = case p of
- Yes t -> trt t
- May b -> P.EIndir $ tri b
- _ -> P.EMeta ---
-
-
-trFlag :: Option -> P.TopDef
-trFlag o = case o of
- Opt (f,[x]) -> P.DefFlag [P.FlagDef (tri $ identC f) (tri $ identC x)]
- _ -> P.DefFlag [] --- warning?
-
-trt :: Term -> P.Exp
-trt trm = case trm of
- Vr s -> P.EIdent $ tri s
- Cn s -> P.ECons $ tri s
- Con s -> P.EConstr $ tri s
- Sort s -> P.ESort $ case s of
- "Type" -> P.Sort_Type
- "PType" -> P.Sort_PType
- "Tok" -> P.Sort_Tok
- "Str" -> P.Sort_Str
- "Strs" -> P.Sort_Strs
- _ -> error $ "not yet sort " +++ show trm ----
-
- App c a -> P.EApp (trt c) (trt a)
- Abs x b -> P.EAbstr [trb x] (trt b)
- Eqs pts -> P.EEqs [P.Equ (map trp ps) (trt t) | (ps,t) <- pts]
- Meta m -> P.EMeta
- Prod x a b | isWildIdent x -> P.EProd (P.DExp (trt a)) (trt b)
- Prod x a b -> P.EProd (P.DDec [trb x] (trt a)) (trt b)
-
- Example t s -> P.EExample (trt t) s
- R [] -> P.ETuple [] --- to get correct parsing when read back
- R r -> P.ERecord $ map trAssign r
- RecType r -> P.ERecord $ map trLabelling r
- ExtR x y -> P.EExtend (trt x) (trt y)
- P t l -> P.EProj (trt t) (trLabel l)
- PI t l _ -> P.EProj (trt t) (trLabel l)
- Q t l -> P.EQCons (tri t) (tri l)
- QC t l -> P.EQConstr (tri t) (tri l)
- TSh (TComp ty) cc -> P.ETTable (trt ty) (map trCases cc)
- TSh (TTyped ty) cc -> P.ETTable (trt ty) (map trCases cc)
- TSh (TWild ty) cc -> P.ETTable (trt ty) (map trCases cc)
- T (TTyped ty) cc -> P.ETTable (trt ty) (map trCase cc)
- T (TComp ty) cc -> P.ETTable (trt ty) (map trCase cc)
- T (TWild ty) cc -> P.ETTable (trt ty) (map trCase cc)
- T _ cc -> P.ETable (map trCase cc)
- V ty cc -> P.EVTable (trt ty) (map trt cc)
-
- Table x v -> P.ETType (trt x) (trt v)
- S f x -> P.ESelect (trt f) (trt x)
----- Alias c a t -> "{-" +++ prt c +++ "=" +++ "-}" +++ prt t
--- Alias c a t -> prt (Let (c,(Just a,t)) (Vr c)) -- thus Alias is only internal
-
- Let (x,(ma,b)) t ->
- P.ELet [maybe (P.LDDef x' b') (\ty -> P.LDFull x' (trt ty) b') ma] (trt t)
- where
- b' = trt b
- x' = [tri x]
-
- Empty -> P.EEmpty
- K [] -> P.EEmpty
- K a -> P.EString a
- C a b -> P.EConcat (trt a) (trt b)
-
- EInt i -> P.EInt i
- EFloat i -> P.EFloat i
-
- EPatt p -> P.EPatt (trp p)
- EPattType t -> P.EPattType (trt t)
-
- Glue a b -> P.EGlue (trt a) (trt b)
- Alts (t, tt) -> P.EPre (trt t) [P.Alt (trt v) (trt c) | (v,c) <- tt]
- FV ts -> P.EVariants $ map trt ts
- Strs tt -> P.EStrs $ map trt tt
- EData -> P.EData
- _ -> error $ "not yet" +++ show trm ----
-
-trp :: Patt -> P.Patt
-trp p = case p of
- PW -> P.PW
- PV s | isWildIdent s -> P.PW
- PV s -> P.PV $ tri s
- PC c [] -> P.PCon $ tri c
- PC c a -> P.PC (tri c) (map trp a)
- PP p c [] -> P.PQ (tri p) (tri c)
- PP p c a -> P.PQC (tri p) (tri c) (map trp a)
- PR r -> P.PR [P.PA [tri $ trLabelIdent l] (trp p) | (l,p) <- r]
- PString s -> P.PStr s
- PInt i -> P.PInt i
- PFloat i -> P.PFloat i
- PT t p -> trp p ---- prParenth (prt p +++ ":" +++ prt t)
-
- PAs x p -> P.PAs (tri x) (trp p)
-
- PAlt p q -> P.PDisj (trp p) (trp q)
- PSeq p q -> P.PSeq (trp p) (trp q)
- PRep p -> P.PRep (trp p)
- PNeg p -> P.PNeg (trp p)
- PChar -> P.PChar
- PChars s -> P.PChars s
- PM m c -> P.PM (tri m) (tri c)
-
-
-trAssign (lab, (mty, t)) = maybe (P.LDDef x t') (\ty -> P.LDFull x (trt ty) t') mty
- where
- t' = trt t
- x = [tri $ trLabelIdent lab]
-
-trLabelling (lab,ty) = P.LDDecl [tri $ trLabelIdent lab] (trt ty)
-
-trCase (patt, trm) = P.Case (trp patt) (trt trm)
-trCases (patts,trm) = P.Case (foldl1 P.PDisj (map trp patts)) (trt trm)
-
-trDecl (x,ty) = P.DDDec [trb x] (trt ty)
-
-tri :: Ident -> P.PIdent
-tri = ppIdent . prIdent
-
-ppIdent i = P.PIdent ((0,0),i)
-
-trb i = if isWildIdent i then P.BWild else P.BIdent (tri i)
-
-trLabel :: Label -> P.Label
-trLabel i = case i of
- LIdent s -> P.LIdent $ ppIdent s
- LVar i -> P.LVar $ toInteger i
-
-trLabelIdent i = identC $ case i of
- LIdent s -> s
- LVar i -> "v" ++ show i --- should not happen
-
-mkName :: P.PIdent -> P.Name
-mkName = P.IdentName
diff --git a/src/GF/Source/LexGF.hs b/src/GF/Source/LexGF.hs
deleted file mode 100644
index 89067b6b6..000000000
--- a/src/GF/Source/LexGF.hs
+++ /dev/null
@@ -1,345 +0,0 @@
-{-# OPTIONS -fglasgow-exts -cpp #-}
-{-# LINE 3 "GF/Source/LexGF.x" #-}
-{-# OPTIONS -fno-warn-incomplete-patterns #-}
-module GF.Source.LexGF where
-
-
-import qualified Data.ByteString.Char8 as BS
-
-#if __GLASGOW_HASKELL__ >= 603
-#include "ghcconfig.h"
-#else
-#include "config.h"
-#endif
-#if __GLASGOW_HASKELL__ >= 503
-import Data.Array
-import Data.Char (ord)
-import Data.Array.Base (unsafeAt)
-#else
-import Array
-import Char (ord)
-#endif
-#if __GLASGOW_HASKELL__ >= 503
-import GHC.Exts
-#else
-import GlaExts
-#endif
-alex_base :: AlexAddr
-alex_base = AlexA# "\x01\x00\x00\x00\x15\x00\x00\x00\x39\x00\x00\x00\x3a\x00\x00\x00\x18\x00\x00\x00\x19\x00\x00\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x45\x00\x00\x00\x1b\x00\x00\x00\x1c\x00\x00\x00\x1d\x00\x00\x00\x42\x00\x00\x00\x00\x00\x00\x00\x26\x00\x00\x00\x27\x00\x00\x00\x13\x00\x00\x00\x9c\x00\x00\x00\x00\x00\x00\x00\x2c\x00\x00\x00\x2d\x00\x00\x00\x6c\x01\x00\x00\x3c\x02\x00\x00\x0c\x03\x00\x00\x00\x00\x00\x00\x17\x01\x00\x00\xe7\x01\x00\x00\xd5\x00\x00\x00\x35\x00\x00\x00\xe7\x00\x00\x00\xf2\x00\x00\x00\x1d\x01\x00\x00\xc2\x01\x00\x00\xcc\x01\x00\x00"#
-
-alex_table :: AlexAddr
-alex_table = AlexA# "\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0d\x00\x0d\x00\x0d\x00\x0d\x00\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0d\x00\x0e\x00\x1a\x00\x0e\x00\x0e\x00\x0e\x00\xff\xff\x14\x00\x0e\x00\x0e\x00\x0f\x00\x10\x00\x0e\x00\x05\x00\x0e\x00\x0e\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x0e\x00\x0e\x00\x0e\x00\x11\x00\x0e\x00\x0e\x00\x0e\x00\x04\x00\xff\xff\xff\xff\x02\x00\x02\x00\x09\x00\x09\x00\x09\x00\x0a\x00\x0d\x00\x0d\x00\x0d\x00\x0d\x00\x0d\x00\x0e\x00\x0e\x00\x0e\x00\x13\x00\x13\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x0e\x00\x0e\x00\xff\xff\x12\x00\xff\xff\x0d\x00\x20\x00\x00\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x1d\x00\x00\x00\x00\x00\x09\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x0e\x00\x0e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x06\x00\x07\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x1b\x00\xff\xff\x00\x00\x00\x00\x17\x00\x1b\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\xff\xff\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x21\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x1c\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x18\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x22\x00\x00\x00\xff\xff\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x1c\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x17\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x18\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x00\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00\x18\x00"#
-
-alex_check :: AlexAddr
-alex_check = AlexA# "\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x2d\x00\x0a\x00\x0a\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x2a\x00\x3e\x00\x2b\x00\x27\x00\x27\x00\xff\xff\xff\xff\x3e\x00\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x20\x00\x2e\x00\xff\xff\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\x2d\x00\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\x7d\x00\x7d\x00\x27\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xd7\x00\xff\xff\xff\xff\xff\xff\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x22\x00\xf7\x00\xff\xff\xff\xff\x5f\x00\x27\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x0a\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x6e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x74\x00\xff\xff\xff\xff\x65\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\x5c\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\x27\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x0a\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\x5c\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\x27\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xff\xff\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\x27\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xff\xff\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xff\xff\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00"#
-
-alex_deflt :: AlexAddr
-alex_deflt = AlexA# "\x16\x00\xff\xff\x03\x00\x03\x00\xff\xff\xff\xff\x0b\x00\xff\xff\x0b\x00\x0b\x00\x0b\x00\x0b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x15\x00\x15\x00\xff\xff\xff\xff\xff\xff\xff\xff\x1b\x00\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#
-
-alex_accept = listArray (0::Int,34) [[],[],[(AlexAccSkip)],[(AlexAccSkip)],[],[(AlexAcc (alex_action_3))],[(AlexAccSkip)],[(AlexAccSkip)],[],[],[],[],[(AlexAcc (alex_action_3))],[(AlexAccSkip)],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_4))],[],[],[(AlexAcc (alex_action_5))],[(AlexAcc (alex_action_5))],[(AlexAcc (alex_action_5))],[(AlexAcc (alex_action_7))],[],[],[],[(AlexAcc (alex_action_8))],[(AlexAcc (alex_action_9))],[(AlexAcc (alex_action_9))],[],[],[]]
-{-# LINE 36 "GF/Source/LexGF.x" #-}
-
-tok f p s = f p s
-
-share :: String -> String
-share = id
-
-data Tok =
- TS !String -- reserved words and symbols
- | TL !String -- string literals
- | TI !String -- integer literals
- | TV !String -- identifiers
- | TD !String -- double precision float literals
- | TC !String -- character literals
- | T_LString !String
- | T_PIdent !String
-
- deriving (Eq,Show,Ord)
-
-data Token =
- PT Posn Tok
- | Err Posn
- deriving (Eq,Show,Ord)
-
-tokenPos (PT (Pn _ l _) _ :_) = "line " ++ show l
-tokenPos (Err (Pn _ l _) :_) = "line " ++ show l
-tokenPos _ = "end of file"
-
-posLineCol (Pn _ l c) = (l,c)
-mkPosToken t@(PT p _) = (posLineCol p, prToken t)
-
-prToken t = case t of
- PT _ (TS s) -> s
- PT _ (TI s) -> s
- PT _ (TV s) -> s
- PT _ (TD s) -> s
- PT _ (TC s) -> s
- PT _ (T_LString s) -> s
- PT _ (T_PIdent s) -> s
-
- _ -> show t
-
-data BTree = N | B String Tok BTree BTree deriving (Show)
-
-eitherResIdent :: (String -> Tok) -> String -> Tok
-eitherResIdent tv s = treeFind resWords
- where
- treeFind N = tv s
- treeFind (B a t left right) | s < a = treeFind left
- | s > a = treeFind right
- | s == a = t
-
-resWords = b "lincat" (b "def" (b "Type" (b "Str" (b "PType" (b "Lin" N N) N) (b "Tok" (b "Strs" N N) N)) (b "cat" (b "case" (b "abstract" N N) N) (b "data" (b "concrete" N N) N))) (b "include" (b "fun" (b "fn" (b "flags" N N) N) (b "in" (b "grammar" N N) N)) (b "interface" (b "instance" (b "incomplete" N N) N) (b "lin" (b "let" N N) N)))) (b "resource" (b "out" (b "of" (b "lintype" (b "lindef" N N) N) (b "oper" (b "open" N N) N)) (b "pattern" (b "param" (b "package" N N) N) (b "printname" (b "pre" N N) N))) (b "union" (b "table" (b "strs" (b "reuse" N N) N) (b "transfer" (b "tokenizer" N N) N)) (b "where" (b "variants" (b "var" N N) N) (b "with" N N))))
- where b s = B s (TS s)
-
-unescapeInitTail :: String -> String
-unescapeInitTail = unesc . tail where
- unesc s = case s of
- '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs
- '\\':'n':cs -> '\n' : unesc cs
- '\\':'t':cs -> '\t' : unesc cs
- '"':[] -> []
- c:cs -> c : unesc cs
- _ -> []
-
--------------------------------------------------------------------
--- Alex wrapper code.
--- A modified "posn" wrapper.
--------------------------------------------------------------------
-
-data Posn = Pn !Int !Int !Int
- deriving (Eq, Show,Ord)
-
-alexStartPos :: Posn
-alexStartPos = Pn 0 1 1
-
-alexMove :: Posn -> Char -> Posn
-alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1)
-alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1
-alexMove (Pn a l c) _ = Pn (a+1) l (c+1)
-
-type AlexInput = (Posn, -- current position,
- Char, -- previous char
- BS.ByteString) -- current input string
-
-tokens :: BS.ByteString -> [Token]
-tokens str = go (alexStartPos, '\n', str)
- where
- go :: AlexInput -> [Token]
- go inp@(pos, _, str) =
- case alexScan inp 0 of
- AlexEOF -> []
- AlexError (pos, _, _) -> [Err pos]
- AlexSkip inp' len -> go inp'
- AlexToken inp' len act -> act pos (BS.unpack (BS.take len str)) : (go inp')
-
-alexGetChar :: AlexInput -> Maybe (Char,AlexInput)
-alexGetChar (p,_,cs) | BS.null cs = Nothing
- | otherwise = let c = BS.head cs
- cs' = BS.tail cs
- p' = alexMove p c
- in p' `seq` cs' `seq` Just (c, (p', c, cs'))
-
-alexInputPrevChar :: AlexInput -> Char
-alexInputPrevChar (p, c, s) = c
-
-alex_action_3 = tok (\p s -> PT p (TS $ share s))
-alex_action_4 = tok (\p s -> PT p (eitherResIdent (T_LString . share) s))
-alex_action_5 = tok (\p s -> PT p (eitherResIdent (T_PIdent . share) s))
-alex_action_6 = tok (\p s -> PT p (eitherResIdent (TV . share) s))
-alex_action_7 = tok (\p s -> PT p (TL $ share $ unescapeInitTail s))
-alex_action_8 = tok (\p s -> PT p (TI $ share s))
-alex_action_9 = tok (\p s -> PT p (TD $ share s))
-{-# LINE 1 "GenericTemplate.hs" #-}
-{-# LINE 1 "" #-}
-{-# LINE 1 "" #-}
-{-# LINE 1 "GenericTemplate.hs" #-}
--- -----------------------------------------------------------------------------
--- ALEX TEMPLATE
---
--- This code is in the PUBLIC DOMAIN; you may copy it freely and use
--- it for any purpose whatsoever.
-
--- -----------------------------------------------------------------------------
--- INTERNALS and main scanner engine
-
-{-# LINE 35 "GenericTemplate.hs" #-}
-
-{-# LINE 45 "GenericTemplate.hs" #-}
-
-
-data AlexAddr = AlexA# Addr#
-
-#if __GLASGOW_HASKELL__ < 503
-uncheckedShiftL# = shiftL#
-#endif
-
-{-# INLINE alexIndexInt16OffAddr #-}
-alexIndexInt16OffAddr (AlexA# arr) off =
-#ifdef WORDS_BIGENDIAN
- narrow16Int# i
- where
- i = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)
- high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
- low = int2Word# (ord# (indexCharOffAddr# arr off'))
- off' = off *# 2#
-#else
- indexInt16OffAddr# arr off
-#endif
-
-
-
-
-
-{-# INLINE alexIndexInt32OffAddr #-}
-alexIndexInt32OffAddr (AlexA# arr) off =
-#ifdef WORDS_BIGENDIAN
- narrow32Int# i
- where
- i = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#`
- (b2 `uncheckedShiftL#` 16#) `or#`
- (b1 `uncheckedShiftL#` 8#) `or#` b0)
- b3 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#)))
- b2 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#)))
- b1 = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))
- b0 = int2Word# (ord# (indexCharOffAddr# arr off'))
- off' = off *# 4#
-#else
- indexInt32OffAddr# arr off
-#endif
-
-
-
-
-
-#if __GLASGOW_HASKELL__ < 503
-quickIndex arr i = arr ! i
-#else
--- GHC >= 503, unsafeAt is available from Data.Array.Base.
-quickIndex = unsafeAt
-#endif
-
-
-
-
--- -----------------------------------------------------------------------------
--- Main lexing routines
-
-data AlexReturn a
- = AlexEOF
- | AlexError !AlexInput
- | AlexSkip !AlexInput !Int
- | AlexToken !AlexInput !Int a
-
--- alexScan :: AlexInput -> StartCode -> AlexReturn a
-alexScan input (I# (sc))
- = alexScanUser undefined input (I# (sc))
-
-alexScanUser user input (I# (sc))
- = case alex_scan_tkn user input 0# input sc AlexNone of
- (AlexNone, input') ->
- case alexGetChar input of
- Nothing ->
-
-
-
- AlexEOF
- Just _ ->
-
-
-
- AlexError input'
-
- (AlexLastSkip input len, _) ->
-
-
-
- AlexSkip input len
-
- (AlexLastAcc k input len, _) ->
-
-
-
- AlexToken input len k
-
-
--- Push the input through the DFA, remembering the most recent accepting
--- state it encountered.
-
-alex_scan_tkn user orig_input len input s last_acc =
- input `seq` -- strict in the input
- let
- new_acc = check_accs (alex_accept `quickIndex` (I# (s)))
- in
- new_acc `seq`
- case alexGetChar input of
- Nothing -> (new_acc, input)
- Just (c, new_input) ->
-
-
-
- let
- base = alexIndexInt32OffAddr alex_base s
- (I# (ord_c)) = ord c
- offset = (base +# ord_c)
- check = alexIndexInt16OffAddr alex_check offset
-
- new_s = if (offset >=# 0#) && (check ==# ord_c)
- then alexIndexInt16OffAddr alex_table offset
- else alexIndexInt16OffAddr alex_deflt s
- in
- case new_s of
- -1# -> (new_acc, input)
- -- on an error, we want to keep the input *before* the
- -- character that failed, not after.
- _ -> alex_scan_tkn user orig_input (len +# 1#)
- new_input new_s new_acc
-
- where
- check_accs [] = last_acc
- check_accs (AlexAcc a : _) = AlexLastAcc a input (I# (len))
- check_accs (AlexAccSkip : _) = AlexLastSkip input (I# (len))
- check_accs (AlexAccPred a pred : rest)
- | pred user orig_input (I# (len)) input
- = AlexLastAcc a input (I# (len))
- check_accs (AlexAccSkipPred pred : rest)
- | pred user orig_input (I# (len)) input
- = AlexLastSkip input (I# (len))
- check_accs (_ : rest) = check_accs rest
-
-data AlexLastAcc a
- = AlexNone
- | AlexLastAcc a !AlexInput !Int
- | AlexLastSkip !AlexInput !Int
-
-data AlexAcc a user
- = AlexAcc a
- | AlexAccSkip
- | AlexAccPred a (AlexAccPred user)
- | AlexAccSkipPred (AlexAccPred user)
-
-type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool
-
--- -----------------------------------------------------------------------------
--- Predicates on a rule
-
-alexAndPred p1 p2 user in1 len in2
- = p1 user in1 len in2 && p2 user in1 len in2
-
---alexPrevCharIsPred :: Char -> AlexAccPred _
-alexPrevCharIs c _ input _ _ = c == alexInputPrevChar input
-
---alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _
-alexPrevCharIsOneOf arr _ input _ _ = arr ! alexInputPrevChar input
-
---alexRightContext :: Int -> AlexAccPred _
-alexRightContext (I# (sc)) user _ _ input =
- case alex_scan_tkn user input 0# input sc AlexNone of
- (AlexNone, _) -> False
- _ -> True
- -- TODO: there's no need to find the longest
- -- match when checking the right context, just
- -- the first match will do.
-
--- used by wrappers
-iUnbox (I# (i)) = i
diff --git a/src/GF/Source/LexGF.x b/src/GF/Source/LexGF.x
deleted file mode 100644
index 7ea768e75..000000000
--- a/src/GF/Source/LexGF.x
+++ /dev/null
@@ -1,137 +0,0 @@
--- -*- haskell -*-
--- This Alex file was machine-generated by the BNF converter
-{
-module LexGF where
-
-import ErrM
-import SharedString
-}
-
-
-$l = [a-zA-Z\192 - \255] # [\215 \247] -- isolatin1 letter FIXME
-$c = [A-Z\192-\221] # [\215] -- capital isolatin1 letter FIXME
-$s = [a-z\222-\255] # [\247] -- small isolatin1 letter FIXME
-$d = [0-9] -- digit
-$i = [$l $d _ '] -- identifier character
-$u = [\0-\255] -- universal: any character
-
-@rsyms = -- reserved words consisting of special symbols
- \; | \= | \{ | \} | \( | \) | \: | \- \> | \* \* | \, | \[ | \] | \- | \. | \| | \% | \? | \< | \> | \@ | \! | \* | \+ | \+ \+ | \\ | \= \> | \_ | \$ | \/
-
-:-
-"--" [.]* ; -- Toss single line comments
-"{-" ([$u # \-] | \- [$u # \}])* ("-")+ "}" ;
-
-$white+ ;
-@rsyms { tok (\p s -> PT p (TS $ share s)) }
-\' ($u # \')* \' { tok (\p s -> PT p (eitherResIdent (T_LString . share) s)) }
-
-$l $i* { tok (\p s -> PT p (eitherResIdent (TV . share) s)) }
-\" ([$u # [\" \\ \n]] | (\\ (\" | \\ | \' | n | t)))* \"{ tok (\p s -> PT p (TL $ share $ unescapeInitTail s)) }
-
-$d+ { tok (\p s -> PT p (TI $ share s)) }
-$d+ \. $d+ (e (\-)? $d+)? { tok (\p s -> PT p (TD $ share s)) }
-
-{
-
-tok f p s = f p s
-
-share :: String -> String
-share = shareString
-
-data Tok =
- TS !String -- reserved words
- | TL !String -- string literals
- | TI !String -- integer literals
- | TV !String -- identifiers
- | TD !String -- double precision float literals
- | TC !String -- character literals
- | T_LString !String
-
- deriving (Eq,Show,Ord)
-
-data Token =
- PT Posn Tok
- | Err Posn
- deriving (Eq,Show,Ord)
-
-tokenPos (PT (Pn _ l _) _ :_) = "line " ++ show l
-tokenPos (Err (Pn _ l _) :_) = "line " ++ show l
-tokenPos _ = "end of file"
-
-posLineCol (Pn _ l c) = (l,c)
-mkPosToken t@(PT p _) = (posLineCol p, prToken t)
-
-prToken t = case t of
- PT _ (TS s) -> s
- PT _ (TI s) -> s
- PT _ (TV s) -> s
- PT _ (TD s) -> s
- PT _ (TC s) -> s
- PT _ (T_LString s) -> s
-
- _ -> show t
-
-data BTree = N | B String Tok BTree BTree deriving (Show)
-
-eitherResIdent :: (String -> Tok) -> String -> Tok
-eitherResIdent tv s = treeFind resWords
- where
- treeFind N = tv s
- treeFind (B a t left right) | s < a = treeFind left
- | s > a = treeFind right
- | s == a = t
-
-resWords = b "lincat" (b "def" (b "Type" (b "Str" (b "PType" (b "Lin" N N) N) (b "Tok" (b "Strs" N N) N)) (b "cat" (b "case" (b "abstract" N N) N) (b "data" (b "concrete" N N) N))) (b "include" (b "fun" (b "fn" (b "flags" N N) N) (b "in" (b "grammar" N N) N)) (b "interface" (b "instance" (b "incomplete" N N) N) (b "lin" (b "let" N N) N)))) (b "resource" (b "out" (b "of" (b "lintype" (b "lindef" N N) N) (b "oper" (b "open" N N) N)) (b "pattern" (b "param" (b "package" N N) N) (b "printname" (b "pre" N N) N))) (b "union" (b "table" (b "strs" (b "reuse" N N) N) (b "transfer" (b "tokenizer" N N) N)) (b "where" (b "variants" (b "var" N N) N) (b "with" N N))))
- where b s = B s (TS s)
-
-unescapeInitTail :: String -> String
-unescapeInitTail = unesc . tail where
- unesc s = case s of
- '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs
- '\\':'n':cs -> '\n' : unesc cs
- '\\':'t':cs -> '\t' : unesc cs
- '"':[] -> []
- c:cs -> c : unesc cs
- _ -> []
-
--------------------------------------------------------------------
--- Alex wrapper code.
--- A modified "posn" wrapper.
--------------------------------------------------------------------
-
-data Posn = Pn !Int !Int !Int
- deriving (Eq, Show,Ord)
-
-alexStartPos :: Posn
-alexStartPos = Pn 0 1 1
-
-alexMove :: Posn -> Char -> Posn
-alexMove (Pn a l c) '\t' = Pn (a+1) l (((c+7) `div` 8)*8+1)
-alexMove (Pn a l c) '\n' = Pn (a+1) (l+1) 1
-alexMove (Pn a l c) _ = Pn (a+1) l (c+1)
-
-type AlexInput = (Posn, -- current position,
- Char, -- previous char
- String) -- current input string
-
-tokens :: String -> [Token]
-tokens str = go (alexStartPos, '\n', str)
- where
- go :: (Posn, Char, String) -> [Token]
- go inp@(pos, _, str) =
- case alexScan inp 0 of
- AlexEOF -> []
- AlexError (pos, _, _) -> fail $ show pos ++ ": lexical error"
- AlexSkip inp' len -> go inp'
- AlexToken inp' len act -> act pos (take len str) : (go inp')
-
-alexGetChar :: AlexInput -> Maybe (Char,AlexInput)
-alexGetChar (p, c, []) = Nothing
-alexGetChar (p, _, (c:s)) =
- let p' = alexMove p c
- in p' `seq` Just (c, (p', c, s))
-
-alexInputPrevChar :: AlexInput -> Char
-alexInputPrevChar (p, c, s) = c
-}
diff --git a/src/GF/Source/ParGF.hs b/src/GF/Source/ParGF.hs
deleted file mode 100644
index 30f83eef6..000000000
--- a/src/GF/Source/ParGF.hs
+++ /dev/null
@@ -1,7845 +0,0 @@
-{-# OPTIONS -fglasgow-exts -cpp #-}
-{-# OPTIONS -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}
- module GF.Source.ParGF (pGrammar, pModDef, pOldGrammar, pExp, pModHeader, myLexer) where --H
-import GF.Source.AbsGF --H
-import GF.Source.LexGF --H
-import GF.Infra.Ident --H
-import GF.Data.ErrM --H
-#if __GLASGOW_HASKELL__ >= 503
-import GHC.Exts
-#else
-import GlaExts
-#endif
-
--- parser produced by Happy Version 1.17
-
-data HappyAbsSyn
- = HappyTerminal Token
- | HappyErrorToken Int
- | HappyAbsSyn8 (Integer)
- | HappyAbsSyn9 (String)
- | HappyAbsSyn10 (Double)
- | HappyAbsSyn11 (LString)
- | HappyAbsSyn12 (PIdent)
- | HappyAbsSyn13 (Grammar)
- | HappyAbsSyn14 ([ModDef])
- | HappyAbsSyn15 (ModDef)
- | HappyAbsSyn16 (ConcSpec)
- | HappyAbsSyn17 ([ConcSpec])
- | HappyAbsSyn18 (ConcExp)
- | HappyAbsSyn19 ([Transfer])
- | HappyAbsSyn20 (Transfer)
- | HappyAbsSyn22 (ModBody)
- | HappyAbsSyn23 (ModType)
- | HappyAbsSyn25 ([TopDef])
- | HappyAbsSyn26 (Extend)
- | HappyAbsSyn27 ([Open])
- | HappyAbsSyn28 (Opens)
- | HappyAbsSyn29 (Open)
- | HappyAbsSyn30 (ComplMod)
- | HappyAbsSyn31 (QualOpen)
- | HappyAbsSyn32 ([Included])
- | HappyAbsSyn33 (Included)
- | HappyAbsSyn34 (Def)
- | HappyAbsSyn35 (TopDef)
- | HappyAbsSyn36 (CatDef)
- | HappyAbsSyn37 (FunDef)
- | HappyAbsSyn38 (DataDef)
- | HappyAbsSyn39 (DataConstr)
- | HappyAbsSyn40 ([DataConstr])
- | HappyAbsSyn41 (ParDef)
- | HappyAbsSyn42 (ParConstr)
- | HappyAbsSyn43 (PrintDef)
- | HappyAbsSyn44 (FlagDef)
- | HappyAbsSyn45 ([Def])
- | HappyAbsSyn46 ([CatDef])
- | HappyAbsSyn47 ([FunDef])
- | HappyAbsSyn48 ([DataDef])
- | HappyAbsSyn49 ([ParDef])
- | HappyAbsSyn50 ([PrintDef])
- | HappyAbsSyn51 ([FlagDef])
- | HappyAbsSyn52 ([ParConstr])
- | HappyAbsSyn53 ([PIdent])
- | HappyAbsSyn54 (Name)
- | HappyAbsSyn55 ([Name])
- | HappyAbsSyn56 (LocDef)
- | HappyAbsSyn57 ([LocDef])
- | HappyAbsSyn58 (Exp)
- | HappyAbsSyn65 ([Exp])
- | HappyAbsSyn66 (Exps)
- | HappyAbsSyn67 (Patt)
- | HappyAbsSyn70 (PattAss)
- | HappyAbsSyn71 (Label)
- | HappyAbsSyn72 (Sort)
- | HappyAbsSyn73 ([PattAss])
- | HappyAbsSyn74 ([Patt])
- | HappyAbsSyn75 (Bind)
- | HappyAbsSyn76 ([Bind])
- | HappyAbsSyn77 (Decl)
- | HappyAbsSyn78 (TupleComp)
- | HappyAbsSyn79 (PattTupleComp)
- | HappyAbsSyn80 ([TupleComp])
- | HappyAbsSyn81 ([PattTupleComp])
- | HappyAbsSyn82 (Case)
- | HappyAbsSyn83 ([Case])
- | HappyAbsSyn84 (Equation)
- | HappyAbsSyn85 ([Equation])
- | HappyAbsSyn86 (Altern)
- | HappyAbsSyn87 ([Altern])
- | HappyAbsSyn88 (DDecl)
- | HappyAbsSyn89 ([DDecl])
- | HappyAbsSyn90 (OldGrammar)
- | HappyAbsSyn91 (Include)
- | HappyAbsSyn92 (FileName)
- | HappyAbsSyn93 ([FileName])
-
-type HappyReduction m =
- Int#
- -> (Token)
- -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)
- -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)]
- -> HappyStk HappyAbsSyn
- -> [(Token)] -> m HappyAbsSyn
-
-action_0,
- action_1,
- action_2,
- action_3,
- action_4,
- action_5,
- action_6,
- action_7,
- action_8,
- action_9,
- action_10,
- action_11,
- action_12,
- action_13,
- action_14,
- action_15,
- action_16,
- action_17,
- action_18,
- action_19,
- action_20,
- action_21,
- action_22,
- action_23,
- action_24,
- action_25,
- action_26,
- action_27,
- action_28,
- action_29,
- action_30,
- action_31,
- action_32,
- action_33,
- action_34,
- action_35,
- action_36,
- action_37,
- action_38,
- action_39,
- action_40,
- action_41,
- action_42,
- action_43,
- action_44,
- action_45,
- action_46,
- action_47,
- action_48,
- action_49,
- action_50,
- action_51,
- action_52,
- action_53,
- action_54,
- action_55,
- action_56,
- action_57,
- action_58,
- action_59,
- action_60,
- action_61,
- action_62,
- action_63,
- action_64,
- action_65,
- action_66,
- action_67,
- action_68,
- action_69,
- action_70,
- action_71,
- action_72,
- action_73,
- action_74,
- action_75,
- action_76,
- action_77,
- action_78,
- action_79,
- action_80,
- action_81,
- action_82,
- action_83,
- action_84,
- action_85,
- action_86,
- action_87,
- action_88,
- action_89,
- action_90,
- action_91,
- action_92,
- action_93,
- action_94,
- action_95,
- action_96,
- action_97,
- action_98,
- action_99,
- action_100,
- action_101,
- action_102,
- action_103,
- action_104,
- action_105,
- action_106,
- action_107,
- action_108,
- action_109,
- action_110,
- action_111,
- action_112,
- action_113,
- action_114,
- action_115,
- action_116,
- action_117,
- action_118,
- action_119,
- action_120,
- action_121,
- action_122,
- action_123,
- action_124,
- action_125,
- action_126,
- action_127,
- action_128,
- action_129,
- action_130,
- action_131,
- action_132,
- action_133,
- action_134,
- action_135,
- action_136,
- action_137,
- action_138,
- action_139,
- action_140,
- action_141,
- action_142,
- action_143,
- action_144,
- action_145,
- action_146,
- action_147,
- action_148,
- action_149,
- action_150,
- action_151,
- action_152,
- action_153,
- action_154,
- action_155,
- action_156,
- action_157,
- action_158,
- action_159,
- action_160,
- action_161,
- action_162,
- action_163,
- action_164,
- action_165,
- action_166,
- action_167,
- action_168,
- action_169,
- action_170,
- action_171,
- action_172,
- action_173,
- action_174,
- action_175,
- action_176,
- action_177,
- action_178,
- action_179,
- action_180,
- action_181,
- action_182,
- action_183,
- action_184,
- action_185,
- action_186,
- action_187,
- action_188,
- action_189,
- action_190,
- action_191,
- action_192,
- action_193,
- action_194,
- action_195,
- action_196,
- action_197,
- action_198,
- action_199,
- action_200,
- action_201,
- action_202,
- action_203,
- action_204,
- action_205,
- action_206,
- action_207,
- action_208,
- action_209,
- action_210,
- action_211,
- action_212,
- action_213,
- action_214,
- action_215,
- action_216,
- action_217,
- action_218,
- action_219,
- action_220,
- action_221,
- action_222,
- action_223,
- action_224,
- action_225,
- action_226,
- action_227,
- action_228,
- action_229,
- action_230,
- action_231,
- action_232,
- action_233,
- action_234,
- action_235,
- action_236,
- action_237,
- action_238,
- action_239,
- action_240,
- action_241,
- action_242,
- action_243,
- action_244,
- action_245,
- action_246,
- action_247,
- action_248,
- action_249,
- action_250,
- action_251,
- action_252,
- action_253,
- action_254,
- action_255,
- action_256,
- action_257,
- action_258,
- action_259,
- action_260,
- action_261,
- action_262,
- action_263,
- action_264,
- action_265,
- action_266,
- action_267,
- action_268,
- action_269,
- action_270,
- action_271,
- action_272,
- action_273,
- action_274,
- action_275,
- action_276,
- action_277,
- action_278,
- action_279,
- action_280,
- action_281,
- action_282,
- action_283,
- action_284,
- action_285,
- action_286,
- action_287,
- action_288,
- action_289,
- action_290,
- action_291,
- action_292,
- action_293,
- action_294,
- action_295,
- action_296,
- action_297,
- action_298,
- action_299,
- action_300,
- action_301,
- action_302,
- action_303,
- action_304,
- action_305,
- action_306,
- action_307,
- action_308,
- action_309,
- action_310,
- action_311,
- action_312,
- action_313,
- action_314,
- action_315,
- action_316,
- action_317,
- action_318,
- action_319,
- action_320,
- action_321,
- action_322,
- action_323,
- action_324,
- action_325,
- action_326,
- action_327,
- action_328,
- action_329,
- action_330,
- action_331,
- action_332,
- action_333,
- action_334,
- action_335,
- action_336,
- action_337,
- action_338,
- action_339,
- action_340,
- action_341,
- action_342,
- action_343,
- action_344,
- action_345,
- action_346,
- action_347,
- action_348,
- action_349,
- action_350,
- action_351,
- action_352,
- action_353,
- action_354,
- action_355,
- action_356,
- action_357,
- action_358,
- action_359,
- action_360,
- action_361,
- action_362,
- action_363,
- action_364,
- action_365,
- action_366,
- action_367,
- action_368,
- action_369,
- action_370,
- action_371,
- action_372,
- action_373,
- action_374,
- action_375,
- action_376,
- action_377,
- action_378,
- action_379,
- action_380,
- action_381,
- action_382,
- action_383,
- action_384,
- action_385,
- action_386,
- action_387,
- action_388,
- action_389,
- action_390,
- action_391,
- action_392,
- action_393,
- action_394,
- action_395,
- action_396,
- action_397,
- action_398,
- action_399,
- action_400,
- action_401,
- action_402,
- action_403,
- action_404,
- action_405,
- action_406,
- action_407,
- action_408,
- action_409,
- action_410,
- action_411,
- action_412,
- action_413,
- action_414,
- action_415,
- action_416,
- action_417,
- action_418,
- action_419,
- action_420,
- action_421,
- action_422,
- action_423,
- action_424,
- action_425,
- action_426,
- action_427,
- action_428,
- action_429,
- action_430,
- action_431,
- action_432,
- action_433,
- action_434,
- action_435,
- action_436,
- action_437,
- action_438,
- action_439,
- action_440,
- action_441,
- action_442,
- action_443,
- action_444,
- action_445,
- action_446,
- action_447,
- action_448,
- action_449,
- action_450,
- action_451,
- action_452,
- action_453,
- action_454,
- action_455,
- action_456,
- action_457,
- action_458,
- action_459,
- action_460,
- action_461,
- action_462,
- action_463,
- action_464,
- action_465,
- action_466,
- action_467,
- action_468,
- action_469,
- action_470,
- action_471,
- action_472,
- action_473,
- action_474,
- action_475,
- action_476,
- action_477,
- action_478,
- action_479,
- action_480,
- action_481,
- action_482,
- action_483,
- action_484,
- action_485,
- action_486,
- action_487,
- action_488,
- action_489,
- action_490,
- action_491,
- action_492,
- action_493,
- action_494,
- action_495,
- action_496,
- action_497,
- action_498,
- action_499,
- action_500,
- action_501,
- action_502,
- action_503,
- action_504,
- action_505,
- action_506,
- action_507,
- action_508,
- action_509,
- action_510,
- action_511,
- action_512,
- action_513,
- action_514,
- action_515,
- action_516,
- action_517,
- action_518,
- action_519,
- action_520,
- action_521,
- action_522,
- action_523,
- action_524,
- action_525,
- action_526,
- action_527,
- action_528,
- action_529,
- action_530,
- action_531,
- action_532,
- action_533,
- action_534,
- action_535,
- action_536,
- action_537,
- action_538,
- action_539,
- action_540,
- action_541,
- action_542,
- action_543,
- action_544,
- action_545,
- action_546,
- action_547 :: () => Int# -> HappyReduction (Err)
-
-happyReduce_5,
- happyReduce_6,
- happyReduce_7,
- happyReduce_8,
- happyReduce_9,
- happyReduce_10,
- happyReduce_11,
- happyReduce_12,
- happyReduce_13,
- happyReduce_14,
- happyReduce_15,
- happyReduce_16,
- happyReduce_17,
- happyReduce_18,
- happyReduce_19,
- happyReduce_20,
- happyReduce_21,
- happyReduce_22,
- happyReduce_23,
- happyReduce_24,
- happyReduce_25,
- happyReduce_26,
- happyReduce_27,
- happyReduce_28,
- happyReduce_29,
- happyReduce_30,
- happyReduce_31,
- happyReduce_32,
- happyReduce_33,
- happyReduce_34,
- happyReduce_35,
- happyReduce_36,
- happyReduce_37,
- happyReduce_38,
- happyReduce_39,
- happyReduce_40,
- happyReduce_41,
- happyReduce_42,
- happyReduce_43,
- happyReduce_44,
- happyReduce_45,
- happyReduce_46,
- happyReduce_47,
- happyReduce_48,
- happyReduce_49,
- happyReduce_50,
- happyReduce_51,
- happyReduce_52,
- happyReduce_53,
- happyReduce_54,
- happyReduce_55,
- happyReduce_56,
- happyReduce_57,
- happyReduce_58,
- happyReduce_59,
- happyReduce_60,
- happyReduce_61,
- happyReduce_62,
- happyReduce_63,
- happyReduce_64,
- happyReduce_65,
- happyReduce_66,
- happyReduce_67,
- happyReduce_68,
- happyReduce_69,
- happyReduce_70,
- happyReduce_71,
- happyReduce_72,
- happyReduce_73,
- happyReduce_74,
- happyReduce_75,
- happyReduce_76,
- happyReduce_77,
- happyReduce_78,
- happyReduce_79,
- happyReduce_80,
- happyReduce_81,
- happyReduce_82,
- happyReduce_83,
- happyReduce_84,
- happyReduce_85,
- happyReduce_86,
- happyReduce_87,
- happyReduce_88,
- happyReduce_89,
- happyReduce_90,
- happyReduce_91,
- happyReduce_92,
- happyReduce_93,
- happyReduce_94,
- happyReduce_95,
- happyReduce_96,
- happyReduce_97,
- happyReduce_98,
- happyReduce_99,
- happyReduce_100,
- happyReduce_101,
- happyReduce_102,
- happyReduce_103,
- happyReduce_104,
- happyReduce_105,
- happyReduce_106,
- happyReduce_107,
- happyReduce_108,
- happyReduce_109,
- happyReduce_110,
- happyReduce_111,
- happyReduce_112,
- happyReduce_113,
- happyReduce_114,
- happyReduce_115,
- happyReduce_116,
- happyReduce_117,
- happyReduce_118,
- happyReduce_119,
- happyReduce_120,
- happyReduce_121,
- happyReduce_122,
- happyReduce_123,
- happyReduce_124,
- happyReduce_125,
- happyReduce_126,
- happyReduce_127,
- happyReduce_128,
- happyReduce_129,
- happyReduce_130,
- happyReduce_131,
- happyReduce_132,
- happyReduce_133,
- happyReduce_134,
- happyReduce_135,
- happyReduce_136,
- happyReduce_137,
- happyReduce_138,
- happyReduce_139,
- happyReduce_140,
- happyReduce_141,
- happyReduce_142,
- happyReduce_143,
- happyReduce_144,
- happyReduce_145,
- happyReduce_146,
- happyReduce_147,
- happyReduce_148,
- happyReduce_149,
- happyReduce_150,
- happyReduce_151,
- happyReduce_152,
- happyReduce_153,
- happyReduce_154,
- happyReduce_155,
- happyReduce_156,
- happyReduce_157,
- happyReduce_158,
- happyReduce_159,
- happyReduce_160,
- happyReduce_161,
- happyReduce_162,
- happyReduce_163,
- happyReduce_164,
- happyReduce_165,
- happyReduce_166,
- happyReduce_167,
- happyReduce_168,
- happyReduce_169,
- happyReduce_170,
- happyReduce_171,
- happyReduce_172,
- happyReduce_173,
- happyReduce_174,
- happyReduce_175,
- happyReduce_176,
- happyReduce_177,
- happyReduce_178,
- happyReduce_179,
- happyReduce_180,
- happyReduce_181,
- happyReduce_182,
- happyReduce_183,
- happyReduce_184,
- happyReduce_185,
- happyReduce_186,
- happyReduce_187,
- happyReduce_188,
- happyReduce_189,
- happyReduce_190,
- happyReduce_191,
- happyReduce_192,
- happyReduce_193,
- happyReduce_194,
- happyReduce_195,
- happyReduce_196,
- happyReduce_197,
- happyReduce_198,
- happyReduce_199,
- happyReduce_200,
- happyReduce_201,
- happyReduce_202,
- happyReduce_203,
- happyReduce_204,
- happyReduce_205,
- happyReduce_206,
- happyReduce_207,
- happyReduce_208,
- happyReduce_209,
- happyReduce_210,
- happyReduce_211,
- happyReduce_212,
- happyReduce_213,
- happyReduce_214,
- happyReduce_215,
- happyReduce_216,
- happyReduce_217,
- happyReduce_218,
- happyReduce_219,
- happyReduce_220,
- happyReduce_221,
- happyReduce_222,
- happyReduce_223,
- happyReduce_224,
- happyReduce_225,
- happyReduce_226,
- happyReduce_227,
- happyReduce_228,
- happyReduce_229,
- happyReduce_230,
- happyReduce_231,
- happyReduce_232,
- happyReduce_233,
- happyReduce_234,
- happyReduce_235,
- happyReduce_236,
- happyReduce_237,
- happyReduce_238,
- happyReduce_239,
- happyReduce_240,
- happyReduce_241,
- happyReduce_242,
- happyReduce_243,
- happyReduce_244,
- happyReduce_245,
- happyReduce_246,
- happyReduce_247,
- happyReduce_248,
- happyReduce_249,
- happyReduce_250,
- happyReduce_251,
- happyReduce_252,
- happyReduce_253,
- happyReduce_254,
- happyReduce_255,
- happyReduce_256,
- happyReduce_257,
- happyReduce_258,
- happyReduce_259,
- happyReduce_260,
- happyReduce_261,
- happyReduce_262,
- happyReduce_263,
- happyReduce_264,
- happyReduce_265,
- happyReduce_266,
- happyReduce_267,
- happyReduce_268,
- happyReduce_269,
- happyReduce_270,
- happyReduce_271,
- happyReduce_272,
- happyReduce_273,
- happyReduce_274 :: () => HappyReduction (Err)
-
-action_0 (13#) = happyGoto action_58
-action_0 (14#) = happyGoto action_59
-action_0 x = happyTcHack x happyReduce_11
-
-action_1 (139#) = happyShift action_57
-action_1 (142#) = happyShift action_9
-action_1 (15#) = happyGoto action_55
-action_1 (30#) = happyGoto action_56
-action_1 x = happyTcHack x happyReduce_60
-
-action_2 (141#) = happyShift action_54
-action_2 (90#) = happyGoto action_52
-action_2 (91#) = happyGoto action_53
-action_2 x = happyTcHack x happyReduce_265
-
-action_3 (96#) = happyShift action_24
-action_3 (98#) = happyShift action_25
-action_3 (104#) = happyShift action_26
-action_3 (109#) = happyShift action_27
-action_3 (110#) = happyShift action_28
-action_3 (111#) = happyShift action_29
-action_3 (114#) = happyShift action_30
-action_3 (119#) = happyShift action_31
-action_3 (124#) = happyShift action_32
-action_3 (125#) = happyShift action_33
-action_3 (126#) = happyShift action_34
-action_3 (127#) = happyShift action_35
-action_3 (128#) = happyShift action_36
-action_3 (129#) = happyShift action_37
-action_3 (131#) = happyShift action_38
-action_3 (134#) = happyShift action_39
-action_3 (137#) = happyShift action_40
-action_3 (140#) = happyShift action_41
-action_3 (145#) = happyShift action_42
-action_3 (156#) = happyShift action_43
-action_3 (157#) = happyShift action_44
-action_3 (161#) = happyShift action_45
-action_3 (162#) = happyShift action_46
-action_3 (167#) = happyShift action_47
-action_3 (170#) = happyShift action_6
-action_3 (171#) = happyShift action_48
-action_3 (172#) = happyShift action_49
-action_3 (173#) = happyShift action_50
-action_3 (174#) = happyShift action_51
-action_3 (8#) = happyGoto action_10
-action_3 (9#) = happyGoto action_11
-action_3 (10#) = happyGoto action_12
-action_3 (11#) = happyGoto action_13
-action_3 (12#) = happyGoto action_14
-action_3 (58#) = happyGoto action_15
-action_3 (59#) = happyGoto action_16
-action_3 (60#) = happyGoto action_17
-action_3 (61#) = happyGoto action_18
-action_3 (62#) = happyGoto action_19
-action_3 (63#) = happyGoto action_20
-action_3 (64#) = happyGoto action_21
-action_3 (72#) = happyGoto action_22
-action_3 (77#) = happyGoto action_23
-action_3 x = happyTcHack x happyFail
-
-action_4 (142#) = happyShift action_9
-action_4 (21#) = happyGoto action_7
-action_4 (30#) = happyGoto action_8
-action_4 x = happyTcHack x happyReduce_60
-
-action_5 (170#) = happyShift action_6
-action_5 x = happyTcHack x happyFail
-
-action_6 x = happyTcHack x happyReduce_5
-
-action_7 (1#) = happyAccept
-action_7 x = happyTcHack x happyFail
-
-action_8 (130#) = happyShift action_63
-action_8 (133#) = happyShift action_64
-action_8 (143#) = happyShift action_65
-action_8 (144#) = happyShift action_66
-action_8 (159#) = happyShift action_67
-action_8 (164#) = happyShift action_68
-action_8 (23#) = happyGoto action_137
-action_8 x = happyTcHack x happyFail
-
-action_9 x = happyTcHack x happyReduce_61
-
-action_10 x = happyTcHack x happyReduce_145
-
-action_11 x = happyTcHack x happyReduce_144
-
-action_12 x = happyTcHack x happyReduce_146
-
-action_13 x = happyTcHack x happyReduce_157
-
-action_14 (113#) = happyShift action_136
-action_14 x = happyTcHack x happyReduce_140
-
-action_15 x = happyTcHack x happyReduce_161
-
-action_16 (107#) = happyShift action_135
-action_16 x = happyTcHack x happyReduce_173
-
-action_17 (96#) = happyShift action_24
-action_17 (98#) = happyShift action_82
-action_17 (101#) = happyReduce_240
-action_17 (104#) = happyShift action_26
-action_17 (109#) = happyShift action_27
-action_17 (110#) = happyShift action_28
-action_17 (111#) = happyShift action_29
-action_17 (125#) = happyShift action_33
-action_17 (126#) = happyShift action_34
-action_17 (127#) = happyShift action_35
-action_17 (128#) = happyShift action_36
-action_17 (129#) = happyShift action_37
-action_17 (134#) = happyShift action_39
-action_17 (170#) = happyShift action_6
-action_17 (171#) = happyShift action_48
-action_17 (172#) = happyShift action_49
-action_17 (173#) = happyShift action_50
-action_17 (174#) = happyShift action_51
-action_17 (8#) = happyGoto action_10
-action_17 (9#) = happyGoto action_11
-action_17 (10#) = happyGoto action_12
-action_17 (11#) = happyGoto action_13
-action_17 (12#) = happyGoto action_79
-action_17 (58#) = happyGoto action_15
-action_17 (59#) = happyGoto action_134
-action_17 (72#) = happyGoto action_22
-action_17 x = happyTcHack x happyReduce_178
-
-action_18 (102#) = happyShift action_129
-action_18 (115#) = happyShift action_130
-action_18 (116#) = happyShift action_131
-action_18 (120#) = happyShift action_132
-action_18 (168#) = happyShift action_133
-action_18 x = happyTcHack x happyReduce_192
-
-action_19 (118#) = happyShift action_128
-action_19 x = happyTcHack x happyReduce_191
-
-action_20 (176#) = happyAccept
-action_20 x = happyTcHack x happyFail
-
-action_21 (117#) = happyShift action_127
-action_21 x = happyTcHack x happyReduce_180
-
-action_22 x = happyTcHack x happyReduce_143
-
-action_23 (101#) = happyShift action_126
-action_23 x = happyTcHack x happyFail
-
-action_24 (174#) = happyShift action_51
-action_24 (12#) = happyGoto action_124
-action_24 (53#) = happyGoto action_88
-action_24 (56#) = happyGoto action_89
-action_24 (57#) = happyGoto action_125
-action_24 x = happyTcHack x happyReduce_137
-
-action_25 (96#) = happyShift action_24
-action_25 (98#) = happyShift action_25
-action_25 (104#) = happyShift action_26
-action_25 (109#) = happyShift action_27
-action_25 (110#) = happyShift action_28
-action_25 (111#) = happyShift action_29
-action_25 (114#) = happyShift action_30
-action_25 (119#) = happyShift action_31
-action_25 (121#) = happyShift action_100
-action_25 (124#) = happyShift action_32
-action_25 (125#) = happyShift action_33
-action_25 (126#) = happyShift action_34
-action_25 (127#) = happyShift action_35
-action_25 (128#) = happyShift action_36
-action_25 (129#) = happyShift action_37
-action_25 (131#) = happyShift action_38
-action_25 (134#) = happyShift action_39
-action_25 (137#) = happyShift action_40
-action_25 (140#) = happyShift action_123
-action_25 (145#) = happyShift action_42
-action_25 (156#) = happyShift action_43
-action_25 (157#) = happyShift action_44
-action_25 (161#) = happyShift action_45
-action_25 (162#) = happyShift action_46
-action_25 (167#) = happyShift action_47
-action_25 (170#) = happyShift action_6
-action_25 (171#) = happyShift action_48
-action_25 (172#) = happyShift action_49
-action_25 (173#) = happyShift action_50
-action_25 (174#) = happyShift action_51
-action_25 (8#) = happyGoto action_10
-action_25 (9#) = happyGoto action_11
-action_25 (10#) = happyGoto action_12
-action_25 (11#) = happyGoto action_13
-action_25 (12#) = happyGoto action_120
-action_25 (58#) = happyGoto action_15
-action_25 (59#) = happyGoto action_16
-action_25 (60#) = happyGoto action_17
-action_25 (61#) = happyGoto action_18
-action_25 (62#) = happyGoto action_19
-action_25 (63#) = happyGoto action_121
-action_25 (64#) = happyGoto action_21
-action_25 (72#) = happyGoto action_22
-action_25 (75#) = happyGoto action_97
-action_25 (76#) = happyGoto action_122
-action_25 (77#) = happyGoto action_23
-action_25 x = happyTcHack x happyReduce_236
-
-action_26 (105#) = happyShift action_119
-action_26 (171#) = happyShift action_48
-action_26 (174#) = happyShift action_51
-action_26 (9#) = happyGoto action_117
-action_26 (12#) = happyGoto action_118
-action_26 x = happyTcHack x happyFail
-
-action_27 (174#) = happyShift action_51
-action_27 (12#) = happyGoto action_116
-action_27 x = happyTcHack x happyFail
-
-action_28 x = happyTcHack x happyReduce_147
-
-action_29 (96#) = happyShift action_24
-action_29 (98#) = happyShift action_25
-action_29 (104#) = happyShift action_26
-action_29 (109#) = happyShift action_27
-action_29 (110#) = happyShift action_28
-action_29 (111#) = happyShift action_29
-action_29 (114#) = happyShift action_30
-action_29 (119#) = happyShift action_31
-action_29 (124#) = happyShift action_32
-action_29 (125#) = happyShift action_33
-action_29 (126#) = happyShift action_34
-action_29 (127#) = happyShift action_35
-action_29 (128#) = happyShift action_36
-action_29 (129#) = happyShift action_37
-action_29 (131#) = happyShift action_38
-action_29 (134#) = happyShift action_39
-action_29 (137#) = happyShift action_40
-action_29 (140#) = happyShift action_41
-action_29 (145#) = happyShift action_42
-action_29 (156#) = happyShift action_43
-action_29 (157#) = happyShift action_44
-action_29 (161#) = happyShift action_45
-action_29 (162#) = happyShift action_46
-action_29 (167#) = happyShift action_47
-action_29 (170#) = happyShift action_6
-action_29 (171#) = happyShift action_48
-action_29 (172#) = happyShift action_49
-action_29 (173#) = happyShift action_50
-action_29 (174#) = happyShift action_51
-action_29 (8#) = happyGoto action_10
-action_29 (9#) = happyGoto action_11
-action_29 (10#) = happyGoto action_12
-action_29 (11#) = happyGoto action_13
-action_29 (12#) = happyGoto action_14
-action_29 (58#) = happyGoto action_15
-action_29 (59#) = happyGoto action_16
-action_29 (60#) = happyGoto action_17
-action_29 (61#) = happyGoto action_18
-action_29 (62#) = happyGoto action_19
-action_29 (63#) = happyGoto action_113
-action_29 (64#) = happyGoto action_21
-action_29 (72#) = happyGoto action_22
-action_29 (77#) = happyGoto action_23
-action_29 (78#) = happyGoto action_114
-action_29 (80#) = happyGoto action_115
-action_29 x = happyTcHack x happyReduce_243
-
-action_30 (96#) = happyShift action_106
-action_30 (98#) = happyShift action_107
-action_30 (104#) = happyShift action_108
-action_30 (110#) = happyShift action_109
-action_30 (111#) = happyShift action_110
-action_30 (114#) = happyShift action_111
-action_30 (121#) = happyShift action_112
-action_30 (170#) = happyShift action_6
-action_30 (171#) = happyShift action_48
-action_30 (172#) = happyShift action_49
-action_30 (174#) = happyShift action_51
-action_30 (8#) = happyGoto action_101
-action_30 (9#) = happyGoto action_102
-action_30 (10#) = happyGoto action_103
-action_30 (12#) = happyGoto action_104
-action_30 (67#) = happyGoto action_105
-action_30 x = happyTcHack x happyFail
-
-action_31 (119#) = happyShift action_99
-action_31 (121#) = happyShift action_100
-action_31 (174#) = happyShift action_51
-action_31 (12#) = happyGoto action_96
-action_31 (75#) = happyGoto action_97
-action_31 (76#) = happyGoto action_98
-action_31 x = happyTcHack x happyReduce_236
-
-action_32 (174#) = happyShift action_51
-action_32 (12#) = happyGoto action_95
-action_32 x = happyTcHack x happyFail
-
-action_33 x = happyTcHack x happyReduce_225
-
-action_34 x = happyTcHack x happyReduce_227
-
-action_35 x = happyTcHack x happyReduce_228
-
-action_36 x = happyTcHack x happyReduce_226
-
-action_37 x = happyTcHack x happyReduce_224
-
-action_38 (96#) = happyShift action_24
-action_38 (98#) = happyShift action_25
-action_38 (104#) = happyShift action_26
-action_38 (109#) = happyShift action_27
-action_38 (110#) = happyShift action_28
-action_38 (111#) = happyShift action_29
-action_38 (114#) = happyShift action_30
-action_38 (119#) = happyShift action_31
-action_38 (124#) = happyShift action_32
-action_38 (125#) = happyShift action_33
-action_38 (126#) = happyShift action_34
-action_38 (127#) = happyShift action_35
-action_38 (128#) = happyShift action_36
-action_38 (129#) = happyShift action_37
-action_38 (131#) = happyShift action_38
-action_38 (134#) = happyShift action_39
-action_38 (137#) = happyShift action_40
-action_38 (140#) = happyShift action_41
-action_38 (145#) = happyShift action_42
-action_38 (156#) = happyShift action_43
-action_38 (157#) = happyShift action_44
-action_38 (161#) = happyShift action_45
-action_38 (162#) = happyShift action_46
-action_38 (167#) = happyShift action_47
-action_38 (170#) = happyShift action_6
-action_38 (171#) = happyShift action_48
-action_38 (172#) = happyShift action_49
-action_38 (173#) = happyShift action_50
-action_38 (174#) = happyShift action_51
-action_38 (8#) = happyGoto action_10
-action_38 (9#) = happyGoto action_11
-action_38 (10#) = happyGoto action_12
-action_38 (11#) = happyGoto action_13
-action_38 (12#) = happyGoto action_14
-action_38 (58#) = happyGoto action_15
-action_38 (59#) = happyGoto action_16
-action_38 (60#) = happyGoto action_17
-action_38 (61#) = happyGoto action_18
-action_38 (62#) = happyGoto action_19
-action_38 (63#) = happyGoto action_94
-action_38 (64#) = happyGoto action_21
-action_38 (72#) = happyGoto action_22
-action_38 (77#) = happyGoto action_23
-action_38 x = happyTcHack x happyFail
-
-action_39 x = happyTcHack x happyReduce_149
-
-action_40 (96#) = happyShift action_93
-action_40 x = happyTcHack x happyFail
-
-action_41 (96#) = happyShift action_24
-action_41 (98#) = happyShift action_82
-action_41 (104#) = happyShift action_26
-action_41 (109#) = happyShift action_27
-action_41 (110#) = happyShift action_28
-action_41 (111#) = happyShift action_29
-action_41 (125#) = happyShift action_33
-action_41 (126#) = happyShift action_34
-action_41 (127#) = happyShift action_35
-action_41 (128#) = happyShift action_36
-action_41 (129#) = happyShift action_37
-action_41 (134#) = happyShift action_39
-action_41 (170#) = happyShift action_6
-action_41 (171#) = happyShift action_48
-action_41 (172#) = happyShift action_49
-action_41 (173#) = happyShift action_50
-action_41 (174#) = happyShift action_51
-action_41 (8#) = happyGoto action_10
-action_41 (9#) = happyGoto action_11
-action_41 (10#) = happyGoto action_12
-action_41 (11#) = happyGoto action_13
-action_41 (12#) = happyGoto action_79
-action_41 (58#) = happyGoto action_15
-action_41 (59#) = happyGoto action_92
-action_41 (72#) = happyGoto action_22
-action_41 x = happyTcHack x happyFail
-
-action_42 (96#) = happyShift action_91
-action_42 (174#) = happyShift action_51
-action_42 (12#) = happyGoto action_87
-action_42 (53#) = happyGoto action_88
-action_42 (56#) = happyGoto action_89
-action_42 (57#) = happyGoto action_90
-action_42 x = happyTcHack x happyReduce_137
-
-action_43 (96#) = happyShift action_24
-action_43 (98#) = happyShift action_82
-action_43 (104#) = happyShift action_26
-action_43 (109#) = happyShift action_27
-action_43 (110#) = happyShift action_28
-action_43 (111#) = happyShift action_29
-action_43 (125#) = happyShift action_33
-action_43 (126#) = happyShift action_34
-action_43 (127#) = happyShift action_35
-action_43 (128#) = happyShift action_36
-action_43 (129#) = happyShift action_37
-action_43 (134#) = happyShift action_39
-action_43 (170#) = happyShift action_6
-action_43 (171#) = happyShift action_48
-action_43 (172#) = happyShift action_49
-action_43 (173#) = happyShift action_50
-action_43 (174#) = happyShift action_51
-action_43 (8#) = happyGoto action_10
-action_43 (9#) = happyGoto action_11
-action_43 (10#) = happyGoto action_12
-action_43 (11#) = happyGoto action_13
-action_43 (12#) = happyGoto action_79
-action_43 (58#) = happyGoto action_15
-action_43 (59#) = happyGoto action_86
-action_43 (72#) = happyGoto action_22
-action_43 x = happyTcHack x happyFail
-
-action_44 (96#) = happyShift action_85
-action_44 x = happyTcHack x happyFail
-
-action_45 (96#) = happyShift action_84
-action_45 x = happyTcHack x happyFail
-
-action_46 (96#) = happyShift action_81
-action_46 (98#) = happyShift action_82
-action_46 (104#) = happyShift action_26
-action_46 (109#) = happyShift action_83
-action_46 (110#) = happyShift action_28
-action_46 (111#) = happyShift action_29
-action_46 (125#) = happyShift action_33
-action_46 (126#) = happyShift action_34
-action_46 (127#) = happyShift action_35
-action_46 (128#) = happyShift action_36
-action_46 (129#) = happyShift action_37
-action_46 (134#) = happyShift action_39
-action_46 (170#) = happyShift action_6
-action_46 (171#) = happyShift action_48
-action_46 (172#) = happyShift action_49
-action_46 (173#) = happyShift action_50
-action_46 (174#) = happyShift action_51
-action_46 (8#) = happyGoto action_10
-action_46 (9#) = happyGoto action_11
-action_46 (10#) = happyGoto action_12
-action_46 (11#) = happyGoto action_13
-action_46 (12#) = happyGoto action_79
-action_46 (58#) = happyGoto action_80
-action_46 (72#) = happyGoto action_22
-action_46 x = happyTcHack x happyFail
-
-action_47 (96#) = happyShift action_78
-action_47 x = happyTcHack x happyFail
-
-action_48 x = happyTcHack x happyReduce_6
-
-action_49 x = happyTcHack x happyReduce_7
-
-action_50 x = happyTcHack x happyReduce_8
-
-action_51 x = happyTcHack x happyReduce_9
-
-action_52 (176#) = happyAccept
-action_52 x = happyTcHack x happyFail
-
-action_53 (25#) = happyGoto action_77
-action_53 x = happyTcHack x happyReduce_48
-
-action_54 (106#) = happyShift action_74
-action_54 (107#) = happyShift action_75
-action_54 (123#) = happyShift action_76
-action_54 (171#) = happyShift action_48
-action_54 (174#) = happyShift action_51
-action_54 (9#) = happyGoto action_70
-action_54 (12#) = happyGoto action_71
-action_54 (92#) = happyGoto action_72
-action_54 (93#) = happyGoto action_73
-action_54 x = happyTcHack x happyFail
-
-action_55 (94#) = happyShift action_69
-action_55 (176#) = happyAccept
-action_55 x = happyTcHack x happyFail
-
-action_56 (130#) = happyShift action_63
-action_56 (133#) = happyShift action_64
-action_56 (143#) = happyShift action_65
-action_56 (144#) = happyShift action_66
-action_56 (159#) = happyShift action_67
-action_56 (164#) = happyShift action_68
-action_56 (23#) = happyGoto action_62
-action_56 x = happyTcHack x happyFail
-
-action_57 (174#) = happyShift action_51
-action_57 (12#) = happyGoto action_61
-action_57 x = happyTcHack x happyFail
-
-action_58 (176#) = happyAccept
-action_58 x = happyTcHack x happyFail
-
-action_59 (139#) = happyShift action_57
-action_59 (142#) = happyShift action_9
-action_59 (176#) = happyReduce_10
-action_59 (15#) = happyGoto action_60
-action_59 (30#) = happyGoto action_56
-action_59 x = happyTcHack x happyReduce_60
-
-action_60 (94#) = happyShift action_69
-action_60 x = happyTcHack x happyReduce_12
-
-action_61 (95#) = happyShift action_239
-action_61 x = happyTcHack x happyFail
-
-action_62 (95#) = happyShift action_238
-action_62 x = happyTcHack x happyFail
-
-action_63 (174#) = happyShift action_51
-action_63 (12#) = happyGoto action_237
-action_63 x = happyTcHack x happyFail
-
-action_64 (174#) = happyShift action_51
-action_64 (12#) = happyGoto action_236
-action_64 x = happyTcHack x happyFail
-
-action_65 (174#) = happyShift action_51
-action_65 (12#) = happyGoto action_235
-action_65 x = happyTcHack x happyFail
-
-action_66 (174#) = happyShift action_51
-action_66 (12#) = happyGoto action_234
-action_66 x = happyTcHack x happyFail
-
-action_67 (174#) = happyShift action_51
-action_67 (12#) = happyGoto action_233
-action_67 x = happyTcHack x happyFail
-
-action_68 (174#) = happyShift action_51
-action_68 (12#) = happyGoto action_232
-action_68 x = happyTcHack x happyFail
-
-action_69 x = happyTcHack x happyReduce_13
-
-action_70 x = happyTcHack x happyReduce_267
-
-action_71 (106#) = happyShift action_74
-action_71 (107#) = happyShift action_75
-action_71 (123#) = happyShift action_76
-action_71 (171#) = happyShift action_48
-action_71 (174#) = happyShift action_51
-action_71 (9#) = happyGoto action_70
-action_71 (12#) = happyGoto action_71
-action_71 (92#) = happyGoto action_231
-action_71 x = happyTcHack x happyReduce_268
-
-action_72 (94#) = happyShift action_230
-action_72 x = happyTcHack x happyFail
-
-action_73 x = happyTcHack x happyReduce_266
-
-action_74 (106#) = happyShift action_74
-action_74 (107#) = happyShift action_75
-action_74 (123#) = happyShift action_76
-action_74 (171#) = happyShift action_48
-action_74 (174#) = happyShift action_51
-action_74 (9#) = happyGoto action_70
-action_74 (12#) = happyGoto action_71
-action_74 (92#) = happyGoto action_229
-action_74 x = happyTcHack x happyFail
-
-action_75 (106#) = happyShift action_74
-action_75 (107#) = happyShift action_75
-action_75 (123#) = happyShift action_76
-action_75 (171#) = happyShift action_48
-action_75 (174#) = happyShift action_51
-action_75 (9#) = happyGoto action_70
-action_75 (12#) = happyGoto action_71
-action_75 (92#) = happyGoto action_228
-action_75 x = happyTcHack x happyFail
-
-action_76 (106#) = happyShift action_74
-action_76 (107#) = happyShift action_75
-action_76 (123#) = happyShift action_76
-action_76 (171#) = happyShift action_48
-action_76 (174#) = happyShift action_51
-action_76 (9#) = happyGoto action_70
-action_76 (12#) = happyGoto action_71
-action_76 (92#) = happyGoto action_227
-action_76 x = happyTcHack x happyFail
-
-action_77 (132#) = happyShift action_210
-action_77 (134#) = happyShift action_211
-action_77 (135#) = happyShift action_212
-action_77 (136#) = happyShift action_213
-action_77 (138#) = happyShift action_214
-action_77 (146#) = happyShift action_215
-action_77 (147#) = happyShift action_216
-action_77 (148#) = happyShift action_217
-action_77 (149#) = happyShift action_218
-action_77 (152#) = happyShift action_219
-action_77 (154#) = happyShift action_220
-action_77 (155#) = happyShift action_221
-action_77 (156#) = happyShift action_222
-action_77 (158#) = happyShift action_223
-action_77 (163#) = happyShift action_224
-action_77 (164#) = happyShift action_225
-action_77 (166#) = happyShift action_226
-action_77 (35#) = happyGoto action_209
-action_77 x = happyTcHack x happyReduce_264
-
-action_78 (96#) = happyShift action_24
-action_78 (98#) = happyShift action_25
-action_78 (104#) = happyShift action_26
-action_78 (109#) = happyShift action_27
-action_78 (110#) = happyShift action_28
-action_78 (111#) = happyShift action_29
-action_78 (114#) = happyShift action_30
-action_78 (119#) = happyShift action_31
-action_78 (124#) = happyShift action_32
-action_78 (125#) = happyShift action_33
-action_78 (126#) = happyShift action_34
-action_78 (127#) = happyShift action_35
-action_78 (128#) = happyShift action_36
-action_78 (129#) = happyShift action_37
-action_78 (131#) = happyShift action_38
-action_78 (134#) = happyShift action_39
-action_78 (137#) = happyShift action_40
-action_78 (140#) = happyShift action_41
-action_78 (145#) = happyShift action_42
-action_78 (156#) = happyShift action_43
-action_78 (157#) = happyShift action_44
-action_78 (161#) = happyShift action_45
-action_78 (162#) = happyShift action_46
-action_78 (167#) = happyShift action_47
-action_78 (170#) = happyShift action_6
-action_78 (171#) = happyShift action_48
-action_78 (172#) = happyShift action_49
-action_78 (173#) = happyShift action_50
-action_78 (174#) = happyShift action_51
-action_78 (8#) = happyGoto action_10
-action_78 (9#) = happyGoto action_11
-action_78 (10#) = happyGoto action_12
-action_78 (11#) = happyGoto action_13
-action_78 (12#) = happyGoto action_14
-action_78 (58#) = happyGoto action_15
-action_78 (59#) = happyGoto action_16
-action_78 (60#) = happyGoto action_17
-action_78 (61#) = happyGoto action_18
-action_78 (62#) = happyGoto action_19
-action_78 (63#) = happyGoto action_199
-action_78 (64#) = happyGoto action_21
-action_78 (65#) = happyGoto action_208
-action_78 (72#) = happyGoto action_22
-action_78 (77#) = happyGoto action_23
-action_78 x = happyTcHack x happyReduce_193
-
-action_79 x = happyTcHack x happyReduce_140
-
-action_80 (96#) = happyShift action_206
-action_80 (104#) = happyShift action_207
-action_80 x = happyTcHack x happyFail
-
-action_81 (96#) = happyShift action_106
-action_81 (98#) = happyShift action_107
-action_81 (104#) = happyShift action_108
-action_81 (106#) = happyShift action_176
-action_81 (110#) = happyShift action_109
-action_81 (111#) = happyShift action_110
-action_81 (114#) = happyShift action_111
-action_81 (121#) = happyShift action_112
-action_81 (170#) = happyShift action_6
-action_81 (171#) = happyShift action_48
-action_81 (172#) = happyShift action_49
-action_81 (174#) = happyShift action_51
-action_81 (8#) = happyGoto action_101
-action_81 (9#) = happyGoto action_102
-action_81 (10#) = happyGoto action_103
-action_81 (12#) = happyGoto action_202
-action_81 (53#) = happyGoto action_88
-action_81 (56#) = happyGoto action_89
-action_81 (57#) = happyGoto action_125
-action_81 (67#) = happyGoto action_171
-action_81 (68#) = happyGoto action_172
-action_81 (69#) = happyGoto action_203
-action_81 (82#) = happyGoto action_204
-action_81 (83#) = happyGoto action_205
-action_81 x = happyTcHack x happyReduce_137
-
-action_82 (96#) = happyShift action_24
-action_82 (98#) = happyShift action_25
-action_82 (104#) = happyShift action_26
-action_82 (109#) = happyShift action_27
-action_82 (110#) = happyShift action_28
-action_82 (111#) = happyShift action_29
-action_82 (114#) = happyShift action_30
-action_82 (119#) = happyShift action_31
-action_82 (124#) = happyShift action_32
-action_82 (125#) = happyShift action_33
-action_82 (126#) = happyShift action_34
-action_82 (127#) = happyShift action_35
-action_82 (128#) = happyShift action_36
-action_82 (129#) = happyShift action_37
-action_82 (131#) = happyShift action_38
-action_82 (134#) = happyShift action_39
-action_82 (137#) = happyShift action_40
-action_82 (140#) = happyShift action_123
-action_82 (145#) = happyShift action_42
-action_82 (156#) = happyShift action_43
-action_82 (157#) = happyShift action_44
-action_82 (161#) = happyShift action_45
-action_82 (162#) = happyShift action_46
-action_82 (167#) = happyShift action_47
-action_82 (170#) = happyShift action_6
-action_82 (171#) = happyShift action_48
-action_82 (172#) = happyShift action_49
-action_82 (173#) = happyShift action_50
-action_82 (174#) = happyShift action_51
-action_82 (8#) = happyGoto action_10
-action_82 (9#) = happyGoto action_11
-action_82 (10#) = happyGoto action_12
-action_82 (11#) = happyGoto action_13
-action_82 (12#) = happyGoto action_14
-action_82 (58#) = happyGoto action_15
-action_82 (59#) = happyGoto action_16
-action_82 (60#) = happyGoto action_17
-action_82 (61#) = happyGoto action_18
-action_82 (62#) = happyGoto action_19
-action_82 (63#) = happyGoto action_121
-action_82 (64#) = happyGoto action_21
-action_82 (72#) = happyGoto action_22
-action_82 (77#) = happyGoto action_23
-action_82 x = happyTcHack x happyFail
-
-action_83 (174#) = happyShift action_51
-action_83 (12#) = happyGoto action_201
-action_83 x = happyTcHack x happyFail
-
-action_84 (96#) = happyShift action_24
-action_84 (98#) = happyShift action_25
-action_84 (104#) = happyShift action_26
-action_84 (109#) = happyShift action_27
-action_84 (110#) = happyShift action_28
-action_84 (111#) = happyShift action_29
-action_84 (114#) = happyShift action_30
-action_84 (119#) = happyShift action_31
-action_84 (124#) = happyShift action_32
-action_84 (125#) = happyShift action_33
-action_84 (126#) = happyShift action_34
-action_84 (127#) = happyShift action_35
-action_84 (128#) = happyShift action_36
-action_84 (129#) = happyShift action_37
-action_84 (131#) = happyShift action_38
-action_84 (134#) = happyShift action_39
-action_84 (137#) = happyShift action_40
-action_84 (140#) = happyShift action_41
-action_84 (145#) = happyShift action_42
-action_84 (156#) = happyShift action_43
-action_84 (157#) = happyShift action_44
-action_84 (161#) = happyShift action_45
-action_84 (162#) = happyShift action_46
-action_84 (167#) = happyShift action_47
-action_84 (170#) = happyShift action_6
-action_84 (171#) = happyShift action_48
-action_84 (172#) = happyShift action_49
-action_84 (173#) = happyShift action_50
-action_84 (174#) = happyShift action_51
-action_84 (8#) = happyGoto action_10
-action_84 (9#) = happyGoto action_11
-action_84 (10#) = happyGoto action_12
-action_84 (11#) = happyGoto action_13
-action_84 (12#) = happyGoto action_14
-action_84 (58#) = happyGoto action_15
-action_84 (59#) = happyGoto action_16
-action_84 (60#) = happyGoto action_17
-action_84 (61#) = happyGoto action_18
-action_84 (62#) = happyGoto action_19
-action_84 (63#) = happyGoto action_199
-action_84 (64#) = happyGoto action_21
-action_84 (65#) = happyGoto action_200
-action_84 (72#) = happyGoto action_22
-action_84 (77#) = happyGoto action_23
-action_84 x = happyTcHack x happyReduce_193
-
-action_85 (96#) = happyShift action_24
-action_85 (98#) = happyShift action_25
-action_85 (104#) = happyShift action_26
-action_85 (109#) = happyShift action_27
-action_85 (110#) = happyShift action_28
-action_85 (111#) = happyShift action_29
-action_85 (114#) = happyShift action_30
-action_85 (119#) = happyShift action_31
-action_85 (124#) = happyShift action_32
-action_85 (125#) = happyShift action_33
-action_85 (126#) = happyShift action_34
-action_85 (127#) = happyShift action_35
-action_85 (128#) = happyShift action_36
-action_85 (129#) = happyShift action_37
-action_85 (131#) = happyShift action_38
-action_85 (134#) = happyShift action_39
-action_85 (137#) = happyShift action_40
-action_85 (140#) = happyShift action_41
-action_85 (145#) = happyShift action_42
-action_85 (156#) = happyShift action_43
-action_85 (157#) = happyShift action_44
-action_85 (161#) = happyShift action_45
-action_85 (162#) = happyShift action_46
-action_85 (167#) = happyShift action_47
-action_85 (170#) = happyShift action_6
-action_85 (171#) = happyShift action_48
-action_85 (172#) = happyShift action_49
-action_85 (173#) = happyShift action_50
-action_85 (174#) = happyShift action_51
-action_85 (8#) = happyGoto action_10
-action_85 (9#) = happyGoto action_11
-action_85 (10#) = happyGoto action_12
-action_85 (11#) = happyGoto action_13
-action_85 (12#) = happyGoto action_14
-action_85 (58#) = happyGoto action_15
-action_85 (59#) = happyGoto action_16
-action_85 (60#) = happyGoto action_17
-action_85 (61#) = happyGoto action_18
-action_85 (62#) = happyGoto action_19
-action_85 (63#) = happyGoto action_198
-action_85 (64#) = happyGoto action_21
-action_85 (72#) = happyGoto action_22
-action_85 (77#) = happyGoto action_23
-action_85 x = happyTcHack x happyFail
-
-action_86 (107#) = happyShift action_135
-action_86 x = happyTcHack x happyReduce_172
-
-action_87 (103#) = happyShift action_156
-action_87 x = happyTcHack x happyReduce_128
-
-action_88 (95#) = happyShift action_196
-action_88 (100#) = happyShift action_197
-action_88 x = happyTcHack x happyFail
-
-action_89 (94#) = happyShift action_195
-action_89 x = happyTcHack x happyReduce_138
-
-action_90 (140#) = happyShift action_194
-action_90 x = happyTcHack x happyFail
-
-action_91 (174#) = happyShift action_51
-action_91 (12#) = happyGoto action_87
-action_91 (53#) = happyGoto action_88
-action_91 (56#) = happyGoto action_89
-action_91 (57#) = happyGoto action_193
-action_91 x = happyTcHack x happyReduce_137
-
-action_92 (107#) = happyShift action_135
-action_92 (171#) = happyShift action_48
-action_92 (9#) = happyGoto action_192
-action_92 x = happyTcHack x happyFail
-
-action_93 (96#) = happyShift action_106
-action_93 (98#) = happyShift action_107
-action_93 (104#) = happyShift action_108
-action_93 (110#) = happyShift action_109
-action_93 (111#) = happyShift action_110
-action_93 (114#) = happyShift action_111
-action_93 (121#) = happyShift action_112
-action_93 (170#) = happyShift action_6
-action_93 (171#) = happyShift action_48
-action_93 (172#) = happyShift action_49
-action_93 (174#) = happyShift action_51
-action_93 (8#) = happyGoto action_101
-action_93 (9#) = happyGoto action_102
-action_93 (10#) = happyGoto action_103
-action_93 (12#) = happyGoto action_104
-action_93 (67#) = happyGoto action_188
-action_93 (74#) = happyGoto action_189
-action_93 (84#) = happyGoto action_190
-action_93 (85#) = happyGoto action_191
-action_93 x = happyTcHack x happyReduce_253
-
-action_94 (150#) = happyShift action_187
-action_94 x = happyTcHack x happyFail
-
-action_95 x = happyTcHack x happyReduce_174
-
-action_96 x = happyTcHack x happyReduce_234
-
-action_97 (103#) = happyShift action_186
-action_97 x = happyTcHack x happyReduce_237
-
-action_98 (101#) = happyShift action_185
-action_98 x = happyTcHack x happyFail
-
-action_99 (121#) = happyShift action_100
-action_99 (174#) = happyShift action_51
-action_99 (12#) = happyGoto action_96
-action_99 (75#) = happyGoto action_97
-action_99 (76#) = happyGoto action_184
-action_99 x = happyTcHack x happyReduce_236
-
-action_100 x = happyTcHack x happyReduce_235
-
-action_101 x = happyTcHack x happyReduce_206
-
-action_102 x = happyTcHack x happyReduce_208
-
-action_103 x = happyTcHack x happyReduce_207
-
-action_104 (107#) = happyShift action_183
-action_104 x = happyTcHack x happyReduce_203
-
-action_105 x = happyTcHack x happyReduce_171
-
-action_106 (174#) = happyShift action_51
-action_106 (12#) = happyGoto action_179
-action_106 (53#) = happyGoto action_180
-action_106 (70#) = happyGoto action_181
-action_106 (73#) = happyGoto action_182
-action_106 x = happyTcHack x happyReduce_229
-
-action_107 (96#) = happyShift action_106
-action_107 (98#) = happyShift action_107
-action_107 (104#) = happyShift action_108
-action_107 (106#) = happyShift action_176
-action_107 (110#) = happyShift action_109
-action_107 (111#) = happyShift action_110
-action_107 (114#) = happyShift action_111
-action_107 (121#) = happyShift action_112
-action_107 (170#) = happyShift action_6
-action_107 (171#) = happyShift action_48
-action_107 (172#) = happyShift action_49
-action_107 (174#) = happyShift action_51
-action_107 (8#) = happyGoto action_101
-action_107 (9#) = happyGoto action_102
-action_107 (10#) = happyGoto action_103
-action_107 (12#) = happyGoto action_170
-action_107 (67#) = happyGoto action_171
-action_107 (68#) = happyGoto action_172
-action_107 (69#) = happyGoto action_178
-action_107 x = happyTcHack x happyFail
-
-action_108 (171#) = happyShift action_48
-action_108 (9#) = happyGoto action_177
-action_108 x = happyTcHack x happyFail
-
-action_109 x = happyTcHack x happyReduce_198
-
-action_110 (96#) = happyShift action_106
-action_110 (98#) = happyShift action_107
-action_110 (104#) = happyShift action_108
-action_110 (106#) = happyShift action_176
-action_110 (110#) = happyShift action_109
-action_110 (111#) = happyShift action_110
-action_110 (114#) = happyShift action_111
-action_110 (121#) = happyShift action_112
-action_110 (170#) = happyShift action_6
-action_110 (171#) = happyShift action_48
-action_110 (172#) = happyShift action_49
-action_110 (174#) = happyShift action_51
-action_110 (8#) = happyGoto action_101
-action_110 (9#) = happyGoto action_102
-action_110 (10#) = happyGoto action_103
-action_110 (12#) = happyGoto action_170
-action_110 (67#) = happyGoto action_171
-action_110 (68#) = happyGoto action_172
-action_110 (69#) = happyGoto action_173
-action_110 (79#) = happyGoto action_174
-action_110 (81#) = happyGoto action_175
-action_110 x = happyTcHack x happyReduce_246
-
-action_111 (174#) = happyShift action_51
-action_111 (12#) = happyGoto action_169
-action_111 x = happyTcHack x happyFail
-
-action_112 x = happyTcHack x happyReduce_202
-
-action_113 (100#) = happyShift action_168
-action_113 x = happyTcHack x happyReduce_241
-
-action_114 (103#) = happyShift action_167
-action_114 x = happyTcHack x happyReduce_244
-
-action_115 (112#) = happyShift action_166
-action_115 x = happyTcHack x happyFail
-
-action_116 (107#) = happyShift action_164
-action_116 (109#) = happyShift action_165
-action_116 x = happyTcHack x happyFail
-
-action_117 (105#) = happyShift action_163
-action_117 x = happyTcHack x happyFail
-
-action_118 (96#) = happyShift action_140
-action_118 (98#) = happyShift action_82
-action_118 (104#) = happyShift action_26
-action_118 (109#) = happyShift action_83
-action_118 (110#) = happyShift action_28
-action_118 (111#) = happyShift action_29
-action_118 (125#) = happyShift action_33
-action_118 (126#) = happyShift action_34
-action_118 (127#) = happyShift action_35
-action_118 (128#) = happyShift action_36
-action_118 (129#) = happyShift action_37
-action_118 (134#) = happyShift action_39
-action_118 (170#) = happyShift action_6
-action_118 (171#) = happyShift action_48
-action_118 (172#) = happyShift action_49
-action_118 (173#) = happyShift action_50
-action_118 (174#) = happyShift action_51
-action_118 (8#) = happyGoto action_10
-action_118 (9#) = happyGoto action_11
-action_118 (10#) = happyGoto action_12
-action_118 (11#) = happyGoto action_13
-action_118 (12#) = happyGoto action_79
-action_118 (58#) = happyGoto action_161
-action_118 (66#) = happyGoto action_162
-action_118 (72#) = happyGoto action_22
-action_118 x = happyTcHack x happyReduce_196
-
-action_119 x = happyTcHack x happyReduce_148
-
-action_120 (100#) = happyReduce_234
-action_120 (103#) = happyReduce_234
-action_120 (113#) = happyShift action_136
-action_120 x = happyTcHack x happyReduce_140
-
-action_121 (99#) = happyShift action_160
-action_121 x = happyTcHack x happyFail
-
-action_122 (100#) = happyShift action_159
-action_122 x = happyTcHack x happyFail
-
-action_123 (96#) = happyShift action_24
-action_123 (98#) = happyShift action_82
-action_123 (104#) = happyShift action_26
-action_123 (109#) = happyShift action_27
-action_123 (110#) = happyShift action_28
-action_123 (111#) = happyShift action_29
-action_123 (125#) = happyShift action_33
-action_123 (126#) = happyShift action_34
-action_123 (127#) = happyShift action_35
-action_123 (128#) = happyShift action_36
-action_123 (129#) = happyShift action_37
-action_123 (134#) = happyShift action_39
-action_123 (170#) = happyShift action_6
-action_123 (171#) = happyShift action_48
-action_123 (172#) = happyShift action_49
-action_123 (173#) = happyShift action_50
-action_123 (174#) = happyShift action_51
-action_123 (8#) = happyGoto action_10
-action_123 (9#) = happyGoto action_11
-action_123 (10#) = happyGoto action_12
-action_123 (11#) = happyGoto action_13
-action_123 (12#) = happyGoto action_158
-action_123 (58#) = happyGoto action_15
-action_123 (59#) = happyGoto action_92
-action_123 (72#) = happyGoto action_22
-action_123 x = happyTcHack x happyFail
-
-action_124 (97#) = happyShift action_155
-action_124 (103#) = happyShift action_156
-action_124 (107#) = happyShift action_157
-action_124 x = happyTcHack x happyReduce_128
-
-action_125 (97#) = happyShift action_154
-action_125 x = happyTcHack x happyFail
-
-action_126 (96#) = happyShift action_24
-action_126 (98#) = happyShift action_25
-action_126 (104#) = happyShift action_26
-action_126 (109#) = happyShift action_27
-action_126 (110#) = happyShift action_28
-action_126 (111#) = happyShift action_29
-action_126 (114#) = happyShift action_30
-action_126 (119#) = happyShift action_31
-action_126 (124#) = happyShift action_32
-action_126 (125#) = happyShift action_33
-action_126 (126#) = happyShift action_34
-action_126 (127#) = happyShift action_35
-action_126 (128#) = happyShift action_36
-action_126 (129#) = happyShift action_37
-action_126 (131#) = happyShift action_38
-action_126 (134#) = happyShift action_39
-action_126 (137#) = happyShift action_40
-action_126 (140#) = happyShift action_41
-action_126 (145#) = happyShift action_42
-action_126 (156#) = happyShift action_43
-action_126 (157#) = happyShift action_44
-action_126 (161#) = happyShift action_45
-action_126 (162#) = happyShift action_46
-action_126 (167#) = happyShift action_47
-action_126 (170#) = happyShift action_6
-action_126 (171#) = happyShift action_48
-action_126 (172#) = happyShift action_49
-action_126 (173#) = happyShift action_50
-action_126 (174#) = happyShift action_51
-action_126 (8#) = happyGoto action_10
-action_126 (9#) = happyGoto action_11
-action_126 (10#) = happyGoto action_12
-action_126 (11#) = happyGoto action_13
-action_126 (12#) = happyGoto action_14
-action_126 (58#) = happyGoto action_15
-action_126 (59#) = happyGoto action_16
-action_126 (60#) = happyGoto action_17
-action_126 (61#) = happyGoto action_18
-action_126 (62#) = happyGoto action_19
-action_126 (63#) = happyGoto action_153
-action_126 (64#) = happyGoto action_21
-action_126 (72#) = happyGoto action_22
-action_126 (77#) = happyGoto action_23
-action_126 x = happyTcHack x happyFail
-
-action_127 (96#) = happyShift action_24
-action_127 (98#) = happyShift action_82
-action_127 (104#) = happyShift action_26
-action_127 (109#) = happyShift action_27
-action_127 (110#) = happyShift action_28
-action_127 (111#) = happyShift action_29
-action_127 (114#) = happyShift action_30
-action_127 (124#) = happyShift action_32
-action_127 (125#) = happyShift action_33
-action_127 (126#) = happyShift action_34
-action_127 (127#) = happyShift action_35
-action_127 (128#) = happyShift action_36
-action_127 (129#) = happyShift action_37
-action_127 (131#) = happyShift action_38
-action_127 (134#) = happyShift action_39
-action_127 (156#) = happyShift action_43
-action_127 (157#) = happyShift action_44
-action_127 (161#) = happyShift action_45
-action_127 (162#) = happyShift action_46
-action_127 (167#) = happyShift action_47
-action_127 (170#) = happyShift action_6
-action_127 (171#) = happyShift action_48
-action_127 (172#) = happyShift action_49
-action_127 (173#) = happyShift action_50
-action_127 (174#) = happyShift action_51
-action_127 (8#) = happyGoto action_10
-action_127 (9#) = happyGoto action_11
-action_127 (10#) = happyGoto action_12
-action_127 (11#) = happyGoto action_13
-action_127 (12#) = happyGoto action_14
-action_127 (58#) = happyGoto action_15
-action_127 (59#) = happyGoto action_16
-action_127 (60#) = happyGoto action_150
-action_127 (61#) = happyGoto action_151
-action_127 (62#) = happyGoto action_152
-action_127 (64#) = happyGoto action_21
-action_127 (72#) = happyGoto action_22
-action_127 x = happyTcHack x happyFail
-
-action_128 (96#) = happyShift action_24
-action_128 (98#) = happyShift action_25
-action_128 (104#) = happyShift action_26
-action_128 (109#) = happyShift action_27
-action_128 (110#) = happyShift action_28
-action_128 (111#) = happyShift action_29
-action_128 (114#) = happyShift action_30
-action_128 (119#) = happyShift action_31
-action_128 (124#) = happyShift action_32
-action_128 (125#) = happyShift action_33
-action_128 (126#) = happyShift action_34
-action_128 (127#) = happyShift action_35
-action_128 (128#) = happyShift action_36
-action_128 (129#) = happyShift action_37
-action_128 (131#) = happyShift action_38
-action_128 (134#) = happyShift action_39
-action_128 (137#) = happyShift action_40
-action_128 (140#) = happyShift action_41
-action_128 (145#) = happyShift action_42
-action_128 (156#) = happyShift action_43
-action_128 (157#) = happyShift action_44
-action_128 (161#) = happyShift action_45
-action_128 (162#) = happyShift action_46
-action_128 (167#) = happyShift action_47
-action_128 (170#) = happyShift action_6
-action_128 (171#) = happyShift action_48
-action_128 (172#) = happyShift action_49
-action_128 (173#) = happyShift action_50
-action_128 (174#) = happyShift action_51
-action_128 (8#) = happyGoto action_10
-action_128 (9#) = happyGoto action_11
-action_128 (10#) = happyGoto action_12
-action_128 (11#) = happyGoto action_13
-action_128 (12#) = happyGoto action_14
-action_128 (58#) = happyGoto action_15
-action_128 (59#) = happyGoto action_16
-action_128 (60#) = happyGoto action_17
-action_128 (61#) = happyGoto action_18
-action_128 (62#) = happyGoto action_19
-action_128 (63#) = happyGoto action_149
-action_128 (64#) = happyGoto action_21
-action_128 (72#) = happyGoto action_22
-action_128 (77#) = happyGoto action_23
-action_128 x = happyTcHack x happyFail
-
-action_129 (96#) = happyShift action_24
-action_129 (98#) = happyShift action_82
-action_129 (104#) = happyShift action_26
-action_129 (109#) = happyShift action_27
-action_129 (110#) = happyShift action_28
-action_129 (111#) = happyShift action_29
-action_129 (114#) = happyShift action_30
-action_129 (124#) = happyShift action_32
-action_129 (125#) = happyShift action_33
-action_129 (126#) = happyShift action_34
-action_129 (127#) = happyShift action_35
-action_129 (128#) = happyShift action_36
-action_129 (129#) = happyShift action_37
-action_129 (131#) = happyShift action_38
-action_129 (134#) = happyShift action_39
-action_129 (156#) = happyShift action_43
-action_129 (157#) = happyShift action_44
-action_129 (161#) = happyShift action_45
-action_129 (162#) = happyShift action_46
-action_129 (167#) = happyShift action_47
-action_129 (170#) = happyShift action_6
-action_129 (171#) = happyShift action_48
-action_129 (172#) = happyShift action_49
-action_129 (173#) = happyShift action_50
-action_129 (174#) = happyShift action_51
-action_129 (8#) = happyGoto action_10
-action_129 (9#) = happyGoto action_11
-action_129 (10#) = happyGoto action_12
-action_129 (11#) = happyGoto action_13
-action_129 (12#) = happyGoto action_14
-action_129 (58#) = happyGoto action_15
-action_129 (59#) = happyGoto action_16
-action_129 (60#) = happyGoto action_148
-action_129 (72#) = happyGoto action_22
-action_129 x = happyTcHack x happyFail
-
-action_130 (96#) = happyShift action_24
-action_130 (98#) = happyShift action_82
-action_130 (104#) = happyShift action_26
-action_130 (109#) = happyShift action_27
-action_130 (110#) = happyShift action_28
-action_130 (111#) = happyShift action_29
-action_130 (114#) = happyShift action_30
-action_130 (124#) = happyShift action_32
-action_130 (125#) = happyShift action_33
-action_130 (126#) = happyShift action_34
-action_130 (127#) = happyShift action_35
-action_130 (128#) = happyShift action_36
-action_130 (129#) = happyShift action_37
-action_130 (131#) = happyShift action_38
-action_130 (134#) = happyShift action_39
-action_130 (156#) = happyShift action_43
-action_130 (157#) = happyShift action_44
-action_130 (161#) = happyShift action_45
-action_130 (162#) = happyShift action_46
-action_130 (167#) = happyShift action_47
-action_130 (170#) = happyShift action_6
-action_130 (171#) = happyShift action_48
-action_130 (172#) = happyShift action_49
-action_130 (173#) = happyShift action_50
-action_130 (174#) = happyShift action_51
-action_130 (8#) = happyGoto action_10
-action_130 (9#) = happyGoto action_11
-action_130 (10#) = happyGoto action_12
-action_130 (11#) = happyGoto action_13
-action_130 (12#) = happyGoto action_14
-action_130 (58#) = happyGoto action_15
-action_130 (59#) = happyGoto action_16
-action_130 (60#) = happyGoto action_147
-action_130 (72#) = happyGoto action_22
-action_130 x = happyTcHack x happyFail
-
-action_131 (96#) = happyShift action_24
-action_131 (98#) = happyShift action_82
-action_131 (104#) = happyShift action_26
-action_131 (109#) = happyShift action_27
-action_131 (110#) = happyShift action_28
-action_131 (111#) = happyShift action_29
-action_131 (114#) = happyShift action_30
-action_131 (124#) = happyShift action_32
-action_131 (125#) = happyShift action_33
-action_131 (126#) = happyShift action_34
-action_131 (127#) = happyShift action_35
-action_131 (128#) = happyShift action_36
-action_131 (129#) = happyShift action_37
-action_131 (131#) = happyShift action_38
-action_131 (134#) = happyShift action_39
-action_131 (156#) = happyShift action_43
-action_131 (157#) = happyShift action_44
-action_131 (161#) = happyShift action_45
-action_131 (162#) = happyShift action_46
-action_131 (167#) = happyShift action_47
-action_131 (170#) = happyShift action_6
-action_131 (171#) = happyShift action_48
-action_131 (172#) = happyShift action_49
-action_131 (173#) = happyShift action_50
-action_131 (174#) = happyShift action_51
-action_131 (8#) = happyGoto action_10
-action_131 (9#) = happyGoto action_11
-action_131 (10#) = happyGoto action_12
-action_131 (11#) = happyGoto action_13
-action_131 (12#) = happyGoto action_14
-action_131 (58#) = happyGoto action_15
-action_131 (59#) = happyGoto action_16
-action_131 (60#) = happyGoto action_146
-action_131 (72#) = happyGoto action_22
-action_131 x = happyTcHack x happyFail
-
-action_132 (96#) = happyShift action_24
-action_132 (98#) = happyShift action_25
-action_132 (104#) = happyShift action_26
-action_132 (109#) = happyShift action_27
-action_132 (110#) = happyShift action_28
-action_132 (111#) = happyShift action_29
-action_132 (114#) = happyShift action_30
-action_132 (119#) = happyShift action_31
-action_132 (124#) = happyShift action_32
-action_132 (125#) = happyShift action_33
-action_132 (126#) = happyShift action_34
-action_132 (127#) = happyShift action_35
-action_132 (128#) = happyShift action_36
-action_132 (129#) = happyShift action_37
-action_132 (131#) = happyShift action_38
-action_132 (134#) = happyShift action_39
-action_132 (137#) = happyShift action_40
-action_132 (140#) = happyShift action_41
-action_132 (145#) = happyShift action_42
-action_132 (156#) = happyShift action_43
-action_132 (157#) = happyShift action_44
-action_132 (161#) = happyShift action_45
-action_132 (162#) = happyShift action_46
-action_132 (167#) = happyShift action_47
-action_132 (170#) = happyShift action_6
-action_132 (171#) = happyShift action_48
-action_132 (172#) = happyShift action_49
-action_132 (173#) = happyShift action_50
-action_132 (174#) = happyShift action_51
-action_132 (8#) = happyGoto action_10
-action_132 (9#) = happyGoto action_11
-action_132 (10#) = happyGoto action_12
-action_132 (11#) = happyGoto action_13
-action_132 (12#) = happyGoto action_14
-action_132 (58#) = happyGoto action_15
-action_132 (59#) = happyGoto action_16
-action_132 (60#) = happyGoto action_17
-action_132 (61#) = happyGoto action_18
-action_132 (62#) = happyGoto action_19
-action_132 (63#) = happyGoto action_145
-action_132 (64#) = happyGoto action_21
-action_132 (72#) = happyGoto action_22
-action_132 (77#) = happyGoto action_23
-action_132 x = happyTcHack x happyFail
-
-action_133 (96#) = happyShift action_144
-action_133 x = happyTcHack x happyFail
-
-action_134 (107#) = happyShift action_135
-action_134 x = happyTcHack x happyReduce_162
-
-action_135 (122#) = happyShift action_143
-action_135 (174#) = happyShift action_51
-action_135 (12#) = happyGoto action_141
-action_135 (71#) = happyGoto action_142
-action_135 x = happyTcHack x happyFail
-
-action_136 (96#) = happyShift action_140
-action_136 (98#) = happyShift action_82
-action_136 (104#) = happyShift action_26
-action_136 (109#) = happyShift action_83
-action_136 (110#) = happyShift action_28
-action_136 (111#) = happyShift action_29
-action_136 (125#) = happyShift action_33
-action_136 (126#) = happyShift action_34
-action_136 (127#) = happyShift action_35
-action_136 (128#) = happyShift action_36
-action_136 (129#) = happyShift action_37
-action_136 (134#) = happyShift action_39
-action_136 (170#) = happyShift action_6
-action_136 (171#) = happyShift action_48
-action_136 (172#) = happyShift action_49
-action_136 (173#) = happyShift action_50
-action_136 (174#) = happyShift action_51
-action_136 (8#) = happyGoto action_10
-action_136 (9#) = happyGoto action_11
-action_136 (10#) = happyGoto action_12
-action_136 (11#) = happyGoto action_13
-action_136 (12#) = happyGoto action_79
-action_136 (58#) = happyGoto action_139
-action_136 (72#) = happyGoto action_22
-action_136 x = happyTcHack x happyFail
-
-action_137 (95#) = happyShift action_138
-action_137 x = happyTcHack x happyFail
-
-action_138 (1#) = happyReduce_65
-action_138 (102#) = happyReduce_65
-action_138 (151#) = happyReduce_51
-action_138 (160#) = happyShift action_347
-action_138 (165#) = happyShift action_348
-action_138 (174#) = happyShift action_51
-action_138 (12#) = happyGoto action_241
-action_138 (22#) = happyGoto action_343
-action_138 (26#) = happyGoto action_344
-action_138 (32#) = happyGoto action_345
-action_138 (33#) = happyGoto action_346
-action_138 x = happyTcHack x happyReduce_65
-
-action_139 x = happyTcHack x happyReduce_170
-
-action_140 (174#) = happyShift action_51
-action_140 (12#) = happyGoto action_342
-action_140 (53#) = happyGoto action_88
-action_140 (56#) = happyGoto action_89
-action_140 (57#) = happyGoto action_125
-action_140 x = happyTcHack x happyReduce_137
-
-action_141 x = happyTcHack x happyReduce_222
-
-action_142 x = happyTcHack x happyReduce_158
-
-action_143 (170#) = happyShift action_6
-action_143 (8#) = happyGoto action_341
-action_143 x = happyTcHack x happyFail
-
-action_144 (174#) = happyShift action_51
-action_144 (12#) = happyGoto action_87
-action_144 (53#) = happyGoto action_88
-action_144 (56#) = happyGoto action_89
-action_144 (57#) = happyGoto action_340
-action_144 x = happyTcHack x happyReduce_137
-
-action_145 x = happyTcHack x happyReduce_185
-
-action_146 (96#) = happyShift action_24
-action_146 (98#) = happyShift action_82
-action_146 (104#) = happyShift action_26
-action_146 (109#) = happyShift action_27
-action_146 (110#) = happyShift action_28
-action_146 (111#) = happyShift action_29
-action_146 (125#) = happyShift action_33
-action_146 (126#) = happyShift action_34
-action_146 (127#) = happyShift action_35
-action_146 (128#) = happyShift action_36
-action_146 (129#) = happyShift action_37
-action_146 (134#) = happyShift action_39
-action_146 (170#) = happyShift action_6
-action_146 (171#) = happyShift action_48
-action_146 (172#) = happyShift action_49
-action_146 (173#) = happyShift action_50
-action_146 (174#) = happyShift action_51
-action_146 (8#) = happyGoto action_10
-action_146 (9#) = happyGoto action_11
-action_146 (10#) = happyGoto action_12
-action_146 (11#) = happyGoto action_13
-action_146 (12#) = happyGoto action_79
-action_146 (58#) = happyGoto action_15
-action_146 (59#) = happyGoto action_134
-action_146 (72#) = happyGoto action_22
-action_146 x = happyTcHack x happyReduce_176
-
-action_147 (96#) = happyShift action_24
-action_147 (98#) = happyShift action_82
-action_147 (104#) = happyShift action_26
-action_147 (109#) = happyShift action_27
-action_147 (110#) = happyShift action_28
-action_147 (111#) = happyShift action_29
-action_147 (125#) = happyShift action_33
-action_147 (126#) = happyShift action_34
-action_147 (127#) = happyShift action_35
-action_147 (128#) = happyShift action_36
-action_147 (129#) = happyShift action_37
-action_147 (134#) = happyShift action_39
-action_147 (170#) = happyShift action_6
-action_147 (171#) = happyShift action_48
-action_147 (172#) = happyShift action_49
-action_147 (173#) = happyShift action_50
-action_147 (174#) = happyShift action_51
-action_147 (8#) = happyGoto action_10
-action_147 (9#) = happyGoto action_11
-action_147 (10#) = happyGoto action_12
-action_147 (11#) = happyGoto action_13
-action_147 (12#) = happyGoto action_79
-action_147 (58#) = happyGoto action_15
-action_147 (59#) = happyGoto action_134
-action_147 (72#) = happyGoto action_22
-action_147 x = happyTcHack x happyReduce_175
-
-action_148 (96#) = happyShift action_24
-action_148 (98#) = happyShift action_82
-action_148 (104#) = happyShift action_26
-action_148 (109#) = happyShift action_27
-action_148 (110#) = happyShift action_28
-action_148 (111#) = happyShift action_29
-action_148 (125#) = happyShift action_33
-action_148 (126#) = happyShift action_34
-action_148 (127#) = happyShift action_35
-action_148 (128#) = happyShift action_36
-action_148 (129#) = happyShift action_37
-action_148 (134#) = happyShift action_39
-action_148 (170#) = happyShift action_6
-action_148 (171#) = happyShift action_48
-action_148 (172#) = happyShift action_49
-action_148 (173#) = happyShift action_50
-action_148 (174#) = happyShift action_51
-action_148 (8#) = happyGoto action_10
-action_148 (9#) = happyGoto action_11
-action_148 (10#) = happyGoto action_12
-action_148 (11#) = happyGoto action_13
-action_148 (12#) = happyGoto action_79
-action_148 (58#) = happyGoto action_15
-action_148 (59#) = happyGoto action_134
-action_148 (72#) = happyGoto action_22
-action_148 x = happyTcHack x happyReduce_177
-
-action_149 x = happyTcHack x happyReduce_181
-
-action_150 (96#) = happyShift action_24
-action_150 (98#) = happyShift action_82
-action_150 (104#) = happyShift action_26
-action_150 (109#) = happyShift action_27
-action_150 (110#) = happyShift action_28
-action_150 (111#) = happyShift action_29
-action_150 (125#) = happyShift action_33
-action_150 (126#) = happyShift action_34
-action_150 (127#) = happyShift action_35
-action_150 (128#) = happyShift action_36
-action_150 (129#) = happyShift action_37
-action_150 (134#) = happyShift action_39
-action_150 (170#) = happyShift action_6
-action_150 (171#) = happyShift action_48
-action_150 (172#) = happyShift action_49
-action_150 (173#) = happyShift action_50
-action_150 (174#) = happyShift action_51
-action_150 (8#) = happyGoto action_10
-action_150 (9#) = happyGoto action_11
-action_150 (10#) = happyGoto action_12
-action_150 (11#) = happyGoto action_13
-action_150 (12#) = happyGoto action_79
-action_150 (58#) = happyGoto action_15
-action_150 (59#) = happyGoto action_134
-action_150 (72#) = happyGoto action_22
-action_150 x = happyTcHack x happyReduce_178
-
-action_151 (102#) = happyShift action_129
-action_151 (115#) = happyShift action_130
-action_151 (116#) = happyShift action_131
-action_151 x = happyTcHack x happyReduce_192
-
-action_152 x = happyTcHack x happyReduce_179
-
-action_153 x = happyTcHack x happyReduce_184
-
-action_154 x = happyTcHack x happyReduce_152
-
-action_155 x = happyTcHack x happyReduce_141
-
-action_156 (174#) = happyShift action_51
-action_156 (12#) = happyGoto action_87
-action_156 (53#) = happyGoto action_339
-action_156 x = happyTcHack x happyFail
-
-action_157 (174#) = happyShift action_51
-action_157 (12#) = happyGoto action_338
-action_157 x = happyTcHack x happyFail
-
-action_158 (99#) = happyShift action_337
-action_158 x = happyTcHack x happyReduce_140
-
-action_159 (96#) = happyShift action_24
-action_159 (98#) = happyShift action_25
-action_159 (104#) = happyShift action_26
-action_159 (109#) = happyShift action_27
-action_159 (110#) = happyShift action_28
-action_159 (111#) = happyShift action_29
-action_159 (114#) = happyShift action_30
-action_159 (119#) = happyShift action_31
-action_159 (124#) = happyShift action_32
-action_159 (125#) = happyShift action_33
-action_159 (126#) = happyShift action_34
-action_159 (127#) = happyShift action_35
-action_159 (128#) = happyShift action_36
-action_159 (129#) = happyShift action_37
-action_159 (131#) = happyShift action_38
-action_159 (134#) = happyShift action_39
-action_159 (137#) = happyShift action_40
-action_159 (140#) = happyShift action_41
-action_159 (145#) = happyShift action_42
-action_159 (156#) = happyShift action_43
-action_159 (157#) = happyShift action_44
-action_159 (161#) = happyShift action_45
-action_159 (162#) = happyShift action_46
-action_159 (167#) = happyShift action_47
-action_159 (170#) = happyShift action_6
-action_159 (171#) = happyShift action_48
-action_159 (172#) = happyShift action_49
-action_159 (173#) = happyShift action_50
-action_159 (174#) = happyShift action_51
-action_159 (8#) = happyGoto action_10
-action_159 (9#) = happyGoto action_11
-action_159 (10#) = happyGoto action_12
-action_159 (11#) = happyGoto action_13
-action_159 (12#) = happyGoto action_14
-action_159 (58#) = happyGoto action_15
-action_159 (59#) = happyGoto action_16
-action_159 (60#) = happyGoto action_17
-action_159 (61#) = happyGoto action_18
-action_159 (62#) = happyGoto action_19
-action_159 (63#) = happyGoto action_336
-action_159 (64#) = happyGoto action_21
-action_159 (72#) = happyGoto action_22
-action_159 (77#) = happyGoto action_23
-action_159 x = happyTcHack x happyFail
-
-action_160 x = happyTcHack x happyReduce_156
-
-action_161 (96#) = happyShift action_140
-action_161 (98#) = happyShift action_82
-action_161 (104#) = happyShift action_26
-action_161 (109#) = happyShift action_83
-action_161 (110#) = happyShift action_28
-action_161 (111#) = happyShift action_29
-action_161 (125#) = happyShift action_33
-action_161 (126#) = happyShift action_34
-action_161 (127#) = happyShift action_35
-action_161 (128#) = happyShift action_36
-action_161 (129#) = happyShift action_37
-action_161 (134#) = happyShift action_39
-action_161 (170#) = happyShift action_6
-action_161 (171#) = happyShift action_48
-action_161 (172#) = happyShift action_49
-action_161 (173#) = happyShift action_50
-action_161 (174#) = happyShift action_51
-action_161 (8#) = happyGoto action_10
-action_161 (9#) = happyGoto action_11
-action_161 (10#) = happyGoto action_12
-action_161 (11#) = happyGoto action_13
-action_161 (12#) = happyGoto action_79
-action_161 (58#) = happyGoto action_161
-action_161 (66#) = happyGoto action_335
-action_161 (72#) = happyGoto action_22
-action_161 x = happyTcHack x happyReduce_196
-
-action_162 (105#) = happyShift action_334
-action_162 x = happyTcHack x happyFail
-
-action_163 x = happyTcHack x happyReduce_151
-
-action_164 (174#) = happyShift action_51
-action_164 (12#) = happyGoto action_333
-action_164 x = happyTcHack x happyFail
-
-action_165 x = happyTcHack x happyReduce_142
-
-action_166 x = happyTcHack x happyReduce_153
-
-action_167 (96#) = happyShift action_24
-action_167 (98#) = happyShift action_25
-action_167 (104#) = happyShift action_26
-action_167 (109#) = happyShift action_27
-action_167 (110#) = happyShift action_28
-action_167 (111#) = happyShift action_29
-action_167 (114#) = happyShift action_30
-action_167 (119#) = happyShift action_31
-action_167 (124#) = happyShift action_32
-action_167 (125#) = happyShift action_33
-action_167 (126#) = happyShift action_34
-action_167 (127#) = happyShift action_35
-action_167 (128#) = happyShift action_36
-action_167 (129#) = happyShift action_37
-action_167 (131#) = happyShift action_38
-action_167 (134#) = happyShift action_39
-action_167 (137#) = happyShift action_40
-action_167 (140#) = happyShift action_41
-action_167 (145#) = happyShift action_42
-action_167 (156#) = happyShift action_43
-action_167 (157#) = happyShift action_44
-action_167 (161#) = happyShift action_45
-action_167 (162#) = happyShift action_46
-action_167 (167#) = happyShift action_47
-action_167 (170#) = happyShift action_6
-action_167 (171#) = happyShift action_48
-action_167 (172#) = happyShift action_49
-action_167 (173#) = happyShift action_50
-action_167 (174#) = happyShift action_51
-action_167 (8#) = happyGoto action_10
-action_167 (9#) = happyGoto action_11
-action_167 (10#) = happyGoto action_12
-action_167 (11#) = happyGoto action_13
-action_167 (12#) = happyGoto action_14
-action_167 (58#) = happyGoto action_15
-action_167 (59#) = happyGoto action_16
-action_167 (60#) = happyGoto action_17
-action_167 (61#) = happyGoto action_18
-action_167 (62#) = happyGoto action_19
-action_167 (63#) = happyGoto action_331
-action_167 (64#) = happyGoto action_21
-action_167 (72#) = happyGoto action_22
-action_167 (77#) = happyGoto action_23
-action_167 (78#) = happyGoto action_114
-action_167 (80#) = happyGoto action_332
-action_167 x = happyTcHack x happyReduce_243
-
-action_168 (96#) = happyShift action_24
-action_168 (98#) = happyShift action_25
-action_168 (104#) = happyShift action_26
-action_168 (109#) = happyShift action_27
-action_168 (110#) = happyShift action_28
-action_168 (111#) = happyShift action_29
-action_168 (114#) = happyShift action_30
-action_168 (119#) = happyShift action_31
-action_168 (124#) = happyShift action_32
-action_168 (125#) = happyShift action_33
-action_168 (126#) = happyShift action_34
-action_168 (127#) = happyShift action_35
-action_168 (128#) = happyShift action_36
-action_168 (129#) = happyShift action_37
-action_168 (131#) = happyShift action_38
-action_168 (134#) = happyShift action_39
-action_168 (137#) = happyShift action_40
-action_168 (140#) = happyShift action_41
-action_168 (145#) = happyShift action_42
-action_168 (156#) = happyShift action_43
-action_168 (157#) = happyShift action_44
-action_168 (161#) = happyShift action_45
-action_168 (162#) = happyShift action_46
-action_168 (167#) = happyShift action_47
-action_168 (170#) = happyShift action_6
-action_168 (171#) = happyShift action_48
-action_168 (172#) = happyShift action_49
-action_168 (173#) = happyShift action_50
-action_168 (174#) = happyShift action_51
-action_168 (8#) = happyGoto action_10
-action_168 (9#) = happyGoto action_11
-action_168 (10#) = happyGoto action_12
-action_168 (11#) = happyGoto action_13
-action_168 (12#) = happyGoto action_14
-action_168 (58#) = happyGoto action_15
-action_168 (59#) = happyGoto action_16
-action_168 (60#) = happyGoto action_17
-action_168 (61#) = happyGoto action_18
-action_168 (62#) = happyGoto action_19
-action_168 (63#) = happyGoto action_330
-action_168 (64#) = happyGoto action_21
-action_168 (72#) = happyGoto action_22
-action_168 (77#) = happyGoto action_23
-action_168 x = happyTcHack x happyFail
-
-action_169 (107#) = happyShift action_329
-action_169 x = happyTcHack x happyReduce_200
-
-action_170 (96#) = happyShift action_106
-action_170 (98#) = happyShift action_107
-action_170 (104#) = happyShift action_108
-action_170 (107#) = happyShift action_300
-action_170 (110#) = happyShift action_109
-action_170 (111#) = happyShift action_110
-action_170 (113#) = happyShift action_301
-action_170 (114#) = happyShift action_111
-action_170 (121#) = happyShift action_112
-action_170 (170#) = happyShift action_6
-action_170 (171#) = happyShift action_48
-action_170 (172#) = happyShift action_49
-action_170 (174#) = happyShift action_51
-action_170 (8#) = happyGoto action_101
-action_170 (9#) = happyGoto action_102
-action_170 (10#) = happyGoto action_103
-action_170 (12#) = happyGoto action_104
-action_170 (67#) = happyGoto action_188
-action_170 (74#) = happyGoto action_299
-action_170 x = happyTcHack x happyReduce_203
-
-action_171 (116#) = happyShift action_328
-action_171 x = happyTcHack x happyReduce_217
-
-action_172 x = happyTcHack x happyReduce_220
-
-action_173 (108#) = happyShift action_296
-action_173 (117#) = happyShift action_297
-action_173 x = happyTcHack x happyReduce_242
-
-action_174 (103#) = happyShift action_327
-action_174 x = happyTcHack x happyReduce_247
-
-action_175 (112#) = happyShift action_326
-action_175 x = happyTcHack x happyFail
-
-action_176 (96#) = happyShift action_106
-action_176 (98#) = happyShift action_107
-action_176 (104#) = happyShift action_108
-action_176 (110#) = happyShift action_109
-action_176 (111#) = happyShift action_110
-action_176 (114#) = happyShift action_111
-action_176 (121#) = happyShift action_112
-action_176 (170#) = happyShift action_6
-action_176 (171#) = happyShift action_48
-action_176 (172#) = happyShift action_49
-action_176 (174#) = happyShift action_51
-action_176 (8#) = happyGoto action_101
-action_176 (9#) = happyGoto action_102
-action_176 (10#) = happyGoto action_103
-action_176 (12#) = happyGoto action_104
-action_176 (67#) = happyGoto action_325
-action_176 x = happyTcHack x happyFail
-
-action_177 (105#) = happyShift action_324
-action_177 x = happyTcHack x happyFail
-
-action_178 (99#) = happyShift action_323
-action_178 (108#) = happyShift action_296
-action_178 (117#) = happyShift action_297
-action_178 x = happyTcHack x happyFail
-
-action_179 (97#) = happyShift action_322
-action_179 (103#) = happyShift action_156
-action_179 x = happyTcHack x happyReduce_128
-
-action_180 (95#) = happyShift action_321
-action_180 x = happyTcHack x happyFail
-
-action_181 (94#) = happyShift action_320
-action_181 x = happyTcHack x happyReduce_230
-
-action_182 (97#) = happyShift action_319
-action_182 x = happyTcHack x happyFail
-
-action_183 (174#) = happyShift action_51
-action_183 (12#) = happyGoto action_318
-action_183 x = happyTcHack x happyFail
-
-action_184 (120#) = happyShift action_317
-action_184 x = happyTcHack x happyFail
-
-action_185 (96#) = happyShift action_24
-action_185 (98#) = happyShift action_25
-action_185 (104#) = happyShift action_26
-action_185 (109#) = happyShift action_27
-action_185 (110#) = happyShift action_28
-action_185 (111#) = happyShift action_29
-action_185 (114#) = happyShift action_30
-action_185 (119#) = happyShift action_31
-action_185 (124#) = happyShift action_32
-action_185 (125#) = happyShift action_33
-action_185 (126#) = happyShift action_34
-action_185 (127#) = happyShift action_35
-action_185 (128#) = happyShift action_36
-action_185 (129#) = happyShift action_37
-action_185 (131#) = happyShift action_38
-action_185 (134#) = happyShift action_39
-action_185 (137#) = happyShift action_40
-action_185 (140#) = happyShift action_41
-action_185 (145#) = happyShift action_42
-action_185 (156#) = happyShift action_43
-action_185 (157#) = happyShift action_44
-action_185 (161#) = happyShift action_45
-action_185 (162#) = happyShift action_46
-action_185 (167#) = happyShift action_47
-action_185 (170#) = happyShift action_6
-action_185 (171#) = happyShift action_48
-action_185 (172#) = happyShift action_49
-action_185 (173#) = happyShift action_50
-action_185 (174#) = happyShift action_51
-action_185 (8#) = happyGoto action_10
-action_185 (9#) = happyGoto action_11
-action_185 (10#) = happyGoto action_12
-action_185 (11#) = happyGoto action_13
-action_185 (12#) = happyGoto action_14
-action_185 (58#) = happyGoto action_15
-action_185 (59#) = happyGoto action_16
-action_185 (60#) = happyGoto action_17
-action_185 (61#) = happyGoto action_18
-action_185 (62#) = happyGoto action_19
-action_185 (63#) = happyGoto action_316
-action_185 (64#) = happyGoto action_21
-action_185 (72#) = happyGoto action_22
-action_185 (77#) = happyGoto action_23
-action_185 x = happyTcHack x happyFail
-
-action_186 (121#) = happyShift action_100
-action_186 (174#) = happyShift action_51
-action_186 (12#) = happyGoto action_96
-action_186 (75#) = happyGoto action_97
-action_186 (76#) = happyGoto action_315
-action_186 x = happyTcHack x happyReduce_236
-
-action_187 (96#) = happyShift action_314
-action_187 x = happyTcHack x happyFail
-
-action_188 (96#) = happyShift action_106
-action_188 (98#) = happyShift action_107
-action_188 (104#) = happyShift action_108
-action_188 (110#) = happyShift action_109
-action_188 (111#) = happyShift action_110
-action_188 (114#) = happyShift action_111
-action_188 (121#) = happyShift action_112
-action_188 (170#) = happyShift action_6
-action_188 (171#) = happyShift action_48
-action_188 (172#) = happyShift action_49
-action_188 (174#) = happyShift action_51
-action_188 (8#) = happyGoto action_101
-action_188 (9#) = happyGoto action_102
-action_188 (10#) = happyGoto action_103
-action_188 (12#) = happyGoto action_104
-action_188 (67#) = happyGoto action_188
-action_188 (74#) = happyGoto action_313
-action_188 x = happyTcHack x happyReduce_232
-
-action_189 (101#) = happyShift action_312
-action_189 x = happyTcHack x happyFail
-
-action_190 (94#) = happyShift action_311
-action_190 x = happyTcHack x happyReduce_254
-
-action_191 (97#) = happyShift action_310
-action_191 x = happyTcHack x happyFail
-
-action_192 x = happyTcHack x happyReduce_190
-
-action_193 (97#) = happyShift action_309
-action_193 x = happyTcHack x happyFail
-
-action_194 (96#) = happyShift action_24
-action_194 (98#) = happyShift action_25
-action_194 (104#) = happyShift action_26
-action_194 (109#) = happyShift action_27
-action_194 (110#) = happyShift action_28
-action_194 (111#) = happyShift action_29
-action_194 (114#) = happyShift action_30
-action_194 (119#) = happyShift action_31
-action_194 (124#) = happyShift action_32
-action_194 (125#) = happyShift action_33
-action_194 (126#) = happyShift action_34
-action_194 (127#) = happyShift action_35
-action_194 (128#) = happyShift action_36
-action_194 (129#) = happyShift action_37
-action_194 (131#) = happyShift action_38
-action_194 (134#) = happyShift action_39
-action_194 (137#) = happyShift action_40
-action_194 (140#) = happyShift action_41
-action_194 (145#) = happyShift action_42
-action_194 (156#) = happyShift action_43
-action_194 (157#) = happyShift action_44
-action_194 (161#) = happyShift action_45
-action_194 (162#) = happyShift action_46
-action_194 (167#) = happyShift action_47
-action_194 (170#) = happyShift action_6
-action_194 (171#) = happyShift action_48
-action_194 (172#) = happyShift action_49
-action_194 (173#) = happyShift action_50
-action_194 (174#) = happyShift action_51
-action_194 (8#) = happyGoto action_10
-action_194 (9#) = happyGoto action_11
-action_194 (10#) = happyGoto action_12
-action_194 (11#) = happyGoto action_13
-action_194 (12#) = happyGoto action_14
-action_194 (58#) = happyGoto action_15
-action_194 (59#) = happyGoto action_16
-action_194 (60#) = happyGoto action_17
-action_194 (61#) = happyGoto action_18
-action_194 (62#) = happyGoto action_19
-action_194 (63#) = happyGoto action_308
-action_194 (64#) = happyGoto action_21
-action_194 (72#) = happyGoto action_22
-action_194 (77#) = happyGoto action_23
-action_194 x = happyTcHack x happyFail
-
-action_195 (174#) = happyShift action_51
-action_195 (12#) = happyGoto action_87
-action_195 (53#) = happyGoto action_88
-action_195 (56#) = happyGoto action_89
-action_195 (57#) = happyGoto action_307
-action_195 x = happyTcHack x happyReduce_137
-
-action_196 (96#) = happyShift action_24
-action_196 (98#) = happyShift action_25
-action_196 (104#) = happyShift action_26
-action_196 (109#) = happyShift action_27
-action_196 (110#) = happyShift action_28
-action_196 (111#) = happyShift action_29
-action_196 (114#) = happyShift action_30
-action_196 (119#) = happyShift action_31
-action_196 (124#) = happyShift action_32
-action_196 (125#) = happyShift action_33
-action_196 (126#) = happyShift action_34
-action_196 (127#) = happyShift action_35
-action_196 (128#) = happyShift action_36
-action_196 (129#) = happyShift action_37
-action_196 (131#) = happyShift action_38
-action_196 (134#) = happyShift action_39
-action_196 (137#) = happyShift action_40
-action_196 (140#) = happyShift action_41
-action_196 (145#) = happyShift action_42
-action_196 (156#) = happyShift action_43
-action_196 (157#) = happyShift action_44
-action_196 (161#) = happyShift action_45
-action_196 (162#) = happyShift action_46
-action_196 (167#) = happyShift action_47
-action_196 (170#) = happyShift action_6
-action_196 (171#) = happyShift action_48
-action_196 (172#) = happyShift action_49
-action_196 (173#) = happyShift action_50
-action_196 (174#) = happyShift action_51
-action_196 (8#) = happyGoto action_10
-action_196 (9#) = happyGoto action_11
-action_196 (10#) = happyGoto action_12
-action_196 (11#) = happyGoto action_13
-action_196 (12#) = happyGoto action_14
-action_196 (58#) = happyGoto action_15
-action_196 (59#) = happyGoto action_16
-action_196 (60#) = happyGoto action_17
-action_196 (61#) = happyGoto action_18
-action_196 (62#) = happyGoto action_19
-action_196 (63#) = happyGoto action_306
-action_196 (64#) = happyGoto action_21
-action_196 (72#) = happyGoto action_22
-action_196 (77#) = happyGoto action_23
-action_196 x = happyTcHack x happyFail
-
-action_197 (96#) = happyShift action_24
-action_197 (98#) = happyShift action_25
-action_197 (104#) = happyShift action_26
-action_197 (109#) = happyShift action_27
-action_197 (110#) = happyShift action_28
-action_197 (111#) = happyShift action_29
-action_197 (114#) = happyShift action_30
-action_197 (119#) = happyShift action_31
-action_197 (124#) = happyShift action_32
-action_197 (125#) = happyShift action_33
-action_197 (126#) = happyShift action_34
-action_197 (127#) = happyShift action_35
-action_197 (128#) = happyShift action_36
-action_197 (129#) = happyShift action_37
-action_197 (131#) = happyShift action_38
-action_197 (134#) = happyShift action_39
-action_197 (137#) = happyShift action_40
-action_197 (140#) = happyShift action_41
-action_197 (145#) = happyShift action_42
-action_197 (156#) = happyShift action_43
-action_197 (157#) = happyShift action_44
-action_197 (161#) = happyShift action_45
-action_197 (162#) = happyShift action_46
-action_197 (167#) = happyShift action_47
-action_197 (170#) = happyShift action_6
-action_197 (171#) = happyShift action_48
-action_197 (172#) = happyShift action_49
-action_197 (173#) = happyShift action_50
-action_197 (174#) = happyShift action_51
-action_197 (8#) = happyGoto action_10
-action_197 (9#) = happyGoto action_11
-action_197 (10#) = happyGoto action_12
-action_197 (11#) = happyGoto action_13
-action_197 (12#) = happyGoto action_14
-action_197 (58#) = happyGoto action_15
-action_197 (59#) = happyGoto action_16
-action_197 (60#) = happyGoto action_17
-action_197 (61#) = happyGoto action_18
-action_197 (62#) = happyGoto action_19
-action_197 (63#) = happyGoto action_305
-action_197 (64#) = happyGoto action_21
-action_197 (72#) = happyGoto action_22
-action_197 (77#) = happyGoto action_23
-action_197 x = happyTcHack x happyFail
-
-action_198 (94#) = happyShift action_304
-action_198 x = happyTcHack x happyFail
-
-action_199 (94#) = happyShift action_303
-action_199 x = happyTcHack x happyReduce_194
-
-action_200 (97#) = happyShift action_302
-action_200 x = happyTcHack x happyFail
-
-action_201 (109#) = happyShift action_165
-action_201 x = happyTcHack x happyFail
-
-action_202 (96#) = happyShift action_106
-action_202 (97#) = happyShift action_155
-action_202 (98#) = happyShift action_107
-action_202 (103#) = happyShift action_156
-action_202 (104#) = happyShift action_108
-action_202 (107#) = happyShift action_300
-action_202 (108#) = happyReduce_203
-action_202 (110#) = happyShift action_109
-action_202 (111#) = happyShift action_110
-action_202 (113#) = happyShift action_301
-action_202 (114#) = happyShift action_111
-action_202 (116#) = happyReduce_203
-action_202 (117#) = happyReduce_203
-action_202 (120#) = happyReduce_203
-action_202 (121#) = happyShift action_112
-action_202 (170#) = happyShift action_6
-action_202 (171#) = happyShift action_48
-action_202 (172#) = happyShift action_49
-action_202 (174#) = happyShift action_51
-action_202 (8#) = happyGoto action_101
-action_202 (9#) = happyGoto action_102
-action_202 (10#) = happyGoto action_103
-action_202 (12#) = happyGoto action_104
-action_202 (67#) = happyGoto action_188
-action_202 (74#) = happyGoto action_299
-action_202 x = happyTcHack x happyReduce_128
-
-action_203 (108#) = happyShift action_296
-action_203 (117#) = happyShift action_297
-action_203 (120#) = happyShift action_298
-action_203 x = happyTcHack x happyFail
-
-action_204 (94#) = happyShift action_295
-action_204 x = happyTcHack x happyReduce_250
-
-action_205 (97#) = happyShift action_294
-action_205 x = happyTcHack x happyFail
-
-action_206 (96#) = happyShift action_106
-action_206 (98#) = happyShift action_107
-action_206 (104#) = happyShift action_108
-action_206 (106#) = happyShift action_176
-action_206 (110#) = happyShift action_109
-action_206 (111#) = happyShift action_110
-action_206 (114#) = happyShift action_111
-action_206 (121#) = happyShift action_112
-action_206 (170#) = happyShift action_6
-action_206 (171#) = happyShift action_48
-action_206 (172#) = happyShift action_49
-action_206 (174#) = happyShift action_51
-action_206 (8#) = happyGoto action_101
-action_206 (9#) = happyGoto action_102
-action_206 (10#) = happyGoto action_103
-action_206 (12#) = happyGoto action_170
-action_206 (67#) = happyGoto action_171
-action_206 (68#) = happyGoto action_172
-action_206 (69#) = happyGoto action_203
-action_206 (82#) = happyGoto action_204
-action_206 (83#) = happyGoto action_293
-action_206 x = happyTcHack x happyFail
-
-action_207 (96#) = happyShift action_24
-action_207 (98#) = happyShift action_25
-action_207 (104#) = happyShift action_26
-action_207 (109#) = happyShift action_27
-action_207 (110#) = happyShift action_28
-action_207 (111#) = happyShift action_29
-action_207 (114#) = happyShift action_30
-action_207 (119#) = happyShift action_31
-action_207 (124#) = happyShift action_32
-action_207 (125#) = happyShift action_33
-action_207 (126#) = happyShift action_34
-action_207 (127#) = happyShift action_35
-action_207 (128#) = happyShift action_36
-action_207 (129#) = happyShift action_37
-action_207 (131#) = happyShift action_38
-action_207 (134#) = happyShift action_39
-action_207 (137#) = happyShift action_40
-action_207 (140#) = happyShift action_41
-action_207 (145#) = happyShift action_42
-action_207 (156#) = happyShift action_43
-action_207 (157#) = happyShift action_44
-action_207 (161#) = happyShift action_45
-action_207 (162#) = happyShift action_46
-action_207 (167#) = happyShift action_47
-action_207 (170#) = happyShift action_6
-action_207 (171#) = happyShift action_48
-action_207 (172#) = happyShift action_49
-action_207 (173#) = happyShift action_50
-action_207 (174#) = happyShift action_51
-action_207 (8#) = happyGoto action_10
-action_207 (9#) = happyGoto action_11
-action_207 (10#) = happyGoto action_12
-action_207 (11#) = happyGoto action_13
-action_207 (12#) = happyGoto action_14
-action_207 (58#) = happyGoto action_15
-action_207 (59#) = happyGoto action_16
-action_207 (60#) = happyGoto action_17
-action_207 (61#) = happyGoto action_18
-action_207 (62#) = happyGoto action_19
-action_207 (63#) = happyGoto action_199
-action_207 (64#) = happyGoto action_21
-action_207 (65#) = happyGoto action_292
-action_207 (72#) = happyGoto action_22
-action_207 (77#) = happyGoto action_23
-action_207 x = happyTcHack x happyReduce_193
-
-action_208 (97#) = happyShift action_291
-action_208 x = happyTcHack x happyFail
-
-action_209 x = happyTcHack x happyReduce_49
-
-action_210 (104#) = happyShift action_290
-action_210 (174#) = happyShift action_51
-action_210 (12#) = happyGoto action_287
-action_210 (36#) = happyGoto action_288
-action_210 (46#) = happyGoto action_289
-action_210 x = happyTcHack x happyFail
-
-action_211 (174#) = happyShift action_51
-action_211 (12#) = happyGoto action_283
-action_211 (37#) = happyGoto action_276
-action_211 (38#) = happyGoto action_284
-action_211 (47#) = happyGoto action_285
-action_211 (48#) = happyGoto action_286
-action_211 (53#) = happyGoto action_278
-action_211 x = happyTcHack x happyFail
-
-action_212 (104#) = happyShift action_257
-action_212 (174#) = happyShift action_51
-action_212 (12#) = happyGoto action_252
-action_212 (34#) = happyGoto action_253
-action_212 (45#) = happyGoto action_282
-action_212 (54#) = happyGoto action_255
-action_212 (55#) = happyGoto action_256
-action_212 x = happyTcHack x happyFail
-
-action_213 (174#) = happyShift action_51
-action_213 (12#) = happyGoto action_279
-action_213 (44#) = happyGoto action_280
-action_213 (51#) = happyGoto action_281
-action_213 x = happyTcHack x happyFail
-
-action_214 (174#) = happyShift action_51
-action_214 (12#) = happyGoto action_87
-action_214 (37#) = happyGoto action_276
-action_214 (47#) = happyGoto action_277
-action_214 (53#) = happyGoto action_278
-action_214 x = happyTcHack x happyFail
-
-action_215 (104#) = happyShift action_257
-action_215 (174#) = happyShift action_51
-action_215 (12#) = happyGoto action_252
-action_215 (34#) = happyGoto action_253
-action_215 (45#) = happyGoto action_275
-action_215 (54#) = happyGoto action_255
-action_215 (55#) = happyGoto action_256
-action_215 x = happyTcHack x happyFail
-
-action_216 (104#) = happyShift action_257
-action_216 (174#) = happyShift action_51
-action_216 (12#) = happyGoto action_252
-action_216 (43#) = happyGoto action_260
-action_216 (50#) = happyGoto action_274
-action_216 (54#) = happyGoto action_262
-action_216 (55#) = happyGoto action_263
-action_216 x = happyTcHack x happyFail
-
-action_217 (104#) = happyShift action_257
-action_217 (174#) = happyShift action_51
-action_217 (12#) = happyGoto action_252
-action_217 (34#) = happyGoto action_253
-action_217 (45#) = happyGoto action_273
-action_217 (54#) = happyGoto action_255
-action_217 (55#) = happyGoto action_256
-action_217 x = happyTcHack x happyFail
-
-action_218 (104#) = happyShift action_257
-action_218 (174#) = happyShift action_51
-action_218 (12#) = happyGoto action_252
-action_218 (34#) = happyGoto action_253
-action_218 (45#) = happyGoto action_272
-action_218 (54#) = happyGoto action_255
-action_218 (55#) = happyGoto action_256
-action_218 x = happyTcHack x happyFail
-
-action_219 (104#) = happyShift action_257
-action_219 (174#) = happyShift action_51
-action_219 (12#) = happyGoto action_252
-action_219 (34#) = happyGoto action_253
-action_219 (45#) = happyGoto action_271
-action_219 (54#) = happyGoto action_255
-action_219 (55#) = happyGoto action_256
-action_219 x = happyTcHack x happyFail
-
-action_220 (174#) = happyShift action_51
-action_220 (12#) = happyGoto action_270
-action_220 x = happyTcHack x happyFail
-
-action_221 (174#) = happyShift action_51
-action_221 (12#) = happyGoto action_267
-action_221 (41#) = happyGoto action_268
-action_221 (49#) = happyGoto action_269
-action_221 x = happyTcHack x happyFail
-
-action_222 (104#) = happyShift action_257
-action_222 (174#) = happyShift action_51
-action_222 (12#) = happyGoto action_252
-action_222 (34#) = happyGoto action_253
-action_222 (45#) = happyGoto action_266
-action_222 (54#) = happyGoto action_255
-action_222 (55#) = happyGoto action_256
-action_222 x = happyTcHack x happyFail
-
-action_223 (104#) = happyShift action_257
-action_223 (132#) = happyShift action_264
-action_223 (138#) = happyShift action_265
-action_223 (174#) = happyShift action_51
-action_223 (12#) = happyGoto action_252
-action_223 (43#) = happyGoto action_260
-action_223 (50#) = happyGoto action_261
-action_223 (54#) = happyGoto action_262
-action_223 (55#) = happyGoto action_263
-action_223 x = happyTcHack x happyFail
-
-action_224 (174#) = happyShift action_51
-action_224 (12#) = happyGoto action_259
-action_224 x = happyTcHack x happyFail
-
-action_225 (104#) = happyShift action_257
-action_225 (174#) = happyShift action_51
-action_225 (12#) = happyGoto action_252
-action_225 (34#) = happyGoto action_253
-action_225 (45#) = happyGoto action_258
-action_225 (54#) = happyGoto action_255
-action_225 (55#) = happyGoto action_256
-action_225 x = happyTcHack x happyFail
-
-action_226 (104#) = happyShift action_257
-action_226 (174#) = happyShift action_51
-action_226 (12#) = happyGoto action_252
-action_226 (34#) = happyGoto action_253
-action_226 (45#) = happyGoto action_254
-action_226 (54#) = happyGoto action_255
-action_226 (55#) = happyGoto action_256
-action_226 x = happyTcHack x happyFail
-
-action_227 x = happyTcHack x happyReduce_269
-
-action_228 x = happyTcHack x happyReduce_270
-
-action_229 x = happyTcHack x happyReduce_271
-
-action_230 (106#) = happyShift action_74
-action_230 (107#) = happyShift action_75
-action_230 (123#) = happyShift action_76
-action_230 (171#) = happyShift action_48
-action_230 (174#) = happyShift action_51
-action_230 (9#) = happyGoto action_70
-action_230 (12#) = happyGoto action_71
-action_230 (92#) = happyGoto action_72
-action_230 (93#) = happyGoto action_251
-action_230 x = happyTcHack x happyReduce_273
-
-action_231 x = happyTcHack x happyReduce_272
-
-action_232 (100#) = happyShift action_250
-action_232 x = happyTcHack x happyFail
-
-action_233 x = happyTcHack x happyReduce_35
-
-action_234 x = happyTcHack x happyReduce_36
-
-action_235 (150#) = happyShift action_249
-action_235 x = happyTcHack x happyFail
-
-action_236 (150#) = happyShift action_248
-action_236 x = happyTcHack x happyFail
-
-action_237 x = happyTcHack x happyReduce_34
-
-action_238 (96#) = happyReduce_51
-action_238 (151#) = happyReduce_51
-action_238 (160#) = happyShift action_246
-action_238 (165#) = happyShift action_247
-action_238 (174#) = happyShift action_51
-action_238 (12#) = happyGoto action_241
-action_238 (24#) = happyGoto action_242
-action_238 (26#) = happyGoto action_243
-action_238 (32#) = happyGoto action_244
-action_238 (33#) = happyGoto action_245
-action_238 x = happyTcHack x happyReduce_65
-
-action_239 (96#) = happyShift action_240
-action_239 x = happyTcHack x happyFail
-
-action_240 (130#) = happyShift action_418
-action_240 x = happyTcHack x happyFail
-
-action_241 (104#) = happyShift action_416
-action_241 (106#) = happyShift action_417
-action_241 x = happyTcHack x happyReduce_68
-
-action_242 x = happyTcHack x happyReduce_15
-
-action_243 (151#) = happyShift action_356
-action_243 (28#) = happyGoto action_415
-action_243 x = happyTcHack x happyReduce_55
-
-action_244 (102#) = happyShift action_414
-action_244 x = happyTcHack x happyReduce_41
-
-action_245 (103#) = happyShift action_352
-action_245 (169#) = happyShift action_413
-action_245 x = happyTcHack x happyReduce_66
-
-action_246 (174#) = happyShift action_51
-action_246 (12#) = happyGoto action_412
-action_246 x = happyTcHack x happyFail
-
-action_247 (174#) = happyShift action_51
-action_247 (12#) = happyGoto action_241
-action_247 (32#) = happyGoto action_411
-action_247 (33#) = happyGoto action_350
-action_247 x = happyTcHack x happyReduce_65
-
-action_248 (174#) = happyShift action_51
-action_248 (12#) = happyGoto action_410
-action_248 x = happyTcHack x happyFail
-
-action_249 (174#) = happyShift action_51
-action_249 (12#) = happyGoto action_409
-action_249 x = happyTcHack x happyFail
-
-action_250 (98#) = happyShift action_408
-action_250 (174#) = happyShift action_51
-action_250 (12#) = happyGoto action_406
-action_250 (29#) = happyGoto action_407
-action_250 x = happyTcHack x happyFail
-
-action_251 x = happyTcHack x happyReduce_274
-
-action_252 x = happyTcHack x happyReduce_130
-
-action_253 (94#) = happyShift action_405
-action_253 x = happyTcHack x happyFail
-
-action_254 x = happyTcHack x happyReduce_93
-
-action_255 (96#) = happyShift action_106
-action_255 (98#) = happyShift action_107
-action_255 (103#) = happyShift action_398
-action_255 (104#) = happyShift action_108
-action_255 (110#) = happyShift action_109
-action_255 (111#) = happyShift action_110
-action_255 (114#) = happyShift action_111
-action_255 (121#) = happyShift action_112
-action_255 (170#) = happyShift action_6
-action_255 (171#) = happyShift action_48
-action_255 (172#) = happyShift action_49
-action_255 (174#) = happyShift action_51
-action_255 (8#) = happyGoto action_101
-action_255 (9#) = happyGoto action_102
-action_255 (10#) = happyGoto action_103
-action_255 (12#) = happyGoto action_104
-action_255 (67#) = happyGoto action_188
-action_255 (74#) = happyGoto action_404
-action_255 x = happyTcHack x happyReduce_132
-
-action_256 (95#) = happyShift action_402
-action_256 (100#) = happyShift action_403
-action_256 x = happyTcHack x happyFail
-
-action_257 (174#) = happyShift action_51
-action_257 (12#) = happyGoto action_401
-action_257 x = happyTcHack x happyFail
-
-action_258 x = happyTcHack x happyReduce_80
-
-action_259 (94#) = happyShift action_400
-action_259 x = happyTcHack x happyFail
-
-action_260 (94#) = happyShift action_399
-action_260 x = happyTcHack x happyFail
-
-action_261 x = happyTcHack x happyReduce_89
-
-action_262 (103#) = happyShift action_398
-action_262 x = happyTcHack x happyReduce_132
-
-action_263 (95#) = happyShift action_397
-action_263 x = happyTcHack x happyFail
-
-action_264 (104#) = happyShift action_257
-action_264 (174#) = happyShift action_51
-action_264 (12#) = happyGoto action_252
-action_264 (43#) = happyGoto action_260
-action_264 (50#) = happyGoto action_396
-action_264 (54#) = happyGoto action_262
-action_264 (55#) = happyGoto action_263
-action_264 x = happyTcHack x happyFail
-
-action_265 (104#) = happyShift action_257
-action_265 (174#) = happyShift action_51
-action_265 (12#) = happyGoto action_252
-action_265 (43#) = happyGoto action_260
-action_265 (50#) = happyGoto action_395
-action_265 (54#) = happyGoto action_262
-action_265 (55#) = happyGoto action_263
-action_265 x = happyTcHack x happyFail
-
-action_266 x = happyTcHack x happyReduce_91
-
-action_267 (95#) = happyShift action_394
-action_267 x = happyTcHack x happyReduce_107
-
-action_268 (94#) = happyShift action_393
-action_268 x = happyTcHack x happyFail
-
-action_269 x = happyTcHack x happyReduce_81
-
-action_270 (95#) = happyShift action_392
-action_270 x = happyTcHack x happyFail
-
-action_271 x = happyTcHack x happyReduce_82
-
-action_272 x = happyTcHack x happyReduce_90
-
-action_273 x = happyTcHack x happyReduce_84
-
-action_274 x = happyTcHack x happyReduce_83
-
-action_275 x = happyTcHack x happyReduce_85
-
-action_276 (94#) = happyShift action_391
-action_276 x = happyTcHack x happyFail
-
-action_277 x = happyTcHack x happyReduce_76
-
-action_278 (100#) = happyShift action_390
-action_278 x = happyTcHack x happyFail
-
-action_279 (95#) = happyShift action_389
-action_279 x = happyTcHack x happyFail
-
-action_280 (94#) = happyShift action_388
-action_280 x = happyTcHack x happyFail
-
-action_281 x = happyTcHack x happyReduce_88
-
-action_282 x = happyTcHack x happyReduce_78
-
-action_283 (95#) = happyShift action_387
-action_283 (103#) = happyShift action_156
-action_283 x = happyTcHack x happyReduce_128
-
-action_284 (94#) = happyShift action_386
-action_284 x = happyTcHack x happyFail
-
-action_285 x = happyTcHack x happyReduce_77
-
-action_286 x = happyTcHack x happyReduce_79
-
-action_287 (89#) = happyGoto action_385
-action_287 x = happyTcHack x happyReduce_262
-
-action_288 (94#) = happyShift action_384
-action_288 x = happyTcHack x happyFail
-
-action_289 x = happyTcHack x happyReduce_75
-
-action_290 (174#) = happyShift action_51
-action_290 (12#) = happyGoto action_383
-action_290 x = happyTcHack x happyFail
-
-action_291 x = happyTcHack x happyReduce_167
-
-action_292 (105#) = happyShift action_382
-action_292 x = happyTcHack x happyFail
-
-action_293 (97#) = happyShift action_381
-action_293 x = happyTcHack x happyFail
-
-action_294 x = happyTcHack x happyReduce_163
-
-action_295 (96#) = happyShift action_106
-action_295 (98#) = happyShift action_107
-action_295 (104#) = happyShift action_108
-action_295 (106#) = happyShift action_176
-action_295 (110#) = happyShift action_109
-action_295 (111#) = happyShift action_110
-action_295 (114#) = happyShift action_111
-action_295 (121#) = happyShift action_112
-action_295 (170#) = happyShift action_6
-action_295 (171#) = happyShift action_48
-action_295 (172#) = happyShift action_49
-action_295 (174#) = happyShift action_51
-action_295 (8#) = happyGoto action_101
-action_295 (9#) = happyGoto action_102
-action_295 (10#) = happyGoto action_103
-action_295 (12#) = happyGoto action_170
-action_295 (67#) = happyGoto action_171
-action_295 (68#) = happyGoto action_172
-action_295 (69#) = happyGoto action_203
-action_295 (82#) = happyGoto action_204
-action_295 (83#) = happyGoto action_380
-action_295 x = happyTcHack x happyFail
-
-action_296 (96#) = happyShift action_106
-action_296 (98#) = happyShift action_107
-action_296 (104#) = happyShift action_108
-action_296 (106#) = happyShift action_176
-action_296 (110#) = happyShift action_109
-action_296 (111#) = happyShift action_110
-action_296 (114#) = happyShift action_111
-action_296 (121#) = happyShift action_112
-action_296 (170#) = happyShift action_6
-action_296 (171#) = happyShift action_48
-action_296 (172#) = happyShift action_49
-action_296 (174#) = happyShift action_51
-action_296 (8#) = happyGoto action_101
-action_296 (9#) = happyGoto action_102
-action_296 (10#) = happyGoto action_103
-action_296 (12#) = happyGoto action_170
-action_296 (67#) = happyGoto action_171
-action_296 (68#) = happyGoto action_379
-action_296 x = happyTcHack x happyFail
-
-action_297 (96#) = happyShift action_106
-action_297 (98#) = happyShift action_107
-action_297 (104#) = happyShift action_108
-action_297 (106#) = happyShift action_176
-action_297 (110#) = happyShift action_109
-action_297 (111#) = happyShift action_110
-action_297 (114#) = happyShift action_111
-action_297 (121#) = happyShift action_112
-action_297 (170#) = happyShift action_6
-action_297 (171#) = happyShift action_48
-action_297 (172#) = happyShift action_49
-action_297 (174#) = happyShift action_51
-action_297 (8#) = happyGoto action_101
-action_297 (9#) = happyGoto action_102
-action_297 (10#) = happyGoto action_103
-action_297 (12#) = happyGoto action_170
-action_297 (67#) = happyGoto action_171
-action_297 (68#) = happyGoto action_378
-action_297 x = happyTcHack x happyFail
-
-action_298 (96#) = happyShift action_24
-action_298 (98#) = happyShift action_25
-action_298 (104#) = happyShift action_26
-action_298 (109#) = happyShift action_27
-action_298 (110#) = happyShift action_28
-action_298 (111#) = happyShift action_29
-action_298 (114#) = happyShift action_30
-action_298 (119#) = happyShift action_31
-action_298 (124#) = happyShift action_32
-action_298 (125#) = happyShift action_33
-action_298 (126#) = happyShift action_34
-action_298 (127#) = happyShift action_35
-action_298 (128#) = happyShift action_36
-action_298 (129#) = happyShift action_37
-action_298 (131#) = happyShift action_38
-action_298 (134#) = happyShift action_39
-action_298 (137#) = happyShift action_40
-action_298 (140#) = happyShift action_41
-action_298 (145#) = happyShift action_42
-action_298 (156#) = happyShift action_43
-action_298 (157#) = happyShift action_44
-action_298 (161#) = happyShift action_45
-action_298 (162#) = happyShift action_46
-action_298 (167#) = happyShift action_47
-action_298 (170#) = happyShift action_6
-action_298 (171#) = happyShift action_48
-action_298 (172#) = happyShift action_49
-action_298 (173#) = happyShift action_50
-action_298 (174#) = happyShift action_51
-action_298 (8#) = happyGoto action_10
-action_298 (9#) = happyGoto action_11
-action_298 (10#) = happyGoto action_12
-action_298 (11#) = happyGoto action_13
-action_298 (12#) = happyGoto action_14
-action_298 (58#) = happyGoto action_15
-action_298 (59#) = happyGoto action_16
-action_298 (60#) = happyGoto action_17
-action_298 (61#) = happyGoto action_18
-action_298 (62#) = happyGoto action_19
-action_298 (63#) = happyGoto action_377
-action_298 (64#) = happyGoto action_21
-action_298 (72#) = happyGoto action_22
-action_298 (77#) = happyGoto action_23
-action_298 x = happyTcHack x happyFail
-
-action_299 x = happyTcHack x happyReduce_212
-
-action_300 (174#) = happyShift action_51
-action_300 (12#) = happyGoto action_376
-action_300 x = happyTcHack x happyFail
-
-action_301 (96#) = happyShift action_106
-action_301 (98#) = happyShift action_107
-action_301 (104#) = happyShift action_108
-action_301 (110#) = happyShift action_109
-action_301 (111#) = happyShift action_110
-action_301 (114#) = happyShift action_111
-action_301 (121#) = happyShift action_112
-action_301 (170#) = happyShift action_6
-action_301 (171#) = happyShift action_48
-action_301 (172#) = happyShift action_49
-action_301 (174#) = happyShift action_51
-action_301 (8#) = happyGoto action_101
-action_301 (9#) = happyGoto action_102
-action_301 (10#) = happyGoto action_103
-action_301 (12#) = happyGoto action_104
-action_301 (67#) = happyGoto action_375
-action_301 x = happyTcHack x happyFail
-
-action_302 x = happyTcHack x happyReduce_169
-
-action_303 (96#) = happyShift action_24
-action_303 (98#) = happyShift action_25
-action_303 (104#) = happyShift action_26
-action_303 (109#) = happyShift action_27
-action_303 (110#) = happyShift action_28
-action_303 (111#) = happyShift action_29
-action_303 (114#) = happyShift action_30
-action_303 (119#) = happyShift action_31
-action_303 (124#) = happyShift action_32
-action_303 (125#) = happyShift action_33
-action_303 (126#) = happyShift action_34
-action_303 (127#) = happyShift action_35
-action_303 (128#) = happyShift action_36
-action_303 (129#) = happyShift action_37
-action_303 (131#) = happyShift action_38
-action_303 (134#) = happyShift action_39
-action_303 (137#) = happyShift action_40
-action_303 (140#) = happyShift action_41
-action_303 (145#) = happyShift action_42
-action_303 (156#) = happyShift action_43
-action_303 (157#) = happyShift action_44
-action_303 (161#) = happyShift action_45
-action_303 (162#) = happyShift action_46
-action_303 (167#) = happyShift action_47
-action_303 (170#) = happyShift action_6
-action_303 (171#) = happyShift action_48
-action_303 (172#) = happyShift action_49
-action_303 (173#) = happyShift action_50
-action_303 (174#) = happyShift action_51
-action_303 (8#) = happyGoto action_10
-action_303 (9#) = happyGoto action_11
-action_303 (10#) = happyGoto action_12
-action_303 (11#) = happyGoto action_13
-action_303 (12#) = happyGoto action_14
-action_303 (58#) = happyGoto action_15
-action_303 (59#) = happyGoto action_16
-action_303 (60#) = happyGoto action_17
-action_303 (61#) = happyGoto action_18
-action_303 (62#) = happyGoto action_19
-action_303 (63#) = happyGoto action_199
-action_303 (64#) = happyGoto action_21
-action_303 (65#) = happyGoto action_374
-action_303 (72#) = happyGoto action_22
-action_303 (77#) = happyGoto action_23
-action_303 x = happyTcHack x happyReduce_193
-
-action_304 (96#) = happyShift action_24
-action_304 (98#) = happyShift action_25
-action_304 (104#) = happyShift action_26
-action_304 (109#) = happyShift action_27
-action_304 (110#) = happyShift action_28
-action_304 (111#) = happyShift action_29
-action_304 (114#) = happyShift action_30
-action_304 (119#) = happyShift action_31
-action_304 (124#) = happyShift action_32
-action_304 (125#) = happyShift action_33
-action_304 (126#) = happyShift action_34
-action_304 (127#) = happyShift action_35
-action_304 (128#) = happyShift action_36
-action_304 (129#) = happyShift action_37
-action_304 (131#) = happyShift action_38
-action_304 (134#) = happyShift action_39
-action_304 (137#) = happyShift action_40
-action_304 (140#) = happyShift action_41
-action_304 (145#) = happyShift action_42
-action_304 (156#) = happyShift action_43
-action_304 (157#) = happyShift action_44
-action_304 (161#) = happyShift action_45
-action_304 (162#) = happyShift action_46
-action_304 (167#) = happyShift action_47
-action_304 (170#) = happyShift action_6
-action_304 (171#) = happyShift action_48
-action_304 (172#) = happyShift action_49
-action_304 (173#) = happyShift action_50
-action_304 (174#) = happyShift action_51
-action_304 (8#) = happyGoto action_10
-action_304 (9#) = happyGoto action_11
-action_304 (10#) = happyGoto action_12
-action_304 (11#) = happyGoto action_13
-action_304 (12#) = happyGoto action_14
-action_304 (58#) = happyGoto action_15
-action_304 (59#) = happyGoto action_16
-action_304 (60#) = happyGoto action_17
-action_304 (61#) = happyGoto action_18
-action_304 (62#) = happyGoto action_19
-action_304 (63#) = happyGoto action_371
-action_304 (64#) = happyGoto action_21
-action_304 (72#) = happyGoto action_22
-action_304 (77#) = happyGoto action_23
-action_304 (86#) = happyGoto action_372
-action_304 (87#) = happyGoto action_373
-action_304 x = happyTcHack x happyReduce_257
-
-action_305 (95#) = happyShift action_370
-action_305 x = happyTcHack x happyReduce_134
-
-action_306 x = happyTcHack x happyReduce_135
-
-action_307 x = happyTcHack x happyReduce_139
-
-action_308 x = happyTcHack x happyReduce_187
-
-action_309 (140#) = happyShift action_369
-action_309 x = happyTcHack x happyFail
-
-action_310 x = happyTcHack x happyReduce_189
-
-action_311 (96#) = happyShift action_106
-action_311 (98#) = happyShift action_107
-action_311 (104#) = happyShift action_108
-action_311 (110#) = happyShift action_109
-action_311 (111#) = happyShift action_110
-action_311 (114#) = happyShift action_111
-action_311 (121#) = happyShift action_112
-action_311 (170#) = happyShift action_6
-action_311 (171#) = happyShift action_48
-action_311 (172#) = happyShift action_49
-action_311 (174#) = happyShift action_51
-action_311 (8#) = happyGoto action_101
-action_311 (9#) = happyGoto action_102
-action_311 (10#) = happyGoto action_103
-action_311 (12#) = happyGoto action_104
-action_311 (67#) = happyGoto action_188
-action_311 (74#) = happyGoto action_189
-action_311 (84#) = happyGoto action_190
-action_311 (85#) = happyGoto action_368
-action_311 x = happyTcHack x happyReduce_253
-
-action_312 (96#) = happyShift action_24
-action_312 (98#) = happyShift action_25
-action_312 (104#) = happyShift action_26
-action_312 (109#) = happyShift action_27
-action_312 (110#) = happyShift action_28
-action_312 (111#) = happyShift action_29
-action_312 (114#) = happyShift action_30
-action_312 (119#) = happyShift action_31
-action_312 (124#) = happyShift action_32
-action_312 (125#) = happyShift action_33
-action_312 (126#) = happyShift action_34
-action_312 (127#) = happyShift action_35
-action_312 (128#) = happyShift action_36
-action_312 (129#) = happyShift action_37
-action_312 (131#) = happyShift action_38
-action_312 (134#) = happyShift action_39
-action_312 (137#) = happyShift action_40
-action_312 (140#) = happyShift action_41
-action_312 (145#) = happyShift action_42
-action_312 (156#) = happyShift action_43
-action_312 (157#) = happyShift action_44
-action_312 (161#) = happyShift action_45
-action_312 (162#) = happyShift action_46
-action_312 (167#) = happyShift action_47
-action_312 (170#) = happyShift action_6
-action_312 (171#) = happyShift action_48
-action_312 (172#) = happyShift action_49
-action_312 (173#) = happyShift action_50
-action_312 (174#) = happyShift action_51
-action_312 (8#) = happyGoto action_10
-action_312 (9#) = happyGoto action_11
-action_312 (10#) = happyGoto action_12
-action_312 (11#) = happyGoto action_13
-action_312 (12#) = happyGoto action_14
-action_312 (58#) = happyGoto action_15
-action_312 (59#) = happyGoto action_16
-action_312 (60#) = happyGoto action_17
-action_312 (61#) = happyGoto action_18
-action_312 (62#) = happyGoto action_19
-action_312 (63#) = happyGoto action_367
-action_312 (64#) = happyGoto action_21
-action_312 (72#) = happyGoto action_22
-action_312 (77#) = happyGoto action_23
-action_312 x = happyTcHack x happyFail
-
-action_313 x = happyTcHack x happyReduce_233
-
-action_314 (96#) = happyShift action_106
-action_314 (98#) = happyShift action_107
-action_314 (104#) = happyShift action_108
-action_314 (106#) = happyShift action_176
-action_314 (110#) = happyShift action_109
-action_314 (111#) = happyShift action_110
-action_314 (114#) = happyShift action_111
-action_314 (121#) = happyShift action_112
-action_314 (170#) = happyShift action_6
-action_314 (171#) = happyShift action_48
-action_314 (172#) = happyShift action_49
-action_314 (174#) = happyShift action_51
-action_314 (8#) = happyGoto action_101
-action_314 (9#) = happyGoto action_102
-action_314 (10#) = happyGoto action_103
-action_314 (12#) = happyGoto action_170
-action_314 (67#) = happyGoto action_171
-action_314 (68#) = happyGoto action_172
-action_314 (69#) = happyGoto action_203
-action_314 (82#) = happyGoto action_204
-action_314 (83#) = happyGoto action_366
-action_314 x = happyTcHack x happyFail
-
-action_315 x = happyTcHack x happyReduce_238
-
-action_316 x = happyTcHack x happyReduce_182
-
-action_317 (96#) = happyShift action_24
-action_317 (98#) = happyShift action_25
-action_317 (104#) = happyShift action_26
-action_317 (109#) = happyShift action_27
-action_317 (110#) = happyShift action_28
-action_317 (111#) = happyShift action_29
-action_317 (114#) = happyShift action_30
-action_317 (119#) = happyShift action_31
-action_317 (124#) = happyShift action_32
-action_317 (125#) = happyShift action_33
-action_317 (126#) = happyShift action_34
-action_317 (127#) = happyShift action_35
-action_317 (128#) = happyShift action_36
-action_317 (129#) = happyShift action_37
-action_317 (131#) = happyShift action_38
-action_317 (134#) = happyShift action_39
-action_317 (137#) = happyShift action_40
-action_317 (140#) = happyShift action_41
-action_317 (145#) = happyShift action_42
-action_317 (156#) = happyShift action_43
-action_317 (157#) = happyShift action_44
-action_317 (161#) = happyShift action_45
-action_317 (162#) = happyShift action_46
-action_317 (167#) = happyShift action_47
-action_317 (170#) = happyShift action_6
-action_317 (171#) = happyShift action_48
-action_317 (172#) = happyShift action_49
-action_317 (173#) = happyShift action_50
-action_317 (174#) = happyShift action_51
-action_317 (8#) = happyGoto action_10
-action_317 (9#) = happyGoto action_11
-action_317 (10#) = happyGoto action_12
-action_317 (11#) = happyGoto action_13
-action_317 (12#) = happyGoto action_14
-action_317 (58#) = happyGoto action_15
-action_317 (59#) = happyGoto action_16
-action_317 (60#) = happyGoto action_17
-action_317 (61#) = happyGoto action_18
-action_317 (62#) = happyGoto action_19
-action_317 (63#) = happyGoto action_365
-action_317 (64#) = happyGoto action_21
-action_317 (72#) = happyGoto action_22
-action_317 (77#) = happyGoto action_23
-action_317 x = happyTcHack x happyFail
-
-action_318 x = happyTcHack x happyReduce_205
-
-action_319 x = happyTcHack x happyReduce_209
-
-action_320 (174#) = happyShift action_51
-action_320 (12#) = happyGoto action_87
-action_320 (53#) = happyGoto action_180
-action_320 (70#) = happyGoto action_181
-action_320 (73#) = happyGoto action_364
-action_320 x = happyTcHack x happyReduce_229
-
-action_321 (96#) = happyShift action_106
-action_321 (98#) = happyShift action_107
-action_321 (104#) = happyShift action_108
-action_321 (106#) = happyShift action_176
-action_321 (110#) = happyShift action_109
-action_321 (111#) = happyShift action_110
-action_321 (114#) = happyShift action_111
-action_321 (121#) = happyShift action_112
-action_321 (170#) = happyShift action_6
-action_321 (171#) = happyShift action_48
-action_321 (172#) = happyShift action_49
-action_321 (174#) = happyShift action_51
-action_321 (8#) = happyGoto action_101
-action_321 (9#) = happyGoto action_102
-action_321 (10#) = happyGoto action_103
-action_321 (12#) = happyGoto action_170
-action_321 (67#) = happyGoto action_171
-action_321 (68#) = happyGoto action_172
-action_321 (69#) = happyGoto action_363
-action_321 x = happyTcHack x happyFail
-
-action_322 x = happyTcHack x happyReduce_204
-
-action_323 x = happyTcHack x happyReduce_211
-
-action_324 x = happyTcHack x happyReduce_199
-
-action_325 x = happyTcHack x happyReduce_216
-
-action_326 x = happyTcHack x happyReduce_210
-
-action_327 (96#) = happyShift action_106
-action_327 (98#) = happyShift action_107
-action_327 (104#) = happyShift action_108
-action_327 (106#) = happyShift action_176
-action_327 (110#) = happyShift action_109
-action_327 (111#) = happyShift action_110
-action_327 (114#) = happyShift action_111
-action_327 (121#) = happyShift action_112
-action_327 (170#) = happyShift action_6
-action_327 (171#) = happyShift action_48
-action_327 (172#) = happyShift action_49
-action_327 (174#) = happyShift action_51
-action_327 (8#) = happyGoto action_101
-action_327 (9#) = happyGoto action_102
-action_327 (10#) = happyGoto action_103
-action_327 (12#) = happyGoto action_170
-action_327 (67#) = happyGoto action_171
-action_327 (68#) = happyGoto action_172
-action_327 (69#) = happyGoto action_173
-action_327 (79#) = happyGoto action_174
-action_327 (81#) = happyGoto action_362
-action_327 x = happyTcHack x happyReduce_246
-
-action_328 x = happyTcHack x happyReduce_214
-
-action_329 (174#) = happyShift action_51
-action_329 (12#) = happyGoto action_361
-action_329 x = happyTcHack x happyFail
-
-action_330 (112#) = happyShift action_360
-action_330 x = happyTcHack x happyFail
-
-action_331 x = happyTcHack x happyReduce_241
-
-action_332 x = happyTcHack x happyReduce_245
-
-action_333 x = happyTcHack x happyReduce_160
-
-action_334 x = happyTcHack x happyReduce_150
-
-action_335 x = happyTcHack x happyReduce_197
-
-action_336 (99#) = happyShift action_359
-action_336 x = happyTcHack x happyFail
-
-action_337 x = happyTcHack x happyReduce_154
-
-action_338 (97#) = happyShift action_358
-action_338 x = happyTcHack x happyFail
-
-action_339 x = happyTcHack x happyReduce_129
-
-action_340 (97#) = happyShift action_357
-action_340 x = happyTcHack x happyFail
-
-action_341 x = happyTcHack x happyReduce_223
-
-action_342 (97#) = happyShift action_155
-action_342 (103#) = happyShift action_156
-action_342 x = happyTcHack x happyReduce_128
-
-action_343 x = happyTcHack x happyReduce_25
-
-action_344 (151#) = happyShift action_356
-action_344 (28#) = happyGoto action_355
-action_344 x = happyTcHack x happyReduce_55
-
-action_345 (102#) = happyShift action_354
-action_345 x = happyTcHack x happyReduce_27
-
-action_346 (103#) = happyShift action_352
-action_346 (169#) = happyShift action_353
-action_346 x = happyTcHack x happyReduce_66
-
-action_347 (174#) = happyShift action_51
-action_347 (12#) = happyGoto action_351
-action_347 x = happyTcHack x happyFail
-
-action_348 (174#) = happyShift action_51
-action_348 (12#) = happyGoto action_241
-action_348 (32#) = happyGoto action_349
-action_348 (33#) = happyGoto action_350
-action_348 x = happyTcHack x happyReduce_65
-
-action_349 x = happyTcHack x happyReduce_33
-
-action_350 (103#) = happyShift action_352
-action_350 x = happyTcHack x happyReduce_66
-
-action_351 x = happyTcHack x happyReduce_32
-
-action_352 (174#) = happyShift action_51
-action_352 (12#) = happyGoto action_241
-action_352 (32#) = happyGoto action_468
-action_352 (33#) = happyGoto action_350
-action_352 x = happyTcHack x happyReduce_65
-
-action_353 (98#) = happyShift action_408
-action_353 (174#) = happyShift action_51
-action_353 (12#) = happyGoto action_406
-action_353 (27#) = happyGoto action_467
-action_353 (29#) = happyGoto action_425
-action_353 x = happyTcHack x happyReduce_52
-
-action_354 (174#) = happyShift action_51
-action_354 (12#) = happyGoto action_241
-action_354 (33#) = happyGoto action_466
-action_354 x = happyTcHack x happyReduce_50
-
-action_355 x = happyTcHack x happyReduce_26
-
-action_356 (98#) = happyShift action_408
-action_356 (174#) = happyShift action_51
-action_356 (12#) = happyGoto action_406
-action_356 (27#) = happyGoto action_465
-action_356 (29#) = happyGoto action_425
-action_356 x = happyTcHack x happyReduce_52
-
-action_357 x = happyTcHack x happyReduce_188
-
-action_358 x = happyTcHack x happyReduce_159
-
-action_359 x = happyTcHack x happyReduce_239
-
-action_360 x = happyTcHack x happyReduce_155
-
-action_361 x = happyTcHack x happyReduce_201
-
-action_362 x = happyTcHack x happyReduce_248
-
-action_363 (108#) = happyShift action_296
-action_363 (117#) = happyShift action_297
-action_363 x = happyTcHack x happyReduce_221
-
-action_364 x = happyTcHack x happyReduce_231
-
-action_365 x = happyTcHack x happyReduce_183
-
-action_366 (97#) = happyShift action_464
-action_366 x = happyTcHack x happyFail
-
-action_367 x = happyTcHack x happyReduce_252
-
-action_368 x = happyTcHack x happyReduce_255
-
-action_369 (96#) = happyShift action_24
-action_369 (98#) = happyShift action_25
-action_369 (104#) = happyShift action_26
-action_369 (109#) = happyShift action_27
-action_369 (110#) = happyShift action_28
-action_369 (111#) = happyShift action_29
-action_369 (114#) = happyShift action_30
-action_369 (119#) = happyShift action_31
-action_369 (124#) = happyShift action_32
-action_369 (125#) = happyShift action_33
-action_369 (126#) = happyShift action_34
-action_369 (127#) = happyShift action_35
-action_369 (128#) = happyShift action_36
-action_369 (129#) = happyShift action_37
-action_369 (131#) = happyShift action_38
-action_369 (134#) = happyShift action_39
-action_369 (137#) = happyShift action_40
-action_369 (140#) = happyShift action_41
-action_369 (145#) = happyShift action_42
-action_369 (156#) = happyShift action_43
-action_369 (157#) = happyShift action_44
-action_369 (161#) = happyShift action_45
-action_369 (162#) = happyShift action_46
-action_369 (167#) = happyShift action_47
-action_369 (170#) = happyShift action_6
-action_369 (171#) = happyShift action_48
-action_369 (172#) = happyShift action_49
-action_369 (173#) = happyShift action_50
-action_369 (174#) = happyShift action_51
-action_369 (8#) = happyGoto action_10
-action_369 (9#) = happyGoto action_11
-action_369 (10#) = happyGoto action_12
-action_369 (11#) = happyGoto action_13
-action_369 (12#) = happyGoto action_14
-action_369 (58#) = happyGoto action_15
-action_369 (59#) = happyGoto action_16
-action_369 (60#) = happyGoto action_17
-action_369 (61#) = happyGoto action_18
-action_369 (62#) = happyGoto action_19
-action_369 (63#) = happyGoto action_463
-action_369 (64#) = happyGoto action_21
-action_369 (72#) = happyGoto action_22
-action_369 (77#) = happyGoto action_23
-action_369 x = happyTcHack x happyFail
-
-action_370 (96#) = happyShift action_24
-action_370 (98#) = happyShift action_25
-action_370 (104#) = happyShift action_26
-action_370 (109#) = happyShift action_27
-action_370 (110#) = happyShift action_28
-action_370 (111#) = happyShift action_29
-action_370 (114#) = happyShift action_30
-action_370 (119#) = happyShift action_31
-action_370 (124#) = happyShift action_32
-action_370 (125#) = happyShift action_33
-action_370 (126#) = happyShift action_34
-action_370 (127#) = happyShift action_35
-action_370 (128#) = happyShift action_36
-action_370 (129#) = happyShift action_37
-action_370 (131#) = happyShift action_38
-action_370 (134#) = happyShift action_39
-action_370 (137#) = happyShift action_40
-action_370 (140#) = happyShift action_41
-action_370 (145#) = happyShift action_42
-action_370 (156#) = happyShift action_43
-action_370 (157#) = happyShift action_44
-action_370 (161#) = happyShift action_45
-action_370 (162#) = happyShift action_46
-action_370 (167#) = happyShift action_47
-action_370 (170#) = happyShift action_6
-action_370 (171#) = happyShift action_48
-action_370 (172#) = happyShift action_49
-action_370 (173#) = happyShift action_50
-action_370 (174#) = happyShift action_51
-action_370 (8#) = happyGoto action_10
-action_370 (9#) = happyGoto action_11
-action_370 (10#) = happyGoto action_12
-action_370 (11#) = happyGoto action_13
-action_370 (12#) = happyGoto action_14
-action_370 (58#) = happyGoto action_15
-action_370 (59#) = happyGoto action_16
-action_370 (60#) = happyGoto action_17
-action_370 (61#) = happyGoto action_18
-action_370 (62#) = happyGoto action_19
-action_370 (63#) = happyGoto action_462
-action_370 (64#) = happyGoto action_21
-action_370 (72#) = happyGoto action_22
-action_370 (77#) = happyGoto action_23
-action_370 x = happyTcHack x happyFail
-
-action_371 (123#) = happyShift action_461
-action_371 x = happyTcHack x happyFail
-
-action_372 (94#) = happyShift action_460
-action_372 x = happyTcHack x happyReduce_258
-
-action_373 (97#) = happyShift action_459
-action_373 x = happyTcHack x happyFail
-
-action_374 x = happyTcHack x happyReduce_195
-
-action_375 x = happyTcHack x happyReduce_215
-
-action_376 (96#) = happyShift action_106
-action_376 (98#) = happyShift action_107
-action_376 (104#) = happyShift action_108
-action_376 (110#) = happyShift action_109
-action_376 (111#) = happyShift action_110
-action_376 (114#) = happyShift action_111
-action_376 (121#) = happyShift action_112
-action_376 (170#) = happyShift action_6
-action_376 (171#) = happyShift action_48
-action_376 (172#) = happyShift action_49
-action_376 (174#) = happyShift action_51
-action_376 (8#) = happyGoto action_101
-action_376 (9#) = happyGoto action_102
-action_376 (10#) = happyGoto action_103
-action_376 (12#) = happyGoto action_104
-action_376 (67#) = happyGoto action_188
-action_376 (74#) = happyGoto action_458
-action_376 x = happyTcHack x happyReduce_205
-
-action_377 x = happyTcHack x happyReduce_249
-
-action_378 x = happyTcHack x happyReduce_219
-
-action_379 x = happyTcHack x happyReduce_218
-
-action_380 x = happyTcHack x happyReduce_251
-
-action_381 x = happyTcHack x happyReduce_164
-
-action_382 x = happyTcHack x happyReduce_165
-
-action_383 (89#) = happyGoto action_457
-action_383 x = happyTcHack x happyReduce_262
-
-action_384 (104#) = happyShift action_290
-action_384 (174#) = happyShift action_51
-action_384 (12#) = happyGoto action_287
-action_384 (36#) = happyGoto action_288
-action_384 (46#) = happyGoto action_456
-action_384 x = happyTcHack x happyReduce_113
-
-action_385 (96#) = happyShift action_140
-action_385 (98#) = happyShift action_455
-action_385 (104#) = happyShift action_26
-action_385 (109#) = happyShift action_83
-action_385 (110#) = happyShift action_28
-action_385 (111#) = happyShift action_29
-action_385 (125#) = happyShift action_33
-action_385 (126#) = happyShift action_34
-action_385 (127#) = happyShift action_35
-action_385 (128#) = happyShift action_36
-action_385 (129#) = happyShift action_37
-action_385 (134#) = happyShift action_39
-action_385 (170#) = happyShift action_6
-action_385 (171#) = happyShift action_48
-action_385 (172#) = happyShift action_49
-action_385 (173#) = happyShift action_50
-action_385 (174#) = happyShift action_51
-action_385 (8#) = happyGoto action_10
-action_385 (9#) = happyGoto action_11
-action_385 (10#) = happyGoto action_12
-action_385 (11#) = happyGoto action_13
-action_385 (12#) = happyGoto action_79
-action_385 (58#) = happyGoto action_453
-action_385 (72#) = happyGoto action_22
-action_385 (88#) = happyGoto action_454
-action_385 x = happyTcHack x happyReduce_95
-
-action_386 (174#) = happyShift action_51
-action_386 (12#) = happyGoto action_451
-action_386 (38#) = happyGoto action_284
-action_386 (48#) = happyGoto action_452
-action_386 x = happyTcHack x happyReduce_117
-
-action_387 (174#) = happyShift action_51
-action_387 (12#) = happyGoto action_448
-action_387 (39#) = happyGoto action_449
-action_387 (40#) = happyGoto action_450
-action_387 x = happyTcHack x happyReduce_102
-
-action_388 (174#) = happyShift action_51
-action_388 (12#) = happyGoto action_279
-action_388 (44#) = happyGoto action_280
-action_388 (51#) = happyGoto action_447
-action_388 x = happyTcHack x happyReduce_123
-
-action_389 (174#) = happyShift action_51
-action_389 (12#) = happyGoto action_446
-action_389 x = happyTcHack x happyFail
-
-action_390 (96#) = happyShift action_24
-action_390 (98#) = happyShift action_25
-action_390 (104#) = happyShift action_26
-action_390 (109#) = happyShift action_27
-action_390 (110#) = happyShift action_28
-action_390 (111#) = happyShift action_29
-action_390 (114#) = happyShift action_30
-action_390 (119#) = happyShift action_31
-action_390 (124#) = happyShift action_32
-action_390 (125#) = happyShift action_33
-action_390 (126#) = happyShift action_34
-action_390 (127#) = happyShift action_35
-action_390 (128#) = happyShift action_36
-action_390 (129#) = happyShift action_37
-action_390 (131#) = happyShift action_38
-action_390 (134#) = happyShift action_39
-action_390 (137#) = happyShift action_40
-action_390 (140#) = happyShift action_41
-action_390 (145#) = happyShift action_42
-action_390 (156#) = happyShift action_43
-action_390 (157#) = happyShift action_44
-action_390 (161#) = happyShift action_45
-action_390 (162#) = happyShift action_46
-action_390 (167#) = happyShift action_47
-action_390 (170#) = happyShift action_6
-action_390 (171#) = happyShift action_48
-action_390 (172#) = happyShift action_49
-action_390 (173#) = happyShift action_50
-action_390 (174#) = happyShift action_51
-action_390 (8#) = happyGoto action_10
-action_390 (9#) = happyGoto action_11
-action_390 (10#) = happyGoto action_12
-action_390 (11#) = happyGoto action_13
-action_390 (12#) = happyGoto action_14
-action_390 (58#) = happyGoto action_15
-action_390 (59#) = happyGoto action_16
-action_390 (60#) = happyGoto action_17
-action_390 (61#) = happyGoto action_18
-action_390 (62#) = happyGoto action_19
-action_390 (63#) = happyGoto action_445
-action_390 (64#) = happyGoto action_21
-action_390 (72#) = happyGoto action_22
-action_390 (77#) = happyGoto action_23
-action_390 x = happyTcHack x happyFail
-
-action_391 (174#) = happyShift action_51
-action_391 (12#) = happyGoto action_87
-action_391 (37#) = happyGoto action_276
-action_391 (47#) = happyGoto action_444
-action_391 (53#) = happyGoto action_278
-action_391 x = happyTcHack x happyReduce_115
-
-action_392 (96#) = happyShift action_443
-action_392 x = happyTcHack x happyFail
-
-action_393 (174#) = happyShift action_51
-action_393 (12#) = happyGoto action_267
-action_393 (41#) = happyGoto action_268
-action_393 (49#) = happyGoto action_442
-action_393 x = happyTcHack x happyReduce_119
-
-action_394 (98#) = happyShift action_441
-action_394 (174#) = happyShift action_51
-action_394 (12#) = happyGoto action_438
-action_394 (42#) = happyGoto action_439
-action_394 (52#) = happyGoto action_440
-action_394 x = happyTcHack x happyReduce_125
-
-action_395 x = happyTcHack x happyReduce_87
-
-action_396 x = happyTcHack x happyReduce_86
-
-action_397 (96#) = happyShift action_24
-action_397 (98#) = happyShift action_25
-action_397 (104#) = happyShift action_26
-action_397 (109#) = happyShift action_27
-action_397 (110#) = happyShift action_28
-action_397 (111#) = happyShift action_29
-action_397 (114#) = happyShift action_30
-action_397 (119#) = happyShift action_31
-action_397 (124#) = happyShift action_32
-action_397 (125#) = happyShift action_33
-action_397 (126#) = happyShift action_34
-action_397 (127#) = happyShift action_35
-action_397 (128#) = happyShift action_36
-action_397 (129#) = happyShift action_37
-action_397 (131#) = happyShift action_38
-action_397 (134#) = happyShift action_39
-action_397 (137#) = happyShift action_40
-action_397 (140#) = happyShift action_41
-action_397 (145#) = happyShift action_42
-action_397 (156#) = happyShift action_43
-action_397 (157#) = happyShift action_44
-action_397 (161#) = happyShift action_45
-action_397 (162#) = happyShift action_46
-action_397 (167#) = happyShift action_47
-action_397 (170#) = happyShift action_6
-action_397 (171#) = happyShift action_48
-action_397 (172#) = happyShift action_49
-action_397 (173#) = happyShift action_50
-action_397 (174#) = happyShift action_51
-action_397 (8#) = happyGoto action_10
-action_397 (9#) = happyGoto action_11
-action_397 (10#) = happyGoto action_12
-action_397 (11#) = happyGoto action_13
-action_397 (12#) = happyGoto action_14
-action_397 (58#) = happyGoto action_15
-action_397 (59#) = happyGoto action_16
-action_397 (60#) = happyGoto action_17
-action_397 (61#) = happyGoto action_18
-action_397 (62#) = happyGoto action_19
-action_397 (63#) = happyGoto action_437
-action_397 (64#) = happyGoto action_21
-action_397 (72#) = happyGoto action_22
-action_397 (77#) = happyGoto action_23
-action_397 x = happyTcHack x happyFail
-
-action_398 (104#) = happyShift action_257
-action_398 (174#) = happyShift action_51
-action_398 (12#) = happyGoto action_252
-action_398 (54#) = happyGoto action_262
-action_398 (55#) = happyGoto action_436
-action_398 x = happyTcHack x happyFail
-
-action_399 (104#) = happyShift action_257
-action_399 (174#) = happyShift action_51
-action_399 (12#) = happyGoto action_252
-action_399 (43#) = happyGoto action_260
-action_399 (50#) = happyGoto action_435
-action_399 (54#) = happyGoto action_262
-action_399 (55#) = happyGoto action_263
-action_399 x = happyTcHack x happyReduce_121
-
-action_400 x = happyTcHack x happyReduce_94
-
-action_401 (105#) = happyShift action_434
-action_401 x = happyTcHack x happyFail
-
-action_402 (96#) = happyShift action_24
-action_402 (98#) = happyShift action_25
-action_402 (104#) = happyShift action_26
-action_402 (109#) = happyShift action_27
-action_402 (110#) = happyShift action_28
-action_402 (111#) = happyShift action_29
-action_402 (114#) = happyShift action_30
-action_402 (119#) = happyShift action_31
-action_402 (124#) = happyShift action_32
-action_402 (125#) = happyShift action_33
-action_402 (126#) = happyShift action_34
-action_402 (127#) = happyShift action_35
-action_402 (128#) = happyShift action_36
-action_402 (129#) = happyShift action_37
-action_402 (131#) = happyShift action_38
-action_402 (134#) = happyShift action_39
-action_402 (137#) = happyShift action_40
-action_402 (140#) = happyShift action_41
-action_402 (145#) = happyShift action_42
-action_402 (156#) = happyShift action_43
-action_402 (157#) = happyShift action_44
-action_402 (161#) = happyShift action_45
-action_402 (162#) = happyShift action_46
-action_402 (167#) = happyShift action_47
-action_402 (170#) = happyShift action_6
-action_402 (171#) = happyShift action_48
-action_402 (172#) = happyShift action_49
-action_402 (173#) = happyShift action_50
-action_402 (174#) = happyShift action_51
-action_402 (8#) = happyGoto action_10
-action_402 (9#) = happyGoto action_11
-action_402 (10#) = happyGoto action_12
-action_402 (11#) = happyGoto action_13
-action_402 (12#) = happyGoto action_14
-action_402 (58#) = happyGoto action_15
-action_402 (59#) = happyGoto action_16
-action_402 (60#) = happyGoto action_17
-action_402 (61#) = happyGoto action_18
-action_402 (62#) = happyGoto action_19
-action_402 (63#) = happyGoto action_433
-action_402 (64#) = happyGoto action_21
-action_402 (72#) = happyGoto action_22
-action_402 (77#) = happyGoto action_23
-action_402 x = happyTcHack x happyFail
-
-action_403 (96#) = happyShift action_24
-action_403 (98#) = happyShift action_25
-action_403 (104#) = happyShift action_26
-action_403 (109#) = happyShift action_27
-action_403 (110#) = happyShift action_28
-action_403 (111#) = happyShift action_29
-action_403 (114#) = happyShift action_30
-action_403 (119#) = happyShift action_31
-action_403 (124#) = happyShift action_32
-action_403 (125#) = happyShift action_33
-action_403 (126#) = happyShift action_34
-action_403 (127#) = happyShift action_35
-action_403 (128#) = happyShift action_36
-action_403 (129#) = happyShift action_37
-action_403 (131#) = happyShift action_38
-action_403 (134#) = happyShift action_39
-action_403 (137#) = happyShift action_40
-action_403 (140#) = happyShift action_41
-action_403 (145#) = happyShift action_42
-action_403 (156#) = happyShift action_43
-action_403 (157#) = happyShift action_44
-action_403 (161#) = happyShift action_45
-action_403 (162#) = happyShift action_46
-action_403 (167#) = happyShift action_47
-action_403 (170#) = happyShift action_6
-action_403 (171#) = happyShift action_48
-action_403 (172#) = happyShift action_49
-action_403 (173#) = happyShift action_50
-action_403 (174#) = happyShift action_51
-action_403 (8#) = happyGoto action_10
-action_403 (9#) = happyGoto action_11
-action_403 (10#) = happyGoto action_12
-action_403 (11#) = happyGoto action_13
-action_403 (12#) = happyGoto action_14
-action_403 (58#) = happyGoto action_15
-action_403 (59#) = happyGoto action_16
-action_403 (60#) = happyGoto action_17
-action_403 (61#) = happyGoto action_18
-action_403 (62#) = happyGoto action_19
-action_403 (63#) = happyGoto action_432
-action_403 (64#) = happyGoto action_21
-action_403 (72#) = happyGoto action_22
-action_403 (77#) = happyGoto action_23
-action_403 x = happyTcHack x happyFail
-
-action_404 (95#) = happyShift action_431
-action_404 x = happyTcHack x happyFail
-
-action_405 (104#) = happyShift action_257
-action_405 (174#) = happyShift action_51
-action_405 (12#) = happyGoto action_252
-action_405 (34#) = happyGoto action_253
-action_405 (45#) = happyGoto action_430
-action_405 (54#) = happyGoto action_255
-action_405 (55#) = happyGoto action_256
-action_405 x = happyTcHack x happyReduce_111
-
-action_406 x = happyTcHack x happyReduce_57
-
-action_407 (101#) = happyShift action_429
-action_407 x = happyTcHack x happyFail
-
-action_408 (142#) = happyShift action_427
-action_408 (144#) = happyShift action_428
-action_408 (31#) = happyGoto action_426
-action_408 x = happyTcHack x happyReduce_62
-
-action_409 x = happyTcHack x happyReduce_38
-
-action_410 x = happyTcHack x happyReduce_37
-
-action_411 x = happyTcHack x happyReduce_47
-
-action_412 x = happyTcHack x happyReduce_46
-
-action_413 (98#) = happyShift action_408
-action_413 (174#) = happyShift action_51
-action_413 (12#) = happyGoto action_406
-action_413 (27#) = happyGoto action_424
-action_413 (29#) = happyGoto action_425
-action_413 x = happyTcHack x happyReduce_52
-
-action_414 (174#) = happyShift action_51
-action_414 (12#) = happyGoto action_241
-action_414 (33#) = happyGoto action_423
-action_414 x = happyTcHack x happyReduce_50
-
-action_415 (96#) = happyShift action_422
-action_415 x = happyTcHack x happyFail
-
-action_416 (174#) = happyShift action_51
-action_416 (12#) = happyGoto action_87
-action_416 (53#) = happyGoto action_421
-action_416 x = happyTcHack x happyFail
-
-action_417 (104#) = happyShift action_420
-action_417 x = happyTcHack x happyFail
-
-action_418 (95#) = happyShift action_419
-action_418 x = happyTcHack x happyFail
-
-action_419 (174#) = happyShift action_51
-action_419 (12#) = happyGoto action_492
-action_419 x = happyTcHack x happyFail
-
-action_420 (174#) = happyShift action_51
-action_420 (12#) = happyGoto action_87
-action_420 (53#) = happyGoto action_491
-action_420 x = happyTcHack x happyFail
-
-action_421 (105#) = happyShift action_490
-action_421 x = happyTcHack x happyFail
-
-action_422 (25#) = happyGoto action_489
-action_422 x = happyTcHack x happyReduce_48
-
-action_423 (169#) = happyShift action_488
-action_423 x = happyTcHack x happyFail
-
-action_424 (102#) = happyShift action_487
-action_424 x = happyTcHack x happyReduce_42
-
-action_425 (103#) = happyShift action_486
-action_425 x = happyTcHack x happyReduce_53
-
-action_426 (174#) = happyShift action_51
-action_426 (12#) = happyGoto action_485
-action_426 x = happyTcHack x happyFail
-
-action_427 x = happyTcHack x happyReduce_63
-
-action_428 x = happyTcHack x happyReduce_64
-
-action_429 (98#) = happyShift action_408
-action_429 (174#) = happyShift action_51
-action_429 (12#) = happyGoto action_406
-action_429 (29#) = happyGoto action_484
-action_429 x = happyTcHack x happyFail
-
-action_430 x = happyTcHack x happyReduce_112
-
-action_431 (96#) = happyShift action_24
-action_431 (98#) = happyShift action_25
-action_431 (104#) = happyShift action_26
-action_431 (109#) = happyShift action_27
-action_431 (110#) = happyShift action_28
-action_431 (111#) = happyShift action_29
-action_431 (114#) = happyShift action_30
-action_431 (119#) = happyShift action_31
-action_431 (124#) = happyShift action_32
-action_431 (125#) = happyShift action_33
-action_431 (126#) = happyShift action_34
-action_431 (127#) = happyShift action_35
-action_431 (128#) = happyShift action_36
-action_431 (129#) = happyShift action_37
-action_431 (131#) = happyShift action_38
-action_431 (134#) = happyShift action_39
-action_431 (137#) = happyShift action_40
-action_431 (140#) = happyShift action_41
-action_431 (145#) = happyShift action_42
-action_431 (156#) = happyShift action_43
-action_431 (157#) = happyShift action_44
-action_431 (161#) = happyShift action_45
-action_431 (162#) = happyShift action_46
-action_431 (167#) = happyShift action_47
-action_431 (170#) = happyShift action_6
-action_431 (171#) = happyShift action_48
-action_431 (172#) = happyShift action_49
-action_431 (173#) = happyShift action_50
-action_431 (174#) = happyShift action_51
-action_431 (8#) = happyGoto action_10
-action_431 (9#) = happyGoto action_11
-action_431 (10#) = happyGoto action_12
-action_431 (11#) = happyGoto action_13
-action_431 (12#) = happyGoto action_14
-action_431 (58#) = happyGoto action_15
-action_431 (59#) = happyGoto action_16
-action_431 (60#) = happyGoto action_17
-action_431 (61#) = happyGoto action_18
-action_431 (62#) = happyGoto action_19
-action_431 (63#) = happyGoto action_483
-action_431 (64#) = happyGoto action_21
-action_431 (72#) = happyGoto action_22
-action_431 (77#) = happyGoto action_23
-action_431 x = happyTcHack x happyFail
-
-action_432 (95#) = happyShift action_482
-action_432 x = happyTcHack x happyReduce_71
-
-action_433 x = happyTcHack x happyReduce_72
-
-action_434 x = happyTcHack x happyReduce_131
-
-action_435 x = happyTcHack x happyReduce_122
-
-action_436 x = happyTcHack x happyReduce_133
-
-action_437 x = happyTcHack x happyReduce_109
-
-action_438 (89#) = happyGoto action_481
-action_438 x = happyTcHack x happyReduce_262
-
-action_439 (108#) = happyShift action_480
-action_439 x = happyTcHack x happyReduce_126
-
-action_440 x = happyTcHack x happyReduce_105
-
-action_441 (140#) = happyShift action_479
-action_441 x = happyTcHack x happyFail
-
-action_442 x = happyTcHack x happyReduce_120
-
-action_443 (25#) = happyGoto action_478
-action_443 x = happyTcHack x happyReduce_48
-
-action_444 x = happyTcHack x happyReduce_116
-
-action_445 x = happyTcHack x happyReduce_98
-
-action_446 x = happyTcHack x happyReduce_110
-
-action_447 x = happyTcHack x happyReduce_124
-
-action_448 (107#) = happyShift action_477
-action_448 x = happyTcHack x happyReduce_100
-
-action_449 (108#) = happyShift action_476
-action_449 x = happyTcHack x happyReduce_103
-
-action_450 x = happyTcHack x happyReduce_99
-
-action_451 (95#) = happyShift action_387
-action_451 x = happyTcHack x happyFail
-
-action_452 x = happyTcHack x happyReduce_118
-
-action_453 x = happyTcHack x happyReduce_261
-
-action_454 x = happyTcHack x happyReduce_263
-
-action_455 (96#) = happyShift action_24
-action_455 (98#) = happyShift action_25
-action_455 (104#) = happyShift action_26
-action_455 (109#) = happyShift action_27
-action_455 (110#) = happyShift action_28
-action_455 (111#) = happyShift action_29
-action_455 (114#) = happyShift action_30
-action_455 (119#) = happyShift action_31
-action_455 (121#) = happyShift action_100
-action_455 (124#) = happyShift action_32
-action_455 (125#) = happyShift action_33
-action_455 (126#) = happyShift action_34
-action_455 (127#) = happyShift action_35
-action_455 (128#) = happyShift action_36
-action_455 (129#) = happyShift action_37
-action_455 (131#) = happyShift action_38
-action_455 (134#) = happyShift action_39
-action_455 (137#) = happyShift action_40
-action_455 (140#) = happyShift action_123
-action_455 (145#) = happyShift action_42
-action_455 (156#) = happyShift action_43
-action_455 (157#) = happyShift action_44
-action_455 (161#) = happyShift action_45
-action_455 (162#) = happyShift action_46
-action_455 (167#) = happyShift action_47
-action_455 (170#) = happyShift action_6
-action_455 (171#) = happyShift action_48
-action_455 (172#) = happyShift action_49
-action_455 (173#) = happyShift action_50
-action_455 (174#) = happyShift action_51
-action_455 (8#) = happyGoto action_10
-action_455 (9#) = happyGoto action_11
-action_455 (10#) = happyGoto action_12
-action_455 (11#) = happyGoto action_13
-action_455 (12#) = happyGoto action_120
-action_455 (58#) = happyGoto action_15
-action_455 (59#) = happyGoto action_16
-action_455 (60#) = happyGoto action_17
-action_455 (61#) = happyGoto action_18
-action_455 (62#) = happyGoto action_19
-action_455 (63#) = happyGoto action_121
-action_455 (64#) = happyGoto action_21
-action_455 (72#) = happyGoto action_22
-action_455 (75#) = happyGoto action_97
-action_455 (76#) = happyGoto action_475
-action_455 (77#) = happyGoto action_23
-action_455 x = happyTcHack x happyReduce_236
-
-action_456 x = happyTcHack x happyReduce_114
-
-action_457 (96#) = happyShift action_140
-action_457 (98#) = happyShift action_455
-action_457 (104#) = happyShift action_26
-action_457 (105#) = happyShift action_474
-action_457 (109#) = happyShift action_83
-action_457 (110#) = happyShift action_28
-action_457 (111#) = happyShift action_29
-action_457 (125#) = happyShift action_33
-action_457 (126#) = happyShift action_34
-action_457 (127#) = happyShift action_35
-action_457 (128#) = happyShift action_36
-action_457 (129#) = happyShift action_37
-action_457 (134#) = happyShift action_39
-action_457 (170#) = happyShift action_6
-action_457 (171#) = happyShift action_48
-action_457 (172#) = happyShift action_49
-action_457 (173#) = happyShift action_50
-action_457 (174#) = happyShift action_51
-action_457 (8#) = happyGoto action_10
-action_457 (9#) = happyGoto action_11
-action_457 (10#) = happyGoto action_12
-action_457 (11#) = happyGoto action_13
-action_457 (12#) = happyGoto action_79
-action_457 (58#) = happyGoto action_453
-action_457 (72#) = happyGoto action_22
-action_457 (88#) = happyGoto action_454
-action_457 x = happyTcHack x happyFail
-
-action_458 x = happyTcHack x happyReduce_213
-
-action_459 x = happyTcHack x happyReduce_168
-
-action_460 (96#) = happyShift action_24
-action_460 (98#) = happyShift action_25
-action_460 (104#) = happyShift action_26
-action_460 (109#) = happyShift action_27
-action_460 (110#) = happyShift action_28
-action_460 (111#) = happyShift action_29
-action_460 (114#) = happyShift action_30
-action_460 (119#) = happyShift action_31
-action_460 (124#) = happyShift action_32
-action_460 (125#) = happyShift action_33
-action_460 (126#) = happyShift action_34
-action_460 (127#) = happyShift action_35
-action_460 (128#) = happyShift action_36
-action_460 (129#) = happyShift action_37
-action_460 (131#) = happyShift action_38
-action_460 (134#) = happyShift action_39
-action_460 (137#) = happyShift action_40
-action_460 (140#) = happyShift action_41
-action_460 (145#) = happyShift action_42
-action_460 (156#) = happyShift action_43
-action_460 (157#) = happyShift action_44
-action_460 (161#) = happyShift action_45
-action_460 (162#) = happyShift action_46
-action_460 (167#) = happyShift action_47
-action_460 (170#) = happyShift action_6
-action_460 (171#) = happyShift action_48
-action_460 (172#) = happyShift action_49
-action_460 (173#) = happyShift action_50
-action_460 (174#) = happyShift action_51
-action_460 (8#) = happyGoto action_10
-action_460 (9#) = happyGoto action_11
-action_460 (10#) = happyGoto action_12
-action_460 (11#) = happyGoto action_13
-action_460 (12#) = happyGoto action_14
-action_460 (58#) = happyGoto action_15
-action_460 (59#) = happyGoto action_16
-action_460 (60#) = happyGoto action_17
-action_460 (61#) = happyGoto action_18
-action_460 (62#) = happyGoto action_19
-action_460 (63#) = happyGoto action_371
-action_460 (64#) = happyGoto action_21
-action_460 (72#) = happyGoto action_22
-action_460 (77#) = happyGoto action_23
-action_460 (86#) = happyGoto action_372
-action_460 (87#) = happyGoto action_473
-action_460 x = happyTcHack x happyReduce_257
-
-action_461 (96#) = happyShift action_24
-action_461 (98#) = happyShift action_25
-action_461 (104#) = happyShift action_26
-action_461 (109#) = happyShift action_27
-action_461 (110#) = happyShift action_28
-action_461 (111#) = happyShift action_29
-action_461 (114#) = happyShift action_30
-action_461 (119#) = happyShift action_31
-action_461 (124#) = happyShift action_32
-action_461 (125#) = happyShift action_33
-action_461 (126#) = happyShift action_34
-action_461 (127#) = happyShift action_35
-action_461 (128#) = happyShift action_36
-action_461 (129#) = happyShift action_37
-action_461 (131#) = happyShift action_38
-action_461 (134#) = happyShift action_39
-action_461 (137#) = happyShift action_40
-action_461 (140#) = happyShift action_41
-action_461 (145#) = happyShift action_42
-action_461 (156#) = happyShift action_43
-action_461 (157#) = happyShift action_44
-action_461 (161#) = happyShift action_45
-action_461 (162#) = happyShift action_46
-action_461 (167#) = happyShift action_47
-action_461 (170#) = happyShift action_6
-action_461 (171#) = happyShift action_48
-action_461 (172#) = happyShift action_49
-action_461 (173#) = happyShift action_50
-action_461 (174#) = happyShift action_51
-action_461 (8#) = happyGoto action_10
-action_461 (9#) = happyGoto action_11
-action_461 (10#) = happyGoto action_12
-action_461 (11#) = happyGoto action_13
-action_461 (12#) = happyGoto action_14
-action_461 (58#) = happyGoto action_15
-action_461 (59#) = happyGoto action_16
-action_461 (60#) = happyGoto action_17
-action_461 (61#) = happyGoto action_18
-action_461 (62#) = happyGoto action_19
-action_461 (63#) = happyGoto action_472
-action_461 (64#) = happyGoto action_21
-action_461 (72#) = happyGoto action_22
-action_461 (77#) = happyGoto action_23
-action_461 x = happyTcHack x happyFail
-
-action_462 x = happyTcHack x happyReduce_136
-
-action_463 x = happyTcHack x happyReduce_186
-
-action_464 x = happyTcHack x happyReduce_166
-
-action_465 (140#) = happyShift action_471
-action_465 x = happyTcHack x happyFail
-
-action_466 (169#) = happyShift action_470
-action_466 x = happyTcHack x happyFail
-
-action_467 (102#) = happyShift action_469
-action_467 x = happyTcHack x happyReduce_28
-
-action_468 x = happyTcHack x happyReduce_67
-
-action_469 (151#) = happyShift action_356
-action_469 (28#) = happyGoto action_510
-action_469 x = happyTcHack x happyReduce_55
-
-action_470 (98#) = happyShift action_408
-action_470 (174#) = happyShift action_51
-action_470 (12#) = happyGoto action_406
-action_470 (27#) = happyGoto action_509
-action_470 (29#) = happyGoto action_425
-action_470 x = happyTcHack x happyReduce_52
-
-action_471 x = happyTcHack x happyReduce_56
-
-action_472 x = happyTcHack x happyReduce_256
-
-action_473 x = happyTcHack x happyReduce_259
-
-action_474 (96#) = happyShift action_508
-action_474 x = happyTcHack x happyReduce_96
-
-action_475 (100#) = happyShift action_507
-action_475 x = happyTcHack x happyFail
-
-action_476 (174#) = happyShift action_51
-action_476 (12#) = happyGoto action_448
-action_476 (39#) = happyGoto action_449
-action_476 (40#) = happyGoto action_506
-action_476 x = happyTcHack x happyReduce_102
-
-action_477 (174#) = happyShift action_51
-action_477 (12#) = happyGoto action_505
-action_477 x = happyTcHack x happyFail
-
-action_478 (97#) = happyShift action_504
-action_478 (132#) = happyShift action_210
-action_478 (134#) = happyShift action_211
-action_478 (135#) = happyShift action_212
-action_478 (136#) = happyShift action_213
-action_478 (138#) = happyShift action_214
-action_478 (146#) = happyShift action_215
-action_478 (147#) = happyShift action_216
-action_478 (148#) = happyShift action_217
-action_478 (149#) = happyShift action_218
-action_478 (152#) = happyShift action_219
-action_478 (154#) = happyShift action_220
-action_478 (155#) = happyShift action_221
-action_478 (156#) = happyShift action_222
-action_478 (158#) = happyShift action_223
-action_478 (163#) = happyShift action_224
-action_478 (164#) = happyShift action_225
-action_478 (166#) = happyShift action_226
-action_478 (35#) = happyGoto action_209
-action_478 x = happyTcHack x happyFail
-
-action_479 (174#) = happyShift action_51
-action_479 (12#) = happyGoto action_503
-action_479 x = happyTcHack x happyFail
-
-action_480 (174#) = happyShift action_51
-action_480 (12#) = happyGoto action_438
-action_480 (42#) = happyGoto action_439
-action_480 (52#) = happyGoto action_502
-action_480 x = happyTcHack x happyReduce_125
-
-action_481 (96#) = happyShift action_140
-action_481 (98#) = happyShift action_455
-action_481 (104#) = happyShift action_26
-action_481 (109#) = happyShift action_83
-action_481 (110#) = happyShift action_28
-action_481 (111#) = happyShift action_29
-action_481 (125#) = happyShift action_33
-action_481 (126#) = happyShift action_34
-action_481 (127#) = happyShift action_35
-action_481 (128#) = happyShift action_36
-action_481 (129#) = happyShift action_37
-action_481 (134#) = happyShift action_39
-action_481 (170#) = happyShift action_6
-action_481 (171#) = happyShift action_48
-action_481 (172#) = happyShift action_49
-action_481 (173#) = happyShift action_50
-action_481 (174#) = happyShift action_51
-action_481 (8#) = happyGoto action_10
-action_481 (9#) = happyGoto action_11
-action_481 (10#) = happyGoto action_12
-action_481 (11#) = happyGoto action_13
-action_481 (12#) = happyGoto action_79
-action_481 (58#) = happyGoto action_453
-action_481 (72#) = happyGoto action_22
-action_481 (88#) = happyGoto action_454
-action_481 x = happyTcHack x happyReduce_108
-
-action_482 (96#) = happyShift action_24
-action_482 (98#) = happyShift action_25
-action_482 (104#) = happyShift action_26
-action_482 (109#) = happyShift action_27
-action_482 (110#) = happyShift action_28
-action_482 (111#) = happyShift action_29
-action_482 (114#) = happyShift action_30
-action_482 (119#) = happyShift action_31
-action_482 (124#) = happyShift action_32
-action_482 (125#) = happyShift action_33
-action_482 (126#) = happyShift action_34
-action_482 (127#) = happyShift action_35
-action_482 (128#) = happyShift action_36
-action_482 (129#) = happyShift action_37
-action_482 (131#) = happyShift action_38
-action_482 (134#) = happyShift action_39
-action_482 (137#) = happyShift action_40
-action_482 (140#) = happyShift action_41
-action_482 (145#) = happyShift action_42
-action_482 (156#) = happyShift action_43
-action_482 (157#) = happyShift action_44
-action_482 (161#) = happyShift action_45
-action_482 (162#) = happyShift action_46
-action_482 (167#) = happyShift action_47
-action_482 (170#) = happyShift action_6
-action_482 (171#) = happyShift action_48
-action_482 (172#) = happyShift action_49
-action_482 (173#) = happyShift action_50
-action_482 (174#) = happyShift action_51
-action_482 (8#) = happyGoto action_10
-action_482 (9#) = happyGoto action_11
-action_482 (10#) = happyGoto action_12
-action_482 (11#) = happyGoto action_13
-action_482 (12#) = happyGoto action_14
-action_482 (58#) = happyGoto action_15
-action_482 (59#) = happyGoto action_16
-action_482 (60#) = happyGoto action_17
-action_482 (61#) = happyGoto action_18
-action_482 (62#) = happyGoto action_19
-action_482 (63#) = happyGoto action_501
-action_482 (64#) = happyGoto action_21
-action_482 (72#) = happyGoto action_22
-action_482 (77#) = happyGoto action_23
-action_482 x = happyTcHack x happyFail
-
-action_483 x = happyTcHack x happyReduce_73
-
-action_484 x = happyTcHack x happyReduce_39
-
-action_485 (95#) = happyShift action_499
-action_485 (99#) = happyShift action_500
-action_485 x = happyTcHack x happyFail
-
-action_486 (98#) = happyShift action_408
-action_486 (174#) = happyShift action_51
-action_486 (12#) = happyGoto action_406
-action_486 (27#) = happyGoto action_498
-action_486 (29#) = happyGoto action_425
-action_486 x = happyTcHack x happyReduce_52
-
-action_487 (151#) = happyShift action_356
-action_487 (28#) = happyGoto action_497
-action_487 x = happyTcHack x happyReduce_55
-
-action_488 (98#) = happyShift action_408
-action_488 (174#) = happyShift action_51
-action_488 (12#) = happyGoto action_406
-action_488 (27#) = happyGoto action_496
-action_488 (29#) = happyGoto action_425
-action_488 x = happyTcHack x happyReduce_52
-
-action_489 (97#) = happyShift action_495
-action_489 (132#) = happyShift action_210
-action_489 (134#) = happyShift action_211
-action_489 (135#) = happyShift action_212
-action_489 (136#) = happyShift action_213
-action_489 (138#) = happyShift action_214
-action_489 (146#) = happyShift action_215
-action_489 (147#) = happyShift action_216
-action_489 (148#) = happyShift action_217
-action_489 (149#) = happyShift action_218
-action_489 (152#) = happyShift action_219
-action_489 (154#) = happyShift action_220
-action_489 (155#) = happyShift action_221
-action_489 (156#) = happyShift action_222
-action_489 (158#) = happyShift action_223
-action_489 (163#) = happyShift action_224
-action_489 (164#) = happyShift action_225
-action_489 (166#) = happyShift action_226
-action_489 (35#) = happyGoto action_209
-action_489 x = happyTcHack x happyFail
-
-action_490 x = happyTcHack x happyReduce_69
-
-action_491 (105#) = happyShift action_494
-action_491 x = happyTcHack x happyFail
-
-action_492 (94#) = happyShift action_493
-action_492 x = happyTcHack x happyFail
-
-action_493 (174#) = happyShift action_51
-action_493 (12#) = happyGoto action_519
-action_493 (16#) = happyGoto action_520
-action_493 (17#) = happyGoto action_521
-action_493 x = happyTcHack x happyReduce_17
-
-action_494 x = happyTcHack x happyReduce_70
-
-action_495 x = happyTcHack x happyReduce_40
-
-action_496 (102#) = happyShift action_518
-action_496 x = happyTcHack x happyReduce_44
-
-action_497 (96#) = happyShift action_517
-action_497 x = happyTcHack x happyFail
-
-action_498 x = happyTcHack x happyReduce_54
-
-action_499 (174#) = happyShift action_51
-action_499 (12#) = happyGoto action_516
-action_499 x = happyTcHack x happyFail
-
-action_500 x = happyTcHack x happyReduce_58
-
-action_501 x = happyTcHack x happyReduce_74
-
-action_502 x = happyTcHack x happyReduce_127
-
-action_503 (99#) = happyShift action_515
-action_503 x = happyTcHack x happyFail
-
-action_504 (94#) = happyShift action_514
-action_504 x = happyTcHack x happyFail
-
-action_505 x = happyTcHack x happyReduce_101
-
-action_506 x = happyTcHack x happyReduce_104
-
-action_507 (96#) = happyShift action_24
-action_507 (98#) = happyShift action_25
-action_507 (104#) = happyShift action_26
-action_507 (109#) = happyShift action_27
-action_507 (110#) = happyShift action_28
-action_507 (111#) = happyShift action_29
-action_507 (114#) = happyShift action_30
-action_507 (119#) = happyShift action_31
-action_507 (124#) = happyShift action_32
-action_507 (125#) = happyShift action_33
-action_507 (126#) = happyShift action_34
-action_507 (127#) = happyShift action_35
-action_507 (128#) = happyShift action_36
-action_507 (129#) = happyShift action_37
-action_507 (131#) = happyShift action_38
-action_507 (134#) = happyShift action_39
-action_507 (137#) = happyShift action_40
-action_507 (140#) = happyShift action_41
-action_507 (145#) = happyShift action_42
-action_507 (156#) = happyShift action_43
-action_507 (157#) = happyShift action_44
-action_507 (161#) = happyShift action_45
-action_507 (162#) = happyShift action_46
-action_507 (167#) = happyShift action_47
-action_507 (170#) = happyShift action_6
-action_507 (171#) = happyShift action_48
-action_507 (172#) = happyShift action_49
-action_507 (173#) = happyShift action_50
-action_507 (174#) = happyShift action_51
-action_507 (8#) = happyGoto action_10
-action_507 (9#) = happyGoto action_11
-action_507 (10#) = happyGoto action_12
-action_507 (11#) = happyGoto action_13
-action_507 (12#) = happyGoto action_14
-action_507 (58#) = happyGoto action_15
-action_507 (59#) = happyGoto action_16
-action_507 (60#) = happyGoto action_17
-action_507 (61#) = happyGoto action_18
-action_507 (62#) = happyGoto action_19
-action_507 (63#) = happyGoto action_513
-action_507 (64#) = happyGoto action_21
-action_507 (72#) = happyGoto action_22
-action_507 (77#) = happyGoto action_23
-action_507 x = happyTcHack x happyFail
-
-action_508 (170#) = happyShift action_6
-action_508 (8#) = happyGoto action_512
-action_508 x = happyTcHack x happyFail
-
-action_509 (102#) = happyShift action_511
-action_509 x = happyTcHack x happyReduce_30
-
-action_510 x = happyTcHack x happyReduce_29
-
-action_511 (151#) = happyShift action_356
-action_511 (28#) = happyGoto action_530
-action_511 x = happyTcHack x happyReduce_55
-
-action_512 (97#) = happyShift action_529
-action_512 x = happyTcHack x happyFail
-
-action_513 (99#) = happyShift action_528
-action_513 x = happyTcHack x happyFail
-
-action_514 x = happyTcHack x happyReduce_92
-
-action_515 x = happyTcHack x happyReduce_106
-
-action_516 (99#) = happyShift action_527
-action_516 x = happyTcHack x happyFail
-
-action_517 (25#) = happyGoto action_526
-action_517 x = happyTcHack x happyReduce_48
-
-action_518 (151#) = happyShift action_356
-action_518 (28#) = happyGoto action_525
-action_518 x = happyTcHack x happyReduce_55
-
-action_519 (95#) = happyShift action_524
-action_519 x = happyTcHack x happyFail
-
-action_520 (94#) = happyShift action_523
-action_520 x = happyTcHack x happyReduce_18
-
-action_521 (97#) = happyShift action_522
-action_521 x = happyTcHack x happyFail
-
-action_522 x = happyTcHack x happyReduce_14
-
-action_523 (174#) = happyShift action_51
-action_523 (12#) = happyGoto action_519
-action_523 (16#) = happyGoto action_520
-action_523 (17#) = happyGoto action_535
-action_523 x = happyTcHack x happyReduce_17
-
-action_524 (174#) = happyShift action_51
-action_524 (12#) = happyGoto action_533
-action_524 (18#) = happyGoto action_534
-action_524 x = happyTcHack x happyFail
-
-action_525 (96#) = happyShift action_532
-action_525 x = happyTcHack x happyFail
-
-action_526 (97#) = happyShift action_531
-action_526 (132#) = happyShift action_210
-action_526 (134#) = happyShift action_211
-action_526 (135#) = happyShift action_212
-action_526 (136#) = happyShift action_213
-action_526 (138#) = happyShift action_214
-action_526 (146#) = happyShift action_215
-action_526 (147#) = happyShift action_216
-action_526 (148#) = happyShift action_217
-action_526 (149#) = happyShift action_218
-action_526 (152#) = happyShift action_219
-action_526 (154#) = happyShift action_220
-action_526 (155#) = happyShift action_221
-action_526 (156#) = happyShift action_222
-action_526 (158#) = happyShift action_223
-action_526 (163#) = happyShift action_224
-action_526 (164#) = happyShift action_225
-action_526 (166#) = happyShift action_226
-action_526 (35#) = happyGoto action_209
-action_526 x = happyTcHack x happyFail
-
-action_527 x = happyTcHack x happyReduce_59
-
-action_528 x = happyTcHack x happyReduce_260
-
-action_529 x = happyTcHack x happyReduce_97
-
-action_530 x = happyTcHack x happyReduce_31
-
-action_531 x = happyTcHack x happyReduce_43
-
-action_532 (25#) = happyGoto action_537
-action_532 x = happyTcHack x happyReduce_48
-
-action_533 (19#) = happyGoto action_536
-action_533 x = happyTcHack x happyReduce_21
-
-action_534 x = happyTcHack x happyReduce_16
-
-action_535 x = happyTcHack x happyReduce_19
-
-action_536 (98#) = happyShift action_540
-action_536 (20#) = happyGoto action_539
-action_536 x = happyTcHack x happyReduce_20
-
-action_537 (97#) = happyShift action_538
-action_537 (132#) = happyShift action_210
-action_537 (134#) = happyShift action_211
-action_537 (135#) = happyShift action_212
-action_537 (136#) = happyShift action_213
-action_537 (138#) = happyShift action_214
-action_537 (146#) = happyShift action_215
-action_537 (147#) = happyShift action_216
-action_537 (148#) = happyShift action_217
-action_537 (149#) = happyShift action_218
-action_537 (152#) = happyShift action_219
-action_537 (154#) = happyShift action_220
-action_537 (155#) = happyShift action_221
-action_537 (156#) = happyShift action_222
-action_537 (158#) = happyShift action_223
-action_537 (163#) = happyShift action_224
-action_537 (164#) = happyShift action_225
-action_537 (166#) = happyShift action_226
-action_537 (35#) = happyGoto action_209
-action_537 x = happyTcHack x happyFail
-
-action_538 x = happyTcHack x happyReduce_45
-
-action_539 x = happyTcHack x happyReduce_22
-
-action_540 (164#) = happyShift action_541
-action_540 x = happyTcHack x happyFail
-
-action_541 (140#) = happyShift action_542
-action_541 (153#) = happyShift action_543
-action_541 x = happyTcHack x happyFail
-
-action_542 (98#) = happyShift action_408
-action_542 (174#) = happyShift action_51
-action_542 (12#) = happyGoto action_406
-action_542 (29#) = happyGoto action_545
-action_542 x = happyTcHack x happyFail
-
-action_543 (98#) = happyShift action_408
-action_543 (174#) = happyShift action_51
-action_543 (12#) = happyGoto action_406
-action_543 (29#) = happyGoto action_544
-action_543 x = happyTcHack x happyFail
-
-action_544 (99#) = happyShift action_547
-action_544 x = happyTcHack x happyFail
-
-action_545 (99#) = happyShift action_546
-action_545 x = happyTcHack x happyFail
-
-action_546 x = happyTcHack x happyReduce_23
-
-action_547 x = happyTcHack x happyReduce_24
-
-happyReduce_5 = happySpecReduce_1 8# happyReduction_5
-happyReduction_5 (HappyTerminal (PT _ (TI happy_var_1)))
- = HappyAbsSyn8
- ((read happy_var_1) :: Integer
- )
-happyReduction_5 _ = notHappyAtAll
-
-happyReduce_6 = happySpecReduce_1 9# happyReduction_6
-happyReduction_6 (HappyTerminal (PT _ (TL happy_var_1)))
- = HappyAbsSyn9
- (happy_var_1
- )
-happyReduction_6 _ = notHappyAtAll
-
-happyReduce_7 = happySpecReduce_1 10# happyReduction_7
-happyReduction_7 (HappyTerminal (PT _ (TD happy_var_1)))
- = HappyAbsSyn10
- ((read happy_var_1) :: Double
- )
-happyReduction_7 _ = notHappyAtAll
-
-happyReduce_8 = happySpecReduce_1 11# happyReduction_8
-happyReduction_8 (HappyTerminal (PT _ (T_LString happy_var_1)))
- = HappyAbsSyn11
- (LString (happy_var_1)
- )
-happyReduction_8 _ = notHappyAtAll
-
-happyReduce_9 = happySpecReduce_1 12# happyReduction_9
-happyReduction_9 (HappyTerminal happy_var_1)
- = HappyAbsSyn12
- (PIdent (mkPosToken happy_var_1)
- )
-happyReduction_9 _ = notHappyAtAll
-
-happyReduce_10 = happySpecReduce_1 13# happyReduction_10
-happyReduction_10 (HappyAbsSyn14 happy_var_1)
- = HappyAbsSyn13
- (Gr (reverse happy_var_1)
- )
-happyReduction_10 _ = notHappyAtAll
-
-happyReduce_11 = happySpecReduce_0 14# happyReduction_11
-happyReduction_11 = HappyAbsSyn14
- ([]
- )
-
-happyReduce_12 = happySpecReduce_2 14# happyReduction_12
-happyReduction_12 (HappyAbsSyn15 happy_var_2)
- (HappyAbsSyn14 happy_var_1)
- = HappyAbsSyn14
- (flip (:) happy_var_1 happy_var_2
- )
-happyReduction_12 _ _ = notHappyAtAll
-
-happyReduce_13 = happySpecReduce_2 15# happyReduction_13
-happyReduction_13 _
- (HappyAbsSyn15 happy_var_1)
- = HappyAbsSyn15
- (happy_var_1
- )
-happyReduction_13 _ _ = notHappyAtAll
-
-happyReduce_14 = happyReduce 10# 15# happyReduction_14
-happyReduction_14 (_ `HappyStk`
- (HappyAbsSyn17 happy_var_9) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_7) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn15
- (MMain happy_var_2 happy_var_7 happy_var_9
- ) `HappyStk` happyRest
-
-happyReduce_15 = happyReduce 4# 15# happyReduction_15
-happyReduction_15 ((HappyAbsSyn22 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn23 happy_var_2) `HappyStk`
- (HappyAbsSyn30 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn15
- (MModule happy_var_1 happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_16 = happySpecReduce_3 16# happyReduction_16
-happyReduction_16 (HappyAbsSyn18 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn16
- (ConcSpec happy_var_1 happy_var_3
- )
-happyReduction_16 _ _ _ = notHappyAtAll
-
-happyReduce_17 = happySpecReduce_0 17# happyReduction_17
-happyReduction_17 = HappyAbsSyn17
- ([]
- )
-
-happyReduce_18 = happySpecReduce_1 17# happyReduction_18
-happyReduction_18 (HappyAbsSyn16 happy_var_1)
- = HappyAbsSyn17
- ((:[]) happy_var_1
- )
-happyReduction_18 _ = notHappyAtAll
-
-happyReduce_19 = happySpecReduce_3 17# happyReduction_19
-happyReduction_19 (HappyAbsSyn17 happy_var_3)
- _
- (HappyAbsSyn16 happy_var_1)
- = HappyAbsSyn17
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_19 _ _ _ = notHappyAtAll
-
-happyReduce_20 = happySpecReduce_2 18# happyReduction_20
-happyReduction_20 (HappyAbsSyn19 happy_var_2)
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn18
- (ConcExp happy_var_1 (reverse happy_var_2)
- )
-happyReduction_20 _ _ = notHappyAtAll
-
-happyReduce_21 = happySpecReduce_0 19# happyReduction_21
-happyReduction_21 = HappyAbsSyn19
- ([]
- )
-
-happyReduce_22 = happySpecReduce_2 19# happyReduction_22
-happyReduction_22 (HappyAbsSyn20 happy_var_2)
- (HappyAbsSyn19 happy_var_1)
- = HappyAbsSyn19
- (flip (:) happy_var_1 happy_var_2
- )
-happyReduction_22 _ _ = notHappyAtAll
-
-happyReduce_23 = happyReduce 5# 20# happyReduction_23
-happyReduction_23 (_ `HappyStk`
- (HappyAbsSyn29 happy_var_4) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn20
- (TransferIn happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_24 = happyReduce 5# 20# happyReduction_24
-happyReduction_24 (_ `HappyStk`
- (HappyAbsSyn29 happy_var_4) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn20
- (TransferOut happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_25 = happyReduce 4# 21# happyReduction_25
-happyReduction_25 ((HappyAbsSyn22 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn23 happy_var_2) `HappyStk`
- (HappyAbsSyn30 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn15
- (MModule happy_var_1 happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_26 = happySpecReduce_2 22# happyReduction_26
-happyReduction_26 (HappyAbsSyn28 happy_var_2)
- (HappyAbsSyn26 happy_var_1)
- = HappyAbsSyn22
- (MBody happy_var_1 happy_var_2 []
- )
-happyReduction_26 _ _ = notHappyAtAll
-
-happyReduce_27 = happySpecReduce_1 22# happyReduction_27
-happyReduction_27 (HappyAbsSyn32 happy_var_1)
- = HappyAbsSyn22
- (MNoBody happy_var_1
- )
-happyReduction_27 _ = notHappyAtAll
-
-happyReduce_28 = happySpecReduce_3 22# happyReduction_28
-happyReduction_28 (HappyAbsSyn27 happy_var_3)
- _
- (HappyAbsSyn33 happy_var_1)
- = HappyAbsSyn22
- (MWith happy_var_1 happy_var_3
- )
-happyReduction_28 _ _ _ = notHappyAtAll
-
-happyReduce_29 = happyReduce 5# 22# happyReduction_29
-happyReduction_29 ((HappyAbsSyn28 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn27 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn33 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MWithBody happy_var_1 happy_var_3 happy_var_5 []
- ) `HappyStk` happyRest
-
-happyReduce_30 = happyReduce 5# 22# happyReduction_30
-happyReduction_30 ((HappyAbsSyn27 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn33 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn32 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MWithE happy_var_1 happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_31 = happyReduce 7# 22# happyReduction_31
-happyReduction_31 ((HappyAbsSyn28 happy_var_7) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn27 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn33 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn32 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MWithEBody happy_var_1 happy_var_3 happy_var_5 happy_var_7 []
- ) `HappyStk` happyRest
-
-happyReduce_32 = happySpecReduce_2 22# happyReduction_32
-happyReduction_32 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn22
- (MReuse happy_var_2
- )
-happyReduction_32 _ _ = notHappyAtAll
-
-happyReduce_33 = happySpecReduce_2 22# happyReduction_33
-happyReduction_33 (HappyAbsSyn32 happy_var_2)
- _
- = HappyAbsSyn22
- (MUnion happy_var_2
- )
-happyReduction_33 _ _ = notHappyAtAll
-
-happyReduce_34 = happySpecReduce_2 23# happyReduction_34
-happyReduction_34 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn23
- (MTAbstract happy_var_2
- )
-happyReduction_34 _ _ = notHappyAtAll
-
-happyReduce_35 = happySpecReduce_2 23# happyReduction_35
-happyReduction_35 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn23
- (MTResource happy_var_2
- )
-happyReduction_35 _ _ = notHappyAtAll
-
-happyReduce_36 = happySpecReduce_2 23# happyReduction_36
-happyReduction_36 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn23
- (MTInterface happy_var_2
- )
-happyReduction_36 _ _ = notHappyAtAll
-
-happyReduce_37 = happyReduce 4# 23# happyReduction_37
-happyReduction_37 ((HappyAbsSyn12 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn23
- (MTConcrete happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_38 = happyReduce 4# 23# happyReduction_38
-happyReduction_38 ((HappyAbsSyn12 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn23
- (MTInstance happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_39 = happyReduce 6# 23# happyReduction_39
-happyReduction_39 ((HappyAbsSyn29 happy_var_6) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn29 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn23
- (MTTransfer happy_var_2 happy_var_4 happy_var_6
- ) `HappyStk` happyRest
-
-happyReduce_40 = happyReduce 5# 24# happyReduction_40
-happyReduction_40 (_ `HappyStk`
- (HappyAbsSyn25 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn28 happy_var_2) `HappyStk`
- (HappyAbsSyn26 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MBody happy_var_1 happy_var_2 (reverse happy_var_4)
- ) `HappyStk` happyRest
-
-happyReduce_41 = happySpecReduce_1 24# happyReduction_41
-happyReduction_41 (HappyAbsSyn32 happy_var_1)
- = HappyAbsSyn22
- (MNoBody happy_var_1
- )
-happyReduction_41 _ = notHappyAtAll
-
-happyReduce_42 = happySpecReduce_3 24# happyReduction_42
-happyReduction_42 (HappyAbsSyn27 happy_var_3)
- _
- (HappyAbsSyn33 happy_var_1)
- = HappyAbsSyn22
- (MWith happy_var_1 happy_var_3
- )
-happyReduction_42 _ _ _ = notHappyAtAll
-
-happyReduce_43 = happyReduce 8# 24# happyReduction_43
-happyReduction_43 (_ `HappyStk`
- (HappyAbsSyn25 happy_var_7) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn28 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn27 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn33 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MWithBody happy_var_1 happy_var_3 happy_var_5 (reverse happy_var_7)
- ) `HappyStk` happyRest
-
-happyReduce_44 = happyReduce 5# 24# happyReduction_44
-happyReduction_44 ((HappyAbsSyn27 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn33 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn32 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MWithE happy_var_1 happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_45 = happyReduce 10# 24# happyReduction_45
-happyReduction_45 (_ `HappyStk`
- (HappyAbsSyn25 happy_var_9) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn28 happy_var_7) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn27 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn33 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn32 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn22
- (MWithEBody happy_var_1 happy_var_3 happy_var_5 happy_var_7 (reverse happy_var_9)
- ) `HappyStk` happyRest
-
-happyReduce_46 = happySpecReduce_2 24# happyReduction_46
-happyReduction_46 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn22
- (MReuse happy_var_2
- )
-happyReduction_46 _ _ = notHappyAtAll
-
-happyReduce_47 = happySpecReduce_2 24# happyReduction_47
-happyReduction_47 (HappyAbsSyn32 happy_var_2)
- _
- = HappyAbsSyn22
- (MUnion happy_var_2
- )
-happyReduction_47 _ _ = notHappyAtAll
-
-happyReduce_48 = happySpecReduce_0 25# happyReduction_48
-happyReduction_48 = HappyAbsSyn25
- ([]
- )
-
-happyReduce_49 = happySpecReduce_2 25# happyReduction_49
-happyReduction_49 (HappyAbsSyn35 happy_var_2)
- (HappyAbsSyn25 happy_var_1)
- = HappyAbsSyn25
- (flip (:) happy_var_1 happy_var_2
- )
-happyReduction_49 _ _ = notHappyAtAll
-
-happyReduce_50 = happySpecReduce_2 26# happyReduction_50
-happyReduction_50 _
- (HappyAbsSyn32 happy_var_1)
- = HappyAbsSyn26
- (Ext happy_var_1
- )
-happyReduction_50 _ _ = notHappyAtAll
-
-happyReduce_51 = happySpecReduce_0 26# happyReduction_51
-happyReduction_51 = HappyAbsSyn26
- (NoExt
- )
-
-happyReduce_52 = happySpecReduce_0 27# happyReduction_52
-happyReduction_52 = HappyAbsSyn27
- ([]
- )
-
-happyReduce_53 = happySpecReduce_1 27# happyReduction_53
-happyReduction_53 (HappyAbsSyn29 happy_var_1)
- = HappyAbsSyn27
- ((:[]) happy_var_1
- )
-happyReduction_53 _ = notHappyAtAll
-
-happyReduce_54 = happySpecReduce_3 27# happyReduction_54
-happyReduction_54 (HappyAbsSyn27 happy_var_3)
- _
- (HappyAbsSyn29 happy_var_1)
- = HappyAbsSyn27
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_54 _ _ _ = notHappyAtAll
-
-happyReduce_55 = happySpecReduce_0 28# happyReduction_55
-happyReduction_55 = HappyAbsSyn28
- (NoOpens
- )
-
-happyReduce_56 = happySpecReduce_3 28# happyReduction_56
-happyReduction_56 _
- (HappyAbsSyn27 happy_var_2)
- _
- = HappyAbsSyn28
- (OpenIn happy_var_2
- )
-happyReduction_56 _ _ _ = notHappyAtAll
-
-happyReduce_57 = happySpecReduce_1 29# happyReduction_57
-happyReduction_57 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn29
- (OName happy_var_1
- )
-happyReduction_57 _ = notHappyAtAll
-
-happyReduce_58 = happyReduce 4# 29# happyReduction_58
-happyReduction_58 (_ `HappyStk`
- (HappyAbsSyn12 happy_var_3) `HappyStk`
- (HappyAbsSyn31 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn29
- (OQualQO happy_var_2 happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_59 = happyReduce 6# 29# happyReduction_59
-happyReduction_59 (_ `HappyStk`
- (HappyAbsSyn12 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_3) `HappyStk`
- (HappyAbsSyn31 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn29
- (OQual happy_var_2 happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_60 = happySpecReduce_0 30# happyReduction_60
-happyReduction_60 = HappyAbsSyn30
- (CMCompl
- )
-
-happyReduce_61 = happySpecReduce_1 30# happyReduction_61
-happyReduction_61 _
- = HappyAbsSyn30
- (CMIncompl
- )
-
-happyReduce_62 = happySpecReduce_0 31# happyReduction_62
-happyReduction_62 = HappyAbsSyn31
- (QOCompl
- )
-
-happyReduce_63 = happySpecReduce_1 31# happyReduction_63
-happyReduction_63 _
- = HappyAbsSyn31
- (QOIncompl
- )
-
-happyReduce_64 = happySpecReduce_1 31# happyReduction_64
-happyReduction_64 _
- = HappyAbsSyn31
- (QOInterface
- )
-
-happyReduce_65 = happySpecReduce_0 32# happyReduction_65
-happyReduction_65 = HappyAbsSyn32
- ([]
- )
-
-happyReduce_66 = happySpecReduce_1 32# happyReduction_66
-happyReduction_66 (HappyAbsSyn33 happy_var_1)
- = HappyAbsSyn32
- ((:[]) happy_var_1
- )
-happyReduction_66 _ = notHappyAtAll
-
-happyReduce_67 = happySpecReduce_3 32# happyReduction_67
-happyReduction_67 (HappyAbsSyn32 happy_var_3)
- _
- (HappyAbsSyn33 happy_var_1)
- = HappyAbsSyn32
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_67 _ _ _ = notHappyAtAll
-
-happyReduce_68 = happySpecReduce_1 33# happyReduction_68
-happyReduction_68 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn33
- (IAll happy_var_1
- )
-happyReduction_68 _ = notHappyAtAll
-
-happyReduce_69 = happyReduce 4# 33# happyReduction_69
-happyReduction_69 (_ `HappyStk`
- (HappyAbsSyn53 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn33
- (ISome happy_var_1 happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_70 = happyReduce 5# 33# happyReduction_70
-happyReduction_70 (_ `HappyStk`
- (HappyAbsSyn53 happy_var_4) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn33
- (IMinus happy_var_1 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_71 = happySpecReduce_3 34# happyReduction_71
-happyReduction_71 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn55 happy_var_1)
- = HappyAbsSyn34
- (DDecl happy_var_1 happy_var_3
- )
-happyReduction_71 _ _ _ = notHappyAtAll
-
-happyReduce_72 = happySpecReduce_3 34# happyReduction_72
-happyReduction_72 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn55 happy_var_1)
- = HappyAbsSyn34
- (DDef happy_var_1 happy_var_3
- )
-happyReduction_72 _ _ _ = notHappyAtAll
-
-happyReduce_73 = happyReduce 4# 34# happyReduction_73
-happyReduction_73 ((HappyAbsSyn58 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn74 happy_var_2) `HappyStk`
- (HappyAbsSyn54 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn34
- (DPatt happy_var_1 happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_74 = happyReduce 5# 34# happyReduction_74
-happyReduction_74 ((HappyAbsSyn58 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn55 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn34
- (DFull happy_var_1 happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_75 = happySpecReduce_2 35# happyReduction_75
-happyReduction_75 (HappyAbsSyn46 happy_var_2)
- _
- = HappyAbsSyn35
- (DefCat happy_var_2
- )
-happyReduction_75 _ _ = notHappyAtAll
-
-happyReduce_76 = happySpecReduce_2 35# happyReduction_76
-happyReduction_76 (HappyAbsSyn47 happy_var_2)
- _
- = HappyAbsSyn35
- (DefFun happy_var_2
- )
-happyReduction_76 _ _ = notHappyAtAll
-
-happyReduce_77 = happySpecReduce_2 35# happyReduction_77
-happyReduction_77 (HappyAbsSyn47 happy_var_2)
- _
- = HappyAbsSyn35
- (DefFunData happy_var_2
- )
-happyReduction_77 _ _ = notHappyAtAll
-
-happyReduce_78 = happySpecReduce_2 35# happyReduction_78
-happyReduction_78 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefDef happy_var_2
- )
-happyReduction_78 _ _ = notHappyAtAll
-
-happyReduce_79 = happySpecReduce_2 35# happyReduction_79
-happyReduction_79 (HappyAbsSyn48 happy_var_2)
- _
- = HappyAbsSyn35
- (DefData happy_var_2
- )
-happyReduction_79 _ _ = notHappyAtAll
-
-happyReduce_80 = happySpecReduce_2 35# happyReduction_80
-happyReduction_80 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefTrans happy_var_2
- )
-happyReduction_80 _ _ = notHappyAtAll
-
-happyReduce_81 = happySpecReduce_2 35# happyReduction_81
-happyReduction_81 (HappyAbsSyn49 happy_var_2)
- _
- = HappyAbsSyn35
- (DefPar happy_var_2
- )
-happyReduction_81 _ _ = notHappyAtAll
-
-happyReduce_82 = happySpecReduce_2 35# happyReduction_82
-happyReduction_82 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefOper happy_var_2
- )
-happyReduction_82 _ _ = notHappyAtAll
-
-happyReduce_83 = happySpecReduce_2 35# happyReduction_83
-happyReduction_83 (HappyAbsSyn50 happy_var_2)
- _
- = HappyAbsSyn35
- (DefLincat happy_var_2
- )
-happyReduction_83 _ _ = notHappyAtAll
-
-happyReduce_84 = happySpecReduce_2 35# happyReduction_84
-happyReduction_84 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefLindef happy_var_2
- )
-happyReduction_84 _ _ = notHappyAtAll
-
-happyReduce_85 = happySpecReduce_2 35# happyReduction_85
-happyReduction_85 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefLin happy_var_2
- )
-happyReduction_85 _ _ = notHappyAtAll
-
-happyReduce_86 = happySpecReduce_3 35# happyReduction_86
-happyReduction_86 (HappyAbsSyn50 happy_var_3)
- _
- _
- = HappyAbsSyn35
- (DefPrintCat happy_var_3
- )
-happyReduction_86 _ _ _ = notHappyAtAll
-
-happyReduce_87 = happySpecReduce_3 35# happyReduction_87
-happyReduction_87 (HappyAbsSyn50 happy_var_3)
- _
- _
- = HappyAbsSyn35
- (DefPrintFun happy_var_3
- )
-happyReduction_87 _ _ _ = notHappyAtAll
-
-happyReduce_88 = happySpecReduce_2 35# happyReduction_88
-happyReduction_88 (HappyAbsSyn51 happy_var_2)
- _
- = HappyAbsSyn35
- (DefFlag happy_var_2
- )
-happyReduction_88 _ _ = notHappyAtAll
-
-happyReduce_89 = happySpecReduce_2 35# happyReduction_89
-happyReduction_89 (HappyAbsSyn50 happy_var_2)
- _
- = HappyAbsSyn35
- (DefPrintOld happy_var_2
- )
-happyReduction_89 _ _ = notHappyAtAll
-
-happyReduce_90 = happySpecReduce_2 35# happyReduction_90
-happyReduction_90 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefLintype happy_var_2
- )
-happyReduction_90 _ _ = notHappyAtAll
-
-happyReduce_91 = happySpecReduce_2 35# happyReduction_91
-happyReduction_91 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefPattern happy_var_2
- )
-happyReduction_91 _ _ = notHappyAtAll
-
-happyReduce_92 = happyReduce 7# 35# happyReduction_92
-happyReduction_92 (_ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn25 happy_var_5) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn35
- (DefPackage happy_var_2 (reverse happy_var_5)
- ) `HappyStk` happyRest
-
-happyReduce_93 = happySpecReduce_2 35# happyReduction_93
-happyReduction_93 (HappyAbsSyn45 happy_var_2)
- _
- = HappyAbsSyn35
- (DefVars happy_var_2
- )
-happyReduction_93 _ _ = notHappyAtAll
-
-happyReduce_94 = happySpecReduce_3 35# happyReduction_94
-happyReduction_94 _
- (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn35
- (DefTokenizer happy_var_2
- )
-happyReduction_94 _ _ _ = notHappyAtAll
-
-happyReduce_95 = happySpecReduce_2 36# happyReduction_95
-happyReduction_95 (HappyAbsSyn89 happy_var_2)
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn36
- (SimpleCatDef happy_var_1 (reverse happy_var_2)
- )
-happyReduction_95 _ _ = notHappyAtAll
-
-happyReduce_96 = happyReduce 4# 36# happyReduction_96
-happyReduction_96 (_ `HappyStk`
- (HappyAbsSyn89 happy_var_3) `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn36
- (ListCatDef happy_var_2 (reverse happy_var_3)
- ) `HappyStk` happyRest
-
-happyReduce_97 = happyReduce 7# 36# happyReduction_97
-happyReduction_97 (_ `HappyStk`
- (HappyAbsSyn8 happy_var_6) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn89 happy_var_3) `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn36
- (ListSizeCatDef happy_var_2 (reverse happy_var_3) happy_var_6
- ) `HappyStk` happyRest
-
-happyReduce_98 = happySpecReduce_3 37# happyReduction_98
-happyReduction_98 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn53 happy_var_1)
- = HappyAbsSyn37
- (FunDef happy_var_1 happy_var_3
- )
-happyReduction_98 _ _ _ = notHappyAtAll
-
-happyReduce_99 = happySpecReduce_3 38# happyReduction_99
-happyReduction_99 (HappyAbsSyn40 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn38
- (DataDef happy_var_1 happy_var_3
- )
-happyReduction_99 _ _ _ = notHappyAtAll
-
-happyReduce_100 = happySpecReduce_1 39# happyReduction_100
-happyReduction_100 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn39
- (DataId happy_var_1
- )
-happyReduction_100 _ = notHappyAtAll
-
-happyReduce_101 = happySpecReduce_3 39# happyReduction_101
-happyReduction_101 (HappyAbsSyn12 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn39
- (DataQId happy_var_1 happy_var_3
- )
-happyReduction_101 _ _ _ = notHappyAtAll
-
-happyReduce_102 = happySpecReduce_0 40# happyReduction_102
-happyReduction_102 = HappyAbsSyn40
- ([]
- )
-
-happyReduce_103 = happySpecReduce_1 40# happyReduction_103
-happyReduction_103 (HappyAbsSyn39 happy_var_1)
- = HappyAbsSyn40
- ((:[]) happy_var_1
- )
-happyReduction_103 _ = notHappyAtAll
-
-happyReduce_104 = happySpecReduce_3 40# happyReduction_104
-happyReduction_104 (HappyAbsSyn40 happy_var_3)
- _
- (HappyAbsSyn39 happy_var_1)
- = HappyAbsSyn40
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_104 _ _ _ = notHappyAtAll
-
-happyReduce_105 = happySpecReduce_3 41# happyReduction_105
-happyReduction_105 (HappyAbsSyn52 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn41
- (ParDefDir happy_var_1 happy_var_3
- )
-happyReduction_105 _ _ _ = notHappyAtAll
-
-happyReduce_106 = happyReduce 6# 41# happyReduction_106
-happyReduction_106 (_ `HappyStk`
- (HappyAbsSyn12 happy_var_5) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn41
- (ParDefIndir happy_var_1 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_107 = happySpecReduce_1 41# happyReduction_107
-happyReduction_107 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn41
- (ParDefAbs happy_var_1
- )
-happyReduction_107 _ = notHappyAtAll
-
-happyReduce_108 = happySpecReduce_2 42# happyReduction_108
-happyReduction_108 (HappyAbsSyn89 happy_var_2)
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn42
- (ParConstr happy_var_1 (reverse happy_var_2)
- )
-happyReduction_108 _ _ = notHappyAtAll
-
-happyReduce_109 = happySpecReduce_3 43# happyReduction_109
-happyReduction_109 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn55 happy_var_1)
- = HappyAbsSyn43
- (PrintDef happy_var_1 happy_var_3
- )
-happyReduction_109 _ _ _ = notHappyAtAll
-
-happyReduce_110 = happySpecReduce_3 44# happyReduction_110
-happyReduction_110 (HappyAbsSyn12 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn44
- (FlagDef happy_var_1 happy_var_3
- )
-happyReduction_110 _ _ _ = notHappyAtAll
-
-happyReduce_111 = happySpecReduce_2 45# happyReduction_111
-happyReduction_111 _
- (HappyAbsSyn34 happy_var_1)
- = HappyAbsSyn45
- ((:[]) happy_var_1
- )
-happyReduction_111 _ _ = notHappyAtAll
-
-happyReduce_112 = happySpecReduce_3 45# happyReduction_112
-happyReduction_112 (HappyAbsSyn45 happy_var_3)
- _
- (HappyAbsSyn34 happy_var_1)
- = HappyAbsSyn45
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_112 _ _ _ = notHappyAtAll
-
-happyReduce_113 = happySpecReduce_2 46# happyReduction_113
-happyReduction_113 _
- (HappyAbsSyn36 happy_var_1)
- = HappyAbsSyn46
- ((:[]) happy_var_1
- )
-happyReduction_113 _ _ = notHappyAtAll
-
-happyReduce_114 = happySpecReduce_3 46# happyReduction_114
-happyReduction_114 (HappyAbsSyn46 happy_var_3)
- _
- (HappyAbsSyn36 happy_var_1)
- = HappyAbsSyn46
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_114 _ _ _ = notHappyAtAll
-
-happyReduce_115 = happySpecReduce_2 47# happyReduction_115
-happyReduction_115 _
- (HappyAbsSyn37 happy_var_1)
- = HappyAbsSyn47
- ((:[]) happy_var_1
- )
-happyReduction_115 _ _ = notHappyAtAll
-
-happyReduce_116 = happySpecReduce_3 47# happyReduction_116
-happyReduction_116 (HappyAbsSyn47 happy_var_3)
- _
- (HappyAbsSyn37 happy_var_1)
- = HappyAbsSyn47
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_116 _ _ _ = notHappyAtAll
-
-happyReduce_117 = happySpecReduce_2 48# happyReduction_117
-happyReduction_117 _
- (HappyAbsSyn38 happy_var_1)
- = HappyAbsSyn48
- ((:[]) happy_var_1
- )
-happyReduction_117 _ _ = notHappyAtAll
-
-happyReduce_118 = happySpecReduce_3 48# happyReduction_118
-happyReduction_118 (HappyAbsSyn48 happy_var_3)
- _
- (HappyAbsSyn38 happy_var_1)
- = HappyAbsSyn48
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_118 _ _ _ = notHappyAtAll
-
-happyReduce_119 = happySpecReduce_2 49# happyReduction_119
-happyReduction_119 _
- (HappyAbsSyn41 happy_var_1)
- = HappyAbsSyn49
- ((:[]) happy_var_1
- )
-happyReduction_119 _ _ = notHappyAtAll
-
-happyReduce_120 = happySpecReduce_3 49# happyReduction_120
-happyReduction_120 (HappyAbsSyn49 happy_var_3)
- _
- (HappyAbsSyn41 happy_var_1)
- = HappyAbsSyn49
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_120 _ _ _ = notHappyAtAll
-
-happyReduce_121 = happySpecReduce_2 50# happyReduction_121
-happyReduction_121 _
- (HappyAbsSyn43 happy_var_1)
- = HappyAbsSyn50
- ((:[]) happy_var_1
- )
-happyReduction_121 _ _ = notHappyAtAll
-
-happyReduce_122 = happySpecReduce_3 50# happyReduction_122
-happyReduction_122 (HappyAbsSyn50 happy_var_3)
- _
- (HappyAbsSyn43 happy_var_1)
- = HappyAbsSyn50
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_122 _ _ _ = notHappyAtAll
-
-happyReduce_123 = happySpecReduce_2 51# happyReduction_123
-happyReduction_123 _
- (HappyAbsSyn44 happy_var_1)
- = HappyAbsSyn51
- ((:[]) happy_var_1
- )
-happyReduction_123 _ _ = notHappyAtAll
-
-happyReduce_124 = happySpecReduce_3 51# happyReduction_124
-happyReduction_124 (HappyAbsSyn51 happy_var_3)
- _
- (HappyAbsSyn44 happy_var_1)
- = HappyAbsSyn51
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_124 _ _ _ = notHappyAtAll
-
-happyReduce_125 = happySpecReduce_0 52# happyReduction_125
-happyReduction_125 = HappyAbsSyn52
- ([]
- )
-
-happyReduce_126 = happySpecReduce_1 52# happyReduction_126
-happyReduction_126 (HappyAbsSyn42 happy_var_1)
- = HappyAbsSyn52
- ((:[]) happy_var_1
- )
-happyReduction_126 _ = notHappyAtAll
-
-happyReduce_127 = happySpecReduce_3 52# happyReduction_127
-happyReduction_127 (HappyAbsSyn52 happy_var_3)
- _
- (HappyAbsSyn42 happy_var_1)
- = HappyAbsSyn52
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_127 _ _ _ = notHappyAtAll
-
-happyReduce_128 = happySpecReduce_1 53# happyReduction_128
-happyReduction_128 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn53
- ((:[]) happy_var_1
- )
-happyReduction_128 _ = notHappyAtAll
-
-happyReduce_129 = happySpecReduce_3 53# happyReduction_129
-happyReduction_129 (HappyAbsSyn53 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn53
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_129 _ _ _ = notHappyAtAll
-
-happyReduce_130 = happySpecReduce_1 54# happyReduction_130
-happyReduction_130 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn54
- (IdentName happy_var_1
- )
-happyReduction_130 _ = notHappyAtAll
-
-happyReduce_131 = happySpecReduce_3 54# happyReduction_131
-happyReduction_131 _
- (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn54
- (ListName happy_var_2
- )
-happyReduction_131 _ _ _ = notHappyAtAll
-
-happyReduce_132 = happySpecReduce_1 55# happyReduction_132
-happyReduction_132 (HappyAbsSyn54 happy_var_1)
- = HappyAbsSyn55
- ((:[]) happy_var_1
- )
-happyReduction_132 _ = notHappyAtAll
-
-happyReduce_133 = happySpecReduce_3 55# happyReduction_133
-happyReduction_133 (HappyAbsSyn55 happy_var_3)
- _
- (HappyAbsSyn54 happy_var_1)
- = HappyAbsSyn55
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_133 _ _ _ = notHappyAtAll
-
-happyReduce_134 = happySpecReduce_3 56# happyReduction_134
-happyReduction_134 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn53 happy_var_1)
- = HappyAbsSyn56
- (LDDecl happy_var_1 happy_var_3
- )
-happyReduction_134 _ _ _ = notHappyAtAll
-
-happyReduce_135 = happySpecReduce_3 56# happyReduction_135
-happyReduction_135 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn53 happy_var_1)
- = HappyAbsSyn56
- (LDDef happy_var_1 happy_var_3
- )
-happyReduction_135 _ _ _ = notHappyAtAll
-
-happyReduce_136 = happyReduce 5# 56# happyReduction_136
-happyReduction_136 ((HappyAbsSyn58 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn53 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn56
- (LDFull happy_var_1 happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_137 = happySpecReduce_0 57# happyReduction_137
-happyReduction_137 = HappyAbsSyn57
- ([]
- )
-
-happyReduce_138 = happySpecReduce_1 57# happyReduction_138
-happyReduction_138 (HappyAbsSyn56 happy_var_1)
- = HappyAbsSyn57
- ((:[]) happy_var_1
- )
-happyReduction_138 _ = notHappyAtAll
-
-happyReduce_139 = happySpecReduce_3 57# happyReduction_139
-happyReduction_139 (HappyAbsSyn57 happy_var_3)
- _
- (HappyAbsSyn56 happy_var_1)
- = HappyAbsSyn57
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_139 _ _ _ = notHappyAtAll
-
-happyReduce_140 = happySpecReduce_1 58# happyReduction_140
-happyReduction_140 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn58
- (EIdent happy_var_1
- )
-happyReduction_140 _ = notHappyAtAll
-
-happyReduce_141 = happySpecReduce_3 58# happyReduction_141
-happyReduction_141 _
- (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn58
- (EConstr happy_var_2
- )
-happyReduction_141 _ _ _ = notHappyAtAll
-
-happyReduce_142 = happySpecReduce_3 58# happyReduction_142
-happyReduction_142 _
- (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn58
- (ECons happy_var_2
- )
-happyReduction_142 _ _ _ = notHappyAtAll
-
-happyReduce_143 = happySpecReduce_1 58# happyReduction_143
-happyReduction_143 (HappyAbsSyn72 happy_var_1)
- = HappyAbsSyn58
- (ESort happy_var_1
- )
-happyReduction_143 _ = notHappyAtAll
-
-happyReduce_144 = happySpecReduce_1 58# happyReduction_144
-happyReduction_144 (HappyAbsSyn9 happy_var_1)
- = HappyAbsSyn58
- (EString happy_var_1
- )
-happyReduction_144 _ = notHappyAtAll
-
-happyReduce_145 = happySpecReduce_1 58# happyReduction_145
-happyReduction_145 (HappyAbsSyn8 happy_var_1)
- = HappyAbsSyn58
- (EInt happy_var_1
- )
-happyReduction_145 _ = notHappyAtAll
-
-happyReduce_146 = happySpecReduce_1 58# happyReduction_146
-happyReduction_146 (HappyAbsSyn10 happy_var_1)
- = HappyAbsSyn58
- (EFloat happy_var_1
- )
-happyReduction_146 _ = notHappyAtAll
-
-happyReduce_147 = happySpecReduce_1 58# happyReduction_147
-happyReduction_147 _
- = HappyAbsSyn58
- (EMeta
- )
-
-happyReduce_148 = happySpecReduce_2 58# happyReduction_148
-happyReduction_148 _
- _
- = HappyAbsSyn58
- (EEmpty
- )
-
-happyReduce_149 = happySpecReduce_1 58# happyReduction_149
-happyReduction_149 _
- = HappyAbsSyn58
- (EData
- )
-
-happyReduce_150 = happyReduce 4# 58# happyReduction_150
-happyReduction_150 (_ `HappyStk`
- (HappyAbsSyn66 happy_var_3) `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EList happy_var_2 happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_151 = happySpecReduce_3 58# happyReduction_151
-happyReduction_151 _
- (HappyAbsSyn9 happy_var_2)
- _
- = HappyAbsSyn58
- (EStrings happy_var_2
- )
-happyReduction_151 _ _ _ = notHappyAtAll
-
-happyReduce_152 = happySpecReduce_3 58# happyReduction_152
-happyReduction_152 _
- (HappyAbsSyn57 happy_var_2)
- _
- = HappyAbsSyn58
- (ERecord happy_var_2
- )
-happyReduction_152 _ _ _ = notHappyAtAll
-
-happyReduce_153 = happySpecReduce_3 58# happyReduction_153
-happyReduction_153 _
- (HappyAbsSyn80 happy_var_2)
- _
- = HappyAbsSyn58
- (ETuple happy_var_2
- )
-happyReduction_153 _ _ _ = notHappyAtAll
-
-happyReduce_154 = happyReduce 4# 58# happyReduction_154
-happyReduction_154 (_ `HappyStk`
- (HappyAbsSyn12 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EIndir happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_155 = happyReduce 5# 58# happyReduction_155
-happyReduction_155 (_ `HappyStk`
- (HappyAbsSyn58 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ETyped happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_156 = happySpecReduce_3 58# happyReduction_156
-happyReduction_156 _
- (HappyAbsSyn58 happy_var_2)
- _
- = HappyAbsSyn58
- (happy_var_2
- )
-happyReduction_156 _ _ _ = notHappyAtAll
-
-happyReduce_157 = happySpecReduce_1 58# happyReduction_157
-happyReduction_157 (HappyAbsSyn11 happy_var_1)
- = HappyAbsSyn58
- (ELString happy_var_1
- )
-happyReduction_157 _ = notHappyAtAll
-
-happyReduce_158 = happySpecReduce_3 59# happyReduction_158
-happyReduction_158 (HappyAbsSyn71 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (EProj happy_var_1 happy_var_3
- )
-happyReduction_158 _ _ _ = notHappyAtAll
-
-happyReduce_159 = happyReduce 5# 59# happyReduction_159
-happyReduction_159 (_ `HappyStk`
- (HappyAbsSyn12 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EQConstr happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_160 = happyReduce 4# 59# happyReduction_160
-happyReduction_160 ((HappyAbsSyn12 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EQCons happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_161 = happySpecReduce_1 59# happyReduction_161
-happyReduction_161 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (happy_var_1
- )
-happyReduction_161 _ = notHappyAtAll
-
-happyReduce_162 = happySpecReduce_2 60# happyReduction_162
-happyReduction_162 (HappyAbsSyn58 happy_var_2)
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (EApp happy_var_1 happy_var_2
- )
-happyReduction_162 _ _ = notHappyAtAll
-
-happyReduce_163 = happyReduce 4# 60# happyReduction_163
-happyReduction_163 (_ `HappyStk`
- (HappyAbsSyn83 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ETable happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_164 = happyReduce 5# 60# happyReduction_164
-happyReduction_164 (_ `HappyStk`
- (HappyAbsSyn83 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ETTable happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_165 = happyReduce 5# 60# happyReduction_165
-happyReduction_165 (_ `HappyStk`
- (HappyAbsSyn65 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EVTable happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_166 = happyReduce 6# 60# happyReduction_166
-happyReduction_166 (_ `HappyStk`
- (HappyAbsSyn83 happy_var_5) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ECase happy_var_2 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_167 = happyReduce 4# 60# happyReduction_167
-happyReduction_167 (_ `HappyStk`
- (HappyAbsSyn65 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EVariants happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_168 = happyReduce 6# 60# happyReduction_168
-happyReduction_168 (_ `HappyStk`
- (HappyAbsSyn87 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EPre happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_169 = happyReduce 4# 60# happyReduction_169
-happyReduction_169 (_ `HappyStk`
- (HappyAbsSyn65 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EStrs happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_170 = happySpecReduce_3 60# happyReduction_170
-happyReduction_170 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn58
- (EConAt happy_var_1 happy_var_3
- )
-happyReduction_170 _ _ _ = notHappyAtAll
-
-happyReduce_171 = happySpecReduce_2 60# happyReduction_171
-happyReduction_171 (HappyAbsSyn67 happy_var_2)
- _
- = HappyAbsSyn58
- (EPatt happy_var_2
- )
-happyReduction_171 _ _ = notHappyAtAll
-
-happyReduce_172 = happySpecReduce_2 60# happyReduction_172
-happyReduction_172 (HappyAbsSyn58 happy_var_2)
- _
- = HappyAbsSyn58
- (EPattType happy_var_2
- )
-happyReduction_172 _ _ = notHappyAtAll
-
-happyReduce_173 = happySpecReduce_1 60# happyReduction_173
-happyReduction_173 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (happy_var_1
- )
-happyReduction_173 _ = notHappyAtAll
-
-happyReduce_174 = happySpecReduce_2 60# happyReduction_174
-happyReduction_174 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn58
- (ELin happy_var_2
- )
-happyReduction_174 _ _ = notHappyAtAll
-
-happyReduce_175 = happySpecReduce_3 61# happyReduction_175
-happyReduction_175 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (ESelect happy_var_1 happy_var_3
- )
-happyReduction_175 _ _ _ = notHappyAtAll
-
-happyReduce_176 = happySpecReduce_3 61# happyReduction_176
-happyReduction_176 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (ETupTyp happy_var_1 happy_var_3
- )
-happyReduction_176 _ _ _ = notHappyAtAll
-
-happyReduce_177 = happySpecReduce_3 61# happyReduction_177
-happyReduction_177 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (EExtend happy_var_1 happy_var_3
- )
-happyReduction_177 _ _ _ = notHappyAtAll
-
-happyReduce_178 = happySpecReduce_1 61# happyReduction_178
-happyReduction_178 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (happy_var_1
- )
-happyReduction_178 _ = notHappyAtAll
-
-happyReduce_179 = happySpecReduce_3 62# happyReduction_179
-happyReduction_179 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (EGlue happy_var_1 happy_var_3
- )
-happyReduction_179 _ _ _ = notHappyAtAll
-
-happyReduce_180 = happySpecReduce_1 62# happyReduction_180
-happyReduction_180 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (happy_var_1
- )
-happyReduction_180 _ = notHappyAtAll
-
-happyReduce_181 = happySpecReduce_3 63# happyReduction_181
-happyReduction_181 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (EConcat happy_var_1 happy_var_3
- )
-happyReduction_181 _ _ _ = notHappyAtAll
-
-happyReduce_182 = happyReduce 4# 63# happyReduction_182
-happyReduction_182 ((HappyAbsSyn58 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn76 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EAbstr happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_183 = happyReduce 5# 63# happyReduction_183
-happyReduction_183 ((HappyAbsSyn58 happy_var_5) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn76 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ECTable happy_var_3 happy_var_5
- ) `HappyStk` happyRest
-
-happyReduce_184 = happySpecReduce_3 63# happyReduction_184
-happyReduction_184 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn77 happy_var_1)
- = HappyAbsSyn58
- (EProd happy_var_1 happy_var_3
- )
-happyReduction_184 _ _ _ = notHappyAtAll
-
-happyReduce_185 = happySpecReduce_3 63# happyReduction_185
-happyReduction_185 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (ETType happy_var_1 happy_var_3
- )
-happyReduction_185 _ _ _ = notHappyAtAll
-
-happyReduce_186 = happyReduce 6# 63# happyReduction_186
-happyReduction_186 ((HappyAbsSyn58 happy_var_6) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn57 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ELet happy_var_3 happy_var_6
- ) `HappyStk` happyRest
-
-happyReduce_187 = happyReduce 4# 63# happyReduction_187
-happyReduction_187 ((HappyAbsSyn58 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn57 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (ELetb happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_188 = happyReduce 5# 63# happyReduction_188
-happyReduction_188 (_ `HappyStk`
- (HappyAbsSyn57 happy_var_4) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn58 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EWhere happy_var_1 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_189 = happyReduce 4# 63# happyReduction_189
-happyReduction_189 (_ `HappyStk`
- (HappyAbsSyn85 happy_var_3) `HappyStk`
- _ `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn58
- (EEqs happy_var_3
- ) `HappyStk` happyRest
-
-happyReduce_190 = happySpecReduce_3 63# happyReduction_190
-happyReduction_190 (HappyAbsSyn9 happy_var_3)
- (HappyAbsSyn58 happy_var_2)
- _
- = HappyAbsSyn58
- (EExample happy_var_2 happy_var_3
- )
-happyReduction_190 _ _ _ = notHappyAtAll
-
-happyReduce_191 = happySpecReduce_1 63# happyReduction_191
-happyReduction_191 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (happy_var_1
- )
-happyReduction_191 _ = notHappyAtAll
-
-happyReduce_192 = happySpecReduce_1 64# happyReduction_192
-happyReduction_192 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn58
- (happy_var_1
- )
-happyReduction_192 _ = notHappyAtAll
-
-happyReduce_193 = happySpecReduce_0 65# happyReduction_193
-happyReduction_193 = HappyAbsSyn65
- ([]
- )
-
-happyReduce_194 = happySpecReduce_1 65# happyReduction_194
-happyReduction_194 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn65
- ((:[]) happy_var_1
- )
-happyReduction_194 _ = notHappyAtAll
-
-happyReduce_195 = happySpecReduce_3 65# happyReduction_195
-happyReduction_195 (HappyAbsSyn65 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn65
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_195 _ _ _ = notHappyAtAll
-
-happyReduce_196 = happySpecReduce_0 66# happyReduction_196
-happyReduction_196 = HappyAbsSyn66
- (NilExp
- )
-
-happyReduce_197 = happySpecReduce_2 66# happyReduction_197
-happyReduction_197 (HappyAbsSyn66 happy_var_2)
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn66
- (ConsExp happy_var_1 happy_var_2
- )
-happyReduction_197 _ _ = notHappyAtAll
-
-happyReduce_198 = happySpecReduce_1 67# happyReduction_198
-happyReduction_198 _
- = HappyAbsSyn67
- (PChar
- )
-
-happyReduce_199 = happySpecReduce_3 67# happyReduction_199
-happyReduction_199 _
- (HappyAbsSyn9 happy_var_2)
- _
- = HappyAbsSyn67
- (PChars happy_var_2
- )
-happyReduction_199 _ _ _ = notHappyAtAll
-
-happyReduce_200 = happySpecReduce_2 67# happyReduction_200
-happyReduction_200 (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn67
- (PMacro happy_var_2
- )
-happyReduction_200 _ _ = notHappyAtAll
-
-happyReduce_201 = happyReduce 4# 67# happyReduction_201
-happyReduction_201 ((HappyAbsSyn12 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn67
- (PM happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_202 = happySpecReduce_1 67# happyReduction_202
-happyReduction_202 _
- = HappyAbsSyn67
- (PW
- )
-
-happyReduce_203 = happySpecReduce_1 67# happyReduction_203
-happyReduction_203 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn67
- (PV happy_var_1
- )
-happyReduction_203 _ = notHappyAtAll
-
-happyReduce_204 = happySpecReduce_3 67# happyReduction_204
-happyReduction_204 _
- (HappyAbsSyn12 happy_var_2)
- _
- = HappyAbsSyn67
- (PCon happy_var_2
- )
-happyReduction_204 _ _ _ = notHappyAtAll
-
-happyReduce_205 = happySpecReduce_3 67# happyReduction_205
-happyReduction_205 (HappyAbsSyn12 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn67
- (PQ happy_var_1 happy_var_3
- )
-happyReduction_205 _ _ _ = notHappyAtAll
-
-happyReduce_206 = happySpecReduce_1 67# happyReduction_206
-happyReduction_206 (HappyAbsSyn8 happy_var_1)
- = HappyAbsSyn67
- (PInt happy_var_1
- )
-happyReduction_206 _ = notHappyAtAll
-
-happyReduce_207 = happySpecReduce_1 67# happyReduction_207
-happyReduction_207 (HappyAbsSyn10 happy_var_1)
- = HappyAbsSyn67
- (PFloat happy_var_1
- )
-happyReduction_207 _ = notHappyAtAll
-
-happyReduce_208 = happySpecReduce_1 67# happyReduction_208
-happyReduction_208 (HappyAbsSyn9 happy_var_1)
- = HappyAbsSyn67
- (PStr happy_var_1
- )
-happyReduction_208 _ = notHappyAtAll
-
-happyReduce_209 = happySpecReduce_3 67# happyReduction_209
-happyReduction_209 _
- (HappyAbsSyn73 happy_var_2)
- _
- = HappyAbsSyn67
- (PR happy_var_2
- )
-happyReduction_209 _ _ _ = notHappyAtAll
-
-happyReduce_210 = happySpecReduce_3 67# happyReduction_210
-happyReduction_210 _
- (HappyAbsSyn81 happy_var_2)
- _
- = HappyAbsSyn67
- (PTup happy_var_2
- )
-happyReduction_210 _ _ _ = notHappyAtAll
-
-happyReduce_211 = happySpecReduce_3 67# happyReduction_211
-happyReduction_211 _
- (HappyAbsSyn67 happy_var_2)
- _
- = HappyAbsSyn67
- (happy_var_2
- )
-happyReduction_211 _ _ _ = notHappyAtAll
-
-happyReduce_212 = happySpecReduce_2 68# happyReduction_212
-happyReduction_212 (HappyAbsSyn74 happy_var_2)
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn67
- (PC happy_var_1 happy_var_2
- )
-happyReduction_212 _ _ = notHappyAtAll
-
-happyReduce_213 = happyReduce 4# 68# happyReduction_213
-happyReduction_213 ((HappyAbsSyn74 happy_var_4) `HappyStk`
- (HappyAbsSyn12 happy_var_3) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn12 happy_var_1) `HappyStk`
- happyRest)
- = HappyAbsSyn67
- (PQC happy_var_1 happy_var_3 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_214 = happySpecReduce_2 68# happyReduction_214
-happyReduction_214 _
- (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn67
- (PRep happy_var_1
- )
-happyReduction_214 _ _ = notHappyAtAll
-
-happyReduce_215 = happySpecReduce_3 68# happyReduction_215
-happyReduction_215 (HappyAbsSyn67 happy_var_3)
- _
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn67
- (PAs happy_var_1 happy_var_3
- )
-happyReduction_215 _ _ _ = notHappyAtAll
-
-happyReduce_216 = happySpecReduce_2 68# happyReduction_216
-happyReduction_216 (HappyAbsSyn67 happy_var_2)
- _
- = HappyAbsSyn67
- (PNeg happy_var_2
- )
-happyReduction_216 _ _ = notHappyAtAll
-
-happyReduce_217 = happySpecReduce_1 68# happyReduction_217
-happyReduction_217 (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn67
- (happy_var_1
- )
-happyReduction_217 _ = notHappyAtAll
-
-happyReduce_218 = happySpecReduce_3 69# happyReduction_218
-happyReduction_218 (HappyAbsSyn67 happy_var_3)
- _
- (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn67
- (PDisj happy_var_1 happy_var_3
- )
-happyReduction_218 _ _ _ = notHappyAtAll
-
-happyReduce_219 = happySpecReduce_3 69# happyReduction_219
-happyReduction_219 (HappyAbsSyn67 happy_var_3)
- _
- (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn67
- (PSeq happy_var_1 happy_var_3
- )
-happyReduction_219 _ _ _ = notHappyAtAll
-
-happyReduce_220 = happySpecReduce_1 69# happyReduction_220
-happyReduction_220 (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn67
- (happy_var_1
- )
-happyReduction_220 _ = notHappyAtAll
-
-happyReduce_221 = happySpecReduce_3 70# happyReduction_221
-happyReduction_221 (HappyAbsSyn67 happy_var_3)
- _
- (HappyAbsSyn53 happy_var_1)
- = HappyAbsSyn70
- (PA happy_var_1 happy_var_3
- )
-happyReduction_221 _ _ _ = notHappyAtAll
-
-happyReduce_222 = happySpecReduce_1 71# happyReduction_222
-happyReduction_222 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn71
- (LIdent happy_var_1
- )
-happyReduction_222 _ = notHappyAtAll
-
-happyReduce_223 = happySpecReduce_2 71# happyReduction_223
-happyReduction_223 (HappyAbsSyn8 happy_var_2)
- _
- = HappyAbsSyn71
- (LVar happy_var_2
- )
-happyReduction_223 _ _ = notHappyAtAll
-
-happyReduce_224 = happySpecReduce_1 72# happyReduction_224
-happyReduction_224 _
- = HappyAbsSyn72
- (Sort_Type
- )
-
-happyReduce_225 = happySpecReduce_1 72# happyReduction_225
-happyReduction_225 _
- = HappyAbsSyn72
- (Sort_PType
- )
-
-happyReduce_226 = happySpecReduce_1 72# happyReduction_226
-happyReduction_226 _
- = HappyAbsSyn72
- (Sort_Tok
- )
-
-happyReduce_227 = happySpecReduce_1 72# happyReduction_227
-happyReduction_227 _
- = HappyAbsSyn72
- (Sort_Str
- )
-
-happyReduce_228 = happySpecReduce_1 72# happyReduction_228
-happyReduction_228 _
- = HappyAbsSyn72
- (Sort_Strs
- )
-
-happyReduce_229 = happySpecReduce_0 73# happyReduction_229
-happyReduction_229 = HappyAbsSyn73
- ([]
- )
-
-happyReduce_230 = happySpecReduce_1 73# happyReduction_230
-happyReduction_230 (HappyAbsSyn70 happy_var_1)
- = HappyAbsSyn73
- ((:[]) happy_var_1
- )
-happyReduction_230 _ = notHappyAtAll
-
-happyReduce_231 = happySpecReduce_3 73# happyReduction_231
-happyReduction_231 (HappyAbsSyn73 happy_var_3)
- _
- (HappyAbsSyn70 happy_var_1)
- = HappyAbsSyn73
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_231 _ _ _ = notHappyAtAll
-
-happyReduce_232 = happySpecReduce_1 74# happyReduction_232
-happyReduction_232 (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn74
- ((:[]) happy_var_1
- )
-happyReduction_232 _ = notHappyAtAll
-
-happyReduce_233 = happySpecReduce_2 74# happyReduction_233
-happyReduction_233 (HappyAbsSyn74 happy_var_2)
- (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn74
- ((:) happy_var_1 happy_var_2
- )
-happyReduction_233 _ _ = notHappyAtAll
-
-happyReduce_234 = happySpecReduce_1 75# happyReduction_234
-happyReduction_234 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn75
- (BIdent happy_var_1
- )
-happyReduction_234 _ = notHappyAtAll
-
-happyReduce_235 = happySpecReduce_1 75# happyReduction_235
-happyReduction_235 _
- = HappyAbsSyn75
- (BWild
- )
-
-happyReduce_236 = happySpecReduce_0 76# happyReduction_236
-happyReduction_236 = HappyAbsSyn76
- ([]
- )
-
-happyReduce_237 = happySpecReduce_1 76# happyReduction_237
-happyReduction_237 (HappyAbsSyn75 happy_var_1)
- = HappyAbsSyn76
- ((:[]) happy_var_1
- )
-happyReduction_237 _ = notHappyAtAll
-
-happyReduce_238 = happySpecReduce_3 76# happyReduction_238
-happyReduction_238 (HappyAbsSyn76 happy_var_3)
- _
- (HappyAbsSyn75 happy_var_1)
- = HappyAbsSyn76
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_238 _ _ _ = notHappyAtAll
-
-happyReduce_239 = happyReduce 5# 77# happyReduction_239
-happyReduction_239 (_ `HappyStk`
- (HappyAbsSyn58 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn76 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn77
- (DDec happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_240 = happySpecReduce_1 77# happyReduction_240
-happyReduction_240 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn77
- (DExp happy_var_1
- )
-happyReduction_240 _ = notHappyAtAll
-
-happyReduce_241 = happySpecReduce_1 78# happyReduction_241
-happyReduction_241 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn78
- (TComp happy_var_1
- )
-happyReduction_241 _ = notHappyAtAll
-
-happyReduce_242 = happySpecReduce_1 79# happyReduction_242
-happyReduction_242 (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn79
- (PTComp happy_var_1
- )
-happyReduction_242 _ = notHappyAtAll
-
-happyReduce_243 = happySpecReduce_0 80# happyReduction_243
-happyReduction_243 = HappyAbsSyn80
- ([]
- )
-
-happyReduce_244 = happySpecReduce_1 80# happyReduction_244
-happyReduction_244 (HappyAbsSyn78 happy_var_1)
- = HappyAbsSyn80
- ((:[]) happy_var_1
- )
-happyReduction_244 _ = notHappyAtAll
-
-happyReduce_245 = happySpecReduce_3 80# happyReduction_245
-happyReduction_245 (HappyAbsSyn80 happy_var_3)
- _
- (HappyAbsSyn78 happy_var_1)
- = HappyAbsSyn80
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_245 _ _ _ = notHappyAtAll
-
-happyReduce_246 = happySpecReduce_0 81# happyReduction_246
-happyReduction_246 = HappyAbsSyn81
- ([]
- )
-
-happyReduce_247 = happySpecReduce_1 81# happyReduction_247
-happyReduction_247 (HappyAbsSyn79 happy_var_1)
- = HappyAbsSyn81
- ((:[]) happy_var_1
- )
-happyReduction_247 _ = notHappyAtAll
-
-happyReduce_248 = happySpecReduce_3 81# happyReduction_248
-happyReduction_248 (HappyAbsSyn81 happy_var_3)
- _
- (HappyAbsSyn79 happy_var_1)
- = HappyAbsSyn81
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_248 _ _ _ = notHappyAtAll
-
-happyReduce_249 = happySpecReduce_3 82# happyReduction_249
-happyReduction_249 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn67 happy_var_1)
- = HappyAbsSyn82
- (Case happy_var_1 happy_var_3
- )
-happyReduction_249 _ _ _ = notHappyAtAll
-
-happyReduce_250 = happySpecReduce_1 83# happyReduction_250
-happyReduction_250 (HappyAbsSyn82 happy_var_1)
- = HappyAbsSyn83
- ((:[]) happy_var_1
- )
-happyReduction_250 _ = notHappyAtAll
-
-happyReduce_251 = happySpecReduce_3 83# happyReduction_251
-happyReduction_251 (HappyAbsSyn83 happy_var_3)
- _
- (HappyAbsSyn82 happy_var_1)
- = HappyAbsSyn83
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_251 _ _ _ = notHappyAtAll
-
-happyReduce_252 = happySpecReduce_3 84# happyReduction_252
-happyReduction_252 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn74 happy_var_1)
- = HappyAbsSyn84
- (Equ happy_var_1 happy_var_3
- )
-happyReduction_252 _ _ _ = notHappyAtAll
-
-happyReduce_253 = happySpecReduce_0 85# happyReduction_253
-happyReduction_253 = HappyAbsSyn85
- ([]
- )
-
-happyReduce_254 = happySpecReduce_1 85# happyReduction_254
-happyReduction_254 (HappyAbsSyn84 happy_var_1)
- = HappyAbsSyn85
- ((:[]) happy_var_1
- )
-happyReduction_254 _ = notHappyAtAll
-
-happyReduce_255 = happySpecReduce_3 85# happyReduction_255
-happyReduction_255 (HappyAbsSyn85 happy_var_3)
- _
- (HappyAbsSyn84 happy_var_1)
- = HappyAbsSyn85
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_255 _ _ _ = notHappyAtAll
-
-happyReduce_256 = happySpecReduce_3 86# happyReduction_256
-happyReduction_256 (HappyAbsSyn58 happy_var_3)
- _
- (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn86
- (Alt happy_var_1 happy_var_3
- )
-happyReduction_256 _ _ _ = notHappyAtAll
-
-happyReduce_257 = happySpecReduce_0 87# happyReduction_257
-happyReduction_257 = HappyAbsSyn87
- ([]
- )
-
-happyReduce_258 = happySpecReduce_1 87# happyReduction_258
-happyReduction_258 (HappyAbsSyn86 happy_var_1)
- = HappyAbsSyn87
- ((:[]) happy_var_1
- )
-happyReduction_258 _ = notHappyAtAll
-
-happyReduce_259 = happySpecReduce_3 87# happyReduction_259
-happyReduction_259 (HappyAbsSyn87 happy_var_3)
- _
- (HappyAbsSyn86 happy_var_1)
- = HappyAbsSyn87
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_259 _ _ _ = notHappyAtAll
-
-happyReduce_260 = happyReduce 5# 88# happyReduction_260
-happyReduction_260 (_ `HappyStk`
- (HappyAbsSyn58 happy_var_4) `HappyStk`
- _ `HappyStk`
- (HappyAbsSyn76 happy_var_2) `HappyStk`
- _ `HappyStk`
- happyRest)
- = HappyAbsSyn88
- (DDDec happy_var_2 happy_var_4
- ) `HappyStk` happyRest
-
-happyReduce_261 = happySpecReduce_1 88# happyReduction_261
-happyReduction_261 (HappyAbsSyn58 happy_var_1)
- = HappyAbsSyn88
- (DDExp happy_var_1
- )
-happyReduction_261 _ = notHappyAtAll
-
-happyReduce_262 = happySpecReduce_0 89# happyReduction_262
-happyReduction_262 = HappyAbsSyn89
- ([]
- )
-
-happyReduce_263 = happySpecReduce_2 89# happyReduction_263
-happyReduction_263 (HappyAbsSyn88 happy_var_2)
- (HappyAbsSyn89 happy_var_1)
- = HappyAbsSyn89
- (flip (:) happy_var_1 happy_var_2
- )
-happyReduction_263 _ _ = notHappyAtAll
-
-happyReduce_264 = happySpecReduce_2 90# happyReduction_264
-happyReduction_264 (HappyAbsSyn25 happy_var_2)
- (HappyAbsSyn91 happy_var_1)
- = HappyAbsSyn90
- (OldGr happy_var_1 (reverse happy_var_2)
- )
-happyReduction_264 _ _ = notHappyAtAll
-
-happyReduce_265 = happySpecReduce_0 91# happyReduction_265
-happyReduction_265 = HappyAbsSyn91
- (NoIncl
- )
-
-happyReduce_266 = happySpecReduce_2 91# happyReduction_266
-happyReduction_266 (HappyAbsSyn93 happy_var_2)
- _
- = HappyAbsSyn91
- (Incl happy_var_2
- )
-happyReduction_266 _ _ = notHappyAtAll
-
-happyReduce_267 = happySpecReduce_1 92# happyReduction_267
-happyReduction_267 (HappyAbsSyn9 happy_var_1)
- = HappyAbsSyn92
- (FString happy_var_1
- )
-happyReduction_267 _ = notHappyAtAll
-
-happyReduce_268 = happySpecReduce_1 92# happyReduction_268
-happyReduction_268 (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn92
- (FIdent happy_var_1
- )
-happyReduction_268 _ = notHappyAtAll
-
-happyReduce_269 = happySpecReduce_2 92# happyReduction_269
-happyReduction_269 (HappyAbsSyn92 happy_var_2)
- _
- = HappyAbsSyn92
- (FSlash happy_var_2
- )
-happyReduction_269 _ _ = notHappyAtAll
-
-happyReduce_270 = happySpecReduce_2 92# happyReduction_270
-happyReduction_270 (HappyAbsSyn92 happy_var_2)
- _
- = HappyAbsSyn92
- (FDot happy_var_2
- )
-happyReduction_270 _ _ = notHappyAtAll
-
-happyReduce_271 = happySpecReduce_2 92# happyReduction_271
-happyReduction_271 (HappyAbsSyn92 happy_var_2)
- _
- = HappyAbsSyn92
- (FMinus happy_var_2
- )
-happyReduction_271 _ _ = notHappyAtAll
-
-happyReduce_272 = happySpecReduce_2 92# happyReduction_272
-happyReduction_272 (HappyAbsSyn92 happy_var_2)
- (HappyAbsSyn12 happy_var_1)
- = HappyAbsSyn92
- (FAddId happy_var_1 happy_var_2
- )
-happyReduction_272 _ _ = notHappyAtAll
-
-happyReduce_273 = happySpecReduce_2 93# happyReduction_273
-happyReduction_273 _
- (HappyAbsSyn92 happy_var_1)
- = HappyAbsSyn93
- ((:[]) happy_var_1
- )
-happyReduction_273 _ _ = notHappyAtAll
-
-happyReduce_274 = happySpecReduce_3 93# happyReduction_274
-happyReduction_274 (HappyAbsSyn93 happy_var_3)
- _
- (HappyAbsSyn92 happy_var_1)
- = HappyAbsSyn93
- ((:) happy_var_1 happy_var_3
- )
-happyReduction_274 _ _ _ = notHappyAtAll
-
-happyNewToken action sts stk [] =
- action 176# 176# notHappyAtAll (HappyState action) sts stk []
-
-happyNewToken action sts stk (tk:tks) =
- let cont i = action i i tk (HappyState action) sts stk tks in
- case tk of {
- PT _ (TS ";") -> cont 94#;
- PT _ (TS "=") -> cont 95#;
- PT _ (TS "{") -> cont 96#;
- PT _ (TS "}") -> cont 97#;
- PT _ (TS "(") -> cont 98#;
- PT _ (TS ")") -> cont 99#;
- PT _ (TS ":") -> cont 100#;
- PT _ (TS "->") -> cont 101#;
- PT _ (TS "**") -> cont 102#;
- PT _ (TS ",") -> cont 103#;
- PT _ (TS "[") -> cont 104#;
- PT _ (TS "]") -> cont 105#;
- PT _ (TS "-") -> cont 106#;
- PT _ (TS ".") -> cont 107#;
- PT _ (TS "|") -> cont 108#;
- PT _ (TS "%") -> cont 109#;
- PT _ (TS "?") -> cont 110#;
- PT _ (TS "<") -> cont 111#;
- PT _ (TS ">") -> cont 112#;
- PT _ (TS "@") -> cont 113#;
- PT _ (TS "#") -> cont 114#;
- PT _ (TS "!") -> cont 115#;
- PT _ (TS "*") -> cont 116#;
- PT _ (TS "+") -> cont 117#;
- PT _ (TS "++") -> cont 118#;
- PT _ (TS "\\") -> cont 119#;
- PT _ (TS "=>") -> cont 120#;
- PT _ (TS "_") -> cont 121#;
- PT _ (TS "$") -> cont 122#;
- PT _ (TS "/") -> cont 123#;
- PT _ (TS "Lin") -> cont 124#;
- PT _ (TS "PType") -> cont 125#;
- PT _ (TS "Str") -> cont 126#;
- PT _ (TS "Strs") -> cont 127#;
- PT _ (TS "Tok") -> cont 128#;
- PT _ (TS "Type") -> cont 129#;
- PT _ (TS "abstract") -> cont 130#;
- PT _ (TS "case") -> cont 131#;
- PT _ (TS "cat") -> cont 132#;
- PT _ (TS "concrete") -> cont 133#;
- PT _ (TS "data") -> cont 134#;
- PT _ (TS "def") -> cont 135#;
- PT _ (TS "flags") -> cont 136#;
- PT _ (TS "fn") -> cont 137#;
- PT _ (TS "fun") -> cont 138#;
- PT _ (TS "grammar") -> cont 139#;
- PT _ (TS "in") -> cont 140#;
- PT _ (TS "include") -> cont 141#;
- PT _ (TS "incomplete") -> cont 142#;
- PT _ (TS "instance") -> cont 143#;
- PT _ (TS "interface") -> cont 144#;
- PT _ (TS "let") -> cont 145#;
- PT _ (TS "lin") -> cont 146#;
- PT _ (TS "lincat") -> cont 147#;
- PT _ (TS "lindef") -> cont 148#;
- PT _ (TS "lintype") -> cont 149#;
- PT _ (TS "of") -> cont 150#;
- PT _ (TS "open") -> cont 151#;
- PT _ (TS "oper") -> cont 152#;
- PT _ (TS "out") -> cont 153#;
- PT _ (TS "package") -> cont 154#;
- PT _ (TS "param") -> cont 155#;
- PT _ (TS "pattern") -> cont 156#;
- PT _ (TS "pre") -> cont 157#;
- PT _ (TS "printname") -> cont 158#;
- PT _ (TS "resource") -> cont 159#;
- PT _ (TS "reuse") -> cont 160#;
- PT _ (TS "strs") -> cont 161#;
- PT _ (TS "table") -> cont 162#;
- PT _ (TS "tokenizer") -> cont 163#;
- PT _ (TS "transfer") -> cont 164#;
- PT _ (TS "union") -> cont 165#;
- PT _ (TS "var") -> cont 166#;
- PT _ (TS "variants") -> cont 167#;
- PT _ (TS "where") -> cont 168#;
- PT _ (TS "with") -> cont 169#;
- PT _ (TI happy_dollar_dollar) -> cont 170#;
- PT _ (TL happy_dollar_dollar) -> cont 171#;
- PT _ (TD happy_dollar_dollar) -> cont 172#;
- PT _ (T_LString happy_dollar_dollar) -> cont 173#;
- PT _ (T_PIdent _) -> cont 174#;
- _ -> cont 175#;
- _ -> happyError' (tk:tks)
- }
-
-happyError_ tk tks = happyError' (tk:tks)
-
-happyThen :: () => Err a -> (a -> Err b) -> Err b
-happyThen = (thenM)
-happyReturn :: () => a -> Err a
-happyReturn = (returnM)
-happyThen1 m k tks = (thenM) m (\a -> k a tks)
-happyReturn1 :: () => a -> b -> Err a
-happyReturn1 = \a tks -> (returnM) a
-happyError' :: () => [Token] -> Err a
-happyError' = happyError
-
-pGrammar tks = happySomeParser where
- happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn13 z -> happyReturn z; _other -> notHappyAtAll })
-
-pModDef tks = happySomeParser where
- happySomeParser = happyThen (happyParse action_1 tks) (\x -> case x of {HappyAbsSyn15 z -> happyReturn z; _other -> notHappyAtAll })
-
-pOldGrammar tks = happySomeParser where
- happySomeParser = happyThen (happyParse action_2 tks) (\x -> case x of {HappyAbsSyn90 z -> happyReturn z; _other -> notHappyAtAll })
-
-pExp tks = happySomeParser where
- happySomeParser = happyThen (happyParse action_3 tks) (\x -> case x of {HappyAbsSyn58 z -> happyReturn z; _other -> notHappyAtAll })
-
-pModHeader tks = happySomeParser where
- happySomeParser = happyThen (happyParse action_4 tks) (\x -> case x of {HappyAbsSyn15 z -> happyReturn z; _other -> notHappyAtAll })
-
-happySeq = happyDontSeq
-
-
-returnM :: a -> Err a
-returnM = return
-
-thenM :: Err a -> (a -> Err b) -> Err b
-thenM = (>>=)
-
-happyError :: [Token] -> Err a
-happyError ts =
- Bad $ "syntax error at " ++ tokenPos ts ++
- case ts of
- [] -> []
- [Err _] -> " due to lexer error"
- _ -> " before " ++ unwords (map prToken (take 4 ts))
-
-myLexer = tokens
-{-# LINE 1 "templates/GenericTemplate.hs" #-}
-{-# LINE 1 "templates/GenericTemplate.hs" #-}
-{-# LINE 1 "" #-}
-{-# LINE 1 "" #-}
-{-# LINE 1 "templates/GenericTemplate.hs" #-}
--- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
-
-{-# LINE 28 "templates/GenericTemplate.hs" #-}
-
-
-
-
-
-
-
-
-{-# LINE 49 "templates/GenericTemplate.hs" #-}
-
-{-# LINE 59 "templates/GenericTemplate.hs" #-}
-
-{-# LINE 68 "templates/GenericTemplate.hs" #-}
-
-infixr 9 `HappyStk`
-data HappyStk a = HappyStk a (HappyStk a)
-
------------------------------------------------------------------------------
--- starting the parse
-
-happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll
-
------------------------------------------------------------------------------
--- Accepting the parse
-
--- If the current token is 1#, it means we've just accepted a partial
--- parse (a %partial parser). We must ignore the saved token on the top of
--- the stack in this case.
-happyAccept 1# tk st sts (_ `HappyStk` ans `HappyStk` _) =
- happyReturn1 ans
-happyAccept j tk st sts (HappyStk ans _) =
- (happyTcHack j ) (happyReturn1 ans)
-
------------------------------------------------------------------------------
--- Arrays only: do the next action
-
-{-# LINE 155 "templates/GenericTemplate.hs" #-}
-
------------------------------------------------------------------------------
--- HappyState data type (not arrays)
-
-
-
-newtype HappyState b c = HappyState
- (Int# -> -- token number
- Int# -> -- token number (yes, again)
- b -> -- token semantic value
- HappyState b c -> -- current state
- [HappyState b c] -> -- state stack
- c)
-
-
-
------------------------------------------------------------------------------
--- Shifting a token
-
-happyShift new_state 1# tk st sts stk@(x `HappyStk` _) =
- let i = (case x of { HappyErrorToken (I# (i)) -> i }) in
--- trace "shifting the error token" $
- new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk)
-
-happyShift new_state i tk st sts stk =
- happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk)
-
--- happyReduce is specialised for the common cases.
-
-happySpecReduce_0 i fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk
- = action nt j tk st ((st):(sts)) (fn `HappyStk` stk)
-
-happySpecReduce_1 i fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk')
- = let r = fn v1 in
- happySeq r (action nt j tk st sts (r `HappyStk` stk'))
-
-happySpecReduce_2 i fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk')
- = let r = fn v1 v2 in
- happySeq r (action nt j tk st sts (r `HappyStk` stk'))
-
-happySpecReduce_3 i fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk')
- = let r = fn v1 v2 v3 in
- happySeq r (action nt j tk st sts (r `HappyStk` stk'))
-
-happyReduce k i fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happyReduce k nt fn j tk st sts stk
- = case happyDrop (k -# (1# :: Int#)) sts of
- sts1@(((st1@(HappyState (action))):(_))) ->
- let r = fn stk in -- it doesn't hurt to always seq here...
- happyDoSeq r (action nt j tk st1 sts1 r)
-
-happyMonadReduce k nt fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happyMonadReduce k nt fn j tk st sts stk =
- happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk))
- where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts))
- drop_stk = happyDropStk k stk
-
-happyMonad2Reduce k nt fn 1# tk st sts stk
- = happyFail 1# tk st sts stk
-happyMonad2Reduce k nt fn j tk st sts stk =
- happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk))
- where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts))
- drop_stk = happyDropStk k stk
-
-
-
-
-
- new_state = action
-
-
-happyDrop 0# l = l
-happyDrop n ((_):(t)) = happyDrop (n -# (1# :: Int#)) t
-
-happyDropStk 0# l = l
-happyDropStk n (x `HappyStk` xs) = happyDropStk (n -# (1#::Int#)) xs
-
------------------------------------------------------------------------------
--- Moving to a new state after a reduction
-
-{-# LINE 253 "templates/GenericTemplate.hs" #-}
-happyGoto action j tk st = action j j tk (HappyState action)
-
-
------------------------------------------------------------------------------
--- Error recovery (1# is the error token)
-
--- parse error if we are in recovery and we fail again
-happyFail 1# tk old_st _ stk =
--- trace "failing" $
- happyError_ tk
-
-{- We don't need state discarding for our restricted implementation of
- "error". In fact, it can cause some bogus parses, so I've disabled it
- for now --SDM
-
--- discard a state
-happyFail 1# tk old_st (((HappyState (action))):(sts))
- (saved_tok `HappyStk` _ `HappyStk` stk) =
--- trace ("discarding state, depth " ++ show (length stk)) $
- action 1# 1# tk (HappyState (action)) sts ((saved_tok`HappyStk`stk))
--}
-
--- Enter error recovery: generate an error token,
--- save the old token and carry on.
-happyFail i tk (HappyState (action)) sts stk =
--- trace "entering error recovery" $
- action 1# 1# tk (HappyState (action)) sts ( (HappyErrorToken (I# (i))) `HappyStk` stk)
-
--- Internal happy errors:
-
-notHappyAtAll = error "Internal Happy error\n"
-
------------------------------------------------------------------------------
--- Hack to get the typechecker to accept our action functions
-
-
-happyTcHack :: Int# -> a -> a
-happyTcHack x y = y
-{-# INLINE happyTcHack #-}
-
-
------------------------------------------------------------------------------
--- Seq-ing. If the --strict flag is given, then Happy emits
--- happySeq = happyDoSeq
--- otherwise it emits
--- happySeq = happyDontSeq
-
-happyDoSeq, happyDontSeq :: a -> b -> b
-happyDoSeq a b = a `seq` b
-happyDontSeq a b = b
-
------------------------------------------------------------------------------
--- Don't inline any functions from the template. GHC has a nasty habit
--- of deciding to inline happyGoto everywhere, which increases the size of
--- the generated parser quite a bit.
-
-{-# LINE 317 "templates/GenericTemplate.hs" #-}
-{-# NOINLINE happyShift #-}
-{-# NOINLINE happySpecReduce_0 #-}
-{-# NOINLINE happySpecReduce_1 #-}
-{-# NOINLINE happySpecReduce_2 #-}
-{-# NOINLINE happySpecReduce_3 #-}
-{-# NOINLINE happyReduce #-}
-{-# NOINLINE happyMonadReduce #-}
-{-# NOINLINE happyGoto #-}
-{-# NOINLINE happyFail #-}
-
--- end of Happy Template.
diff --git a/src/GF/Source/ParGF.y b/src/GF/Source/ParGF.y
deleted file mode 100644
index 2109434e5..000000000
--- a/src/GF/Source/ParGF.y
+++ /dev/null
@@ -1,642 +0,0 @@
--- This Happy file was machine-generated by the BNF converter
-{
-{-# OPTIONS -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}
- module GF.Source.ParGF (pGrammar, pModDef, pOldGrammar, pExp, pModHeader, myLexer) where --H
-import GF.Source.AbsGF --H
-import GF.Source.LexGF --H
-import GF.Infra.Ident --H
-import GF.Data.ErrM --H
-}
-
-%name pGrammar Grammar
-%name pModDef ModDef
-%name pOldGrammar OldGrammar
-%name pExp Exp
-%partial pModHeader ModHeader
-
--- no lexer declaration
-%monad { Err } { thenM } { returnM }
-%tokentype { Token }
-
-%token
- ';' { PT _ (TS ";") }
- '=' { PT _ (TS "=") }
- '{' { PT _ (TS "{") }
- '}' { PT _ (TS "}") }
- '(' { PT _ (TS "(") }
- ')' { PT _ (TS ")") }
- ':' { PT _ (TS ":") }
- '->' { PT _ (TS "->") }
- '**' { PT _ (TS "**") }
- ',' { PT _ (TS ",") }
- '[' { PT _ (TS "[") }
- ']' { PT _ (TS "]") }
- '-' { PT _ (TS "-") }
- '.' { PT _ (TS ".") }
- '|' { PT _ (TS "|") }
- '%' { PT _ (TS "%") }
- '?' { PT _ (TS "?") }
- '<' { PT _ (TS "<") }
- '>' { PT _ (TS ">") }
- '@' { PT _ (TS "@") }
- '#' { PT _ (TS "#") }
- '!' { PT _ (TS "!") }
- '*' { PT _ (TS "*") }
- '+' { PT _ (TS "+") }
- '++' { PT _ (TS "++") }
- '\\' { PT _ (TS "\\") }
- '=>' { PT _ (TS "=>") }
- '_' { PT _ (TS "_") }
- '$' { PT _ (TS "$") }
- '/' { PT _ (TS "/") }
- 'Lin' { PT _ (TS "Lin") }
- 'PType' { PT _ (TS "PType") }
- 'Str' { PT _ (TS "Str") }
- 'Strs' { PT _ (TS "Strs") }
- 'Tok' { PT _ (TS "Tok") }
- 'Type' { PT _ (TS "Type") }
- 'abstract' { PT _ (TS "abstract") }
- 'case' { PT _ (TS "case") }
- 'cat' { PT _ (TS "cat") }
- 'concrete' { PT _ (TS "concrete") }
- 'data' { PT _ (TS "data") }
- 'def' { PT _ (TS "def") }
- 'flags' { PT _ (TS "flags") }
- 'fn' { PT _ (TS "fn") }
- 'fun' { PT _ (TS "fun") }
- 'grammar' { PT _ (TS "grammar") }
- 'in' { PT _ (TS "in") }
- 'include' { PT _ (TS "include") }
- 'incomplete' { PT _ (TS "incomplete") }
- 'instance' { PT _ (TS "instance") }
- 'interface' { PT _ (TS "interface") }
- 'let' { PT _ (TS "let") }
- 'lin' { PT _ (TS "lin") }
- 'lincat' { PT _ (TS "lincat") }
- 'lindef' { PT _ (TS "lindef") }
- 'lintype' { PT _ (TS "lintype") }
- 'of' { PT _ (TS "of") }
- 'open' { PT _ (TS "open") }
- 'oper' { PT _ (TS "oper") }
- 'out' { PT _ (TS "out") }
- 'package' { PT _ (TS "package") }
- 'param' { PT _ (TS "param") }
- 'pattern' { PT _ (TS "pattern") }
- 'pre' { PT _ (TS "pre") }
- 'printname' { PT _ (TS "printname") }
- 'resource' { PT _ (TS "resource") }
- 'reuse' { PT _ (TS "reuse") }
- 'strs' { PT _ (TS "strs") }
- 'table' { PT _ (TS "table") }
- 'tokenizer' { PT _ (TS "tokenizer") }
- 'transfer' { PT _ (TS "transfer") }
- 'union' { PT _ (TS "union") }
- 'var' { PT _ (TS "var") }
- 'variants' { PT _ (TS "variants") }
- 'where' { PT _ (TS "where") }
- 'with' { PT _ (TS "with") }
-
-L_integ { PT _ (TI $$) }
-L_quoted { PT _ (TL $$) }
-L_doubl { PT _ (TD $$) }
-L_LString { PT _ (T_LString $$) }
-L_PIdent { PT _ (T_PIdent _) }
-L_err { _ }
-
-
-%%
-
-Integer :: { Integer } : L_integ { (read $1) :: Integer }
-String :: { String } : L_quoted { $1 }
-Double :: { Double } : L_doubl { (read $1) :: Double }
-LString :: { LString} : L_LString { LString ($1)}
-PIdent :: { PIdent} : L_PIdent { PIdent (mkPosToken $1)}
-
-Grammar :: { Grammar }
-Grammar : ListModDef { Gr (reverse $1) }
-
-
-ListModDef :: { [ModDef] }
-ListModDef : {- empty -} { [] }
- | ListModDef ModDef { flip (:) $1 $2 }
-
-
-ModDef :: { ModDef }
-ModDef : ModDef ';' { $1 }
- | 'grammar' PIdent '=' '{' 'abstract' '=' PIdent ';' ListConcSpec '}' { MMain $2 $7 $9 }
- | ComplMod ModType '=' ModBody { MModule $1 $2 $4 }
-
-
-ConcSpec :: { ConcSpec }
-ConcSpec : PIdent '=' ConcExp { ConcSpec $1 $3 }
-
-
-ListConcSpec :: { [ConcSpec] }
-ListConcSpec : {- empty -} { [] }
- | ConcSpec { (:[]) $1 }
- | ConcSpec ';' ListConcSpec { (:) $1 $3 }
-
-
-ConcExp :: { ConcExp }
-ConcExp : PIdent ListTransfer { ConcExp $1 (reverse $2) }
-
-
-ListTransfer :: { [Transfer] }
-ListTransfer : {- empty -} { [] }
- | ListTransfer Transfer { flip (:) $1 $2 }
-
-
-Transfer :: { Transfer }
-Transfer : '(' 'transfer' 'in' Open ')' { TransferIn $4 }
- | '(' 'transfer' 'out' Open ')' { TransferOut $4 }
-
-
-ModHeader :: { ModDef }
-ModHeader : ComplMod ModType '=' ModHeaderBody { MModule $1 $2 $4 }
-
-
-ModHeaderBody :: { ModBody }
-ModHeaderBody : Extend Opens { MBody $1 $2 [] }
- | ListIncluded { MNoBody $1 }
- | Included 'with' ListOpen { MWith $1 $3 }
- | Included 'with' ListOpen '**' Opens { MWithBody $1 $3 $5 [] }
- | ListIncluded '**' Included 'with' ListOpen { MWithE $1 $3 $5 }
- | ListIncluded '**' Included 'with' ListOpen '**' Opens { MWithEBody $1 $3 $5 $7 [] }
- | 'reuse' PIdent { MReuse $2 }
- | 'union' ListIncluded { MUnion $2 }
-
-
-ModType :: { ModType }
-ModType : 'abstract' PIdent { MTAbstract $2 }
- | 'resource' PIdent { MTResource $2 }
- | 'interface' PIdent { MTInterface $2 }
- | 'concrete' PIdent 'of' PIdent { MTConcrete $2 $4 }
- | 'instance' PIdent 'of' PIdent { MTInstance $2 $4 }
- | 'transfer' PIdent ':' Open '->' Open { MTTransfer $2 $4 $6 }
-
-
-ModBody :: { ModBody }
-ModBody : Extend Opens '{' ListTopDef '}' { MBody $1 $2 (reverse $4) }
- | ListIncluded { MNoBody $1 }
- | Included 'with' ListOpen { MWith $1 $3 }
- | Included 'with' ListOpen '**' Opens '{' ListTopDef '}' { MWithBody $1 $3 $5 (reverse $7) }
- | ListIncluded '**' Included 'with' ListOpen { MWithE $1 $3 $5 }
- | ListIncluded '**' Included 'with' ListOpen '**' Opens '{' ListTopDef '}' { MWithEBody $1 $3 $5 $7 (reverse $9) }
- | 'reuse' PIdent { MReuse $2 }
- | 'union' ListIncluded { MUnion $2 }
-
-
-ListTopDef :: { [TopDef] }
-ListTopDef : {- empty -} { [] }
- | ListTopDef TopDef { flip (:) $1 $2 }
-
-
-Extend :: { Extend }
-Extend : ListIncluded '**' { Ext $1 }
- | {- empty -} { NoExt }
-
-
-ListOpen :: { [Open] }
-ListOpen : {- empty -} { [] }
- | Open { (:[]) $1 }
- | Open ',' ListOpen { (:) $1 $3 }
-
-
-Opens :: { Opens }
-Opens : {- empty -} { NoOpens }
- | 'open' ListOpen 'in' { OpenIn $2 }
-
-
-Open :: { Open }
-Open : PIdent { OName $1 }
- | '(' QualOpen PIdent ')' { OQualQO $2 $3 }
- | '(' QualOpen PIdent '=' PIdent ')' { OQual $2 $3 $5 }
-
-
-ComplMod :: { ComplMod }
-ComplMod : {- empty -} { CMCompl }
- | 'incomplete' { CMIncompl }
-
-
-QualOpen :: { QualOpen }
-QualOpen : {- empty -} { QOCompl }
- | 'incomplete' { QOIncompl }
- | 'interface' { QOInterface }
-
-
-ListIncluded :: { [Included] }
-ListIncluded : {- empty -} { [] }
- | Included { (:[]) $1 }
- | Included ',' ListIncluded { (:) $1 $3 }
-
-
-Included :: { Included }
-Included : PIdent { IAll $1 }
- | PIdent '[' ListPIdent ']' { ISome $1 $3 }
- | PIdent '-' '[' ListPIdent ']' { IMinus $1 $4 }
-
-
-Def :: { Def }
-Def : ListName ':' Exp { DDecl $1 $3 }
- | ListName '=' Exp { DDef $1 $3 }
- | Name ListPatt '=' Exp { DPatt $1 $2 $4 }
- | ListName ':' Exp '=' Exp { DFull $1 $3 $5 }
-
-
-TopDef :: { TopDef }
-TopDef : 'cat' ListCatDef { DefCat $2 }
- | 'fun' ListFunDef { DefFun $2 }
- | 'data' ListFunDef { DefFunData $2 }
- | 'def' ListDef { DefDef $2 }
- | 'data' ListDataDef { DefData $2 }
- | 'transfer' ListDef { DefTrans $2 }
- | 'param' ListParDef { DefPar $2 }
- | 'oper' ListDef { DefOper $2 }
- | 'lincat' ListPrintDef { DefLincat $2 }
- | 'lindef' ListDef { DefLindef $2 }
- | 'lin' ListDef { DefLin $2 }
- | 'printname' 'cat' ListPrintDef { DefPrintCat $3 }
- | 'printname' 'fun' ListPrintDef { DefPrintFun $3 }
- | 'flags' ListFlagDef { DefFlag $2 }
- | 'printname' ListPrintDef { DefPrintOld $2 }
- | 'lintype' ListDef { DefLintype $2 }
- | 'pattern' ListDef { DefPattern $2 }
- | 'package' PIdent '=' '{' ListTopDef '}' ';' { DefPackage $2 (reverse $5) }
- | 'var' ListDef { DefVars $2 }
- | 'tokenizer' PIdent ';' { DefTokenizer $2 }
-
-
-CatDef :: { CatDef }
-CatDef : PIdent ListDDecl { SimpleCatDef $1 (reverse $2) }
- | '[' PIdent ListDDecl ']' { ListCatDef $2 (reverse $3) }
- | '[' PIdent ListDDecl ']' '{' Integer '}' { ListSizeCatDef $2 (reverse $3) $6 }
-
-
-FunDef :: { FunDef }
-FunDef : ListPIdent ':' Exp { FunDef $1 $3 }
-
-
-DataDef :: { DataDef }
-DataDef : PIdent '=' ListDataConstr { DataDef $1 $3 }
-
-
-DataConstr :: { DataConstr }
-DataConstr : PIdent { DataId $1 }
- | PIdent '.' PIdent { DataQId $1 $3 }
-
-
-ListDataConstr :: { [DataConstr] }
-ListDataConstr : {- empty -} { [] }
- | DataConstr { (:[]) $1 }
- | DataConstr '|' ListDataConstr { (:) $1 $3 }
-
-
-ParDef :: { ParDef }
-ParDef : PIdent '=' ListParConstr { ParDefDir $1 $3 }
- | PIdent '=' '(' 'in' PIdent ')' { ParDefIndir $1 $5 }
- | PIdent { ParDefAbs $1 }
-
-
-ParConstr :: { ParConstr }
-ParConstr : PIdent ListDDecl { ParConstr $1 (reverse $2) }
-
-
-PrintDef :: { PrintDef }
-PrintDef : ListName '=' Exp { PrintDef $1 $3 }
-
-
-FlagDef :: { FlagDef }
-FlagDef : PIdent '=' PIdent { FlagDef $1 $3 }
-
-
-ListDef :: { [Def] }
-ListDef : Def ';' { (:[]) $1 }
- | Def ';' ListDef { (:) $1 $3 }
-
-
-ListCatDef :: { [CatDef] }
-ListCatDef : CatDef ';' { (:[]) $1 }
- | CatDef ';' ListCatDef { (:) $1 $3 }
-
-
-ListFunDef :: { [FunDef] }
-ListFunDef : FunDef ';' { (:[]) $1 }
- | FunDef ';' ListFunDef { (:) $1 $3 }
-
-
-ListDataDef :: { [DataDef] }
-ListDataDef : DataDef ';' { (:[]) $1 }
- | DataDef ';' ListDataDef { (:) $1 $3 }
-
-
-ListParDef :: { [ParDef] }
-ListParDef : ParDef ';' { (:[]) $1 }
- | ParDef ';' ListParDef { (:) $1 $3 }
-
-
-ListPrintDef :: { [PrintDef] }
-ListPrintDef : PrintDef ';' { (:[]) $1 }
- | PrintDef ';' ListPrintDef { (:) $1 $3 }
-
-
-ListFlagDef :: { [FlagDef] }
-ListFlagDef : FlagDef ';' { (:[]) $1 }
- | FlagDef ';' ListFlagDef { (:) $1 $3 }
-
-
-ListParConstr :: { [ParConstr] }
-ListParConstr : {- empty -} { [] }
- | ParConstr { (:[]) $1 }
- | ParConstr '|' ListParConstr { (:) $1 $3 }
-
-
-ListPIdent :: { [PIdent] }
-ListPIdent : PIdent { (:[]) $1 }
- | PIdent ',' ListPIdent { (:) $1 $3 }
-
-
-Name :: { Name }
-Name : PIdent { IdentName $1 }
- | '[' PIdent ']' { ListName $2 }
-
-
-ListName :: { [Name] }
-ListName : Name { (:[]) $1 }
- | Name ',' ListName { (:) $1 $3 }
-
-
-LocDef :: { LocDef }
-LocDef : ListPIdent ':' Exp { LDDecl $1 $3 }
- | ListPIdent '=' Exp { LDDef $1 $3 }
- | ListPIdent ':' Exp '=' Exp { LDFull $1 $3 $5 }
-
-
-ListLocDef :: { [LocDef] }
-ListLocDef : {- empty -} { [] }
- | LocDef { (:[]) $1 }
- | LocDef ';' ListLocDef { (:) $1 $3 }
-
-
-Exp6 :: { Exp }
-Exp6 : PIdent { EIdent $1 }
- | '{' PIdent '}' { EConstr $2 }
- | '%' PIdent '%' { ECons $2 }
- | Sort { ESort $1 }
- | String { EString $1 }
- | Integer { EInt $1 }
- | Double { EFloat $1 }
- | '?' { EMeta }
- | '[' ']' { EEmpty }
- | 'data' { EData }
- | '[' PIdent Exps ']' { EList $2 $3 }
- | '[' String ']' { EStrings $2 }
- | '{' ListLocDef '}' { ERecord $2 }
- | '<' ListTupleComp '>' { ETuple $2 }
- | '(' 'in' PIdent ')' { EIndir $3 }
- | '<' Exp ':' Exp '>' { ETyped $2 $4 }
- | '(' Exp ')' { $2 }
- | LString { ELString $1 }
-
-
-Exp5 :: { Exp }
-Exp5 : Exp5 '.' Label { EProj $1 $3 }
- | '{' PIdent '.' PIdent '}' { EQConstr $2 $4 }
- | '%' PIdent '.' PIdent { EQCons $2 $4 }
- | Exp6 { $1 }
-
-
-Exp4 :: { Exp }
-Exp4 : Exp4 Exp5 { EApp $1 $2 }
- | 'table' '{' ListCase '}' { ETable $3 }
- | 'table' Exp6 '{' ListCase '}' { ETTable $2 $4 }
- | 'table' Exp6 '[' ListExp ']' { EVTable $2 $4 }
- | 'case' Exp 'of' '{' ListCase '}' { ECase $2 $5 }
- | 'variants' '{' ListExp '}' { EVariants $3 }
- | 'pre' '{' Exp ';' ListAltern '}' { EPre $3 $5 }
- | 'strs' '{' ListExp '}' { EStrs $3 }
- | PIdent '@' Exp6 { EConAt $1 $3 }
- | '#' Patt2 { EPatt $2 }
- | 'pattern' Exp5 { EPattType $2 }
- | Exp5 { $1 }
- | 'Lin' PIdent { ELin $2 }
-
-
-Exp3 :: { Exp }
-Exp3 : Exp3 '!' Exp4 { ESelect $1 $3 }
- | Exp3 '*' Exp4 { ETupTyp $1 $3 }
- | Exp3 '**' Exp4 { EExtend $1 $3 }
- | Exp4 { $1 }
-
-
-Exp1 :: { Exp }
-Exp1 : Exp2 '+' Exp1 { EGlue $1 $3 }
- | Exp2 { $1 }
-
-
-Exp :: { Exp }
-Exp : Exp1 '++' Exp { EConcat $1 $3 }
- | '\\' ListBind '->' Exp { EAbstr $2 $4 }
- | '\\' '\\' ListBind '=>' Exp { ECTable $3 $5 }
- | Decl '->' Exp { EProd $1 $3 }
- | Exp3 '=>' Exp { ETType $1 $3 }
- | 'let' '{' ListLocDef '}' 'in' Exp { ELet $3 $6 }
- | 'let' ListLocDef 'in' Exp { ELetb $2 $4 }
- | Exp3 'where' '{' ListLocDef '}' { EWhere $1 $4 }
- | 'fn' '{' ListEquation '}' { EEqs $3 }
- | 'in' Exp5 String { EExample $2 $3 }
- | Exp1 { $1 }
-
-
-Exp2 :: { Exp }
-Exp2 : Exp3 { $1 }
-
-
-ListExp :: { [Exp] }
-ListExp : {- empty -} { [] }
- | Exp { (:[]) $1 }
- | Exp ';' ListExp { (:) $1 $3 }
-
-
-Exps :: { Exps }
-Exps : {- empty -} { NilExp }
- | Exp6 Exps { ConsExp $1 $2 }
-
-
-Patt2 :: { Patt }
-Patt2 : '?' { PChar }
- | '[' String ']' { PChars $2 }
- | '#' PIdent { PMacro $2 }
- | '#' PIdent '.' PIdent { PM $2 $4 }
- | '_' { PW }
- | PIdent { PV $1 }
- | '{' PIdent '}' { PCon $2 }
- | PIdent '.' PIdent { PQ $1 $3 }
- | Integer { PInt $1 }
- | Double { PFloat $1 }
- | String { PStr $1 }
- | '{' ListPattAss '}' { PR $2 }
- | '<' ListPattTupleComp '>' { PTup $2 }
- | '(' Patt ')' { $2 }
-
-
-Patt1 :: { Patt }
-Patt1 : PIdent ListPatt { PC $1 $2 }
- | PIdent '.' PIdent ListPatt { PQC $1 $3 $4 }
- | Patt2 '*' { PRep $1 }
- | PIdent '@' Patt2 { PAs $1 $3 }
- | '-' Patt2 { PNeg $2 }
- | Patt2 { $1 }
-
-
-Patt :: { Patt }
-Patt : Patt '|' Patt1 { PDisj $1 $3 }
- | Patt '+' Patt1 { PSeq $1 $3 }
- | Patt1 { $1 }
-
-
-PattAss :: { PattAss }
-PattAss : ListPIdent '=' Patt { PA $1 $3 }
-
-
-Label :: { Label }
-Label : PIdent { LIdent $1 }
- | '$' Integer { LVar $2 }
-
-
-Sort :: { Sort }
-Sort : 'Type' { Sort_Type }
- | 'PType' { Sort_PType }
- | 'Tok' { Sort_Tok }
- | 'Str' { Sort_Str }
- | 'Strs' { Sort_Strs }
-
-
-ListPattAss :: { [PattAss] }
-ListPattAss : {- empty -} { [] }
- | PattAss { (:[]) $1 }
- | PattAss ';' ListPattAss { (:) $1 $3 }
-
-
-ListPatt :: { [Patt] }
-ListPatt : Patt2 { (:[]) $1 }
- | Patt2 ListPatt { (:) $1 $2 }
-
-
-Bind :: { Bind }
-Bind : PIdent { BIdent $1 }
- | '_' { BWild }
-
-
-ListBind :: { [Bind] }
-ListBind : {- empty -} { [] }
- | Bind { (:[]) $1 }
- | Bind ',' ListBind { (:) $1 $3 }
-
-
-Decl :: { Decl }
-Decl : '(' ListBind ':' Exp ')' { DDec $2 $4 }
- | Exp4 { DExp $1 }
-
-
-TupleComp :: { TupleComp }
-TupleComp : Exp { TComp $1 }
-
-
-PattTupleComp :: { PattTupleComp }
-PattTupleComp : Patt { PTComp $1 }
-
-
-ListTupleComp :: { [TupleComp] }
-ListTupleComp : {- empty -} { [] }
- | TupleComp { (:[]) $1 }
- | TupleComp ',' ListTupleComp { (:) $1 $3 }
-
-
-ListPattTupleComp :: { [PattTupleComp] }
-ListPattTupleComp : {- empty -} { [] }
- | PattTupleComp { (:[]) $1 }
- | PattTupleComp ',' ListPattTupleComp { (:) $1 $3 }
-
-
-Case :: { Case }
-Case : Patt '=>' Exp { Case $1 $3 }
-
-
-ListCase :: { [Case] }
-ListCase : Case { (:[]) $1 }
- | Case ';' ListCase { (:) $1 $3 }
-
-
-Equation :: { Equation }
-Equation : ListPatt '->' Exp { Equ $1 $3 }
-
-
-ListEquation :: { [Equation] }
-ListEquation : {- empty -} { [] }
- | Equation { (:[]) $1 }
- | Equation ';' ListEquation { (:) $1 $3 }
-
-
-Altern :: { Altern }
-Altern : Exp '/' Exp { Alt $1 $3 }
-
-
-ListAltern :: { [Altern] }
-ListAltern : {- empty -} { [] }
- | Altern { (:[]) $1 }
- | Altern ';' ListAltern { (:) $1 $3 }
-
-
-DDecl :: { DDecl }
-DDecl : '(' ListBind ':' Exp ')' { DDDec $2 $4 }
- | Exp6 { DDExp $1 }
-
-
-ListDDecl :: { [DDecl] }
-ListDDecl : {- empty -} { [] }
- | ListDDecl DDecl { flip (:) $1 $2 }
-
-
-OldGrammar :: { OldGrammar }
-OldGrammar : Include ListTopDef { OldGr $1 (reverse $2) }
-
-
-Include :: { Include }
-Include : {- empty -} { NoIncl }
- | 'include' ListFileName { Incl $2 }
-
-
-FileName :: { FileName }
-FileName : String { FString $1 }
- | PIdent { FIdent $1 }
- | '/' FileName { FSlash $2 }
- | '.' FileName { FDot $2 }
- | '-' FileName { FMinus $2 }
- | PIdent FileName { FAddId $1 $2 }
-
-
-ListFileName :: { [FileName] }
-ListFileName : FileName ';' { (:[]) $1 }
- | FileName ';' ListFileName { (:) $1 $3 }
-
-
-
-{
-
-returnM :: a -> Err a
-returnM = return
-
-thenM :: Err a -> (a -> Err b) -> Err b
-thenM = (>>=)
-
-happyError :: [Token] -> Err a
-happyError ts =
- Bad $ "syntax error at " ++ tokenPos ts ++
- case ts of
- [] -> []
- [Err _] -> " due to lexer error"
- _ -> " before " ++ unwords (map prToken (take 4 ts))
-
-myLexer = tokens
-}
-
diff --git a/src/GF/Source/PrintGF.hs b/src/GF/Source/PrintGF.hs
deleted file mode 100644
index 0a260f5bf..000000000
--- a/src/GF/Source/PrintGF.hs
+++ /dev/null
@@ -1,532 +0,0 @@
-{-# OPTIONS -fno-warn-incomplete-patterns #-}
-module GF.Source.PrintGF where
-
--- pretty-printer generated by the BNF converter
-
-import GF.Source.AbsGF
-import Char
-
--- the top-level printing method
-printTree :: Print a => a -> String
-printTree = render . prt 0
-
-type Doc = [ShowS] -> [ShowS]
-
-doc :: ShowS -> Doc
-doc = (:)
-
-render :: Doc -> String
-render d = rend 0 (map ($ "") $ d []) "" where
- rend i ss = case ss of
- "[" :ts -> showChar '[' . rend i ts
- "(" :ts -> showChar '(' . rend i ts
- "{" :ts -> showChar '{' . new (i+1) . rend (i+1) ts
- "}" : ";":ts -> new (i-1) . space "}" . showChar ';' . new (i-1) . rend (i-1) ts
- "}" :ts -> new (i-1) . showChar '}' . new (i-1) . rend (i-1) ts
- ";" :ts -> showChar ';' . new i . rend i ts
- t : "," :ts -> showString t . space "," . rend i ts
- t : ")" :ts -> showString t . showChar ')' . rend i ts
- t : "]" :ts -> showString t . showChar ']' . rend i ts
- t :ts -> space t . rend i ts
- _ -> id
- new i = showChar '\n' . replicateS (2*i) (showChar ' ') . dropWhile isSpace
- space t = showString t . (\s -> if null s then "" else (' ':s))
-
-parenth :: Doc -> Doc
-parenth ss = doc (showChar '(') . ss . doc (showChar ')')
-
-concatS :: [ShowS] -> ShowS
-concatS = foldr (.) id
-
-concatD :: [Doc] -> Doc
-concatD = foldr (.) id
-
-replicateS :: Int -> ShowS -> ShowS
-replicateS n f = concatS (replicate n f)
-
--- the printer class does the job
-class Print a where
- prt :: Int -> a -> Doc
- prtList :: [a] -> Doc
- prtList = concatD . map (prt 0)
-
-instance Print a => Print [a] where
- prt _ = prtList
-
-instance Print Char where
- prt _ s = doc (showChar '\'' . mkEsc '\'' s . showChar '\'')
- prtList s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"')
-
-mkEsc :: Char -> Char -> ShowS
-mkEsc q s = case s of
- _ | s == q -> showChar '\\' . showChar s
- '\\'-> showString "\\\\"
- '\n' -> showString "\\n"
- '\t' -> showString "\\t"
- _ -> showChar s
-
-prPrec :: Int -> Int -> Doc -> Doc
-prPrec i j = if j (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-
-
-instance Print Grammar where
- prt i e = case e of
- Gr moddefs -> prPrec i 0 (concatD [prt 0 moddefs])
-
-
-instance Print ModDef where
- prt i e = case e of
- MMain pident0 pident concspecs -> prPrec i 0 (concatD [doc (showString "grammar") , prt 0 pident0 , doc (showString "=") , doc (showString "{") , doc (showString "abstract") , doc (showString "=") , prt 0 pident , doc (showString ";") , prt 0 concspecs , doc (showString "}")])
- MModule complmod modtype modbody -> prPrec i 0 (concatD [prt 0 complmod , prt 0 modtype , doc (showString "=") , prt 0 modbody])
-
- prtList es = case es of
- [] -> (concatD [])
- x:xs -> (concatD [prt 0 x , prt 0 xs])
-
-instance Print ConcSpec where
- prt i e = case e of
- ConcSpec pident concexp -> prPrec i 0 (concatD [prt 0 pident , doc (showString "=") , prt 0 concexp])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print ConcExp where
- prt i e = case e of
- ConcExp pident transfers -> prPrec i 0 (concatD [prt 0 pident , prt 0 transfers])
-
-
-instance Print Transfer where
- prt i e = case e of
- TransferIn open -> prPrec i 0 (concatD [doc (showString "(") , doc (showString "transfer") , doc (showString "in") , prt 0 open , doc (showString ")")])
- TransferOut open -> prPrec i 0 (concatD [doc (showString "(") , doc (showString "transfer") , doc (showString "out") , prt 0 open , doc (showString ")")])
-
- prtList es = case es of
- [] -> (concatD [])
- x:xs -> (concatD [prt 0 x , prt 0 xs])
-
-instance Print ModType where
- prt i e = case e of
- MTAbstract pident -> prPrec i 0 (concatD [doc (showString "abstract") , prt 0 pident])
- MTResource pident -> prPrec i 0 (concatD [doc (showString "resource") , prt 0 pident])
- MTInterface pident -> prPrec i 0 (concatD [doc (showString "interface") , prt 0 pident])
- MTConcrete pident0 pident -> prPrec i 0 (concatD [doc (showString "concrete") , prt 0 pident0 , doc (showString "of") , prt 0 pident])
- MTInstance pident0 pident -> prPrec i 0 (concatD [doc (showString "instance") , prt 0 pident0 , doc (showString "of") , prt 0 pident])
- MTTransfer pident open0 open -> prPrec i 0 (concatD [doc (showString "transfer") , prt 0 pident , doc (showString ":") , prt 0 open0 , doc (showString "->") , prt 0 open])
-
-
-instance Print ModBody where
- prt i e = case e of
- MBody extend opens topdefs -> prPrec i 0 (concatD [prt 0 extend , prt 0 opens , doc (showString "{") , prt 0 topdefs , doc (showString "}")])
- MNoBody includeds -> prPrec i 0 (concatD [prt 0 includeds])
- MWith included opens -> prPrec i 0 (concatD [prt 0 included , doc (showString "with") , prt 0 opens])
- MWithBody included opens0 opens topdefs -> prPrec i 0 (concatD [prt 0 included , doc (showString "with") , prt 0 opens0 , doc (showString "**") , prt 0 opens , doc (showString "{") , prt 0 topdefs , doc (showString "}")])
- MWithE includeds included opens -> prPrec i 0 (concatD [prt 0 includeds , doc (showString "**") , prt 0 included , doc (showString "with") , prt 0 opens])
- MWithEBody includeds included opens0 opens topdefs -> prPrec i 0 (concatD [prt 0 includeds , doc (showString "**") , prt 0 included , doc (showString "with") , prt 0 opens0 , doc (showString "**") , prt 0 opens , doc (showString "{") , prt 0 topdefs , doc (showString "}")])
- MReuse pident -> prPrec i 0 (concatD [doc (showString "reuse") , prt 0 pident])
- MUnion includeds -> prPrec i 0 (concatD [doc (showString "union") , prt 0 includeds])
-
-
-instance Print Extend where
- prt i e = case e of
- Ext includeds -> prPrec i 0 (concatD [prt 0 includeds , doc (showString "**")])
- NoExt -> prPrec i 0 (concatD [])
-
-
-instance Print Opens where
- prt i e = case e of
- NoOpens -> prPrec i 0 (concatD [])
- OpenIn opens -> prPrec i 0 (concatD [doc (showString "open") , prt 0 opens , doc (showString "in")])
-
-
-instance Print Open where
- prt i e = case e of
- OName pident -> prPrec i 0 (concatD [prt 0 pident])
- OQualQO qualopen pident -> prPrec i 0 (concatD [doc (showString "(") , prt 0 qualopen , prt 0 pident , doc (showString ")")])
- OQual qualopen pident0 pident -> prPrec i 0 (concatD [doc (showString "(") , prt 0 qualopen , prt 0 pident0 , doc (showString "=") , prt 0 pident , doc (showString ")")])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-instance Print ComplMod where
- prt i e = case e of
- CMCompl -> prPrec i 0 (concatD [])
- CMIncompl -> prPrec i 0 (concatD [doc (showString "incomplete")])
-
-
-instance Print QualOpen where
- prt i e = case e of
- QOCompl -> prPrec i 0 (concatD [])
- QOIncompl -> prPrec i 0 (concatD [doc (showString "incomplete")])
- QOInterface -> prPrec i 0 (concatD [doc (showString "interface")])
-
-
-instance Print Included where
- prt i e = case e of
- IAll pident -> prPrec i 0 (concatD [prt 0 pident])
- ISome pident pidents -> prPrec i 0 (concatD [prt 0 pident , doc (showString "[") , prt 0 pidents , doc (showString "]")])
- IMinus pident pidents -> prPrec i 0 (concatD [prt 0 pident , doc (showString "-") , doc (showString "[") , prt 0 pidents , doc (showString "]")])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-instance Print Def where
- prt i e = case e of
- DDecl names exp -> prPrec i 0 (concatD [prt 0 names , doc (showString ":") , prt 0 exp])
- DDef names exp -> prPrec i 0 (concatD [prt 0 names , doc (showString "=") , prt 0 exp])
- DPatt name patts exp -> prPrec i 0 (concatD [prt 0 name , prt 0 patts , doc (showString "=") , prt 0 exp])
- DFull names exp0 exp -> prPrec i 0 (concatD [prt 0 names , doc (showString ":") , prt 0 exp0 , doc (showString "=") , prt 0 exp])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print TopDef where
- prt i e = case e of
- DefCat catdefs -> prPrec i 0 (concatD [doc (showString "cat") , prt 0 catdefs])
- DefFun fundefs -> prPrec i 0 (concatD [doc (showString "fun") , prt 0 fundefs])
- DefFunData fundefs -> prPrec i 0 (concatD [doc (showString "data") , prt 0 fundefs])
- DefDef defs -> prPrec i 0 (concatD [doc (showString "def") , prt 0 defs])
- DefData datadefs -> prPrec i 0 (concatD [doc (showString "data") , prt 0 datadefs])
- DefTrans defs -> prPrec i 0 (concatD [doc (showString "transfer") , prt 0 defs])
- DefPar pardefs -> prPrec i 0 (concatD [doc (showString "param") , prt 0 pardefs])
- DefOper defs -> prPrec i 0 (concatD [doc (showString "oper") , prt 0 defs])
- DefLincat printdefs -> prPrec i 0 (concatD [doc (showString "lincat") , prt 0 printdefs])
- DefLindef defs -> prPrec i 0 (concatD [doc (showString "lindef") , prt 0 defs])
- DefLin defs -> prPrec i 0 (concatD [doc (showString "lin") , prt 0 defs])
- DefPrintCat printdefs -> prPrec i 0 (concatD [doc (showString "printname") , doc (showString "cat") , prt 0 printdefs])
- DefPrintFun printdefs -> prPrec i 0 (concatD [doc (showString "printname") , doc (showString "fun") , prt 0 printdefs])
- DefFlag flagdefs -> prPrec i 0 (concatD [doc (showString "flags") , prt 0 flagdefs])
- DefPrintOld printdefs -> prPrec i 0 (concatD [doc (showString "printname") , prt 0 printdefs])
- DefLintype defs -> prPrec i 0 (concatD [doc (showString "lintype") , prt 0 defs])
- DefPattern defs -> prPrec i 0 (concatD [doc (showString "pattern") , prt 0 defs])
- DefPackage pident topdefs -> prPrec i 0 (concatD [doc (showString "package") , prt 0 pident , doc (showString "=") , doc (showString "{") , prt 0 topdefs , doc (showString "}") , doc (showString ";")])
- DefVars defs -> prPrec i 0 (concatD [doc (showString "var") , prt 0 defs])
- DefTokenizer pident -> prPrec i 0 (concatD [doc (showString "tokenizer") , prt 0 pident , doc (showString ";")])
-
- prtList es = case es of
- [] -> (concatD [])
- x:xs -> (concatD [prt 0 x , prt 0 xs])
-
-instance Print CatDef where
- prt i e = case e of
- SimpleCatDef pident ddecls -> prPrec i 0 (concatD [prt 0 pident , prt 0 ddecls])
- ListCatDef pident ddecls -> prPrec i 0 (concatD [doc (showString "[") , prt 0 pident , prt 0 ddecls , doc (showString "]")])
- ListSizeCatDef pident ddecls n -> prPrec i 0 (concatD [doc (showString "[") , prt 0 pident , prt 0 ddecls , doc (showString "]") , doc (showString "{") , prt 0 n , doc (showString "}")])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print FunDef where
- prt i e = case e of
- FunDef pidents exp -> prPrec i 0 (concatD [prt 0 pidents , doc (showString ":") , prt 0 exp])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print DataDef where
- prt i e = case e of
- DataDef pident dataconstrs -> prPrec i 0 (concatD [prt 0 pident , doc (showString "=") , prt 0 dataconstrs])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print DataConstr where
- prt i e = case e of
- DataId pident -> prPrec i 0 (concatD [prt 0 pident])
- DataQId pident0 pident -> prPrec i 0 (concatD [prt 0 pident0 , doc (showString ".") , prt 0 pident])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString "|") , prt 0 xs])
-
-instance Print ParDef where
- prt i e = case e of
- ParDefDir pident parconstrs -> prPrec i 0 (concatD [prt 0 pident , doc (showString "=") , prt 0 parconstrs])
- ParDefIndir pident0 pident -> prPrec i 0 (concatD [prt 0 pident0 , doc (showString "=") , doc (showString "(") , doc (showString "in") , prt 0 pident , doc (showString ")")])
- ParDefAbs pident -> prPrec i 0 (concatD [prt 0 pident])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print ParConstr where
- prt i e = case e of
- ParConstr pident ddecls -> prPrec i 0 (concatD [prt 0 pident , prt 0 ddecls])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString "|") , prt 0 xs])
-
-instance Print PrintDef where
- prt i e = case e of
- PrintDef names exp -> prPrec i 0 (concatD [prt 0 names , doc (showString "=") , prt 0 exp])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print FlagDef where
- prt i e = case e of
- FlagDef pident0 pident -> prPrec i 0 (concatD [prt 0 pident0 , doc (showString "=") , prt 0 pident])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print Name where
- prt i e = case e of
- IdentName pident -> prPrec i 0 (concatD [prt 0 pident])
- ListName pident -> prPrec i 0 (concatD [doc (showString "[") , prt 0 pident , doc (showString "]")])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-instance Print LocDef where
- prt i e = case e of
- LDDecl pidents exp -> prPrec i 0 (concatD [prt 0 pidents , doc (showString ":") , prt 0 exp])
- LDDef pidents exp -> prPrec i 0 (concatD [prt 0 pidents , doc (showString "=") , prt 0 exp])
- LDFull pidents exp0 exp -> prPrec i 0 (concatD [prt 0 pidents , doc (showString ":") , prt 0 exp0 , doc (showString "=") , prt 0 exp])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print Exp where
- prt i e = case e of
- EIdent pident -> prPrec i 6 (concatD [prt 0 pident])
- EConstr pident -> prPrec i 6 (concatD [doc (showString "{") , prt 0 pident , doc (showString "}")])
- ECons pident -> prPrec i 6 (concatD [doc (showString "%") , prt 0 pident , doc (showString "%")])
- ESort sort -> prPrec i 6 (concatD [prt 0 sort])
- EString str -> prPrec i 6 (concatD [prt 0 str])
- EInt n -> prPrec i 6 (concatD [prt 0 n])
- EFloat d -> prPrec i 6 (concatD [prt 0 d])
- EMeta -> prPrec i 6 (concatD [doc (showString "?")])
- EEmpty -> prPrec i 6 (concatD [doc (showString "[") , doc (showString "]")])
- EData -> prPrec i 6 (concatD [doc (showString "data")])
- EList pident exps -> prPrec i 6 (concatD [doc (showString "[") , prt 0 pident , prt 0 exps , doc (showString "]")])
- EStrings str -> prPrec i 6 (concatD [doc (showString "[") , prt 0 str , doc (showString "]")])
- ERecord locdefs -> prPrec i 6 (concatD [doc (showString "{") , prt 0 locdefs , doc (showString "}")])
- ETuple tuplecomps -> prPrec i 6 (concatD [doc (showString "<") , prt 0 tuplecomps , doc (showString ">")])
- EIndir pident -> prPrec i 6 (concatD [doc (showString "(") , doc (showString "in") , prt 0 pident , doc (showString ")")])
- ETyped exp0 exp -> prPrec i 6 (concatD [doc (showString "<") , prt 0 exp0 , doc (showString ":") , prt 0 exp , doc (showString ">")])
- EProj exp label -> prPrec i 5 (concatD [prt 5 exp , doc (showString ".") , prt 0 label])
- EQConstr pident0 pident -> prPrec i 5 (concatD [doc (showString "{") , prt 0 pident0 , doc (showString ".") , prt 0 pident , doc (showString "}")])
- EQCons pident0 pident -> prPrec i 5 (concatD [doc (showString "%") , prt 0 pident0 , doc (showString ".") , prt 0 pident])
- EApp exp0 exp -> prPrec i 4 (concatD [prt 4 exp0 , prt 5 exp])
- ETable cases -> prPrec i 4 (concatD [doc (showString "table") , doc (showString "{") , prt 0 cases , doc (showString "}")])
- ETTable exp cases -> prPrec i 4 (concatD [doc (showString "table") , prt 6 exp , doc (showString "{") , prt 0 cases , doc (showString "}")])
- EVTable exp exps -> prPrec i 4 (concatD [doc (showString "table") , prt 6 exp , doc (showString "[") , prt 0 exps , doc (showString "]")])
- ECase exp cases -> prPrec i 4 (concatD [doc (showString "case") , prt 0 exp , doc (showString "of") , doc (showString "{") , prt 0 cases , doc (showString "}")])
- EVariants exps -> prPrec i 4 (concatD [doc (showString "variants") , doc (showString "{") , prt 0 exps , doc (showString "}")])
- EPre exp alterns -> prPrec i 4 (concatD [doc (showString "pre") , doc (showString "{") , prt 0 exp , doc (showString ";") , prt 0 alterns , doc (showString "}")])
- EStrs exps -> prPrec i 4 (concatD [doc (showString "strs") , doc (showString "{") , prt 0 exps , doc (showString "}")])
- EConAt pident exp -> prPrec i 4 (concatD [prt 0 pident , doc (showString "@") , prt 6 exp])
- EPatt patt -> prPrec i 4 (concatD [doc (showString "#") , prt 2 patt])
- EPattType exp -> prPrec i 4 (concatD [doc (showString "pattern") , prt 5 exp])
- ESelect exp0 exp -> prPrec i 3 (concatD [prt 3 exp0 , doc (showString "!") , prt 4 exp])
- ETupTyp exp0 exp -> prPrec i 3 (concatD [prt 3 exp0 , doc (showString "*") , prt 4 exp])
- EExtend exp0 exp -> prPrec i 3 (concatD [prt 3 exp0 , doc (showString "**") , prt 4 exp])
- EGlue exp0 exp -> prPrec i 1 (concatD [prt 2 exp0 , doc (showString "+") , prt 1 exp])
- EConcat exp0 exp -> prPrec i 0 (concatD [prt 1 exp0 , doc (showString "++") , prt 0 exp])
- EAbstr binds exp -> prPrec i 0 (concatD [doc (showString "\\") , prt 0 binds , doc (showString "->") , prt 0 exp])
- ECTable binds exp -> prPrec i 0 (concatD [doc (showString "\\") , doc (showString "\\") , prt 0 binds , doc (showString "=>") , prt 0 exp])
- EProd decl exp -> prPrec i 0 (concatD [prt 0 decl , doc (showString "->") , prt 0 exp])
- ETType exp0 exp -> prPrec i 0 (concatD [prt 3 exp0 , doc (showString "=>") , prt 0 exp])
- ELet locdefs exp -> prPrec i 0 (concatD [doc (showString "let") , doc (showString "{") , prt 0 locdefs , doc (showString "}") , doc (showString "in") , prt 0 exp])
- ELetb locdefs exp -> prPrec i 0 (concatD [doc (showString "let") , prt 0 locdefs , doc (showString "in") , prt 0 exp])
- EWhere exp locdefs -> prPrec i 0 (concatD [prt 3 exp , doc (showString "where") , doc (showString "{") , prt 0 locdefs , doc (showString "}")])
- EEqs equations -> prPrec i 0 (concatD [doc (showString "fn") , doc (showString "{") , prt 0 equations , doc (showString "}")])
- EExample exp str -> prPrec i 0 (concatD [doc (showString "in") , prt 5 exp , prt 0 str])
- ELString lstring -> prPrec i 6 (concatD [prt 0 lstring])
- ELin pident -> prPrec i 4 (concatD [doc (showString "Lin") , prt 0 pident])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print Exps where
- prt i e = case e of
- NilExp -> prPrec i 0 (concatD [])
- ConsExp exp exps -> prPrec i 0 (concatD [prt 6 exp , prt 0 exps])
-
-
-instance Print Patt where
- prt i e = case e of
- PChar -> prPrec i 2 (concatD [doc (showString "?")])
- PChars str -> prPrec i 2 (concatD [doc (showString "[") , prt 0 str , doc (showString "]")])
- PMacro pident -> prPrec i 2 (concatD [doc (showString "#") , prt 0 pident])
- PM pident0 pident -> prPrec i 2 (concatD [doc (showString "#") , prt 0 pident0 , doc (showString ".") , prt 0 pident])
- PW -> prPrec i 2 (concatD [doc (showString "_")])
- PV pident -> prPrec i 2 (concatD [prt 0 pident])
- PCon pident -> prPrec i 2 (concatD [doc (showString "{") , prt 0 pident , doc (showString "}")])
- PQ pident0 pident -> prPrec i 2 (concatD [prt 0 pident0 , doc (showString ".") , prt 0 pident])
- PInt n -> prPrec i 2 (concatD [prt 0 n])
- PFloat d -> prPrec i 2 (concatD [prt 0 d])
- PStr str -> prPrec i 2 (concatD [prt 0 str])
- PR pattasss -> prPrec i 2 (concatD [doc (showString "{") , prt 0 pattasss , doc (showString "}")])
- PTup patttuplecomps -> prPrec i 2 (concatD [doc (showString "<") , prt 0 patttuplecomps , doc (showString ">")])
- PC pident patts -> prPrec i 1 (concatD [prt 0 pident , prt 0 patts])
- PQC pident0 pident patts -> prPrec i 1 (concatD [prt 0 pident0 , doc (showString ".") , prt 0 pident , prt 0 patts])
- PDisj patt0 patt -> prPrec i 0 (concatD [prt 0 patt0 , doc (showString "|") , prt 1 patt])
- PSeq patt0 patt -> prPrec i 0 (concatD [prt 0 patt0 , doc (showString "+") , prt 1 patt])
- PRep patt -> prPrec i 1 (concatD [prt 2 patt , doc (showString "*")])
- PAs pident patt -> prPrec i 1 (concatD [prt 0 pident , doc (showString "@") , prt 2 patt])
- PNeg patt -> prPrec i 1 (concatD [doc (showString "-") , prt 2 patt])
-
- prtList es = case es of
- [x] -> (concatD [prt 2 x])
- x:xs -> (concatD [prt 2 x , prt 0 xs])
-
-instance Print PattAss where
- prt i e = case e of
- PA pidents patt -> prPrec i 0 (concatD [prt 0 pidents , doc (showString "=") , prt 0 patt])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print Label where
- prt i e = case e of
- LIdent pident -> prPrec i 0 (concatD [prt 0 pident])
- LVar n -> prPrec i 0 (concatD [doc (showString "$") , prt 0 n])
-
-
-instance Print Sort where
- prt i e = case e of
- Sort_Type -> prPrec i 0 (concatD [doc (showString "Type")])
- Sort_PType -> prPrec i 0 (concatD [doc (showString "PType")])
- Sort_Tok -> prPrec i 0 (concatD [doc (showString "Tok")])
- Sort_Str -> prPrec i 0 (concatD [doc (showString "Str")])
- Sort_Strs -> prPrec i 0 (concatD [doc (showString "Strs")])
-
-
-instance Print Bind where
- prt i e = case e of
- BIdent pident -> prPrec i 0 (concatD [prt 0 pident])
- BWild -> prPrec i 0 (concatD [doc (showString "_")])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-instance Print Decl where
- prt i e = case e of
- DDec binds exp -> prPrec i 0 (concatD [doc (showString "(") , prt 0 binds , doc (showString ":") , prt 0 exp , doc (showString ")")])
- DExp exp -> prPrec i 0 (concatD [prt 4 exp])
-
-
-instance Print TupleComp where
- prt i e = case e of
- TComp exp -> prPrec i 0 (concatD [prt 0 exp])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-instance Print PattTupleComp where
- prt i e = case e of
- PTComp patt -> prPrec i 0 (concatD [prt 0 patt])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ",") , prt 0 xs])
-
-instance Print Case where
- prt i e = case e of
- Case patt exp -> prPrec i 0 (concatD [prt 0 patt , doc (showString "=>") , prt 0 exp])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print Equation where
- prt i e = case e of
- Equ patts exp -> prPrec i 0 (concatD [prt 0 patts , doc (showString "->") , prt 0 exp])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print Altern where
- prt i e = case e of
- Alt exp0 exp -> prPrec i 0 (concatD [prt 0 exp0 , doc (showString "/") , prt 0 exp])
-
- prtList es = case es of
- [] -> (concatD [])
- [x] -> (concatD [prt 0 x])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-instance Print DDecl where
- prt i e = case e of
- DDDec binds exp -> prPrec i 0 (concatD [doc (showString "(") , prt 0 binds , doc (showString ":") , prt 0 exp , doc (showString ")")])
- DDExp exp -> prPrec i 0 (concatD [prt 6 exp])
-
- prtList es = case es of
- [] -> (concatD [])
- x:xs -> (concatD [prt 0 x , prt 0 xs])
-
-instance Print OldGrammar where
- prt i e = case e of
- OldGr include topdefs -> prPrec i 0 (concatD [prt 0 include , prt 0 topdefs])
-
-
-instance Print Include where
- prt i e = case e of
- NoIncl -> prPrec i 0 (concatD [])
- Incl filenames -> prPrec i 0 (concatD [doc (showString "include") , prt 0 filenames])
-
-
-instance Print FileName where
- prt i e = case e of
- FString str -> prPrec i 0 (concatD [prt 0 str])
- FIdent pident -> prPrec i 0 (concatD [prt 0 pident])
- FSlash filename -> prPrec i 0 (concatD [doc (showString "/") , prt 0 filename])
- FDot filename -> prPrec i 0 (concatD [doc (showString ".") , prt 0 filename])
- FMinus filename -> prPrec i 0 (concatD [doc (showString "-") , prt 0 filename])
- FAddId pident filename -> prPrec i 0 (concatD [prt 0 pident , prt 0 filename])
-
- prtList es = case es of
- [x] -> (concatD [prt 0 x , doc (showString ";")])
- x:xs -> (concatD [prt 0 x , doc (showString ";") , prt 0 xs])
-
-
diff --git a/src/GF/Source/SkelGF.hs b/src/GF/Source/SkelGF.hs
deleted file mode 100644
index 3bd192f9d..000000000
--- a/src/GF/Source/SkelGF.hs
+++ /dev/null
@@ -1,364 +0,0 @@
-module GF.Source.SkelGF where
-
--- Haskell module generated by the BNF converter
-
-import GF.Source.AbsGF
-import GF.Source.ErrM
-type Result = Err String
-
-failure :: Show a => a -> Result
-failure x = Bad $ "Undefined case: " ++ show x
-
-transLString :: LString -> Result
-transLString x = case x of
- LString str -> failure x
-
-
-transPIdent :: PIdent -> Result
-transPIdent x = case x of
- PIdent str -> failure x
-
-
-transGrammar :: Grammar -> Result
-transGrammar x = case x of
- Gr moddefs -> failure x
-
-
-transModDef :: ModDef -> Result
-transModDef x = case x of
- MMain pident0 pident concspecs -> failure x
- MModule complmod modtype modbody -> failure x
-
-
-transConcSpec :: ConcSpec -> Result
-transConcSpec x = case x of
- ConcSpec pident concexp -> failure x
-
-
-transConcExp :: ConcExp -> Result
-transConcExp x = case x of
- ConcExp pident transfers -> failure x
-
-
-transTransfer :: Transfer -> Result
-transTransfer x = case x of
- TransferIn open -> failure x
- TransferOut open -> failure x
-
-
-transModType :: ModType -> Result
-transModType x = case x of
- MTAbstract pident -> failure x
- MTResource pident -> failure x
- MTInterface pident -> failure x
- MTConcrete pident0 pident -> failure x
- MTInstance pident0 pident -> failure x
- MTTransfer pident open0 open -> failure x
-
-
-transModBody :: ModBody -> Result
-transModBody x = case x of
- MBody extend opens topdefs -> failure x
- MNoBody includeds -> failure x
- MWith included opens -> failure x
- MWithBody included opens0 opens topdefs -> failure x
- MWithE includeds included opens -> failure x
- MWithEBody includeds included opens0 opens topdefs -> failure x
- MReuse pident -> failure x
- MUnion includeds -> failure x
-
-
-transExtend :: Extend -> Result
-transExtend x = case x of
- Ext includeds -> failure x
- NoExt -> failure x
-
-
-transOpens :: Opens -> Result
-transOpens x = case x of
- NoOpens -> failure x
- OpenIn opens -> failure x
-
-
-transOpen :: Open -> Result
-transOpen x = case x of
- OName pident -> failure x
- OQualQO qualopen pident -> failure x
- OQual qualopen pident0 pident -> failure x
-
-
-transComplMod :: ComplMod -> Result
-transComplMod x = case x of
- CMCompl -> failure x
- CMIncompl -> failure x
-
-
-transQualOpen :: QualOpen -> Result
-transQualOpen x = case x of
- QOCompl -> failure x
- QOIncompl -> failure x
- QOInterface -> failure x
-
-
-transIncluded :: Included -> Result
-transIncluded x = case x of
- IAll pident -> failure x
- ISome pident pidents -> failure x
- IMinus pident pidents -> failure x
-
-
-transDef :: Def -> Result
-transDef x = case x of
- DDecl names exp -> failure x
- DDef names exp -> failure x
- DPatt name patts exp -> failure x
- DFull names exp0 exp -> failure x
-
-
-transTopDef :: TopDef -> Result
-transTopDef x = case x of
- DefCat catdefs -> failure x
- DefFun fundefs -> failure x
- DefFunData fundefs -> failure x
- DefDef defs -> failure x
- DefData datadefs -> failure x
- DefTrans defs -> failure x
- DefPar pardefs -> failure x
- DefOper defs -> failure x
- DefLincat printdefs -> failure x
- DefLindef defs -> failure x
- DefLin defs -> failure x
- DefPrintCat printdefs -> failure x
- DefPrintFun printdefs -> failure x
- DefFlag flagdefs -> failure x
- DefPrintOld printdefs -> failure x
- DefLintype defs -> failure x
- DefPattern defs -> failure x
- DefPackage pident topdefs -> failure x
- DefVars defs -> failure x
- DefTokenizer pident -> failure x
-
-
-transCatDef :: CatDef -> Result
-transCatDef x = case x of
- SimpleCatDef pident ddecls -> failure x
- ListCatDef pident ddecls -> failure x
- ListSizeCatDef pident ddecls n -> failure x
-
-
-transFunDef :: FunDef -> Result
-transFunDef x = case x of
- FunDef pidents exp -> failure x
-
-
-transDataDef :: DataDef -> Result
-transDataDef x = case x of
- DataDef pident dataconstrs -> failure x
-
-
-transDataConstr :: DataConstr -> Result
-transDataConstr x = case x of
- DataId pident -> failure x
- DataQId pident0 pident -> failure x
-
-
-transParDef :: ParDef -> Result
-transParDef x = case x of
- ParDefDir pident parconstrs -> failure x
- ParDefIndir pident0 pident -> failure x
- ParDefAbs pident -> failure x
-
-
-transParConstr :: ParConstr -> Result
-transParConstr x = case x of
- ParConstr pident ddecls -> failure x
-
-
-transPrintDef :: PrintDef -> Result
-transPrintDef x = case x of
- PrintDef names exp -> failure x
-
-
-transFlagDef :: FlagDef -> Result
-transFlagDef x = case x of
- FlagDef pident0 pident -> failure x
-
-
-transName :: Name -> Result
-transName x = case x of
- IdentName pident -> failure x
- ListName pident -> failure x
-
-
-transLocDef :: LocDef -> Result
-transLocDef x = case x of
- LDDecl pidents exp -> failure x
- LDDef pidents exp -> failure x
- LDFull pidents exp0 exp -> failure x
-
-
-transExp :: Exp -> Result
-transExp x = case x of
- EIdent pident -> failure x
- EConstr pident -> failure x
- ECons pident -> failure x
- ESort sort -> failure x
- EString str -> failure x
- EInt n -> failure x
- EFloat d -> failure x
- EMeta -> failure x
- EEmpty -> failure x
- EData -> failure x
- EList pident exps -> failure x
- EStrings str -> failure x
- ERecord locdefs -> failure x
- ETuple tuplecomps -> failure x
- EIndir pident -> failure x
- ETyped exp0 exp -> failure x
- EProj exp label -> failure x
- EQConstr pident0 pident -> failure x
- EQCons pident0 pident -> failure x
- EApp exp0 exp -> failure x
- ETable cases -> failure x
- ETTable exp cases -> failure x
- EVTable exp exps -> failure x
- ECase exp cases -> failure x
- EVariants exps -> failure x
- EPre exp alterns -> failure x
- EStrs exps -> failure x
- EConAt pident exp -> failure x
- EPatt patt -> failure x
- EPattType exp -> failure x
- ESelect exp0 exp -> failure x
- ETupTyp exp0 exp -> failure x
- EExtend exp0 exp -> failure x
- EGlue exp0 exp -> failure x
- EConcat exp0 exp -> failure x
- EAbstr binds exp -> failure x
- ECTable binds exp -> failure x
- EProd decl exp -> failure x
- ETType exp0 exp -> failure x
- ELet locdefs exp -> failure x
- ELetb locdefs exp -> failure x
- EWhere exp locdefs -> failure x
- EEqs equations -> failure x
- EExample exp str -> failure x
- ELString lstring -> failure x
- ELin pident -> failure x
-
-
-transExps :: Exps -> Result
-transExps x = case x of
- NilExp -> failure x
- ConsExp exp exps -> failure x
-
-
-transPatt :: Patt -> Result
-transPatt x = case x of
- PChar -> failure x
- PChars str -> failure x
- PMacro pident -> failure x
- PM pident0 pident -> failure x
- PW -> failure x
- PV pident -> failure x
- PCon pident -> failure x
- PQ pident0 pident -> failure x
- PInt n -> failure x
- PFloat d -> failure x
- PStr str -> failure x
- PR pattasss -> failure x
- PTup patttuplecomps -> failure x
- PC pident patts -> failure x
- PQC pident0 pident patts -> failure x
- PDisj patt0 patt -> failure x
- PSeq patt0 patt -> failure x
- PRep patt -> failure x
- PAs pident patt -> failure x
- PNeg patt -> failure x
-
-
-transPattAss :: PattAss -> Result
-transPattAss x = case x of
- PA pidents patt -> failure x
-
-
-transLabel :: Label -> Result
-transLabel x = case x of
- LIdent pident -> failure x
- LVar n -> failure x
-
-
-transSort :: Sort -> Result
-transSort x = case x of
- Sort_Type -> failure x
- Sort_PType -> failure x
- Sort_Tok -> failure x
- Sort_Str -> failure x
- Sort_Strs -> failure x
-
-
-transBind :: Bind -> Result
-transBind x = case x of
- BIdent pident -> failure x
- BWild -> failure x
-
-
-transDecl :: Decl -> Result
-transDecl x = case x of
- DDec binds exp -> failure x
- DExp exp -> failure x
-
-
-transTupleComp :: TupleComp -> Result
-transTupleComp x = case x of
- TComp exp -> failure x
-
-
-transPattTupleComp :: PattTupleComp -> Result
-transPattTupleComp x = case x of
- PTComp patt -> failure x
-
-
-transCase :: Case -> Result
-transCase x = case x of
- Case patt exp -> failure x
-
-
-transEquation :: Equation -> Result
-transEquation x = case x of
- Equ patts exp -> failure x
-
-
-transAltern :: Altern -> Result
-transAltern x = case x of
- Alt exp0 exp -> failure x
-
-
-transDDecl :: DDecl -> Result
-transDDecl x = case x of
- DDDec binds exp -> failure x
- DDExp exp -> failure x
-
-
-transOldGrammar :: OldGrammar -> Result
-transOldGrammar x = case x of
- OldGr include topdefs -> failure x
-
-
-transInclude :: Include -> Result
-transInclude x = case x of
- NoIncl -> failure x
- Incl filenames -> failure x
-
-
-transFileName :: FileName -> Result
-transFileName x = case x of
- FString str -> failure x
- FIdent pident -> failure x
- FSlash filename -> failure x
- FDot filename -> failure x
- FMinus filename -> failure x
- FAddId pident filename -> failure x
-
-
-
diff --git a/src/GF/Source/SourceToGrammar.hs b/src/GF/Source/SourceToGrammar.hs
deleted file mode 100644
index 132bd4704..000000000
--- a/src/GF/Source/SourceToGrammar.hs
+++ /dev/null
@@ -1,755 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : SourceToGrammar
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/04 11:05:07 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.28 $
---
--- based on the skeleton Haskell module generated by the BNF converter
------------------------------------------------------------------------------
-
-module GF.Source.SourceToGrammar ( transGrammar,
- transInclude,
- transModDef,
- transOldGrammar,
- transExp,
- newReservedWords
- ) where
-
-import qualified GF.Grammar.Grammar as G
-import qualified GF.Grammar.PrGrammar as GP
-import qualified GF.Infra.Modules as GM
-import qualified GF.Grammar.Macros as M
-import qualified GF.Compile.Update as U
-import qualified GF.Infra.Option as GO
-import qualified GF.Compile.ModDeps as GD
-import GF.Infra.Ident
-import GF.Source.AbsGF
-import GF.Source.PrintGF
-import GF.Compile.RemoveLiT --- for bw compat
-import GF.Data.Operations
-import GF.Infra.Option
-
-import Control.Monad
-import Data.Char
-import Data.List (genericReplicate)
-
--- based on the skeleton Haskell module generated by the BNF converter
-
-type Result = Err String
-
-failure :: Show a => a -> Err b
-failure x = Bad $ "Undefined case: " ++ show x
-
-prPIdent :: PIdent -> String
-prPIdent (PIdent (_,c)) = c
-
-getIdentPos :: PIdent -> Err (Ident,Int)
-getIdentPos x = case x of
- PIdent ((line,_),c) -> return (IC c,line)
-
-transIdent :: PIdent -> Err Ident
-transIdent = liftM fst . getIdentPos
-
-transName :: Name -> Err Ident
-transName n = case n of
- IdentName i -> transIdent i
- ListName i -> liftM mkListId (transIdent i)
-
-transGrammar :: Grammar -> Err G.SourceGrammar
-transGrammar x = case x of
- Gr moddefs -> do
- moddefs' <- mapM transModDef moddefs
- GD.mkSourceGrammar moddefs'
-
-transModDef :: ModDef -> Err (Ident, G.SourceModInfo)
-transModDef x = case x of
-
- MMain id0 id concspecs -> do
- id0' <- transIdent id0
- id' <- transIdent id
- concspecs' <- mapM transConcSpec concspecs
- return $ (id0', GM.ModMainGrammar (GM.MainGrammar id' concspecs'))
-
- MModule compl mtyp body -> do
-
- let mstat' = transComplMod compl
-
- (trDef, mtyp', id') <- case mtyp of
- MTAbstract id -> do
- id' <- transIdent id
- return (transAbsDef, GM.MTAbstract, id')
- MTResource id -> mkModRes id GM.MTResource body
- MTConcrete id open -> do
- id' <- transIdent id
- open' <- transIdent open
- return (transCncDef, GM.MTConcrete open', id')
- MTTransfer id a b -> do
- id' <- transIdent id
- a' <- transOpen a
- b' <- transOpen a
- return (transAbsDef, GM.MTTransfer a' b', id')
- MTInterface id -> mkModRes id GM.MTInterface body
- MTInstance id open -> do
- open' <- transIdent open
- mkModRes id (GM.MTInstance open') body
-
- mkBody (mstat', trDef, mtyp', id') body
- where
- mkBody xx@(mstat', trDef, mtyp', id') bod = case bod of
- MNoBody incls -> do
- mkBody xx $ MBody (Ext incls) NoOpens []
- MBody extends opens defs -> do
- extends' <- transExtend extends
- opens' <- transOpens opens
- defs0 <- mapM trDef $ getTopDefs defs
- defs' <- U.buildAnyTree [d | Left ds <- defs0, d <- ds]
- flags' <- return [f | Right fs <- defs0, f <- fs]
- return (id',GM.ModMod (GM.Module mtyp' mstat' flags' extends' opens' defs'))
- MReuse _ -> do
- return (id', GM.ModMod (GM.Module mtyp' mstat' [] [] [] emptyBinTree))
- MUnion imps -> do
- imps' <- mapM transIncluded imps
- return (id',
- GM.ModMod (GM.Module (GM.MTUnion mtyp' imps') mstat' [] [] [] emptyBinTree))
-
- MWith m insts -> mkBody xx $ MWithEBody [] m insts NoOpens []
- MWithBody m insts opens defs -> mkBody xx $ MWithEBody [] m insts opens defs
- MWithE extends m insts -> mkBody xx $ MWithEBody extends m insts NoOpens []
- MWithEBody extends m insts opens defs -> do
- extends' <- mapM transIncludedExt extends
- m' <- transIncludedExt m
- insts' <- mapM transOpen insts
- opens' <- transOpens opens
- defs0 <- mapM trDef $ getTopDefs defs
- defs' <- U.buildAnyTree [d | Left ds <- defs0, d <- ds]
- flags' <- return [f | Right fs <- defs0, f <- fs]
- return (id',
- GM.ModWith (GM.Module mtyp' mstat' flags' extends' opens' defs') m' insts')
-
- mkModRes id mtyp body = do
- id' <- transIdent id
- case body of
- MReuse c -> do
- c' <- transIdent c
- mtyp' <- trMReuseType mtyp c'
- return (transResDef, GM.MTReuse mtyp', id')
- _ -> return (transResDef, mtyp, id')
- trMReuseType mtyp c = case mtyp of
- GM.MTInterface -> return $ GM.MRInterface c
- GM.MTInstance op -> return $ GM.MRInstance c op
- GM.MTResource -> return $ GM.MRResource c
-
-
-transComplMod :: ComplMod -> GM.ModuleStatus
-transComplMod x = case x of
- CMCompl -> GM.MSComplete
- CMIncompl -> GM.MSIncomplete
-
-getTopDefs :: [TopDef] -> [TopDef]
-getTopDefs x = x
-
-transConcSpec :: ConcSpec -> Err (GM.MainConcreteSpec Ident)
-transConcSpec x = case x of
- ConcSpec id concexp -> do
- id' <- transIdent id
- (m,mi,mo) <- transConcExp concexp
- return $ GM.MainConcreteSpec id' m mi mo
-
-transConcExp :: ConcExp ->
- Err (Ident, Maybe (GM.OpenSpec Ident),Maybe (GM.OpenSpec Ident))
-transConcExp x = case x of
- ConcExp id transfers -> do
- id' <- transIdent id
- trs <- mapM transTransfer transfers
- tin <- case [o | Left o <- trs] of
- [o] -> return $ Just o
- [] -> return $ Nothing
- _ -> Bad "ambiguous transfer in"
- tout <- case [o | Right o <- trs] of
- [o] -> return $ Just o
- [] -> return $ Nothing
- _ -> Bad "ambiguous transfer out"
- return (id',tin,tout)
-
-transTransfer :: Transfer ->
- Err (Either (GM.OpenSpec Ident)(GM.OpenSpec Ident))
-transTransfer x = case x of
- TransferIn open -> liftM Left $ transOpen open
- TransferOut open -> liftM Right $ transOpen open
-
-transExtend :: Extend -> Err [(Ident,GM.MInclude Ident)]
-transExtend x = case x of
- Ext ids -> mapM transIncludedExt ids
- NoExt -> return []
-
-transOpens :: Opens -> Err [GM.OpenSpec Ident]
-transOpens x = case x of
- NoOpens -> return []
- OpenIn opens -> mapM transOpen opens
-
-transOpen :: Open -> Err (GM.OpenSpec Ident)
-transOpen x = case x of
- OName id -> liftM (GM.OSimple GM.OQNormal) $ transIdent id
- OQualQO q id -> liftM2 GM.OSimple (transQualOpen q) (transIdent id)
- OQual q id m -> liftM3 GM.OQualif (transQualOpen q) (transIdent id) (transIdent m)
-
-transQualOpen :: QualOpen -> Err GM.OpenQualif
-transQualOpen x = case x of
- QOCompl -> return GM.OQNormal
- QOInterface -> return GM.OQInterface
- QOIncompl -> return GM.OQIncomplete
-
-transIncluded :: Included -> Err (Ident,[Ident])
-transIncluded x = case x of
- IAll i -> liftM (flip (curry id) []) $ transIdent i
- ISome i ids -> liftM2 (curry id) (transIdent i) (mapM transIdent ids)
- IMinus i ids -> liftM2 (curry id) (transIdent i) (mapM transIdent ids) ----
-
-transIncludedExt :: Included -> Err (Ident, GM.MInclude Ident)
-transIncludedExt x = case x of
- IAll i -> liftM2 (,) (transIdent i) (return GM.MIAll)
- ISome i ids -> liftM2 (,) (transIdent i) (liftM GM.MIOnly $ mapM transIdent ids)
- IMinus i ids -> liftM2 (,) (transIdent i) (liftM GM.MIExcept $ mapM transIdent ids)
-
-transAbsDef :: TopDef -> Err (Either [(Ident, G.Info)] [GO.Option])
-transAbsDef x = case x of
- DefCat catdefs -> liftM (Left . concat) $ mapM transCatDef catdefs
- DefFun fundefs -> do
- fundefs' <- mapM transFunDef fundefs
- returnl [(fun, G.AbsFun (yes typ) nope) | (funs,typ) <- fundefs', fun <- funs]
- DefFunData fundefs -> do
- fundefs' <- mapM transFunDef fundefs
- returnl $
- [(cat, G.AbsCat nope (yes [M.cn fun])) | (funs,typ) <- fundefs',
- fun <- funs,
- Ok (_,cat) <- [M.valCat typ]
- ] ++
- [(fun, G.AbsFun (yes typ) (yes G.EData)) | (funs,typ) <- fundefs', fun <- funs]
- DefDef defs -> do
- defs' <- liftM concat $ mapM getDefsGen defs
- returnl [(c, G.AbsFun nope pe) | (c,(_,pe)) <- defs']
- DefData ds -> do
- ds' <- mapM transDataDef ds
- returnl $
- [(c, G.AbsCat nope (yes ps)) | (c,ps) <- ds'] ++
- [(f, G.AbsFun nope (yes G.EData)) | (_,fs) <- ds', tf <- fs, f <- funs tf]
- DefTrans defs -> do
- defs' <- liftM concat $ mapM getDefsGen defs
- returnl [(c, G.AbsTrans f) | (c,(_,Yes f)) <- defs']
- DefFlag defs -> liftM Right $ mapM transFlagDef defs
- _ -> Bad $ "illegal definition in abstract module:" ++++ printTree x
- where
- -- to get data constructors as terms
- funs t = case t of
- G.Cn f -> [f]
- G.Q _ f -> [f]
- G.QC _ f -> [f]
- _ -> []
-
-returnl :: a -> Err (Either a b)
-returnl = return . Left
-
-transFlagDef :: FlagDef -> Err GO.Option
-transFlagDef x = case x of
- FlagDef f x -> return $ GO.Opt (prPIdent f,[prPIdent x])
-
--- | Cat definitions can also return some fun defs
--- if it is a list category definition
-transCatDef :: CatDef -> Err [(Ident, G.Info)]
-transCatDef x = case x of
- SimpleCatDef id ddecls -> do
- id' <- transIdent id
- liftM (:[]) $ cat id' ddecls
- ListCatDef id ddecls -> listCat id ddecls 0
- ListSizeCatDef id ddecls size -> listCat id ddecls size
- where
- cat i ddecls = do
- -- i <- transIdent id
- cont <- liftM concat $ mapM transDDecl ddecls
- return (i, G.AbsCat (yes cont) nope)
- listCat id ddecls size = do
- id' <- transIdent id
- let
- li = mkListId id'
- baseId = mkBaseId id'
- consId = mkConsId id'
- catd0@(c,G.AbsCat (Yes cont0) _) <- cat li ddecls
- let
- catd = (c,G.AbsCat (Yes cont0) (Yes [M.cn baseId,M.cn consId]))
- cont = [(mkId x i,ty) | (i,(x,ty)) <- zip [0..] cont0]
- xs = map (G.Vr . fst) cont
- cd = M.mkDecl (M.mkApp (G.Vr id') xs)
- lc = M.mkApp (G.Vr li) xs
- niltyp = M.mkProdSimple (cont ++ genericReplicate size cd) lc
- nilfund = (baseId, G.AbsFun (yes niltyp) (yes G.EData))
- constyp = M.mkProdSimple (cont ++ [cd, M.mkDecl lc]) lc
- consfund = (consId, G.AbsFun (yes constyp) (yes G.EData))
- return [catd,nilfund,consfund]
- mkId x i = if isWildIdent x then (mkIdent "x" i) else x
-
-transFunDef :: FunDef -> Err ([Ident], G.Type)
-transFunDef x = case x of
- FunDef ids typ -> liftM2 (,) (mapM transIdent ids) (transExp typ)
-
-transDataDef :: DataDef -> Err (Ident,[G.Term])
-transDataDef x = case x of
- DataDef id ds -> liftM2 (,) (transIdent id) (mapM transData ds)
- where
- transData d = case d of
- DataId id -> liftM G.Cn $ transIdent id
- DataQId id0 id -> liftM2 G.QC (transIdent id0) (transIdent id)
-
-transResDef :: TopDef -> Err (Either [(Ident, G.Info)] [GO.Option])
-transResDef x = case x of
- DefPar pardefs -> do
- pardefs' <- mapM transParDef pardefs
- returnl $ [(p, G.ResParam (if null pars
- then nope -- abstract param type
- else (yes (pars,Nothing))))
- | (p,pars) <- pardefs']
- ++ [(f, G.ResValue (yes (M.mkProdSimple co (G.Cn p),Nothing))) |
- (p,pars) <- pardefs', (f,co) <- pars]
-
-{-
- ---- encoding of AnyInd without changing syntax. AR 20/9/2007
- DefOper [DDef [c] (EApp (EInt status) (EIdent mo))] -> do
- c' <- transName c
- mo' <- transIdent mo
- return $ Left [(c',G.AnyInd (status==1) mo')]
--}
- DefOper defs -> do
- defs' <- liftM concat $ mapM getDefs defs
- returnl $ concatMap mkOverload [(f, G.ResOper pt pe) | (f,(pt,pe)) <- defs']
-
- DefLintype defs -> do
- defs' <- liftM concat $ mapM getDefs defs
- returnl [(f, G.ResOper pt pe) | (f,(pt,pe)) <- defs']
-
- DefFlag defs -> liftM Right $ mapM transFlagDef defs
- _ -> Bad $ "illegal definition form in resource" +++ printTree x
- where
- mkOverload (c,j) = case j of
- G.ResOper _ (Yes (G.App keyw (G.R fs@(_:_:_)))) |
- isOverloading keyw c fs ->
- [(c,G.ResOverload [(ty,fu) | (_,(Just ty,fu)) <- fs])]
-
- -- to enable separare type signature --- not type-checked
- G.ResOper (Yes (G.App keyw (G.RecType fs@(_:_:_)))) _ |
- isOverloading keyw c fs -> []
- _ -> [(c,j)]
- isOverloading keyw c fs =
- GP.prt keyw == "overload" && -- overload is a "soft keyword"
- all (== GP.prt c) (map (GP.prt . fst) fs)
-
-transParDef :: ParDef -> Err (Ident, [G.Param])
-transParDef x = case x of
- ParDefDir id params -> liftM2 (,) (transIdent id) (mapM transParConstr params)
- ParDefAbs id -> liftM2 (,) (transIdent id) (return [])
- _ -> Bad $ "illegal definition in resource:" ++++ printTree x
-
-transCncDef :: TopDef -> Err (Either [(Ident, G.Info)] [GO.Option])
-transCncDef x = case x of
- DefLincat defs -> do
- defs' <- liftM concat $ mapM transPrintDef defs
- returnl [(f, G.CncCat (yes t) nope nope) | (f,t) <- defs']
- DefLindef defs -> do
- defs' <- liftM concat $ mapM getDefs defs
- returnl [(f, G.CncCat pt pe nope) | (f,(pt,pe)) <- defs']
- DefLin defs -> do
- defs' <- liftM concat $ mapM getDefs defs
- returnl [(f, G.CncFun Nothing pe nope) | (f,(_,pe)) <- defs']
- DefPrintCat defs -> do
- defs' <- liftM concat $ mapM transPrintDef defs
- returnl [(f, G.CncCat nope nope (yes e)) | (f,e) <- defs']
- DefPrintFun defs -> do
- defs' <- liftM concat $ mapM transPrintDef defs
- returnl [(f, G.CncFun Nothing nope (yes e)) | (f,e) <- defs']
- DefPrintOld defs -> do --- a guess, for backward compatibility
- defs' <- liftM concat $ mapM transPrintDef defs
- returnl [(f, G.CncFun Nothing nope (yes e)) | (f,e) <- defs']
- DefFlag defs -> liftM Right $ mapM transFlagDef defs
- DefPattern defs -> do
- defs' <- liftM concat $ mapM getDefs defs
- let defs2 = [(f, termInPattern t) | (f,(_,Yes t)) <- defs']
- returnl [(f, G.CncFun Nothing (yes t) nope) | (f,t) <- defs2]
-
- _ -> errIn ("illegal definition in concrete syntax:") $ transResDef x
-
-transPrintDef :: PrintDef -> Err [(Ident,G.Term)]
-transPrintDef x = case x of
- PrintDef ids exp -> do
- (ids,e) <- liftM2 (,) (mapM transName ids) (transExp exp)
- return $ [(i,e) | i <- ids]
-
-getDefsGen :: Def -> Err [(Ident, (G.Perh G.Type, G.Perh G.Term))]
-getDefsGen d = case d of
- DDecl ids t -> do
- ids' <- mapM transName ids
- t' <- transExp t
- return [(i,(yes t', nope)) | i <- ids']
- DDef ids e -> do
- ids' <- mapM transName ids
- e' <- transExp e
- return [(i,(nope, yes e')) | i <- ids']
- DFull ids t e -> do
- ids' <- mapM transName ids
- t' <- transExp t
- e' <- transExp e
- return [(i,(yes t', yes e')) | i <- ids']
- DPatt id patts e -> do
- id' <- transName id
- ps' <- mapM transPatt patts
- e' <- transExp e
- return [(id',(nope, yes (G.Eqs [(ps',e')])))]
-
--- | sometimes you need this special case, e.g. in linearization rules
-getDefs :: Def -> Err [(Ident, (G.Perh G.Type, G.Perh G.Term))]
-getDefs d = case d of
- DPatt id patts e -> do
- id' <- transName id
- xs <- mapM tryMakeVar patts
- e' <- transExp e
- return [(id',(nope, yes (M.mkAbs xs e')))]
- _ -> getDefsGen d
-
--- | accepts a pattern that is either a variable or a wild card
-tryMakeVar :: Patt -> Err Ident
-tryMakeVar p = do
- p' <- transPatt p
- case p' of
- G.PV i -> return i
- G.PW -> return identW
- _ -> Bad $ "not a legal pattern in lambda binding" +++ GP.prt p'
-
-transExp :: Exp -> Err G.Term
-transExp x = case x of
- EIdent id -> liftM G.Vr $ transIdent id
- EConstr id -> liftM G.Con $ transIdent id
- ECons id -> liftM G.Cn $ transIdent id
- EQConstr m c -> liftM2 G.QC (transIdent m) (transIdent c)
- EQCons m c -> liftM2 G.Q (transIdent m) (transIdent c)
- EString str -> return $ G.K str
- ESort sort -> liftM G.Sort $ transSort sort
- EInt n -> return $ G.EInt n
- EFloat n -> return $ G.EFloat n
- EMeta -> return $ M.meta $ M.int2meta 0
- EEmpty -> return G.Empty
- -- [ C x_1 ... x_n ] becomes (ListC x_1 ... x_n)
- EList i es -> do
- i' <- transIdent i
- es' <- mapM transExp (exps2list es)
- return $ foldl G.App (G.Vr (mkListId i')) es'
- EStrings [] -> return G.Empty
- EStrings str -> return $ foldr1 G.C $ map G.K $ words str
- ERecord defs -> erecord2term defs
- ETupTyp _ _ -> do
- let tups t = case t of
- ETupTyp x y -> tups x ++ [y] -- right-associative parsing
- _ -> [t]
- es <- mapM transExp $ tups x
- return $ G.RecType $ M.tuple2recordType es
- ETuple tuplecomps -> do
- es <- mapM transExp [e | TComp e <- tuplecomps]
- return $ G.R $ M.tuple2record es
- EProj exp id -> liftM2 G.P (transExp exp) (trLabel id)
- EApp exp0 exp -> liftM2 G.App (transExp exp0) (transExp exp)
- ETable cases -> liftM (G.T G.TRaw) (transCases cases)
- ETTable exp cases ->
- liftM2 (\t c -> G.T (G.TTyped t) c) (transExp exp) (transCases cases)
- EVTable exp cases ->
- liftM2 (\t c -> G.V t c) (transExp exp) (mapM transExp cases)
- ECase exp cases -> do
- exp' <- transExp exp
- cases' <- transCases cases
- let annot = case exp' of
- G.Typed _ t -> G.TTyped t
- _ -> G.TRaw
- return $ G.S (G.T annot cases') exp'
- ECTable binds exp -> liftM2 M.mkCTable (mapM transBind binds) (transExp exp)
-
- EVariants exps -> liftM G.FV $ mapM transExp exps
- EPre exp alts -> liftM2 (curry G.Alts) (transExp exp) (mapM transAltern alts)
- EStrs exps -> liftM G.Strs $ mapM transExp exps
- ESelect exp0 exp -> liftM2 G.S (transExp exp0) (transExp exp)
- EExtend exp0 exp -> liftM2 G.ExtR (transExp exp0) (transExp exp)
- EAbstr binds exp -> liftM2 M.mkAbs (mapM transBind binds) (transExp exp)
- ETyped exp0 exp -> liftM2 G.Typed (transExp exp0) (transExp exp)
- EExample exp str -> liftM2 G.Example (transExp exp) (return str)
-
- EProd decl exp -> liftM2 M.mkProdSimple (transDecl decl) (transExp exp)
- ETType exp0 exp -> liftM2 G.Table (transExp exp0) (transExp exp)
- EConcat exp0 exp -> liftM2 G.C (transExp exp0) (transExp exp)
- EGlue exp0 exp -> liftM2 G.Glue (transExp exp0) (transExp exp)
- ELet defs exp -> do
- exp' <- transExp exp
- defs0 <- mapM locdef2fields defs
- defs' <- mapM tryLoc $ concat defs0
- return $ M.mkLet defs' exp'
- where
- tryLoc (c,(mty,Just e)) = return (c,(mty,e))
- tryLoc (c,_) = Bad $ "local definition of" +++ GP.prt c +++ "without value"
- ELetb defs exp -> transExp $ ELet defs exp
- EWhere exp defs -> transExp $ ELet defs exp
-
- EPattType typ -> liftM G.EPattType (transExp typ)
- EPatt patt -> liftM G.EPatt (transPatt patt)
-
- ELString (LString str) -> return $ G.K str
- ELin id -> liftM G.LiT $ transIdent id
-
- EEqs eqs -> liftM G.Eqs $ mapM transEquation eqs
-
- _ -> Bad $ "translation not yet defined for" +++ printTree x ----
-
-exps2list :: Exps -> [Exp]
-exps2list NilExp = []
-exps2list (ConsExp e es) = e : exps2list es
-
---- this is complicated: should we change Exp or G.Term ?
-
-erecord2term :: [LocDef] -> Err G.Term
-erecord2term ds = do
- ds' <- mapM locdef2fields ds
- mkR $ concat ds'
- where
- mkR fs = do
- fs' <- transF fs
- return $ case fs' of
- Left ts -> G.RecType ts
- Right ds -> G.R ds
- transF [] = return $ Left [] --- empty record always interpreted as record type
- transF fs@(f:_) = case f of
- (lab,(Just ty,Nothing)) -> mapM tryRT fs >>= return . Left
- _ -> mapM tryR fs >>= return . Right
- tryRT f = case f of
- (lab,(Just ty,Nothing)) -> return (M.ident2label lab,ty)
- _ -> Bad $ "illegal record type field" +++ GP.prt (fst f) --- manifest fields ?!
- tryR f = case f of
- (lab,(mty, Just t)) -> return (M.ident2label lab,(mty,t))
- _ -> Bad $ "illegal record field" +++ GP.prt (fst f)
-
-
-locdef2fields :: LocDef -> Err [(Ident, (Maybe G.Type, Maybe G.Type))]
-locdef2fields d = case d of
- LDDecl ids t -> do
- labs <- mapM transIdent ids
- t' <- transExp t
- return [(lab,(Just t',Nothing)) | lab <- labs]
- LDDef ids e -> do
- labs <- mapM transIdent ids
- e' <- transExp e
- return [(lab,(Nothing, Just e')) | lab <- labs]
- LDFull ids t e -> do
- labs <- mapM transIdent ids
- t' <- transExp t
- e' <- transExp e
- return [(lab,(Just t', Just e')) | lab <- labs]
-
-trLabel :: Label -> Err G.Label
-trLabel x = case x of
-
- -- this case is for bward compatibility and should be removed
- LIdent (PIdent (_,'v':ds@(_:_))) | all isDigit ds -> return $ G.LVar $ readIntArg ds
-
- LIdent (PIdent (_, s)) -> return $ G.LIdent s
- LVar x -> return $ G.LVar $ fromInteger x
-
-transSort :: Sort -> Err String
-transSort x = case x of
- _ -> return $ printTree x
-
-{-
---- no more used 7/1/2006 AR
-transPatts :: Patt -> Err [G.Patt]
-transPatts p = case p of
- PDisj p1 p2 -> liftM2 (++) (transPatts p1) (transPatts p2)
- PC id patts -> liftM (map (G.PC id) . combinations) $ mapM transPatts patts
- PQC q id patts -> liftM (map (G.PP q id) . combinations) (mapM transPatts patts)
-
- PR pattasss -> do
- let (lss,ps) = unzip [(ls,p) | PA ls p <- pattasss]
- ls = map LIdent $ concat lss
- ps0 <- mapM transPatts ps
- let ps' = combinations ps0
- lss' <- mapM trLabel ls
- let rss = map (zip lss') ps'
- return $ map G.PR rss
- PTup pcs -> do
- ps0 <- mapM transPatts [e | PTComp e <- pcs]
- let ps' = combinations ps0
- return $ map (G.PR . M.tuple2recordPatt) ps'
- _ -> liftM singleton $ transPatt p
--}
-
-transPatt :: Patt -> Err G.Patt
-transPatt x = case x of
- PW -> return G.wildPatt
- PV id -> liftM G.PV $ transIdent id
- PC id patts -> liftM2 G.PC (transIdent id) (mapM transPatt patts)
- PCon id -> liftM2 G.PC (transIdent id) (return [])
- PInt n -> return $ G.PInt n
- PFloat n -> return $ G.PFloat n
- PStr str -> return $ G.PString str
- PR pattasss -> do
- let (lss,ps) = unzip [(ls,p) | PA ls p <- pattasss]
- ls = map LIdent $ concat lss
- liftM G.PR $ liftM2 zip (mapM trLabel ls) (mapM transPatt ps)
- PTup pcs ->
- liftM (G.PR . M.tuple2recordPatt) (mapM transPatt [e | PTComp e <- pcs])
- PQ id0 id -> liftM3 G.PP (transIdent id0) (transIdent id) (return [])
- PQC id0 id patts ->
- liftM3 G.PP (transIdent id0) (transIdent id) (mapM transPatt patts)
- PDisj p1 p2 -> liftM2 G.PAlt (transPatt p1) (transPatt p2)
- PSeq p1 p2 -> liftM2 G.PSeq (transPatt p1) (transPatt p2)
- PRep p -> liftM G.PRep (transPatt p)
- PNeg p -> liftM G.PNeg (transPatt p)
- PAs x p -> liftM2 G.PAs (transIdent x) (transPatt p)
- PChar -> return G.PChar
- PChars s -> return $ G.PChars s
- PMacro c -> liftM G.PMacro $ transIdent c
- PM m c -> liftM2 G.PM (transIdent m) (transIdent c)
-
-transBind :: Bind -> Err Ident
-transBind x = case x of
- BIdent id -> transIdent id
- BWild -> return identW
-
-transDecl :: Decl -> Err [G.Decl]
-transDecl x = case x of
- DDec binds exp -> do
- xs <- mapM transBind binds
- exp' <- transExp exp
- return [(x,exp') | x <- xs]
- DExp exp -> liftM (return . M.mkDecl) $ transExp exp
-
-transCases :: [Case] -> Err [G.Case]
-transCases = mapM transCase
-
-transCase :: Case -> Err G.Case
-transCase (Case p exp) = do
- patt <- transPatt p
- exp' <- transExp exp
- return (patt,exp')
-
-transEquation :: Equation -> Err G.Equation
-transEquation x = case x of
- Equ apatts exp -> liftM2 (,) (mapM transPatt apatts) (transExp exp)
-
-transAltern :: Altern -> Err (G.Term, G.Term)
-transAltern x = case x of
- Alt exp0 exp -> liftM2 (,) (transExp exp0) (transExp exp)
-
-transParConstr :: ParConstr -> Err G.Param
-transParConstr x = case x of
- ParConstr id ddecls -> do
- id' <- transIdent id
- ddecls' <- mapM transDDecl ddecls
- return (id',concat ddecls')
-
-transDDecl :: DDecl -> Err [G.Decl]
-transDDecl x = case x of
- DDDec binds exp -> transDecl $ DDec binds exp
- DDExp exp -> transDecl $ DExp exp
-
--- | to deal with the old format, sort judgements in three modules, forming
--- their names from a given string, e.g. file name or overriding user-given string
-transOldGrammar :: Options -> FilePath -> OldGrammar -> Err G.SourceGrammar
-transOldGrammar opts name0 x = case x of
- OldGr includes topdefs -> do --- includes must be collected separately
- let moddefs = sortTopDefs topdefs
- g1 <- transGrammar $ Gr moddefs
- removeLiT g1 --- needed for bw compatibility with an obsolete feature
- where
- sortTopDefs ds = [mkAbs a,mkRes ops r,mkCnc ops c] ++ map mkPack ps
- where
- ops = map fst ps
- (a,r,c,ps) = foldr srt ([],[],[],[]) ds
- srt d (a,r,c,ps) = case d of
- DefCat catdefs -> (d:a,r,c,ps)
- DefFun fundefs -> (d:a,r,c,ps)
- DefFunData fundefs -> (d:a,r,c,ps)
- DefDef defs -> (d:a,r,c,ps)
- DefData pardefs -> (d:a,r,c,ps)
- DefPar pardefs -> (a,d:r,c,ps)
- DefOper defs -> (a,d:r,c,ps)
- DefLintype defs -> (a,d:r,c,ps)
- DefLincat defs -> (a,r,d:c,ps)
- DefLindef defs -> (a,r,d:c,ps)
- DefLin defs -> (a,r,d:c,ps)
- DefPattern defs -> (a,r,d:c,ps)
- DefFlag defs -> (a,r,d:c,ps) --- a guess
- DefPrintCat printdefs -> (a,r,d:c,ps)
- DefPrintFun printdefs -> (a,r,d:c,ps)
- DefPrintOld printdefs -> (a,r,d:c,ps)
- DefPackage m ds -> (a,r,c,(m,ds):ps)
- _ -> (a,r,c,ps)
- mkAbs a = MModule q (MTAbstract absName) (MBody ne (OpenIn []) (topDefs a))
- mkRes ps r = MModule q (MTResource resName) (MBody ne (OpenIn ops) (topDefs r))
- where ops = map OName ps
- mkCnc ps r = MModule q (MTConcrete cncName absName)
- (MBody ne (OpenIn (map OName (resName:ps))) (topDefs r))
- mkPack (m, ds) = MModule q (MTResource m) (MBody ne (OpenIn []) (topDefs ds))
- topDefs t = t
- ne = NoExt
- q = CMCompl
-
- name = maybe name0 (++ ".gf") $ getOptVal opts useName
- absName = identPI $ maybe topic id $ getOptVal opts useAbsName
- resName = identPI $ maybe ("Res" ++ lang) id $ getOptVal opts useResName
- cncName = identPI $ maybe lang id $ getOptVal opts useCncName
-
- identPI s = PIdent ((0,0),s)
-
- (beg,rest) = span (/='.') name
- (topic,lang) = case rest of -- to avoid overwriting old files
- ".gf" -> ("Abs" ++ beg,"Cnc" ++ beg)
- ".cf" -> ("Abs" ++ beg,"Cnc" ++ beg)
- ".ebnf" -> ("Abs" ++ beg,"Cnc" ++ beg)
- [] -> ("Abs" ++ beg,"Cnc" ++ beg)
- _:s -> (beg, takeWhile (/='.') s)
-
-transInclude :: Include -> Err [FilePath]
-transInclude x = case x of
- NoIncl -> return []
- Incl filenames -> return $ map trans filenames
- where
- trans f = case f of
- FString s -> s
- FIdent (PIdent (_, s)) -> modif s
- FSlash filename -> '/' : trans filename
- FDot filename -> '.' : trans filename
- FMinus filename -> '-' : trans filename
- FAddId (PIdent (_, s)) filename -> modif s ++ trans filename
- modif s = let s' = init s ++ [toLower (last s)] in
- if elem s' newReservedWords then s' else s
- --- unsafe hack ; cf. GetGrammar.oldLexer
-
-
-newReservedWords :: [String]
-newReservedWords =
- words $ "abstract concrete interface incomplete " ++
- "instance out open resource reuse transfer union with where"
-
-termInPattern :: G.Term -> G.Term
-termInPattern t = M.mkAbs xx $ G.R [(s, (Nothing, toP body))] where
- toP t = case t of
- G.Vr x -> G.P t s
- _ -> M.composSafeOp toP t
- s = G.LIdent "s"
- (xx,body) = abss [] t
- abss xs t = case t of
- G.Abs x b -> abss (x:xs) b
- _ -> (reverse xs,t)
-
-mkListId,mkConsId,mkBaseId :: Ident -> Ident
-mkListId = prefixId "List"
-mkConsId = prefixId "Cons"
-mkBaseId = prefixId "Base"
-
-prefixId :: String -> Ident -> Ident
-prefixId pref id = IC (pref ++ prIdent id)
diff --git a/src/GF/Source/TestGF.hs b/src/GF/Source/TestGF.hs
deleted file mode 100644
index e4c072467..000000000
--- a/src/GF/Source/TestGF.hs
+++ /dev/null
@@ -1,58 +0,0 @@
--- automatically generated by BNF Converter
-module Main where
-
-
-import IO ( stdin, hGetContents )
-import System ( getArgs, getProgName )
-
-import GF.Source.LexGF
-import GF.Source.ParGF
-import GF.Source.SkelGF
-import GF.Source.PrintGF
-import GF.Source.AbsGF
-
-
-
-
-import GF.Source.ErrM
-
-type ParseFun a = [Token] -> Err a
-
-myLLexer = myLexer
-
-type Verbosity = Int
-
-putStrV :: Verbosity -> String -> IO ()
-putStrV v s = if v > 1 then putStrLn s else return ()
-
-runFile :: (Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()
-runFile v p f = putStrLn f >> readFile f >>= run v p
-
-run :: (Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()
-run v p s = let ts = myLLexer s in case p ts of
- Bad s -> do putStrLn "\nParse Failed...\n"
- putStrV v "Tokens:"
- putStrV v $ show ts
- putStrLn s
- Ok tree -> do putStrLn "\nParse Successful!"
- showTree v tree
-
-
-
-showTree :: (Show a, Print a) => Int -> a -> IO ()
-showTree v tree
- = do
- putStrV v $ "\n[Abstract Syntax]\n\n" ++ show tree
- putStrV v $ "\n[Linearized tree]\n\n" ++ printTree tree
-
-main :: IO ()
-main = do args <- getArgs
- case args of
- [] -> hGetContents stdin >>= run 2 pGrammar
- "-s":fs -> mapM_ (runFile 0 pGrammar) fs
- fs -> mapM_ (runFile 2 pGrammar) fs
-
-
-
-
-
diff --git a/src/GF/Speech/CFGToFiniteState.hs b/src/GF/Speech/CFGToFiniteState.hs
deleted file mode 100644
index 7e6f80ba1..000000000
--- a/src/GF/Speech/CFGToFiniteState.hs
+++ /dev/null
@@ -1,265 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : CFGToFiniteState
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/10 16:43:44 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.6 $
---
--- Approximates CFGs with finite state networks.
------------------------------------------------------------------------------
-
-module GF.Speech.CFGToFiniteState (cfgToFA, makeSimpleRegular,
- MFA(..), MFALabel, cfgToMFA,cfgToFA') where
-
-import Data.List
-import Data.Maybe
-import Data.Map (Map)
-import qualified Data.Map as Map
-import Data.Set (Set)
-import qualified Data.Set as Set
-
-import GF.Data.Utilities
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), mapSymbol, filterCats, symbol, NameProfile(..))
-import GF.Conversion.Types
-import GF.Infra.Ident (Ident)
-import GF.Infra.Option (Options)
-import GF.Compile.ShellState (StateGrammar)
-
-import GF.Speech.FiniteState
-import GF.Speech.Graph
-import GF.Speech.Relation
-import GF.Speech.TransformCFG
-
-data Recursivity = RightR | LeftR | NotR
-
-data MutRecSet = MutRecSet {
- mrCats :: Set Cat_,
- mrNonRecRules :: [CFRule_],
- mrRecRules :: [CFRule_],
- mrRec :: Recursivity
- }
-
-
-type MutRecSets = Map Cat_ MutRecSet
-
---
--- * Multiple DFA type
---
-
-type MFALabel a = Symbol String a
-
-data MFA a = MFA String [(String,DFA (MFALabel a))]
-
-
-
-cfgToFA :: Options -> StateGrammar -> DFA Token
-cfgToFA opts s = minimize $ compileAutomaton start $ makeSimpleRegular opts s
- where start = getStartCatCF opts s
-
-makeSimpleRegular :: Options -> StateGrammar -> CFRules
-makeSimpleRegular opts s = makeRegular $ preprocess $ cfgToCFRules s
- where start = getStartCatCF opts s
- preprocess = topDownFilter start . bottomUpFilter
- . removeCycles
-
-
---
--- * Compile strongly regular grammars to NFAs
---
-
--- Convert a strongly regular grammar to a finite automaton.
-compileAutomaton :: Cat_ -- ^ Start category
- -> CFRules
- -> NFA Token
-compileAutomaton start g = make_fa (g,ns) s [Cat start] f fa
- where
- (fa,s,f) = newFA_
- ns = mutRecSets g $ mutRecCats False g
-
--- | The make_fa algorithm from \"Regular approximation of CFLs: a grammatical view\",
--- Mark-Jan Nederhof, Advances in Probabilistic and other Parsing Technologies, 2000.
-make_fa :: (CFRules,MutRecSets) -> State -> [Symbol Cat_ Token] -> State
- -> NFA Token -> NFA Token
-make_fa c@(g,ns) q0 alpha q1 fa =
- case alpha of
- [] -> newTransition q0 q1 Nothing fa
- [Tok t] -> newTransition q0 q1 (Just t) fa
- [Cat a] -> case Map.lookup a ns of
- -- a is recursive
- Just n@(MutRecSet { mrCats = ni, mrNonRecRules = nrs, mrRecRules = rs} ) ->
- case mrRec n of
- RightR ->
- -- the set Ni is right-recursive or cyclic
- let new = [(getState c, xs, q1) | CFRule c xs _ <- nrs]
- ++ [(getState c, xs, getState d) | CFRule c ss _ <- rs,
- let (xs,Cat d) = (init ss,last ss)]
- in make_fas new $ newTransition q0 (getState a) Nothing fa'
- LeftR ->
- -- the set Ni is left-recursive
- let new = [(q0, xs, getState c) | CFRule c xs _ <- nrs]
- ++ [(getState d, xs, getState c) | CFRule c (Cat d:xs) _ <- rs]
- in make_fas new $ newTransition (getState a) q1 Nothing fa'
- where
- (fa',stateMap) = addStatesForCats ni fa
- getState x = Map.findWithDefault
- (error $ "CFGToFiniteState: No state for " ++ x)
- x stateMap
- -- a is not recursive
- Nothing -> let rs = catRules g a
- in foldl' (\f (CFRule _ b _) -> make_fa_ q0 b q1 f) fa rs
- (x:beta) -> let (fa',q) = newState () fa
- in make_fa_ q beta q1 $ make_fa_ q0 [x] q fa'
- where
- make_fa_ = make_fa c
- make_fas xs fa = foldl' (\f' (s1,xs,s2) -> make_fa_ s1 xs s2 f') fa xs
-
---
--- * Compile a strongly regular grammar to a DFA with sub-automata
---
-
-cfgToMFA :: Options -> StateGrammar -> MFA Token
-cfgToMFA opts s = buildMFA start $ makeSimpleRegular opts s
- where start = getStartCatCF opts s
-
--- | Build a DFA by building and expanding an MFA
-cfgToFA' :: Options -> StateGrammar -> DFA Token
-cfgToFA' opts s = mfaToDFA $ cfgToMFA opts s
-
-buildMFA :: Cat_ -- ^ Start category
- -> CFRules -> MFA Token
-buildMFA start g = sortSubLats $ removeUnusedSubLats mfa
- where fas = compileAutomata g
- mfa = MFA start [(c, minimize fa) | (c,fa) <- fas]
-
-mfaStartDFA :: MFA a -> DFA (MFALabel a)
-mfaStartDFA (MFA start subs) =
- fromMaybe (error $ "Bad start MFA: " ++ start) $ lookup start subs
-
-mfaToDFA :: Ord a => MFA a -> DFA a
-mfaToDFA mfa@(MFA _ subs) = minimize $ expand $ dfa2nfa $ mfaStartDFA mfa
- where
- subs' = Map.fromList [(c, dfa2nfa n) | (c,n) <- subs]
- getSub l = fromJust $ Map.lookup l subs'
- expand (FA (Graph c ns es) s f)
- = foldl' expandEdge (FA (Graph c ns []) s f) es
- expandEdge fa (f,t,x) =
- case x of
- Nothing -> newTransition f t Nothing fa
- Just (Tok s) -> newTransition f t (Just s) fa
- Just (Cat l) -> insertNFA fa (f,t) (expand $ getSub l)
-
-removeUnusedSubLats :: MFA a -> MFA a
-removeUnusedSubLats mfa@(MFA start subs) = MFA start [(c,s) | (c,s) <- subs, isUsed c]
- where
- usedMap = subLatUseMap mfa
- used = growUsedSet (Set.singleton start)
- isUsed c = c `Set.member` used
- growUsedSet = fix (\s -> foldl Set.union s $ mapMaybe (flip Map.lookup usedMap) $ Set.toList s)
-
-subLatUseMap :: MFA a -> Map String (Set String)
-subLatUseMap (MFA _ subs) = Map.fromList [(c,usedSubLats n) | (c,n) <- subs]
-
-usedSubLats :: DFA (MFALabel a) -> Set String
-usedSubLats fa = Set.fromList [s | (_,_,Cat s) <- transitions fa]
-
-revMultiMap :: (Ord a, Ord b) => Map a (Set b) -> Map b (Set a)
-revMultiMap m = Map.fromListWith Set.union [ (y,Set.singleton x) | (x,s) <- Map.toList m, y <- Set.toList s]
-
--- | Sort sub-networks topologically.
-sortSubLats :: MFA a -> MFA a
-sortSubLats mfa@(MFA main subs) = MFA main (reverse $ sortLats usedByMap subs)
- where
- usedByMap = revMultiMap (subLatUseMap mfa)
- sortLats _ [] = []
- sortLats ub ls = xs ++ sortLats ub' ys
- where (xs,ys) = partition ((==0) . indeg) ls
- ub' = Map.map (Set.\\ Set.fromList (map fst xs)) ub
- indeg (c,_) = maybe 0 Set.size $ Map.lookup c ub
-
--- | Convert a strongly regular grammar to a number of finite automata,
--- one for each non-terminal.
--- The edges in the automata accept tokens, or name another automaton to use.
-compileAutomata :: CFRules
- -> [(Cat_,NFA (Symbol Cat_ Token))]
- -- ^ A map of non-terminals and their automata.
-compileAutomata g = [(c, makeOneFA c) | c <- allCats g]
- where
- mrs = mutRecSets g $ mutRecCats True g
- makeOneFA c = make_fa1 mr s [Cat c] f fa
- where (fa,s,f) = newFA_
- mr = fromJust (Map.lookup c mrs)
-
-
--- | The make_fa algorithm from \"Regular approximation of CFLs: a grammatical view\",
--- Mark-Jan Nederhof, Advances in Probabilistic and other Parsing Technologies, 2000,
--- adapted to build a finite automaton for a single (mutually recursive) set only.
--- Categories not in the set will result in category-labelled edges.
-make_fa1 :: MutRecSet -- ^ The set of (mutually recursive) categories for which
- -- we are building the automaton.
- -> State -- ^ State to come from
- -> [Symbol Cat_ Token] -- ^ Symbols to accept
- -> State -- ^ State to end up in
- -> NFA (Symbol Cat_ Token) -- ^ FA to add to.
- -> NFA (Symbol Cat_ Token)
-make_fa1 mr q0 alpha q1 fa =
- case alpha of
- [] -> newTransition q0 q1 Nothing fa
- [t@(Tok _)] -> newTransition q0 q1 (Just t) fa
- [c@(Cat a)] | not (a `Set.member` mrCats mr) -> newTransition q0 q1 (Just c) fa
- [Cat a] ->
- case mrRec mr of
- NotR -> -- the set is a non-recursive (always singleton) set of categories
- -- so the set of category rules is the set of rules for the whole set
- make_fas [(q0, b, q1) | CFRule _ b _ <- mrNonRecRules mr] fa
- RightR -> -- the set is right-recursive or cyclic
- let new = [(getState c, xs, q1) | CFRule c xs _ <- mrNonRecRules mr]
- ++ [(getState c, xs, getState d) | CFRule c ss _ <- mrRecRules mr,
- let (xs,Cat d) = (init ss,last ss)]
- in make_fas new $ newTransition q0 (getState a) Nothing fa'
- LeftR -> -- the set is left-recursive
- let new = [(q0, xs, getState c) | CFRule c xs _ <- mrNonRecRules mr]
- ++ [(getState d, xs, getState c) | CFRule c (Cat d:xs) _ <- mrRecRules mr]
- in make_fas new $ newTransition (getState a) q1 Nothing fa'
- where
- (fa',stateMap) = addStatesForCats (mrCats mr) fa
- getState x = Map.findWithDefault
- (error $ "CFGToFiniteState: No state for " ++ x)
- x stateMap
- (x:beta) -> let (fa',q) = newState () fa
- in make_fas [(q0,[x],q),(q,beta,q1)] fa'
- where
- make_fas xs fa = foldl' (\f' (s1,xs,s2) -> make_fa1 mr s1 xs s2 f') fa xs
-
-mutRecSets :: CFRules -> [Set Cat_] -> MutRecSets
-mutRecSets g = Map.fromList . concatMap mkMutRecSet
- where
- mkMutRecSet cs = [ (c,ms) | c <- csl ]
- where csl = Set.toList cs
- rs = catSetRules g cs
- (nrs,rrs) = partition (ruleIsNonRecursive cs) rs
- ms = MutRecSet {
- mrCats = cs,
- mrNonRecRules = nrs,
- mrRecRules = rrs,
- mrRec = rec
- }
- rec | null rrs = NotR
- | all (isRightLinear cs) rrs = RightR
- | otherwise = LeftR
-
---
--- * Utilities
---
-
--- | Add a state for the given NFA for each of the categories
--- in the given set. Returns a map of categories to their
--- corresponding states.
-addStatesForCats :: Set Cat_ -> NFA t -> (NFA t, Map Cat_ State)
-addStatesForCats cs fa = (fa', m)
- where (fa', ns) = newStates (replicate (Set.size cs) ()) fa
- m = Map.fromList (zip (Set.toList cs) (map fst ns))
diff --git a/src/GF/Speech/FiniteState.hs b/src/GF/Speech/FiniteState.hs
deleted file mode 100644
index 35274e3c4..000000000
--- a/src/GF/Speech/FiniteState.hs
+++ /dev/null
@@ -1,329 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : FiniteState
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/10 16:43:44 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.16 $
---
--- A simple finite state network module.
------------------------------------------------------------------------------
-module GF.Speech.FiniteState (FA(..), State, NFA, DFA,
- startState, finalStates,
- states, transitions,
- isInternal,
- newFA, newFA_,
- addFinalState,
- newState, newStates,
- newTransition, newTransitions,
- insertTransitionWith, insertTransitionsWith,
- mapStates, mapTransitions,
- modifyTransitions,
- nonLoopTransitionsTo, nonLoopTransitionsFrom,
- loops,
- removeState,
- oneFinalState,
- insertNFA,
- onGraph,
- moveLabelsToNodes, removeTrivialEmptyNodes,
- minimize,
- dfa2nfa,
- unusedNames, renameStates,
- prFAGraphviz, faToGraphviz) where
-
-import Data.List
-import Data.Maybe
-import Data.Map (Map)
-import qualified Data.Map as Map
-import Data.Set (Set)
-import qualified Data.Set as Set
-
-import GF.Data.Utilities
-import GF.Speech.Graph
-import qualified GF.Visualization.Graphviz as Dot
-
-type State = Int
-
--- | Type parameters: node id type, state label type, edge label type
--- Data constructor arguments: nodes and edges, start state, final states
-data FA n a b = FA !(Graph n a b) !n ![n]
-
-type NFA a = FA State () (Maybe a)
-
-type DFA a = FA State () a
-
-
-startState :: FA n a b -> n
-startState (FA _ s _) = s
-
-finalStates :: FA n a b -> [n]
-finalStates (FA _ _ ss) = ss
-
-states :: FA n a b -> [(n,a)]
-states (FA g _ _) = nodes g
-
-transitions :: FA n a b -> [(n,n,b)]
-transitions (FA g _ _) = edges g
-
-newFA :: Enum n => a -- ^ Start node label
- -> FA n a b
-newFA l = FA g s []
- where (g,s) = newNode l (newGraph [toEnum 0..])
-
--- | Create a new finite automaton with an initial and a final state.
-newFA_ :: Enum n => (FA n () b, n, n)
-newFA_ = (fa'', s, f)
- where fa = newFA ()
- s = startState fa
- (fa',f) = newState () fa
- fa'' = addFinalState f fa'
-
-addFinalState :: n -> FA n a b -> FA n a b
-addFinalState f (FA g s ss) = FA g s (f:ss)
-
-newState :: a -> FA n a b -> (FA n a b, n)
-newState x (FA g s ss) = (FA g' s ss, n)
- where (g',n) = newNode x g
-
-newStates :: [a] -> FA n a b -> (FA n a b, [(n,a)])
-newStates xs (FA g s ss) = (FA g' s ss, ns)
- where (g',ns) = newNodes xs g
-
-newTransition :: n -> n -> b -> FA n a b -> FA n a b
-newTransition f t l = onGraph (newEdge (f,t,l))
-
-newTransitions :: [(n, n, b)] -> FA n a b -> FA n a b
-newTransitions es = onGraph (newEdges es)
-
-insertTransitionWith :: Eq n =>
- (b -> b -> b) -> (n, n, b) -> FA n a b -> FA n a b
-insertTransitionWith f t = onGraph (insertEdgeWith f t)
-
-insertTransitionsWith :: Eq n =>
- (b -> b -> b) -> [(n, n, b)] -> FA n a b -> FA n a b
-insertTransitionsWith f ts fa =
- foldl' (flip (insertTransitionWith f)) fa ts
-
-mapStates :: (a -> c) -> FA n a b -> FA n c b
-mapStates f = onGraph (nmap f)
-
-mapTransitions :: (b -> c) -> FA n a b -> FA n a c
-mapTransitions f = onGraph (emap f)
-
-modifyTransitions :: ([(n,n,b)] -> [(n,n,b)]) -> FA n a b -> FA n a b
-modifyTransitions f = onGraph (\ (Graph r ns es) -> Graph r ns (f es))
-
-removeState :: Ord n => n -> FA n a b -> FA n a b
-removeState n = onGraph (removeNode n)
-
-minimize :: Ord a => NFA a -> DFA a
-minimize = determinize . reverseNFA . dfa2nfa . determinize . reverseNFA
-
-unusedNames :: FA n a b -> [n]
-unusedNames (FA (Graph names _ _) _ _) = names
-
--- | Gets all incoming transitions to a given state, excluding
--- transtions from the state itself.
-nonLoopTransitionsTo :: Eq n => n -> FA n a b -> [(n,b)]
-nonLoopTransitionsTo s fa =
- [(f,l) | (f,t,l) <- transitions fa, t == s && f /= s]
-
-nonLoopTransitionsFrom :: Eq n => n -> FA n a b -> [(n,b)]
-nonLoopTransitionsFrom s fa =
- [(t,l) | (f,t,l) <- transitions fa, f == s && t /= s]
-
-loops :: Eq n => n -> FA n a b -> [b]
-loops s fa = [l | (f,t,l) <- transitions fa, f == s && t == s]
-
--- | Give new names to all nodes.
-renameStates :: Ord x => [y] -- ^ Infinite supply of new names
- -> FA x a b
- -> FA y a b
-renameStates supply (FA g s fs) = FA (renameNodes newName rest g) s' fs'
- where (ns,rest) = splitAt (length (nodes g)) supply
- newNodes = Map.fromList (zip (map fst (nodes g)) ns)
- newName n = Map.findWithDefault (error "FiniteState.newName") n newNodes
- s' = newName s
- fs' = map newName fs
-
--- | Insert an NFA into another
-insertNFA :: NFA a -- ^ NFA to insert into
- -> (State, State) -- ^ States to insert between
- -> NFA a -- ^ NFA to insert.
- -> NFA a
-insertNFA (FA g1 s1 fs1) (f,t) (FA g2 s2 fs2)
- = FA (newEdges es g') s1 fs1
- where
- es = (f,ren s2,Nothing):[(ren f2,t,Nothing) | f2 <- fs2]
- (g',ren) = mergeGraphs g1 g2
-
-onGraph :: (Graph n a b -> Graph n c d) -> FA n a b -> FA n c d
-onGraph f (FA g s ss) = FA (f g) s ss
-
-
--- | Make the finite automaton have a single final state
--- by adding a new final state and adding an edge
--- from the old final states to the new state.
-oneFinalState :: a -- ^ Label to give the new node
- -> b -- ^ Label to give the new edges
- -> FA n a b -- ^ The old network
- -> FA n a b -- ^ The new network
-oneFinalState nl el fa =
- let (FA g s fs,nf) = newState nl fa
- es = [ (f,nf,el) | f <- fs ]
- in FA (newEdges es g) s [nf]
-
--- | Transform a standard finite automaton with labelled edges
--- to one where the labels are on the nodes instead. This can add
--- up to one extra node per edge.
-moveLabelsToNodes :: (Ord n,Eq a) => FA n () (Maybe a) -> FA n (Maybe a) ()
-moveLabelsToNodes = onGraph f
- where f g@(Graph c _ _) = Graph c' ns (concat ess)
- where is = [ ((n,l),inc) | (n, (l,inc,_)) <- Map.toList (nodeInfo g)]
- (c',is') = mapAccumL fixIncoming c is
- (ns,ess) = unzip (concat is')
-
-
--- | Remove empty nodes which are not start or final, and have
--- exactly one outgoing edge or exactly one incoming edge.
-removeTrivialEmptyNodes :: (Eq a, Ord n) => FA n (Maybe a) () -> FA n (Maybe a) ()
-removeTrivialEmptyNodes = pruneUnusable . skipSimpleEmptyNodes
-
--- | Move edges to empty nodes to point to the next node(s).
--- This is not done if the pointed-to node is a final node.
-skipSimpleEmptyNodes :: (Eq a, Ord n) => FA n (Maybe a) () -> FA n (Maybe a) ()
-skipSimpleEmptyNodes fa = onGraph og fa
- where
- og g@(Graph c ns es) = if es' == es then g else og (Graph c ns es')
- where
- es' = concatMap changeEdge es
- info = nodeInfo g
- changeEdge e@(f,t,())
- | isNothing (getNodeLabel info t)
- -- && (i * o <= i + o)
- && not (isFinal fa t)
- = [ (f,t',()) | (_,t',()) <- getOutgoing info t]
- | otherwise = [e]
--- where i = inDegree info t
--- o = outDegree info t
-
-isInternal :: Eq n => FA n a b -> n -> Bool
-isInternal (FA _ start final) n = n /= start && n `notElem` final
-
-isFinal :: Eq n => FA n a b -> n -> Bool
-isFinal (FA _ _ final) n = n `elem` final
-
--- | Remove all internal nodes with no incoming edges
--- or no outgoing edges.
-pruneUnusable :: Ord n => FA n (Maybe a) () -> FA n (Maybe a) ()
-pruneUnusable fa = onGraph f fa
- where
- f g = if Set.null rns then g else f (removeNodes rns g)
- where info = nodeInfo g
- rns = Set.fromList [ n | (n,_) <- nodes g,
- isInternal fa n,
- inDegree info n == 0
- || outDegree info n == 0]
-
-fixIncoming :: (Ord n, Eq a) => [n]
- -> (Node n (),[Edge n (Maybe a)]) -- ^ A node and its incoming edges
- -> ([n],[(Node n (Maybe a),[Edge n ()])]) -- ^ Replacement nodes with their
- -- incoming edges.
-fixIncoming cs c@((n,()),es) = (cs'', ((n,Nothing),es'):newContexts)
- where ls = nub $ map edgeLabel es
- (cs',cs'') = splitAt (length ls) cs
- newNodes = zip cs' ls
- es' = [ (x,n,()) | x <- map fst newNodes ]
- -- separate cyclic and non-cyclic edges
- (cyc,ncyc) = partition (\ (f,_,_) -> f == n) es
- -- keep all incoming non-cyclic edges with the right label
- to (x,l) = [ (f,x,()) | (f,_,l') <- ncyc, l == l']
- -- for each cyclic edge with the right label,
- -- add an edge from each of the new nodes (including this one)
- ++ [ (y,x,()) | (f,_,l') <- cyc, l == l', (y,_) <- newNodes]
- newContexts = [ (v, to v) | v <- newNodes ]
-
-alphabet :: Eq b => Graph n a (Maybe b) -> [b]
-alphabet = nub . catMaybes . map edgeLabel . edges
-
-determinize :: Ord a => NFA a -> DFA a
-determinize (FA g s f) = let (ns,es) = h (Set.singleton start) Set.empty Set.empty
- (ns',es') = (Set.toList ns, Set.toList es)
- final = filter isDFAFinal ns'
- fa = FA (Graph undefined [(n,()) | n <- ns'] es') start final
- in renameStates [0..] fa
- where info = nodeInfo g
--- reach = nodesReachable out
- start = closure info $ Set.singleton s
- isDFAFinal n = not (Set.null (Set.fromList f `Set.intersection` n))
- h currentStates oldStates es
- | Set.null currentStates = (oldStates,es)
- | otherwise = ((h $! uniqueNewStates) $! allOldStates) $! es'
- where
- allOldStates = oldStates `Set.union` currentStates
- (newStates,es') = new (Set.toList currentStates) Set.empty es
- uniqueNewStates = newStates Set.\\ allOldStates
- -- Get the sets of states reachable from the given states
- -- by consuming one symbol, and the associated edges.
- new [] rs es = (rs,es)
- new (n:ns) rs es = new ns rs' es'
- where cs = reachable info n --reachable reach n
- rs' = rs `Set.union` Set.fromList (map snd cs)
- es' = es `Set.union` Set.fromList [(n,s,c) | (c,s) <- cs]
-
-
--- | Get all the nodes reachable from a list of nodes by only empty edges.
-closure :: Ord n => NodeInfo n a (Maybe b) -> Set n -> Set n
-closure info x = closure_ x x
- where closure_ acc check | Set.null check = acc
- | otherwise = closure_ acc' check'
- where
- reach = Set.fromList [y | x <- Set.toList check,
- (_,y,Nothing) <- getOutgoing info x]
- acc' = acc `Set.union` reach
- check' = reach Set.\\ acc
-
--- | Get a map of labels to sets of all nodes reachable
--- from a the set of nodes by one edge with the given
--- label and then any number of empty edges.
-reachable :: (Ord n,Ord b) => NodeInfo n a (Maybe b) -> Set n -> [(b,Set n)]
-reachable info ns = Map.toList $ Map.map (closure info . Set.fromList) $ reachable1 info ns
-reachable1 info ns = Map.fromListWith (++) [(c, [y]) | n <- Set.toList ns, (_,y,Just c) <- getOutgoing info n]
-
-reverseNFA :: NFA a -> NFA a
-reverseNFA (FA g s fs) = FA g''' s' [s]
- where g' = reverseGraph g
- (g'',s') = newNode () g'
- g''' = newEdges [(s',f,Nothing) | f <- fs] g''
-
-dfa2nfa :: DFA a -> NFA a
-dfa2nfa = mapTransitions Just
-
---
--- * Visualization
---
-
-prFAGraphviz :: (Eq n,Show n) => FA n String String -> String
-prFAGraphviz = Dot.prGraphviz . faToGraphviz
-
-prFAGraphviz_ :: (Eq n,Show n,Show a, Show b) => FA n a b -> String
-prFAGraphviz_ = Dot.prGraphviz . faToGraphviz . mapStates show . mapTransitions show
-
-faToGraphviz :: (Eq n,Show n) => FA n String String -> Dot.Graph
-faToGraphviz (FA (Graph _ ns es) s f)
- = Dot.Graph Dot.Directed Nothing [] (map mkNode ns) (map mkEdge es) []
- where mkNode (n,l) = Dot.Node (show n) attrs
- where attrs = [("label",l)]
- ++ if n == s then [("shape","box")] else []
- ++ if n `elem` f then [("style","bold")] else []
- mkEdge (x,y,l) = Dot.Edge (show x) (show y) [("label",l)]
-
---
--- * Utilities
---
-
-lookups :: Ord k => [k] -> Map k a -> [a]
-lookups xs m = mapMaybe (flip Map.lookup m) xs
diff --git a/src/GF/Speech/GrammarToVoiceXML.hs b/src/GF/Speech/GrammarToVoiceXML.hs
deleted file mode 100644
index ad7f25d1c..000000000
--- a/src/GF/Speech/GrammarToVoiceXML.hs
+++ /dev/null
@@ -1,285 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GrammarToVoiceXML
--- Maintainer : Bjorn Bringert
--- Stability : (stable)
--- Portability : (portable)
---
--- Create VoiceXML dialogue system from a GF grammar.
------------------------------------------------------------------------------
-
-module GF.Speech.GrammarToVoiceXML (grammar2vxml) where
-
-import GF.Canon.CanonToGFCC (canon2gfcc)
-import qualified GF.GFCC.CId as C
-import GF.GFCC.DataGFCC (GFCC(..), Abstr(..))
-import GF.GFCC.Macros
-import qualified GF.Canon.GFC as GFC
-import GF.Canon.AbsGFC (Term)
-import GF.Canon.PrintGFC (printTree)
-import GF.Canon.CMacros (noMark, strsFromTerm)
-import GF.Canon.Unlex (formatAsText)
-import GF.Data.Utilities
-import GF.CF.CFIdent (cfCat2Ident)
-import GF.Compile.ShellState (StateGrammar,stateGrammarST,cncId,grammar,
- startCatStateOpts,stateOptions)
-import GF.Data.Str (sstrV)
-import GF.Grammar.Macros hiding (assign,strsFromTerm)
-import GF.Grammar.Grammar (Fun)
-import GF.Grammar.Values (Tree)
-import GF.Infra.Option (Options, addOptions, getOptVal, speechLanguage)
-import GF.UseGrammar.GetTree (string2treeErr)
-import GF.UseGrammar.Linear (linTree2strings)
-
-import GF.Infra.Ident
-import GF.Infra.Option (noOptions)
-import GF.Infra.Modules
-import GF.Data.Operations
-
-import GF.Data.XML
-
-import Control.Monad (liftM)
-import Data.List (isPrefixOf, find, intersperse)
-import qualified Data.Map as Map
-import Data.Maybe (fromMaybe)
-
-import Debug.Trace
-
--- | the main function
-grammar2vxml :: Options -> StateGrammar -> String
-grammar2vxml opt s = showsXMLDoc (skel2vxml name language startcat gr' qs) ""
- where (_, gr') = vSkeleton (stateGrammarST s)
- name = prIdent (cncId s)
- qs = catQuestions s (map fst gr')
- opts = addOptions opt (stateOptions s)
- language = fmap (replace '_' '-') $ getOptVal opts speechLanguage
- startcat = C.CId $ prIdent $ cfCat2Ident $ startCatStateOpts opts s
-
---
--- * VSkeleton: a simple description of the abstract syntax.
---
-
-type VSkeleton = [(VIdent, [(VIdent, [VIdent])])]
-type VIdent = C.CId
-
-prid :: VIdent -> String
-prid (C.CId x) = x
-
-vSkeleton :: GFC.CanonGrammar -> (VIdent,VSkeleton)
-vSkeleton = gfccSkeleton . canon2gfcc noOptions
-
-gfccSkeleton :: GFCC -> (VIdent,VSkeleton)
-gfccSkeleton gfcc = (absname gfcc, ts)
- where a = abstract gfcc
- ts = [(c,[(f,ft f) | f <- fs]) | (c,fs) <- Map.toList (catfuns a)]
- ft f = case lookMap (error $ prid f) f (funs a) of
- (ty,_) -> fst $ GF.GFCC.Macros.catSkeleton ty
-
---
--- * Questions to ask
---
-
-type CatQuestions = [(VIdent,String)]
-
-catQuestions :: StateGrammar -> [VIdent] -> CatQuestions
-catQuestions gr cats = [(c,catQuestion gr c) | c <- cats]
-
-catQuestion :: StateGrammar -> VIdent -> String
-catQuestion gr cat = err errHandler id (getPrintname gr cat >>= term2string)
- where -- FIXME: use some better warning facility
- errHandler e = trace ("GrammarToVoiceXML: " ++ e) ("quest_"++prid cat)
- term2string = liftM sstrV . strsFromTerm
-
-getPrintname :: StateGrammar -> VIdent -> Err Term
-getPrintname gr cat =
- do m <- lookupModMod (grammar gr) (cncId gr)
- i <- lookupInfo m (IC (prid cat))
- case i of
- GFC.CncCat _ _ p -> return p
- _ -> fail $ "getPrintname " ++ prid cat
- ++ ": Expected CncCat, got " ++ show i
-
-
-{-
-lin :: StateGrammar -> String -> Err String
-lin gr fun = do
- tree <- string2treeErr gr fun
- let ls = map unt $ linTree2strings noMark g c tree
- case ls of
- [] -> fail $ "No linearization of " ++ fun
- l:_ -> return l
- where c = cncId gr
- g = stateGrammarST gr
- unt = formatAsText
--}
-
-getCatQuestion :: VIdent -> CatQuestions -> String
-getCatQuestion c qs =
- fromMaybe (error "No question for category " ++ prid c) (lookup c qs)
-
---
--- * Generate VoiceXML
---
-
-skel2vxml :: String -> Maybe String -> VIdent -> VSkeleton -> CatQuestions -> XML
-skel2vxml name language start skel qs =
- vxml language ([startForm] ++ concatMap (uncurry (catForms gr qs)) skel)
- where
- gr = grammarURI name
- startForm = Tag "form" [] [subdialog "sub" [("src", "#"++catFormId start)]
- [param "old" "{ name : '?' }"]]
-
-grammarURI :: String -> String
-grammarURI name = name ++ ".grxml"
-
-
-catForms :: String -> CatQuestions -> VIdent -> [(VIdent, [VIdent])] -> [XML]
-catForms gr qs cat fs =
- comments [prid cat ++ " category."]
- ++ [cat2form gr qs cat fs]
-
-cat2form :: String -> CatQuestions -> VIdent -> [(VIdent, [VIdent])] -> XML
-cat2form gr qs cat fs =
- form (catFormId cat) $
- [var "old" Nothing,
- blockCond "old.name != '?'" [assign "term" "old"],
- field "term" []
- [promptString (getCatQuestion cat qs),
- vxmlGrammar (gr++"#"++catFormId cat)
- ]
- ]
- ++ concatMap (uncurry (fun2sub gr cat)) fs
- ++ [block [return_ ["term"]{-]-}]]
-
-fun2sub :: String -> VIdent -> VIdent -> [VIdent] -> [XML]
-fun2sub gr cat fun args =
- comments [prid fun ++ " : ("
- ++ concat (intersperse ", " (map prid args))
- ++ ") " ++ prid cat] ++ ss
- where
- ss = zipWith mkSub [0..] args
- mkSub n t = subdialog s [("src","#"++catFormId t),
- ("cond","term.name == "++string (prid fun))]
- [param "old" v,
- filled [] [assign v (s++".term")]]
- where s = prid fun ++ "_" ++ show n
- v = "term.args["++show n++"]"
-
-catFormId :: VIdent -> String
-catFormId c = prid c ++ "_cat"
-
-
---
--- * VoiceXML stuff
---
-
-vxml :: Maybe String -> [XML] -> XML
-vxml ml = Tag "vxml" $ [("version","2.0"),
- ("xmlns","http://www.w3.org/2001/vxml")]
- ++ maybe [] (\l -> [("xml:lang", l)]) ml
-
-form :: String -> [XML] -> XML
-form id xs = Tag "form" [("id", id)] xs
-
-field :: String -> [(String,String)] -> [XML] -> XML
-field name attrs = Tag "field" ([("name",name)]++attrs)
-
-subdialog :: String -> [(String,String)] -> [XML] -> XML
-subdialog name attrs = Tag "subdialog" ([("name",name)]++attrs)
-
-filled :: [(String,String)] -> [XML] -> XML
-filled = Tag "filled"
-
-vxmlGrammar :: String -> XML
-vxmlGrammar uri = ETag "grammar" [("src",uri)]
-
-prompt :: [XML] -> XML
-prompt = Tag "prompt" []
-
-promptString :: String -> XML
-promptString p = prompt [Data p]
-
-reprompt :: XML
-reprompt = ETag "reprompt" []
-
-assign :: String -> String -> XML
-assign n e = ETag "assign" [("name",n),("expr",e)]
-
-value :: String -> XML
-value expr = ETag "value" [("expr",expr)]
-
-if_ :: String -> [XML] -> XML
-if_ c b = if_else c b []
-
-if_else :: String -> [XML] -> [XML] -> XML
-if_else c t f = cond [(c,t)] f
-
-cond :: [(String,[XML])] -> [XML] -> XML
-cond ((c,b):rest) els = Tag "if" [("cond",c)] (b ++ es)
- where es = [Tag "elseif" [("cond",c')] b' | (c',b') <- rest]
- ++ if null els then [] else (Tag "else" [] []:els)
-
-goto_item :: String -> XML
-goto_item nextitem = ETag "goto" [("nextitem",nextitem)]
-
-return_ :: [String] -> XML
-return_ names = ETag "return" [("namelist", unwords names)]
-
-block :: [XML] -> XML
-block = Tag "block" []
-
-blockCond :: String -> [XML] -> XML
-blockCond cond = Tag "block" [("cond", cond)]
-
-throw :: String -> String -> XML
-throw event msg = Tag "throw" [("event",event),("message",msg)] []
-
-nomatch :: [XML] -> XML
-nomatch = Tag "nomatch" []
-
-help :: [XML] -> XML
-help = Tag "help" []
-
-param :: String -> String -> XML
-param name expr = ETag "param" [("name",name),("expr",expr)]
-
-var :: String -> Maybe String -> XML
-var name expr = ETag "var" ([("name",name)]++e)
- where e = maybe [] ((:[]) . (,) "expr") expr
-
-script :: String -> XML
-script s = Tag "script" [] [CData s]
-
-scriptURI :: String -> XML
-scriptURI uri = Tag "script" [("uri", uri)] []
-
---
--- * ECMAScript stuff
---
-
-string :: String -> String
-string s = "'" ++ concatMap esc s ++ "'"
- where esc '\'' = "\\'"
- esc c = [c]
-
-{-
---
--- * List stuff
---
-
-isListCat :: (VIdent, [(VIdent, [VIdent])]) -> Bool
-isListCat (cat,rules) = "List" `isPrefixOf` prIdent cat && length rules == 2
- && ("Base"++c) `elem` fs && ("Cons"++c) `elem` fs
- where c = drop 4 (prIdent cat)
- fs = map (prIdent . fst) rules
-
-isBaseFun :: VIdent -> Bool
-isBaseFun f = "Base" `isPrefixOf` prIdent f
-
-isConsFun :: VIdent -> Bool
-isConsFun f = "Cons" `isPrefixOf` prIdent f
-
-baseSize :: (VIdent, [(VIdent, [VIdent])]) -> Int
-baseSize (_,rules) = length bs
- where Just (_,bs) = find (isBaseFun . fst) rules
--}
diff --git a/src/GF/Speech/Graph.hs b/src/GF/Speech/Graph.hs
deleted file mode 100644
index 1a0ebe0c0..000000000
--- a/src/GF/Speech/Graph.hs
+++ /dev/null
@@ -1,178 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Graph
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/10 16:43:44 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- A simple graph module.
------------------------------------------------------------------------------
-module GF.Speech.Graph ( Graph(..), Node, Edge, NodeInfo
- , newGraph, nodes, edges
- , nmap, emap, newNode, newNodes, newEdge, newEdges
- , insertEdgeWith
- , removeNode, removeNodes
- , nodeInfo
- , getIncoming, getOutgoing, getNodeLabel
- , inDegree, outDegree
- , nodeLabel
- , edgeFrom, edgeTo, edgeLabel
- , reverseGraph, mergeGraphs, renameNodes
- ) where
-
-import GF.Data.Utilities
-
-import Data.List
-import Data.Maybe
-import Data.Map (Map)
-import qualified Data.Map as Map
-import Data.Set (Set)
-import qualified Data.Set as Set
-
-data Graph n a b = Graph [n] ![Node n a] ![Edge n b]
- deriving (Eq,Show)
-
-type Node n a = (n,a)
-type Edge n b = (n,n,b)
-
-type NodeInfo n a b = Map n (a, [Edge n b], [Edge n b])
-
--- | Create a new empty graph.
-newGraph :: [n] -> Graph n a b
-newGraph ns = Graph ns [] []
-
--- | Get all the nodes in the graph.
-nodes :: Graph n a b -> [Node n a]
-nodes (Graph _ ns _) = ns
-
--- | Get all the edges in the graph.
-edges :: Graph n a b -> [Edge n b]
-edges (Graph _ _ es) = es
-
--- | Map a function over the node labels.
-nmap :: (a -> c) -> Graph n a b -> Graph n c b
-nmap f (Graph c ns es) = Graph c [(n,f l) | (n,l) <- ns] es
-
--- | Map a function over the edge labels.
-emap :: (b -> c) -> Graph n a b -> Graph n a c
-emap f (Graph c ns es) = Graph c ns [(x,y,f l) | (x,y,l) <- es]
-
--- | Add a node to the graph.
-newNode :: a -- ^ Node label
- -> Graph n a b
- -> (Graph n a b,n) -- ^ Node graph and name of new node
-newNode l (Graph (c:cs) ns es) = (Graph cs ((c,l):ns) es, c)
-
-newNodes :: [a] -> Graph n a b -> (Graph n a b,[Node n a])
-newNodes ls g = (g', zip ns ls)
- where (g',ns) = mapAccumL (flip newNode) g ls
--- lazy version:
---newNodes ls (Graph cs ns es) = (Graph cs' (ns'++ns) es, ns')
--- where (xs,cs') = splitAt (length ls) cs
--- ns' = zip xs ls
-
-newEdge :: Edge n b -> Graph n a b -> Graph n a b
-newEdge e (Graph c ns es) = Graph c ns (e:es)
-
-newEdges :: [Edge n b] -> Graph n a b -> Graph n a b
-newEdges es g = foldl' (flip newEdge) g es
--- lazy version:
--- newEdges es' (Graph c ns es) = Graph c ns (es'++es)
-
-insertEdgeWith :: Eq n =>
- (b -> b -> b) -> Edge n b -> Graph n a b -> Graph n a b
-insertEdgeWith f e@(x,y,l) (Graph c ns es) = Graph c ns (h es)
- where h [] = [e]
- h (e'@(x',y',l'):es') | x' == x && y' == y = (x',y', f l l'):es'
- | otherwise = e':h es'
-
--- | Remove a node and all edges to and from that node.
-removeNode :: Ord n => n -> Graph n a b -> Graph n a b
-removeNode n = removeNodes (Set.singleton n)
-
--- | Remove a set of nodes and all edges to and from those nodes.
-removeNodes :: Ord n => Set n -> Graph n a b -> Graph n a b
-removeNodes xs (Graph c ns es) = Graph c ns' es'
- where
- keepNode n = not (Set.member n xs)
- ns' = [ x | x@(n,_) <- ns, keepNode n ]
- es' = [ e | e@(f,t,_) <- es, keepNode f && keepNode t ]
-
--- | Get a map of node names to info about each node.
-nodeInfo :: Ord n => Graph n a b -> NodeInfo n a b
-nodeInfo g = Map.fromList [ (n, (x, fn inc n, fn out n)) | (n,x) <- nodes g ]
- where
- inc = groupEdgesBy edgeTo g
- out = groupEdgesBy edgeFrom g
- fn m n = fromMaybe [] (Map.lookup n m)
-
-groupEdgesBy :: (Ord n) => (Edge n b -> n) -- ^ Gets the node to group by
- -> Graph n a b -> Map n [Edge n b]
-groupEdgesBy f g = Map.fromListWith (++) [(f e, [e]) | e <- edges g]
-
-lookupNode :: Ord n => NodeInfo n a b -> n -> (a, [Edge n b], [Edge n b])
-lookupNode i n = fromJust $ Map.lookup n i
-
-getIncoming :: Ord n => NodeInfo n a b -> n -> [Edge n b]
-getIncoming i n = let (_,inc,_) = lookupNode i n in inc
-
-getOutgoing :: Ord n => NodeInfo n a b -> n -> [Edge n b]
-getOutgoing i n = let (_,_,out) = lookupNode i n in out
-
-inDegree :: Ord n => NodeInfo n a b -> n -> Int
-inDegree i n = length $ getIncoming i n
-
-outDegree :: Ord n => NodeInfo n a b -> n -> Int
-outDegree i n = length $ getOutgoing i n
-
-getNodeLabel :: Ord n => NodeInfo n a b -> n -> a
-getNodeLabel i n = let (l,_,_) = lookupNode i n in l
-
-nodeLabel :: Node n a -> a
-nodeLabel = snd
-
-edgeFrom :: Edge n b -> n
-edgeFrom (f,_,_) = f
-
-edgeTo :: Edge n b -> n
-edgeTo (_,t,_) = t
-
-edgeLabel :: Edge n b -> b
-edgeLabel (_,_,l) = l
-
-reverseGraph :: Graph n a b -> Graph n a b
-reverseGraph (Graph c ns es) = Graph c ns [ (t,f,l) | (f,t,l) <- es ]
-
--- | Add the nodes from the second graph to the first graph.
--- The nodes in the second graph will be renamed using the name
--- supply in the first graph.
--- This function is more efficient when the second graph
--- is smaller than the first.
-mergeGraphs :: Ord m => Graph n a b -> Graph m a b
- -> (Graph n a b, m -> n) -- ^ The new graph and a function translating
- -- the old names of nodes in the second graph
- -- to names in the new graph.
-mergeGraphs (Graph c ns1 es1) g2 = (Graph c' (ns2++ns1) (es2++es1), newName)
- where
- (xs,c') = splitAt (length (nodes g2)) c
- newNames = Map.fromList (zip (map fst (nodes g2)) xs)
- newName n = fromJust $ Map.lookup n newNames
- Graph _ ns2 es2 = renameNodes newName undefined g2
-
--- | Rename the nodes in the graph.
-renameNodes :: (n -> m) -- ^ renaming function
- -> [m] -- ^ infinite supply of fresh node names, to
- -- use when adding nodes in the future.
- -> Graph n a b -> Graph m a b
-renameNodes newName c (Graph _ ns es) = Graph c ns' es'
- where ns' = map' (\ (n,x) -> (newName n,x)) ns
- es' = map' (\ (f,t,l) -> (newName f, newName t, l)) es
-
--- | A strict 'map'
-map' :: (a -> b) -> [a] -> [b]
-map' _ [] = []
-map' f (x:xs) = ((:) $! f x) $! map' f xs
diff --git a/src/GF/Speech/PrFA.hs b/src/GF/Speech/PrFA.hs
deleted file mode 100644
index 2856039ec..000000000
--- a/src/GF/Speech/PrFA.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrSLF
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/10 16:43:44 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- This module prints finite automata and regular grammars
--- for a context-free grammar.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
------------------------------------------------------------------------------
-
-module GF.Speech.PrFA (faGraphvizPrinter,regularPrinter,faCPrinter) where
-
-import GF.Data.Utilities
-import GF.Conversion.Types
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..),symbol)
-import GF.Infra.Ident
-import GF.Infra.Option (Options)
-import GF.Infra.Print
-import GF.Speech.CFGToFiniteState
-import GF.Speech.FiniteState
-import GF.Speech.TransformCFG
-import GF.Compile.ShellState (StateGrammar)
-
-import Data.Char (toUpper,toLower)
-import Data.List
-import Data.Maybe (fromMaybe)
-
-
-
-faGraphvizPrinter :: Options -> StateGrammar -> String
-faGraphvizPrinter opts s =
- prFAGraphviz $ mapStates (const "") $ cfgToFA opts s
-
--- | Convert the grammar to a regular grammar and print it in BNF
-regularPrinter :: Options -> StateGrammar -> String
-regularPrinter opts s = prCFRules $ makeSimpleRegular opts s
- where
- prCFRules :: CFRules -> String
- prCFRules g = unlines [ c ++ " ::= " ++ join " | " (map (showRhs . ruleRhs) rs) | (c,rs) <- allRulesGrouped g]
- join g = concat . intersperse g
- showRhs = unwords . map (symbol id show)
-
-faCPrinter :: Options -> StateGrammar -> String
-faCPrinter opts s = fa2c $ cfgToFA opts s
-
-fa2c :: DFA String -> String
-fa2c fa = undefined
diff --git a/src/GF/Speech/PrGSL.hs b/src/GF/Speech/PrGSL.hs
deleted file mode 100644
index 248991380..000000000
--- a/src/GF/Speech/PrGSL.hs
+++ /dev/null
@@ -1,113 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrGSL
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/01 20:09:04 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.22 $
---
--- This module prints a CFG as a Nuance GSL 2.0 grammar.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
------------------------------------------------------------------------------
-
-module GF.Speech.PrGSL (gslPrinter) where
-
-import GF.Data.Utilities
-import GF.Speech.SRG
-import GF.Speech.RegExp
-import GF.Infra.Ident
-
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..))
-import GF.Conversion.Types
-import GF.Infra.Print
-import GF.Infra.Option
-import GF.Probabilistic.Probabilistic (Probs)
-import GF.Compile.ShellState (StateGrammar)
-
-import Data.Char (toUpper,toLower)
-import Data.List (partition)
-import Text.PrettyPrint.HughesPJ
-
-width :: Int
-width = 75
-
-gslPrinter :: Options -> StateGrammar -> String
-gslPrinter opts s = renderStyle st $ prGSL $ makeSimpleSRG opts s
- where st = style { lineLength = width }
-
-prGSL :: SRG -> Doc
-prGSL (SRG{grammarName=name,startCat=start,origStartCat=origStart,rules=rs})
- = header $++$ mainCat $++$ foldr ($++$) empty (map prRule rs)
- where
- header = text ";GSL2.0" $$
- comment ("Nuance speech recognition grammar for " ++ name) $$
- comment ("Generated by GF")
- mainCat = comment ("Start category: " ++ origStart) $$
- text ".MAIN" <+> prCat start
- prRule (SRGRule cat origCat rhs) =
- comment (prt origCat) $$
- prCat cat <+> union (map prAlt rhs)
- -- FIXME: use the probability
- prAlt (SRGAlt mp _ rhs) = prItem rhs
-
-
-prItem :: SRGItem -> Doc
-prItem = f
- where
- f (REUnion xs) = (if null es then empty else text "?") <> union (map f nes)
- where (es,nes) = partition isEpsilon xs
- f (REConcat [x]) = f x
- f (REConcat xs) = text "(" <> fsep (map f xs) <> text ")"
- f (RERepeat x) = text "*" <> f x
- f (RESymbol s) = prSymbol s
-
-union :: [Doc] -> Doc
-union [x] = x
-union xs = text "[" <> fsep xs <> text "]"
-
-prSymbol :: Symbol SRGNT Token -> Doc
-prSymbol (Cat (c,_)) = prCat c
-prSymbol (Tok t) = doubleQuotes (showToken t)
-
--- GSL requires an upper case letter in category names
-prCat :: SRGCat -> Doc
-prCat c = text (firstToUpper c)
-
-
-firstToUpper :: String -> String
-firstToUpper [] = []
-firstToUpper (x:xs) = toUpper x : xs
-
-{-
-rmPunctCFG :: CGrammar -> CGrammar
-rmPunctCFG g = [CFRule c (filter keepSymbol ss) n | CFRule c ss n <- g]
-
-keepSymbol :: Symbol c Token -> Bool
-keepSymbol (Tok t) = not (all isPunct (prt t))
-keepSymbol _ = True
--}
-
--- Nuance does not like upper case characters in tokens
-showToken :: Token -> Doc
-showToken t = text (map toLower (prt t))
-
-isPunct :: Char -> Bool
-isPunct c = c `elem` "-_.:;.,?!()[]{}"
-
-comment :: String -> Doc
-comment s = text ";" <+> text s
-
-
--- Pretty-printing utilities
-
-emptyLine :: Doc
-emptyLine = text ""
-
-($++$) :: Doc -> Doc -> Doc
-x $++$ y = x $$ emptyLine $$ y
diff --git a/src/GF/Speech/PrJSGF.hs b/src/GF/Speech/PrJSGF.hs
deleted file mode 100644
index 037a4f4e2..000000000
--- a/src/GF/Speech/PrJSGF.hs
+++ /dev/null
@@ -1,145 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrJSGF
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/01 20:09:04 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.16 $
---
--- This module prints a CFG as a JSGF grammar.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
---
--- FIXME: convert to UTF-8
------------------------------------------------------------------------------
-
-module GF.Speech.PrJSGF (jsgfPrinter) where
-
-import GF.Conversion.Types
-import GF.Data.Utilities
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), NameProfile(..), Profile(..), filterCats)
-import GF.Infra.Ident
-import GF.Infra.Print
-import GF.Infra.Option
-import GF.Probabilistic.Probabilistic (Probs)
-import GF.Speech.SISR
-import GF.Speech.SRG
-import GF.Speech.RegExp
-import GF.Compile.ShellState (StateGrammar)
-
-import Data.Char
-import Data.List
-import Data.Maybe
-import Text.PrettyPrint.HughesPJ
-import Debug.Trace
-
-width :: Int
-width = 75
-
-jsgfPrinter :: Maybe SISRFormat
- -> Options
- -> StateGrammar -> String
-jsgfPrinter sisr opts s = renderStyle st $ prJSGF sisr $ makeSimpleSRG opts s
- where st = style { lineLength = width }
-
-prJSGF :: Maybe SISRFormat -> SRG -> Doc
-prJSGF sisr srg@(SRG{grammarName=name,grammarLanguage=ml,
- startCat=start,origStartCat=origStart,rules=rs})
- = header $++$ mainCat $++$ vcat topCatRules $++$ foldr ($++$) empty (map prRule rs)
- where
- header = text "#JSGF" <+> text "V1.0" <+> text "UTF-8" <+> lang <> char ';' $$
- comment ("JSGF speech recognition grammar for " ++ name) $$
- comment "Generated by GF" $$
- text ("grammar " ++ name ++ ";")
- lang = maybe empty text ml
- mainCat = comment ("Start category: " ++ origStart) $$
- case cfgCatToGFCat origStart of
- Just c -> rule True "MAIN" [prCat (catFormId c)]
- Nothing -> empty
- prRule (SRGRule cat origCat rhs) =
- comment origCat $$
- rule False cat (map prAlt rhs)
--- rule False cat (map prAlt rhs)
- -- FIXME: use the probability
- prAlt (SRGAlt mp n rhs) = sep [initTag, p (prItem sisr n rhs), finalTag]
--- prAlt (SRGAlt mp n rhs) = initTag <+> prItem sisr n rhs <+> finalTag
- where initTag | isEmpty t = empty
- | otherwise = text "" <+> t
- where t = tag sisr (profileInitSISR n)
- finalTag = tag sisr (profileFinalSISR n)
- p = if isEmpty initTag && isEmpty finalTag then id else parens
-
- topCatRules = [rule True (catFormId tc) (map (it tc) cs) | (tc,cs) <- srgTopCats srg]
- where it i c = prCat c <+> tag sisr (topCatSISR c)
-
-catFormId :: String -> String
-catFormId = (++ "_cat")
-
-prCat :: SRGCat -> Doc
-prCat c = char '<' <> text c <> char '>'
-
-prItem :: Maybe SISRFormat -> CFTerm -> SRGItem -> Doc
-prItem sisr t = f 0
- where
- f _ (REUnion []) = text ""
- f p (REUnion xs)
- | not (null es) = brackets (f 0 (REUnion nes))
- | otherwise = (if p >= 1 then parens else id) (alts (map (f 1) xs))
- where (es,nes) = partition isEpsilon xs
- f _ (REConcat []) = text ""
- f p (REConcat xs) = (if p >= 3 then parens else id) (fsep (map (f 2) xs))
- f p (RERepeat x) = f 3 x <> char '*'
- f _ (RESymbol s) = prSymbol sisr t s
-
-{-
-prItem :: Maybe SISRFormat -> CFTerm -> [Symbol SRGNT Token] -> Doc
-prItem _ _ [] = text ""
-prItem sisr cn ss = paren $ hsep $ map (prSymbol sisr cn) ss
- where paren = if length ss == 1 then id else parens
--}
-
-prSymbol :: Maybe SISRFormat -> CFTerm -> Symbol SRGNT Token -> Doc
-prSymbol sisr cn (Cat n@(c,_)) = prCat c <+> tag sisr (catSISR cn n)
-prSymbol _ cn (Tok t) | all isPunct (prt t) = empty -- removes punctuation
- | otherwise = text (prt t) -- FIXME: quote if there is whitespace or odd chars
-
-tag :: Maybe SISRFormat -> (SISRFormat -> SISRTag) -> Doc
-tag Nothing _ = empty
-tag (Just fmt) t = case t fmt of
- [] -> empty
- ts -> char '{' <+> (text (e $ prSISR ts)) <+> char '}'
- where e [] = []
- e ('}':xs) = '\\':'}':e xs
- e ('\n':xs) = ' ' : e (dropWhile isSpace xs)
- e (x:xs) = x:e xs
-
-isPunct :: Char -> Bool
-isPunct c = c `elem` "-_.;.,?!"
-
-comment :: String -> Doc
-comment s = text "//" <+> text s
-
-alts :: [Doc] -> Doc
-alts = fsep . prepunctuate (text "| ")
-
-rule :: Bool -> SRGCat -> [Doc] -> Doc
-rule pub c xs = p <+> prCat c <+> char '=' <+> nest 2 (alts xs) <+> char ';'
- where p = if pub then text "public" else empty
-
--- Pretty-printing utilities
-
-emptyLine :: Doc
-emptyLine = text ""
-
-prepunctuate :: Doc -> [Doc] -> [Doc]
-prepunctuate _ [] = []
-prepunctuate p (x:xs) = x : map (p <>) xs
-
-($++$) :: Doc -> Doc -> Doc
-x $++$ y = x $$ emptyLine $$ y
-
diff --git a/src/GF/Speech/PrRegExp.hs b/src/GF/Speech/PrRegExp.hs
deleted file mode 100644
index 55a25d69b..000000000
--- a/src/GF/Speech/PrRegExp.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrSLF
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- This module prints a grammar as a regular expression.
------------------------------------------------------------------------------
-
-module GF.Speech.PrRegExp (regexpPrinter,multiRegexpPrinter) where
-
-import GF.Conversion.Types
-import GF.Formalism.Utilities
-import GF.Infra.Ident
-import GF.Infra.Option (Options)
-import GF.Speech.CFGToFiniteState
-import GF.Speech.RegExp
-import GF.Compile.ShellState (StateGrammar)
-
-
-regexpPrinter :: Options -> StateGrammar -> String
-regexpPrinter opts s = (++"\n") $ prRE $ dfa2re $ cfgToFA opts s
-
-multiRegexpPrinter :: Options -> StateGrammar -> String
-multiRegexpPrinter opts s = prREs $ mfa2res $ cfgToMFA opts s
-
-prREs :: [(String,RE (MFALabel String))] -> String
-prREs res = unlines [l ++ " = " ++ prRE (mapRE showLabel re) | (l,re) <- res]
- where showLabel = symbol (\l -> "<" ++ l ++ ">") id
-
-mfa2res :: MFA String -> [(String,RE (MFALabel String))]
-mfa2res (MFA _ dfas) = [(l, minimizeRE (dfa2re dfa)) | (l,dfa) <- dfas]
diff --git a/src/GF/Speech/PrSLF.hs b/src/GF/Speech/PrSLF.hs
deleted file mode 100644
index 9bc025558..000000000
--- a/src/GF/Speech/PrSLF.hs
+++ /dev/null
@@ -1,190 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrSLF
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/10 16:43:44 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.12 $
---
--- This module converts a CFG to an SLF finite-state network
--- for use with the ATK recognizer. The SLF format is described
--- in the HTK manual, and an example for use in ATK is shown
--- in the ATK manual.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
------------------------------------------------------------------------------
-
-module GF.Speech.PrSLF (slfPrinter,slfGraphvizPrinter,
- slfSubPrinter,slfSubGraphvizPrinter) where
-
-import GF.Data.Utilities
-import GF.Conversion.Types
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..),symbol,mapSymbol)
-import GF.Infra.Ident
-import GF.Infra.Option (Options)
-import GF.Infra.Print
-import GF.Speech.CFGToFiniteState
-import GF.Speech.FiniteState
-import GF.Speech.TransformCFG
-import qualified GF.Visualization.Graphviz as Dot
-import GF.Compile.ShellState (StateGrammar)
-
-import Control.Monad
-import qualified Control.Monad.State as STM
-import Data.Char (toUpper)
-import Data.List
-import Data.Maybe
-
-data SLFs = SLFs [(String,SLF)] SLF
-
-data SLF = SLF { slfNodes :: [SLFNode], slfEdges :: [SLFEdge] }
-
-data SLFNode = SLFNode { nId :: Int, nWord :: SLFWord, nTag :: Maybe String }
- | SLFSubLat { nId :: Int, nLat :: String }
-
--- | An SLF word is a word, or the empty string.
-type SLFWord = Maybe String
-
-data SLFEdge = SLFEdge { eId :: Int, eStart :: Int, eEnd :: Int }
-
-type SLF_FA = FA State (Maybe (MFALabel String)) ()
-
-mkFAs :: Options -> StateGrammar -> (SLF_FA, [(String,SLF_FA)])
-mkFAs opts s = (slfStyleFA main, [(c,slfStyleFA n) | (c,n) <- subs])
- where MFA start subs = {- renameSubs $ -} cfgToMFA opts s
- main = let (fa,s,f) = newFA_ in newTransition s f (Cat start) fa
-
-slfStyleFA :: Eq a => DFA a -> FA State (Maybe a) ()
-slfStyleFA = renameStates [0..] . removeTrivialEmptyNodes . oneFinalState Nothing ()
- . moveLabelsToNodes . dfa2nfa
-
--- | Give sequential names to subnetworks.
-renameSubs :: MFA String -> MFA String
-renameSubs (MFA start subs) = MFA (newName start) subs'
- where newNames = zip (map fst subs) ["sub"++show n | n <- [0..]]
- newName s = lookup' s newNames
- subs' = [(newName s,renameLabels n) | (s,n) <- subs]
- renameLabels = mapTransitions (mapSymbol newName id)
-
---
--- * SLF graphviz printing (without sub-networks)
---
-
-slfGraphvizPrinter :: Options -> StateGrammar -> String
-slfGraphvizPrinter opts s
- = prFAGraphviz $ gvFA $ slfStyleFA $ cfgToFA' opts s
- where
- gvFA = mapStates (fromMaybe "") . mapTransitions (const "")
-
---
--- * SLF graphviz printing (with sub-networks)
---
-
-slfSubGraphvizPrinter :: Options -> StateGrammar -> String
-slfSubGraphvizPrinter opts s = Dot.prGraphviz g
- where (main, subs) = mkFAs opts s
- g = STM.evalState (liftM2 Dot.addSubGraphs ss m) [0..]
- ss = mapM (\ (c,f) -> gvSLFFA (Just c) f) subs
- m = gvSLFFA Nothing main
-
-gvSLFFA :: Maybe String -> SLF_FA -> STM.State [State] Dot.Graph
-gvSLFFA n fa =
- liftM (mkCluster n . faToGraphviz . mapStates (maybe "" mfaLabelToGv)
- . mapTransitions (const "")) (rename fa)
- where mfaLabelToGv = symbol ("#"++) id
- mkCluster Nothing = id
- mkCluster (Just x)
- = Dot.setName ("cluster_"++x) . Dot.setAttr "label" x
- rename fa = do
- names <- STM.get
- let fa' = renameStates names fa
- names' = unusedNames fa'
- STM.put names'
- return fa'
-
---
--- * SLF printing (without sub-networks)
---
-
-slfPrinter :: Options -> StateGrammar -> String
-slfPrinter opts s
- = prSLF $ automatonToSLF mkSLFNode $ slfStyleFA $ cfgToFA' opts s
-
---
--- * SLF printing (with sub-networks)
---
-
--- | Make a network with subnetworks in SLF
-slfSubPrinter :: Options -> StateGrammar -> String
-slfSubPrinter opts s = prSLFs slfs
- where
- (main,subs) = mkFAs opts s
- slfs = SLFs [(c, faToSLF fa) | (c,fa) <- subs] (faToSLF main)
- faToSLF = automatonToSLF mfaNodeToSLFNode
-
-automatonToSLF :: (Int -> a -> SLFNode) -> FA State a () -> SLF
-automatonToSLF mkNode fa = SLF { slfNodes = ns, slfEdges = es }
- where ns = map (uncurry mkNode) (states fa)
- es = zipWith (\i (f,t,()) -> mkSLFEdge i (f,t)) [0..] (transitions fa)
-
-mfaNodeToSLFNode :: Int -> Maybe (MFALabel String) -> SLFNode
-mfaNodeToSLFNode i l = case l of
- Nothing -> mkSLFNode i Nothing
- Just (Tok x) -> mkSLFNode i (Just x)
- Just (Cat s) -> mkSLFSubLat i s
-
-mkSLFNode :: Int -> Maybe String -> SLFNode
-mkSLFNode i Nothing = SLFNode { nId = i, nWord = Nothing, nTag = Nothing }
-mkSLFNode i (Just w)
- | isNonWord w = SLFNode { nId = i,
- nWord = Nothing,
- nTag = Just w }
- | otherwise = SLFNode { nId = i,
- nWord = Just (map toUpper w),
- nTag = Just w }
-
-mkSLFSubLat :: Int -> String -> SLFNode
-mkSLFSubLat i sub = SLFSubLat { nId = i, nLat = sub }
-
-mkSLFEdge :: Int -> (Int,Int) -> SLFEdge
-mkSLFEdge i (f,t) = SLFEdge { eId = i, eStart = f, eEnd = t }
-
-prSLFs :: SLFs -> String
-prSLFs (SLFs subs main) = unlinesS (map prSub subs ++ [prOneSLF main]) ""
- where prSub (n,s) = showString "SUBLAT=" . shows n
- . nl . prOneSLF s . showString "." . nl
-
-prSLF :: SLF -> String
-prSLF slf = prOneSLF slf ""
-
-prOneSLF :: SLF -> ShowS
-prOneSLF (SLF { slfNodes = ns, slfEdges = es})
- = header . unlinesS (map prNode ns) . nl . unlinesS (map prEdge es) . nl
- where
- header = prFields [("N",show (length ns)),("L", show (length es))] . nl
- prNode (SLFNode { nId = i, nWord = w, nTag = t })
- = prFields $ [("I",show i),("W",showWord w)]
- ++ maybe [] (\t -> [("s",t)]) t
- prNode (SLFSubLat { nId = i, nLat = l })
- = prFields [("I",show i),("L",show l)]
- prEdge e = prFields [("J",show (eId e)),("S",show (eStart e)),("E",show (eEnd e))]
-
--- | Check if a word should not correspond to a word in the SLF file.
-isNonWord :: String -> Bool
-isNonWord = any isPunct
-
-isPunct :: Char -> Bool
-isPunct c = c `elem` "-_.;.,?!()[]{}"
-
-showWord :: SLFWord -> String
-showWord Nothing = "!NULL"
-showWord (Just w) | null w = "!NULL"
- | otherwise = w
-
-prFields :: [(String,String)] -> ShowS
-prFields fs = unwordsS [ showString l . showChar '=' . showString v | (l,v) <- fs ]
diff --git a/src/GF/Speech/PrSRGS.hs b/src/GF/Speech/PrSRGS.hs
deleted file mode 100644
index d8ae07867..000000000
--- a/src/GF/Speech/PrSRGS.hs
+++ /dev/null
@@ -1,153 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrSRGS
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- This module prints a CFG as an SRGS XML grammar.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
------------------------------------------------------------------------------
-
-module GF.Speech.PrSRGS (srgsXmlPrinter, srgsXmlNonRecursivePrinter) where
-
-import GF.Data.Utilities
-import GF.Data.XML
-import GF.Speech.RegExp
-import GF.Speech.SISR as SISR
-import GF.Speech.SRG
-import GF.Infra.Ident
-import GF.Today
-
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), NameProfile(..), Profile(..), forestName, filterCats)
-import GF.Conversion.Types
-import GF.Infra.Print
-import GF.Infra.Option
-import GF.Probabilistic.Probabilistic (Probs)
-import GF.Compile.ShellState (StateGrammar)
-
-import Data.Char (toUpper,toLower)
-import Data.List
-import Data.Maybe
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-
-srgsXmlPrinter :: Maybe SISRFormat
- -> Bool -- ^ Include probabilities
- -> Options
- -> StateGrammar -> String
-srgsXmlPrinter sisr probs opts s = prSrgsXml sisr probs $ makeSimpleSRG opts s
-
-srgsXmlNonRecursivePrinter :: Options -> StateGrammar -> String
-srgsXmlNonRecursivePrinter opts s = prSrgsXml Nothing False $ makeNonRecursiveSRG opts s
-
-
-prSrgsXml :: Maybe SISRFormat -> Bool -> SRG -> String
-prSrgsXml sisr probs srg@(SRG{grammarName=name,startCat=start,
- origStartCat=origStart,grammarLanguage=l,rules=rs})
- = showXMLDoc (optimizeSRGS xmlGr)
- where
- Just root = cfgCatToGFCat origStart
- xmlGr = grammar sisr (catFormId root) l $
- [meta "description"
- ("SRGS XML speech recognition grammar for " ++ name
- ++ ". " ++ "Original start category: " ++ origStart),
- meta "generator" ("Grammatical Framework " ++ version)]
- ++ topCatRules
- ++ concatMap ruleToXML rs
- ruleToXML (SRGRule cat origCat alts) =
- comments ["Category " ++ origCat] ++ [rule cat (prRhs alts)]
- prRhs rhss = [oneOf (map (mkProd sisr probs) rhss)]
- -- externally visible rules for each of the GF categories
- topCatRules = [topRule tc [oneOf (map (it tc) cs)] | (tc,cs) <- srgTopCats srg]
- where it i c = Tag "item" [] ([ETag "ruleref" [("uri","#" ++ c)]]
- ++ tag sisr (topCatSISR c))
- topRule i is = Tag "rule" [("id",catFormId i),("scope","public")] is
-
-rule :: String -> [XML] -> XML
-rule i = Tag "rule" [("id",i)]
-
-mkProd :: Maybe SISRFormat -> Bool -> SRGAlt -> XML
-mkProd sisr probs (SRGAlt mp n rhs) = Tag "item" w (ti ++ [x] ++ tf)
- where x = mkItem sisr n rhs
- w | probs = maybe [] (\p -> [("weight", show p)]) mp
- | otherwise = []
- ti = tag sisr (profileInitSISR n)
- tf = tag sisr (profileFinalSISR n)
-
-mkItem :: Maybe SISRFormat -> CFTerm -> SRGItem -> XML
-mkItem sisr cn = f
- where
- f (REUnion []) = ETag "ruleref" [("special","VOID")]
- f (REUnion xs)
- | not (null es) = Tag "item" [("repeat","0-1")] [f (REUnion nes)]
- | otherwise = oneOf (map f xs)
- where (es,nes) = partition isEpsilon xs
- f (REConcat []) = ETag "ruleref" [("special","NULL")]
- f (REConcat xs) = Tag "item" [] (map f xs)
- f (RERepeat x) = Tag "item" [("repeat","0-")] [f x]
- f (RESymbol s) = symItem sisr cn s
-
-{-
-mkProd :: Maybe SISRFormat -> Bool -> SRGAlt -> XML
-mkProd sisr probs (SRGAlt mp n rhs) = Tag "item" w (ti ++ xs ++ tf)
- where xs = mkItem sisr n rhs
- w | probs = maybe [] (\p -> [("weight", show p)]) mp
- | otherwise = []
- ti = [tag sisr (profileInitSISR n)]
- tf = [tag sisr (profileFinalSISR n)]
-
-
-mkItem :: Maybe SISRFormat -> CFTerm -> [Symbol SRGNT Token] -> [XML]
-mkItem sisr cn ss = map (symItem sisr cn) ss
--}
-
-symItem :: Maybe SISRFormat -> CFTerm -> Symbol SRGNT Token -> XML
-symItem sisr cn (Cat n@(c,_)) =
- Tag "item" [] $ [ETag "ruleref" [("uri","#" ++ c)]] ++ tag sisr (catSISR cn n)
-symItem _ _ (Tok t) = Tag "item" [] [Data (showToken t)]
-
-tag :: Maybe SISRFormat -> (SISRFormat -> SISRTag) -> [XML]
-tag Nothing _ = []
-tag (Just fmt) t = case t fmt of
- [] -> []
- ts -> [Tag "tag" [] [Data (prSISR ts)]]
-
-catFormId :: String -> String
-catFormId = (++ "_cat")
-
-
-showToken :: Token -> String
-showToken t = t
-
-oneOf :: [XML] -> XML
-oneOf = Tag "one-of" []
-
-grammar :: Maybe SISRFormat
- -> String -- ^ root
- -> Maybe String -- ^language
- -> [XML] -> XML
-grammar sisr root ml =
- Tag "grammar" $ [("xmlns","http://www.w3.org/2001/06/grammar"),
- ("version","1.0"),
- ("mode","voice"),
- ("root",root)]
- ++ (if isJust sisr then [("tag-format","semantics/1.0")] else [])
- ++ maybe [] (\l -> [("xml:lang", l)]) ml
-
-meta :: String -> String -> XML
-meta n c = ETag "meta" [("name",n),("content",c)]
-
-optimizeSRGS :: XML -> XML
-optimizeSRGS = bottomUpXML f
- where f (Tag "item" [] [x@(Tag "item" _ _)]) = x
- f (Tag "item" [] [x@(Tag "one-of" _ _)]) = x
- f (Tag "item" as [Tag "item" [] xs]) = Tag "item" as xs
- f (Tag "item" as xs) = Tag "item" as (map g xs)
- where g (Tag "item" [] [x@(ETag "ruleref" _)]) = x
- g x = x
- f (Tag "one-of" [] [x]) = x
- f x = x
diff --git a/src/GF/Speech/PrSRGS_ABNF.hs b/src/GF/Speech/PrSRGS_ABNF.hs
deleted file mode 100644
index abb84c5dc..000000000
--- a/src/GF/Speech/PrSRGS_ABNF.hs
+++ /dev/null
@@ -1,147 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : PrJSRGS_ABNF
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/01 20:09:04 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.16 $
---
--- This module prints a CFG as a JSGF grammar.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
---
--- FIXME: convert to UTF-8
------------------------------------------------------------------------------
-
-module GF.Speech.PrSRGS_ABNF (srgsAbnfPrinter, srgsAbnfNonRecursivePrinter) where
-
-import GF.Conversion.Types
-import GF.Data.Utilities
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), NameProfile(..), Profile(..), filterCats)
-import GF.Infra.Ident
-import GF.Infra.Print
-import GF.Infra.Option
-import GF.Probabilistic.Probabilistic (Probs)
-import GF.Speech.SISR
-import GF.Speech.SRG
-import GF.Speech.RegExp
-import GF.Compile.ShellState (StateGrammar)
-import GF.Today
-
-import Data.Char
-import Data.List
-import Data.Maybe
-import Text.PrettyPrint.HughesPJ
-import Debug.Trace
-
-width :: Int
-width = 75
-
-srgsAbnfPrinter :: Maybe SISRFormat
- -> Bool -- ^ Include probabilities
- -> Options
- -> StateGrammar -> String
-srgsAbnfPrinter sisr probs opts s = showDoc $ prABNF sisr probs $ makeSimpleSRG opts s
-
-srgsAbnfNonRecursivePrinter :: Options -> StateGrammar -> String
-srgsAbnfNonRecursivePrinter opts s = showDoc $ prABNF Nothing False $ makeNonRecursiveSRG opts s
-
-showDoc = renderStyle (style { lineLength = width })
-
-prABNF :: Maybe SISRFormat -> Bool -> SRG -> Doc
-prABNF sisr probs srg@(SRG{grammarName=name,grammarLanguage=ml,
- startCat=start,origStartCat=origStart,rules=rs})
- = header $++$ vcat topCatRules $++$ foldr ($++$) empty (map prRule rs)
- where
- header = text "#ABNF 1.0 UTF-8;" $$
- meta "description"
- ("Speech recognition grammar for " ++ name
- ++ ". " ++ "Original start category: " ++ origStart) $$
- meta "generator" ("Grammatical Framework " ++ version) $$
- language $$ tagFormat $$ mainCat
- language = maybe empty (\l -> text "language" <+> text l <> char ';') ml
- tagFormat | isJust sisr = text "tag-format" <+> text "" <> char ';'
- | otherwise = empty
- mainCat = case cfgCatToGFCat origStart of
- Just c -> text "root" <+> prCat (catFormId c) <> char ';'
- Nothing -> empty
- prRule (SRGRule cat origCat rhs) =
- comment origCat $$
- rule False cat (map prAlt rhs)
- -- FIXME: use the probability
- prAlt (SRGAlt mp n rhs) = sep [initTag, p (prItem sisr n rhs), finalTag]
- where initTag = tag sisr (profileInitSISR n)
- finalTag = tag sisr (profileFinalSISR n)
- p = if isEmpty initTag && isEmpty finalTag then id else parens
-
- topCatRules = [rule True (catFormId tc) (map (it tc) cs) | (tc,cs) <- srgTopCats srg]
- where it i c = prCat c <+> tag sisr (topCatSISR c)
-
-catFormId :: String -> String
-catFormId = (++ "_cat")
-
-prCat :: SRGCat -> Doc
-prCat c = char '$' <> text c
-
-prItem :: Maybe SISRFormat -> CFTerm -> SRGItem -> Doc
-prItem sisr t = f 0
- where
- f _ (REUnion []) = text "$VOID"
- f p (REUnion xs)
- | not (null es) = brackets (f 0 (REUnion nes))
- | otherwise = (if p >= 1 then parens else id) (alts (map (f 1) xs))
- where (es,nes) = partition isEpsilon xs
- f _ (REConcat []) = text "$NULL"
- f p (REConcat xs) = (if p >= 3 then parens else id) (fsep (map (f 2) xs))
- f p (RERepeat x) = f 3 x <> text "<0->"
- f _ (RESymbol s) = prSymbol sisr t s
-
-
-prSymbol :: Maybe SISRFormat -> CFTerm -> Symbol SRGNT Token -> Doc
-prSymbol sisr cn (Cat n@(c,_)) = prCat c <+> tag sisr (catSISR cn n)
-prSymbol _ cn (Tok t) | all isPunct (prt t) = empty -- removes punctuation
- | otherwise = text (prt t) -- FIXME: quote if there is whitespace or odd chars
-
-tag :: Maybe SISRFormat -> (SISRFormat -> SISRTag) -> Doc
-tag Nothing _ = empty
-tag (Just fmt) t =
- case t fmt of
- [] -> empty
- -- grr, silly SRGS ABNF does not have an escaping mechanism
- ts | '{' `elem` x || '}' `elem` x -> text "{!{" <+> text x <+> text "}!}"
- | otherwise -> text "{" <+> text x <+> text "}"
- where x = prSISR ts
-
-isPunct :: Char -> Bool
-isPunct c = c `elem` "-_.;.,?!"
-
-comment :: String -> Doc
-comment s = text "//" <+> text s
-
-alts :: [Doc] -> Doc
-alts = fsep . prepunctuate (text "| ")
-
-rule :: Bool -> SRGCat -> [Doc] -> Doc
-rule pub c xs = p <+> prCat c <+> char '=' <+> nest 2 (alts xs) <+> char ';'
- where p = if pub then text "public" else empty
-
-meta :: String -> String -> Doc
-meta n v = text "meta" <+> text (show n) <+> text "is" <+> text (show v) <> char ';'
-
--- Pretty-printing utilities
-
-emptyLine :: Doc
-emptyLine = text ""
-
-prepunctuate :: Doc -> [Doc] -> [Doc]
-prepunctuate _ [] = []
-prepunctuate p (x:xs) = x : map (p <>) xs
-
-($++$) :: Doc -> Doc -> Doc
-x $++$ y = x $$ emptyLine $$ y
-
diff --git a/src/GF/Speech/RegExp.hs b/src/GF/Speech/RegExp.hs
deleted file mode 100644
index 5ee40828e..000000000
--- a/src/GF/Speech/RegExp.hs
+++ /dev/null
@@ -1,143 +0,0 @@
-module GF.Speech.RegExp (RE(..),
- epsilonRE, nullRE,
- isEpsilon, isNull,
- unionRE, concatRE, seqRE,
- repeatRE, minimizeRE,
- mapRE, mapRE', joinRE,
- symbolsRE,
- dfa2re, prRE) where
-
-import Data.List
-
-import GF.Data.Utilities
-import GF.Speech.FiniteState
-
-data RE a =
- REUnion [RE a] -- ^ REUnion [] is null
- | REConcat [RE a] -- ^ REConcat [] is epsilon
- | RERepeat (RE a)
- | RESymbol a
- deriving (Eq,Ord,Show)
-
-
-dfa2re :: (Ord a) => DFA a -> RE a
-dfa2re = finalRE . elimStates . modifyTransitions merge . addLoops
- . oneFinalState () epsilonRE . mapTransitions RESymbol
- where addLoops fa = newTransitions [(s,s,nullRE) | (s,_) <- states fa] fa
- merge es = [(f,t,unionRE ls)
- | ((f,t),ls) <- buildMultiMap [((f,t),l) | (f,t,l) <- es]]
-
-elimStates :: (Ord a) => DFA (RE a) -> DFA (RE a)
-elimStates fa =
- case [s | (s,_) <- states fa, isInternal fa s] of
- [] -> fa
- sE:_ -> elimStates $ insertTransitionsWith (\x y -> unionRE [x,y]) ts $ removeState sE fa
- where sAs = nonLoopTransitionsTo sE fa
- sBs = nonLoopTransitionsFrom sE fa
- r2 = unionRE $ loops sE fa
- ts = [(sA, sB, r r1 r3) | (sA,r1) <- sAs, (sB,r3) <- sBs]
- r r1 r3 = concatRE [r1, repeatRE r2, r3]
-
-epsilonRE :: RE a
-epsilonRE = REConcat []
-
-nullRE :: RE a
-nullRE = REUnion []
-
-isNull :: RE a -> Bool
-isNull (REUnion []) = True
-isNull _ = False
-
-isEpsilon :: RE a -> Bool
-isEpsilon (REConcat []) = True
-isEpsilon _ = False
-
-unionRE :: Ord a => [RE a] -> RE a
-unionRE = unionOrId . sortNub . concatMap toList
- where
- toList (REUnion xs) = xs
- toList x = [x]
- unionOrId [r] = r
- unionOrId rs = REUnion rs
-
-concatRE :: [RE a] -> RE a
-concatRE xs | any isNull xs = nullRE
- | otherwise = case concatMap toList xs of
- [r] -> r
- rs -> REConcat rs
- where
- toList (REConcat xs) = xs
- toList x = [x]
-
-seqRE :: [a] -> RE a
-seqRE = concatRE . map RESymbol
-
-repeatRE :: RE a -> RE a
-repeatRE x | isNull x || isEpsilon x = epsilonRE
- | otherwise = RERepeat x
-
-finalRE :: Ord a => DFA (RE a) -> RE a
-finalRE fa = concatRE [repeatRE r1, r2,
- repeatRE (unionRE [r3, concatRE [r4, repeatRE r1, r2]])]
- where
- s0 = startState fa
- [sF] = finalStates fa
- r1 = unionRE $ loops s0 fa
- r2 = unionRE $ map snd $ nonLoopTransitionsTo sF fa
- r3 = unionRE $ loops sF fa
- r4 = unionRE $ map snd $ nonLoopTransitionsFrom sF fa
-
-reverseRE :: RE a -> RE a
-reverseRE (REConcat xs) = REConcat $ map reverseRE $ reverse xs
-reverseRE (REUnion xs) = REUnion (map reverseRE xs)
-reverseRE (RERepeat x) = RERepeat (reverseRE x)
-reverseRE x = x
-
-minimizeRE :: Ord a => RE a -> RE a
-minimizeRE = reverseRE . mergeForward . reverseRE . mergeForward
-
-mergeForward :: Ord a => RE a -> RE a
-mergeForward (REUnion xs) =
- unionRE [concatRE [mergeForward y,mergeForward (unionRE rs)] | (y,rs) <- buildMultiMap (map firstRE xs)]
-mergeForward (REConcat (x:xs)) = concatRE [mergeForward x,mergeForward (REConcat xs)]
-mergeForward (RERepeat r) = repeatRE (mergeForward r)
-mergeForward r = r
-
-firstRE :: RE a -> (RE a, RE a)
-firstRE (REConcat (x:xs)) = (x, REConcat xs)
-firstRE r = (r,epsilonRE)
-
-mapRE :: (a -> b) -> RE a -> RE b
-mapRE f = mapRE' (RESymbol . f)
-
-mapRE' :: (a -> RE b) -> RE a -> RE b
-mapRE' f (REConcat xs) = REConcat (map (mapRE' f) xs)
-mapRE' f (REUnion xs) = REUnion (map (mapRE' f) xs)
-mapRE' f (RERepeat x) = RERepeat (mapRE' f x)
-mapRE' f (RESymbol s) = f s
-
-joinRE :: RE (RE a) -> RE a
-joinRE (REConcat xs) = REConcat (map joinRE xs)
-joinRE (REUnion xs) = REUnion (map joinRE xs)
-joinRE (RERepeat xs) = RERepeat (joinRE xs)
-joinRE (RESymbol ss) = ss
-
-symbolsRE :: RE a -> [a]
-symbolsRE (REConcat xs) = concatMap symbolsRE xs
-symbolsRE (REUnion xs) = concatMap symbolsRE xs
-symbolsRE (RERepeat x) = symbolsRE x
-symbolsRE (RESymbol x) = [x]
-
--- Debugging
-
-prRE :: RE String -> String
-prRE = prRE' 0
-
-prRE' _ (REUnion []) = ""
-prRE' n (REUnion xs) = p n 1 (concat (intersperse " | " (map (prRE' 1) xs)))
-prRE' n (REConcat xs) = p n 2 (unwords (map (prRE' 2) xs))
-prRE' n (RERepeat x) = p n 3 (prRE' 3 x) ++ "*"
-prRE' _ (RESymbol s) = s
-
-p n m s | n >= m = "(" ++ s ++ ")"
- | True = s
diff --git a/src/GF/Speech/Relation.hs b/src/GF/Speech/Relation.hs
deleted file mode 100644
index 641d671a9..000000000
--- a/src/GF/Speech/Relation.hs
+++ /dev/null
@@ -1,130 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Relation
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/26 17:13:13 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.1 $
---
--- A simple module for relations.
------------------------------------------------------------------------------
-
-module GF.Speech.Relation (Rel, mkRel, mkRel'
- , allRelated , isRelatedTo
- , transitiveClosure
- , reflexiveClosure, reflexiveClosure_
- , symmetricClosure
- , symmetricSubrelation, reflexiveSubrelation
- , reflexiveElements
- , equivalenceClasses
- , isTransitive, isReflexive, isSymmetric
- , isEquivalence
- , isSubRelationOf) where
-
-import Data.List
-import Data.Maybe
-import Data.Map (Map)
-import qualified Data.Map as Map
-import Data.Set (Set)
-import qualified Data.Set as Set
-
-import GF.Data.Utilities
-
-type Rel a = Map a (Set a)
-
--- | Creates a relation from a list of related pairs.
-mkRel :: Ord a => [(a,a)] -> Rel a
-mkRel ps = relates ps Map.empty
-
--- | Creates a relation from a list pairs of elements and the elements
--- related to them.
-mkRel' :: Ord a => [(a,[a])] -> Rel a
-mkRel' xs = Map.fromListWith Set.union [(x,Set.fromList ys) | (x,ys) <- xs]
-
-relToList :: Rel a -> [(a,a)]
-relToList r = [ (x,y) | (x,ys) <- Map.toList r, y <- Set.toList ys ]
-
--- | Add a pair to the relation.
-relate :: Ord a => a -> a -> Rel a -> Rel a
-relate x y r = Map.insertWith Set.union x (Set.singleton y) r
-
--- | Add a list of pairs to the relation.
-relates :: Ord a => [(a,a)] -> Rel a -> Rel a
-relates ps r = foldl (\r' (x,y) -> relate x y r') r ps
-
--- | Checks if an element is related to another.
-isRelatedTo :: Ord a => Rel a -> a -> a -> Bool
-isRelatedTo r x y = maybe False (y `Set.member`) (Map.lookup x r)
-
--- | Get the set of elements to which a given element is related.
-allRelated :: Ord a => Rel a -> a -> Set a
-allRelated r x = fromMaybe Set.empty (Map.lookup x r)
-
--- | Get all elements in the relation.
-domain :: Ord a => Rel a -> Set a
-domain r = foldl Set.union (Map.keysSet r) (Map.elems r)
-
--- | Keep only pairs for which both elements are in the given set.
-intersectSetRel :: Ord a => Set a -> Rel a -> Rel a
-intersectSetRel s = filterRel (\x y -> x `Set.member` s && y `Set.member` s)
-
-transitiveClosure :: Ord a => Rel a -> Rel a
-transitiveClosure r = fix (Map.map growSet) r
- where growSet ys = foldl Set.union ys (map (allRelated r) $ Set.toList ys)
-
-reflexiveClosure_ :: Ord a => [a] -- ^ The set over which the relation is defined.
- -> Rel a -> Rel a
-reflexiveClosure_ u r = relates [(x,x) | x <- u] r
-
--- | Uses 'domain'
-reflexiveClosure :: Ord a => Rel a -> Rel a
-reflexiveClosure r = reflexiveClosure_ (Set.toList $ domain r) r
-
-symmetricClosure :: Ord a => Rel a -> Rel a
-symmetricClosure r = relates [ (y,x) | (x,y) <- relToList r ] r
-
-symmetricSubrelation :: Ord a => Rel a -> Rel a
-symmetricSubrelation r = filterRel (flip $ isRelatedTo r) r
-
-reflexiveSubrelation :: Ord a => Rel a -> Rel a
-reflexiveSubrelation r = intersectSetRel (reflexiveElements r) r
-
--- | Get the set of elements which are related to themselves.
-reflexiveElements :: Ord a => Rel a -> Set a
-reflexiveElements r = Set.fromList [ x | (x,ys) <- Map.toList r, x `Set.member` ys ]
-
--- | Keep the related pairs for which the predicate is true.
-filterRel :: Ord a => (a -> a -> Bool) -> Rel a -> Rel a
-filterRel p = purgeEmpty . Map.mapWithKey (Set.filter . p)
-
--- | Remove keys that map to no elements.
-purgeEmpty :: Ord a => Rel a -> Rel a
-purgeEmpty r = Map.filter (not . Set.null) r
-
-
--- | Get the equivalence classes from an equivalence relation.
-equivalenceClasses :: Ord a => Rel a -> [Set a]
-equivalenceClasses r = equivalenceClasses_ (Map.keys r) r
- where equivalenceClasses_ [] _ = []
- equivalenceClasses_ (x:xs) r = ys:equivalenceClasses_ zs r
- where ys = allRelated r x
- zs = [x' | x' <- xs, not (x' `Set.member` ys)]
-
-isTransitive :: Ord a => Rel a -> Bool
-isTransitive r = and [z `Set.member` ys | (x,ys) <- Map.toList r,
- y <- Set.toList ys, z <- Set.toList (allRelated r y)]
-
-isReflexive :: Ord a => Rel a -> Bool
-isReflexive r = all (\ (x,ys) -> x `Set.member` ys) (Map.toList r)
-
-isSymmetric :: Ord a => Rel a -> Bool
-isSymmetric r = and [isRelatedTo r y x | (x,y) <- relToList r]
-
-isEquivalence :: Ord a => Rel a -> Bool
-isEquivalence r = isReflexive r && isSymmetric r && isTransitive r
-
-isSubRelationOf :: Ord a => Rel a -> Rel a -> Bool
-isSubRelationOf r1 r2 = all (uncurry (isRelatedTo r2)) (relToList r1)
diff --git a/src/GF/Speech/RelationQC.hs b/src/GF/Speech/RelationQC.hs
deleted file mode 100644
index 47f783986..000000000
--- a/src/GF/Speech/RelationQC.hs
+++ /dev/null
@@ -1,39 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : RelationQC
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/26 17:13:13 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.1 $
---
--- QuickCheck properties for GF.Speech.Relation
------------------------------------------------------------------------------
-
-module GF.Speech.RelationQC where
-
-import GF.Speech.Relation
-
-import Test.QuickCheck
-
-prop_transitiveClosure_trans :: [(Int,Int)] -> Bool
-prop_transitiveClosure_trans ps = isTransitive (transitiveClosure (mkRel ps))
-
-prop_symmetricSubrelation_symm :: [(Int,Int)] -> Bool
-prop_symmetricSubrelation_symm ps = isSymmetric (symmetricSubrelation (mkRel ps))
-
-prop_symmetricSubrelation_sub :: [(Int,Int)] -> Bool
-prop_symmetricSubrelation_sub ps = symmetricSubrelation r `isSubRelationOf` r
- where r = mkRel ps
-
-prop_symmetricClosure_symm :: [(Int,Int)] -> Bool
-prop_symmetricClosure_symm ps = isSymmetric (symmetricClosure (mkRel ps))
-
-prop_reflexiveClosure_refl :: [(Int,Int)] -> Bool
-prop_reflexiveClosure_refl ps = isReflexive (reflexiveClosure (mkRel ps))
-
-prop_mkEquiv_equiv :: [(Int,Int)] -> Bool
-prop_mkEquiv_equiv ps = isEquivalence (mkEquiv ps)
- where mkEquiv = transitiveClosure . symmetricClosure . reflexiveClosure . mkRel
diff --git a/src/GF/Speech/SISR.hs b/src/GF/Speech/SISR.hs
deleted file mode 100644
index 3e68a2e55..000000000
--- a/src/GF/Speech/SISR.hs
+++ /dev/null
@@ -1,87 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.Speech.SISR
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- Abstract syntax and pretty printer for SISR,
--- (Semantic Interpretation for Speech Recognition)
---
------------------------------------------------------------------------------
-
-module GF.Speech.SISR (SISRFormat(..), SISRTag, prSISR,
- topCatSISR, profileInitSISR, catSISR, profileFinalSISR) where
-
-import Data.List
-
-import GF.Conversion.Types
-import GF.Data.Utilities
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), NameProfile(..), Profile(..), forestName)
-import GF.Infra.Ident
-import GF.Speech.TransformCFG
-import GF.Speech.SRG (SRGNT)
-
-import qualified GF.JavaScript.AbsJS as JS
-import qualified GF.JavaScript.PrintJS as JS
-
-data SISRFormat =
- -- SISR Working draft 1 April 2003
- -- http://www.w3.org/TR/2003/WD-semantic-interpretation-20030401/
- SISROld
- deriving Show
-
-type SISRTag = [JS.DeclOrExpr]
-
-
-prSISR :: SISRTag -> String
-prSISR = JS.printTree
-
-topCatSISR :: String -> SISRFormat -> SISRTag
-topCatSISR c fmt = map JS.DExpr [fmtOut fmt `ass` fmtRef fmt c]
-
-profileInitSISR :: CFTerm -> SISRFormat -> SISRTag
-profileInitSISR t fmt
- | null (usedArgs t) = []
- | otherwise = [JS.Decl [JS.DInit args (JS.EArray [])]]
-
-usedArgs :: CFTerm -> [Int]
-usedArgs (CFObj _ ts) = foldr union [] (map usedArgs ts)
-usedArgs (CFAbs _ x) = usedArgs x
-usedArgs (CFApp x y) = usedArgs x `union` usedArgs y
-usedArgs (CFRes i) = [i]
-usedArgs _ = []
-
-catSISR :: CFTerm -> SRGNT -> SISRFormat -> SISRTag
-catSISR t (c,i) fmt
- | i `elem` usedArgs t = map JS.DExpr
- [JS.EIndex (JS.EVar args) (JS.EInt (fromIntegral i)) `ass` fmtRef fmt c]
- | otherwise = []
-
-profileFinalSISR :: CFTerm -> SISRFormat -> SISRTag
-profileFinalSISR term fmt = [JS.DExpr $ fmtOut fmt `ass` f term]
- where
- f (CFObj n ts) = tree (prIdent n) (map f ts)
- f (CFAbs v x) = JS.EFun [var v] [JS.SReturn (f x)]
- f (CFApp x y) = JS.ECall (f x) [f y]
- f (CFRes i) = JS.EIndex (JS.EVar args) (JS.EInt (fromIntegral i))
- f (CFVar v) = JS.EVar (var v)
- f (CFMeta typ) = obj [("name",JS.EStr "?"), ("type",JS.EStr typ)]
-
-fmtOut SISROld = JS.EVar (JS.Ident "$")
-
-fmtRef SISROld c = JS.EVar (JS.Ident ("$" ++ c))
-
-args = JS.Ident "a"
-
-var v = JS.Ident ("x" ++ show v)
-
-field x y = JS.EMember x (JS.Ident y)
-
-ass = JS.EAssign
-
-tree n xs = obj [("name", JS.EStr n), ("args", JS.EArray xs)]
-
-obj ps = JS.EObj [JS.Prop (JS.StringPropName x) y | (x,y) <- ps]
-
diff --git a/src/GF/Speech/SRG.hs b/src/GF/Speech/SRG.hs
deleted file mode 100644
index 19b6c1c1b..000000000
--- a/src/GF/Speech/SRG.hs
+++ /dev/null
@@ -1,235 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : SRG
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/01 20:09:04 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.20 $
---
--- Representation of, conversion to, and utilities for
--- printing of a general Speech Recognition Grammar.
---
--- FIXME: remove \/ warn \/ fail if there are int \/ string literal
--- categories in the grammar
------------------------------------------------------------------------------
-
-module GF.Speech.SRG (SRG(..), SRGRule(..), SRGAlt(..), SRGItem,
- SRGCat, SRGNT, CFTerm
- , makeSRG
- , makeSimpleSRG
- , makeNonRecursiveSRG
- , lookupFM_, prtS
- , cfgCatToGFCat, srgTopCats
- ) where
-
-import GF.Data.Operations
-import GF.Data.Utilities
-import GF.Infra.Ident
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), NameProfile(..)
- , Profile(..), SyntaxForest
- , filterCats, mapSymbol, symbol)
-import GF.Conversion.Types
-import GF.Infra.Print
-import GF.Speech.TransformCFG
-import GF.Speech.Relation
-import GF.Speech.FiniteState
-import GF.Speech.RegExp
-import GF.Speech.CFGToFiniteState
-import GF.Infra.Option
-import GF.Probabilistic.Probabilistic (Probs)
-import GF.Compile.ShellState (StateGrammar, stateProbs, stateOptions, cncId)
-
-import Data.List
-import Data.Maybe (fromMaybe, maybeToList)
-import Data.Map (Map)
-import qualified Data.Map as Map
-import Data.Set (Set)
-import qualified Data.Set as Set
-
-import Debug.Trace
-
-data SRG = SRG { grammarName :: String -- ^ grammar name
- , startCat :: SRGCat -- ^ start category name
- , origStartCat :: String -- ^ original start category name
- , grammarLanguage :: Maybe String -- ^ The language for which the grammar
- -- is intended, e.g. en-UK
- , rules :: [SRGRule]
- }
- deriving (Eq,Show)
-
-data SRGRule = SRGRule SRGCat String [SRGAlt] -- ^ SRG category name, original category name
- -- and productions
- deriving (Eq,Show)
-
--- | maybe a probability, a rule name and an EBNF right-hand side
-data SRGAlt = SRGAlt (Maybe Double) CFTerm SRGItem
- deriving (Eq,Show)
-
-type SRGItem = RE (Symbol SRGNT Token)
-
-type SRGCat = String
-
--- | An SRG non-terminal. Category name and its number in the profile.
-type SRGNT = (SRGCat, Int)
-
--- | SRG category name and original name
-type CatName = (SRGCat,String)
-
-type CatNames = Map String String
-
--- | Create a non-left-recursive SRG.
--- FIXME: the probabilities in the returned
--- grammar may be meaningless.
-makeSimpleSRG :: Options -- ^ Grammar options
- -> StateGrammar
- -> SRG
-makeSimpleSRG opt s = makeSRG preprocess opt s
- where
- preprocess origStart = traceStats "After mergeIdentical"
- . mergeIdentical
- . traceStats "After removeLeftRecursion"
- . removeLeftRecursion origStart
- . traceStats "After topDownFilter"
- . topDownFilter origStart
- . traceStats "After bottomUpFilter"
- . bottomUpFilter
- . traceStats "After removeCycles"
- . removeCycles
- . traceStats "Inital CFG"
-
-traceStats s g = trace ("---- " ++ s ++ ": " ++ stats g {- ++ "\n" ++ prCFRules g ++ "----" -}) g
-
-stats g = "Categories: " ++ show (countCats g)
- ++ " Rules: " ++ show (countRules g)
-
-makeNonRecursiveSRG :: Options
- -> StateGrammar
- -> SRG
-makeNonRecursiveSRG opt s = renameSRG $
- SRG { grammarName = prIdent (cncId s),
- startCat = start,
- origStartCat = origStart,
- grammarLanguage = getSpeechLanguage opt s,
- rules = rs }
- where
- origStart = getStartCatCF opt s
- MFA start dfas = cfgToMFA opt s
- rs = [SRGRule l l [SRGAlt Nothing dummyCFTerm (dfaToSRGItem dfa)] | (l,dfa) <- dfas]
- where dfaToSRGItem = mapRE dummySRGNT . minimizeRE . dfa2re
- dummyCFTerm = CFMeta "dummy"
- dummySRGNT = mapSymbol (\c -> (c,0)) id
-
-makeSRG :: (Cat_ -> CFRules -> CFRules)
- -> Options -- ^ Grammar options
- -> StateGrammar
- -> SRG
-makeSRG preprocess opt s = renameSRG $
- SRG { grammarName = name,
- startCat = origStart,
- origStartCat = origStart,
- grammarLanguage = getSpeechLanguage opt s,
- rules = rs }
- where
- name = prIdent (cncId s)
- origStart = getStartCatCF opt s
- (_,cfgRules) = unzip $ allRulesGrouped $ preprocess origStart $ cfgToCFRules s
- rs = map (cfgRulesToSRGRule (stateProbs s)) cfgRules
-
--- | Give names on the form NameX to all categories.
-renameSRG :: SRG -> SRG
-renameSRG srg = srg { startCat = renameCat (startCat srg),
- rules = map renameRule (rules srg) }
- where
- names = mkCatNames (grammarName srg) (allSRGCats srg)
- renameRule (SRGRule _ origCat alts) = SRGRule (renameCat origCat) origCat (map renameAlt alts)
- renameAlt (SRGAlt mp n rhs) = SRGAlt mp n (mapRE renameSymbol rhs)
- renameSymbol = mapSymbol (\ (c,x) -> (renameCat c, x)) id
- renameCat = lookupFM_ names
-
-getSpeechLanguage :: Options -> StateGrammar -> Maybe String
-getSpeechLanguage opt s =
- fmap (replace '_' '-') $ getOptVal (addOptions opt (stateOptions s)) speechLanguage
-
--- FIXME: merge alternatives with same rhs and profile but different probabilities
-cfgRulesToSRGRule :: Probs -> [CFRule_] -> SRGRule
-cfgRulesToSRGRule probs rs@(r:_) = SRGRule origCat origCat rhs
- where
- origCat = lhsCat r
- alts = [((n,ruleProb probs r),mkSRGSymbols 0 ss) | CFRule c ss n <- rs]
- rhs = [SRGAlt p n (srgItem sss) | ((n,p),sss) <- buildMultiMap alts ]
-
- mkSRGSymbols _ [] = []
- mkSRGSymbols i (Cat c:ss) = Cat (c,i) : mkSRGSymbols (i+1) ss
- mkSRGSymbols i (Tok t:ss) = Tok t : mkSRGSymbols i ss
-
-ruleProb :: Probs -> CFRule_ -> Maybe Double
-ruleProb probs r = lookupProb probs (ruleFun r)
-
--- FIXME: move to GF.Probabilistic.Probabilistic?
-lookupProb :: Probs -> Ident -> Maybe Double
-lookupProb probs i = lookupTree prIdent i probs
-
-mkCatNames :: String -- ^ Category name prefix
- -> [String] -- ^ Original category names
- -> Map String String -- ^ Maps original names to SRG names
-mkCatNames prefix origNames = Map.fromList (zip origNames names)
- where names = [prefix ++ "_" ++ show x | x <- [0..]]
-
-
-allSRGCats :: SRG -> [String]
-allSRGCats SRG { rules = rs } = [c | SRGRule c _ _ <- rs]
-
-cfgCatToGFCat :: SRGCat -> Maybe String
-cfgCatToGFCat c
- -- categories introduced by removeLeftRecursion contain dashes
- | '-' `elem` c = Nothing
- -- some categories introduced by -conversion=finite have the form
- -- "{fun:cat}..."
- | "{" `isPrefixOf` c = case dropWhile (/=':') $ takeWhile (/='}') $ tail c of
- ':':c' -> Just c'
- _ -> error $ "cfgCatToGFCat: Strange category " ++ show c
- | otherwise = Just $ takeWhile (/='{') c
-
-srgTopCats :: SRG -> [(String,[SRGCat])]
-srgTopCats srg = buildMultiMap [(oc, cat) | SRGRule cat origCat _ <- rules srg,
- oc <- maybeToList $ cfgCatToGFCat origCat]
-
---
--- * Size-optimized EBNF SRGs
---
-
-srgItem :: [[Symbol SRGNT Token]] -> SRGItem
-srgItem = unionRE . map mergeItems . sortGroupBy (compareBy filterCats)
--- non-optimizing version:
---srgItem = unionRE . map seqRE
-
--- | Merges a list of right-hand sides which all have the same
--- sequence of non-terminals.
-mergeItems :: [[Symbol SRGNT Token]] -> SRGItem
-mergeItems = minimizeRE . ungroupTokens . minimizeRE . unionRE . map seqRE . map groupTokens
-
-groupTokens :: [Symbol SRGNT Token] -> [Symbol SRGNT [Token]]
-groupTokens [] = []
-groupTokens (Tok t:ss) = case groupTokens ss of
- Tok ts:ss' -> Tok (t:ts):ss'
- ss' -> Tok [t]:ss'
-groupTokens (Cat c:ss) = Cat c : groupTokens ss
-
-ungroupTokens :: RE (Symbol SRGNT [Token]) -> RE (Symbol SRGNT Token)
-ungroupTokens = joinRE . mapRE (symbol (RESymbol . Cat) (REConcat . map (RESymbol . Tok)))
-
---
--- * Utilities for building and printing SRGs
---
-
-lookupFM_ :: (Ord key, Show key) => Map key elt -> key -> elt
-lookupFM_ fm k = Map.findWithDefault err k fm
- where err = error $ "Key not found: " ++ show k
- ++ "\namong " ++ show (Map.keys fm)
-
-prtS :: Print a => a -> ShowS
-prtS = showString . prt
diff --git a/src/GF/Speech/TransformCFG.hs b/src/GF/Speech/TransformCFG.hs
deleted file mode 100644
index 3d7ebd809..000000000
--- a/src/GF/Speech/TransformCFG.hs
+++ /dev/null
@@ -1,378 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : TransformCFG
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/01 20:09:04 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.24 $
---
--- This module does some useful transformations on CFGs.
---
--- peb thinks: most of this module should be moved to GF.Conversion...
------------------------------------------------------------------------------
-
-module GF.Speech.TransformCFG where
-
-import GF.Canon.CanonToGFCC (canon2gfcc)
-import qualified GF.GFCC.CId as C
-import GF.GFCC.Macros (lookType,catSkeleton)
-import GF.GFCC.DataGFCC (GFCC)
-import GF.Conversion.Types
-import GF.CF.PPrCF (prCFCat)
-import GF.Data.Utilities
-import GF.Formalism.CFG
-import GF.Formalism.Utilities (Symbol(..), mapSymbol, filterCats, symbol,
- NameProfile(..), Profile(..), name2fun, forestName)
-import GF.Infra.Ident
-import GF.Infra.Option
-import GF.Infra.Print
-import GF.Speech.Relation
-import GF.Compile.ShellState (StateGrammar, stateCFG, stateGrammarST, startCatStateOpts, stateOptions)
-
-import Control.Monad
-import Control.Monad.State (State, get, put, evalState)
-import Data.Map (Map)
-import qualified Data.Map as Map
-import Data.List
-import Data.Maybe (fromMaybe)
-import Data.Monoid (mconcat)
-import Data.Set (Set)
-import qualified Data.Set as Set
-
--- not very nice to replace the structured CFCat type with a simple string
-type CFRule_ = CFRule Cat_ CFTerm Token
-
-data CFTerm
- = CFObj Fun [CFTerm] -- ^ an abstract syntax function with arguments
- | CFAbs Int CFTerm -- ^ A lambda abstraction. The Int is the variable id.
- | CFApp CFTerm CFTerm -- ^ Application
- | CFRes Int -- ^ The result of the n:th (0-based) non-terminal
- | CFVar Int -- ^ A lambda-bound variable
- | CFMeta String -- ^ A metavariable
- deriving (Eq,Ord,Show)
-
-type Cat_ = String
-type CFSymbol_ = Symbol Cat_ Token
-
-type CFRules = Map Cat_ (Set CFRule_)
-
-
-cfgToCFRules :: StateGrammar -> CFRules
-cfgToCFRules s =
- groupProds [CFRule (catToString c) (map symb r) (nameToTerm n)
- | CFRule c r n <- cfg]
- where cfg = stateCFG s
- symb = mapSymbol catToString id
- catToString = prt
- gfcc = stateGFCC s
- nameToTerm (Name IW [Unify [n]]) = CFRes n
- nameToTerm (Name f@(IC c) prs) =
- CFObj f (zipWith profileToTerm args prs)
- where (args,_) = catSkeleton $ lookType gfcc (C.CId c)
- nameToTerm n = error $ "cfgToCFRules.nameToTerm" ++ show n
- profileToTerm (C.CId t) (Unify []) = CFMeta t
- profileToTerm _ (Unify xs) = CFRes (last xs) -- FIXME: unify
- profileToTerm (C.CId t) (Constant f) = maybe (CFMeta t) (\x -> CFObj x []) (forestName f)
-
-getStartCat :: Options -> StateGrammar -> String
-getStartCat opts sgr = prCFCat (startCatStateOpts opts' sgr)
- where opts' = addOptions opts (stateOptions sgr)
-
-getStartCatCF :: Options -> StateGrammar -> String
-getStartCatCF opts sgr = getStartCat opts sgr ++ "{}.s"
-
-stateGFCC :: StateGrammar -> GFCC
-stateGFCC = canon2gfcc noOptions . stateGrammarST
-
--- * Grammar filtering
-
--- | Removes all directly and indirectly cyclic productions.
--- FIXME: this may be too aggressive, only one production
--- needs to be removed to break a given cycle. But which
--- one should we pick?
--- FIXME: Does not (yet) remove productions which are cyclic
--- because of empty productions.
-removeCycles :: CFRules -> CFRules
-removeCycles = groupProds . f . allRules
- where f rs = filter (not . isCycle) rs
- where alias = transitiveClosure $ mkRel [(c,c') | CFRule c [Cat c'] _ <- rs]
- isCycle (CFRule c [Cat c'] _) = isRelatedTo alias c' c
- isCycle _ = False
-
--- | Better bottom-up filter that also removes categories which contain no finite
--- strings.
-bottomUpFilter :: CFRules -> CFRules
-bottomUpFilter gr = fix grow Map.empty
- where grow g = g `unionCFRules` filterCFRules (all (okSym g) . ruleRhs) gr
- okSym g = symbol (`elem` allCats g) (const True)
-
--- | Removes categories which are not reachable from the start category.
-topDownFilter :: Cat_ -> CFRules -> CFRules
-topDownFilter start rules = filterCFRulesCats (isRelatedTo uses start) rules
- where
- rhsCats = [ (lhsCat r, c') | r <- allRules rules, c' <- filterCats (ruleRhs r) ]
- uses = reflexiveClosure_ (allCats rules) $ transitiveClosure $ mkRel rhsCats
-
--- | Merges categories with identical right-hand-sides.
--- FIXME: handle probabilities
-mergeIdentical :: CFRules -> CFRules
-mergeIdentical g = groupProds $ map subst $ allRules g
- where
- -- maps categories to their replacement
- m = Map.fromList [(y,concat (intersperse "+" xs))
- | (_,xs) <- buildMultiMap [(rulesKey rs,c) | (c,rs) <- Map.toList g], y <- xs]
- -- build data to compare for each category: a set of name,rhs pairs
- rulesKey = Set.map (\ (CFRule _ r n) -> (n,r))
- subst (CFRule c r n) = CFRule (substCat c) (map (mapSymbol substCat id) r) n
- substCat c = Map.findWithDefault (error $ "mergeIdentical: " ++ c) c m
-
--- * Removing left recursion
-
--- The LC_LR algorithm from
--- http://research.microsoft.com/users/bobmoore/naacl2k-proc-rev.pdf
-removeLeftRecursion :: Cat_ -> CFRules -> CFRules
-removeLeftRecursion start gr
- = groupProds $ concat [scheme1, scheme2, scheme3, scheme4]
- where
- scheme1 = [CFRule a [x,Cat a_x] n' |
- a <- retainedLeftRecursive,
- x <- properLeftCornersOf a,
- not (isLeftRecursive x),
- let a_x = mkCat (Cat a) x,
- -- this is an extension of LC_LR to avoid generating
- -- A-X categories for which there are no productions:
- a_x `Set.member` newCats,
- let n' = symbol (\_ -> CFApp (CFRes 1) (CFRes 0))
- (\_ -> CFRes 0) x]
- scheme2 = [CFRule a_x (beta++[Cat a_b]) n' |
- a <- retainedLeftRecursive,
- b@(Cat b') <- properLeftCornersOf a,
- isLeftRecursive b,
- CFRule _ (x:beta) n <- catRules gr b',
- let a_x = mkCat (Cat a) x,
- let a_b = mkCat (Cat a) b,
- let i = length $ filterCats beta,
- let n' = symbol (\_ -> CFAbs 1 (CFApp (CFRes i) (shiftTerm n)))
- (\_ -> CFApp (CFRes i) n) x]
- scheme3 = [CFRule a_x beta n' |
- a <- retainedLeftRecursive,
- x <- properLeftCornersOf a,
- CFRule _ (x':beta) n <- catRules gr a,
- x == x',
- let a_x = mkCat (Cat a) x,
- let n' = symbol (\_ -> CFAbs 1 (shiftTerm n))
- (\_ -> n) x]
- scheme4 = catSetRules gr $ Set.fromList $ filter (not . isLeftRecursive . Cat) cats
-
- newCats = Set.fromList (map lhsCat (scheme2 ++ scheme3))
-
- shiftTerm :: CFTerm -> CFTerm
- shiftTerm (CFObj f ts) = CFObj f (map shiftTerm ts)
- shiftTerm (CFRes 0) = CFVar 1
- shiftTerm (CFRes n) = CFRes (n-1)
- shiftTerm t = t
- -- note: the rest don't occur in the original grammar
-
- cats = allCats gr
- rules = allRules gr
-
- directLeftCorner = mkRel [(Cat c,t) | CFRule c (t:_) _ <- allRules gr]
- leftCorner = reflexiveClosure_ (map Cat cats) $ transitiveClosure directLeftCorner
- properLeftCorner = transitiveClosure directLeftCorner
- properLeftCornersOf = Set.toList . allRelated properLeftCorner . Cat
- isProperLeftCornerOf = flip (isRelatedTo properLeftCorner)
-
- leftRecursive = reflexiveElements properLeftCorner
- isLeftRecursive = (`Set.member` leftRecursive)
-
- retained = start `Set.insert`
- Set.fromList [a | r <- allRules (filterCFRulesCats (not . isLeftRecursive . Cat) gr),
- Cat a <- ruleRhs r]
- isRetained = (`Set.member` retained)
-
- retainedLeftRecursive = filter (isLeftRecursive . Cat) $ Set.toList retained
-
-mkCat :: CFSymbol_ -> CFSymbol_ -> Cat_
-mkCat x y = showSymbol x ++ "-" ++ showSymbol y
- where showSymbol = symbol id show
-
-{-
-
--- Paull's algorithm, see
--- http://research.microsoft.com/users/bobmoore/naacl2k-proc-rev.pdf
-removeLeftRecursion :: Cat_ -> CFRules -> CFRules
-removeLeftRecursion start rs = removeDirectLeftRecursions $ map handleProds rs
- where
- handleProds (c, r) = (c, concatMap handleProd r)
- handleProd (CFRule ai (Cat aj:alpha) n) | aj < ai =
- -- FIXME: for non-recursive categories, this changes
- -- the grammar unneccessarily, maybe we can use mutRecCats
- -- to make this less invasive
- -- FIXME: this will give multiple rules with the same name,
- -- which may mess up the probabilities.
- [CFRule ai (beta ++ alpha) n | CFRule _ beta _ <- lookup' aj rs]
- handleProd r = [r]
-
-removeDirectLeftRecursions :: CFRules -> CFRules
-removeDirectLeftRecursions = concat . flip evalState 0 . mapM removeDirectLeftRecursion
-
-removeDirectLeftRecursion :: (Cat_,[CFRule_]) -- ^ All productions for a category
- -> State Int CFRules
-removeDirectLeftRecursion (a,rs)
- | null dr = return [(a,rs)]
- | otherwise =
- do
- a' <- fresh a
- let as = maybeEndWithA' nr
- is = [CFRule a' (tail r) n | CFRule _ r n <- dr]
- a's = maybeEndWithA' is
- -- the not null constraint here avoids creating new
- -- left recursive (cyclic) rules.
- maybeEndWithA' xs = xs ++ [CFRule c (r++[Cat a']) n | CFRule c r n <- xs,
- not (null r)]
- return [(a, as), (a', a's)]
- where
- (dr,nr) = partition isDirectLeftRecursive rs
- fresh x = do { n <- get; put (n+1); return $ x ++ "-" ++ show n }
-
-isDirectLeftRecursive :: CFRule_ -> Bool
-isDirectLeftRecursive (CFRule c (Cat c':_) _) = c == c'
-isDirectLeftRecursive _ = False
-
--}
-
--- | Get the sets of mutually recursive non-terminals for a grammar.
-mutRecCats :: Bool -- ^ If true, all categories will be in some set.
- -- If false, only recursive categories will be included.
- -> CFRules -> [Set Cat_]
-mutRecCats incAll g = equivalenceClasses $ refl $ symmetricSubrelation $ transitiveClosure r
- where r = mkRel [(c,c') | CFRule c ss _ <- allRules g, Cat c' <- ss]
- refl = if incAll then reflexiveClosure_ (allCats g) else reflexiveSubrelation
-
---
--- * Approximate context-free grammars with regular grammars.
---
-
--- Use the transformation algorithm from \"Regular Approximation of Context-free
--- Grammars through Approximation\", Mohri and Nederhof, 2000
--- to create an over-generating regular frammar for a context-free
--- grammar
-makeRegular :: CFRules -> CFRules
-makeRegular g = groupProds $ concatMap trSet (mutRecCats True g)
- where trSet cs | allXLinear cs rs = rs
- | otherwise = concatMap handleCat csl
- where csl = Set.toList cs
- rs = catSetRules g cs
- handleCat c = [CFRule c' [] (mkCFTerm (c++"-empty"))] -- introduce A' -> e
- ++ concatMap (makeRightLinearRules c) (catRules g c)
- where c' = newCat c
- makeRightLinearRules b' (CFRule c ss n) =
- case ys of
- [] -> newRule b' (xs ++ [Cat (newCat c)]) n -- no non-terminals left
- (Cat b:zs) -> newRule b' (xs ++ [Cat b]) n
- ++ makeRightLinearRules (newCat b) (CFRule c zs n)
- where (xs,ys) = break (`catElem` cs) ss
- -- don't add rules on the form A -> A
- newRule c rhs n | rhs == [Cat c] = []
- | otherwise = [CFRule c rhs n]
- newCat c = c ++ "$"
-
---
--- * CFG rule utilities
---
-
--- | Group productions by their lhs categories
-groupProds :: [CFRule_] -> CFRules
-groupProds = Map.fromListWith Set.union . map (\r -> (lhsCat r,Set.singleton r))
-
-allRules :: CFRules -> [CFRule_]
-allRules = concat . map Set.toList . Map.elems
-
-allRulesGrouped :: CFRules -> [(Cat_,[CFRule_])]
-allRulesGrouped = Map.toList . Map.map Set.toList
-
-allCats :: CFRules -> [Cat_]
-allCats = Map.keys
-
-catRules :: CFRules -> Cat_ -> [CFRule_]
-catRules rs c = Set.toList $ Map.findWithDefault Set.empty c rs
-
-catSetRules :: CFRules -> Set Cat_ -> [CFRule_]
-catSetRules g cs = allRules $ Map.filterWithKey (\c _ -> c `Set.member` cs) g
-
-cleanCFRules :: CFRules -> CFRules
-cleanCFRules = Map.filter (not . Set.null)
-
-unionCFRules :: CFRules -> CFRules -> CFRules
-unionCFRules = Map.unionWith Set.union
-
-filterCFRules :: (CFRule_ -> Bool) -> CFRules -> CFRules
-filterCFRules p = cleanCFRules . Map.map (Set.filter p)
-
-filterCFRulesCats :: (Cat_ -> Bool) -> CFRules -> CFRules
-filterCFRulesCats p = Map.filterWithKey (\c _ -> p c)
-
-countCats :: CFRules -> Int
-countCats = Map.size . cleanCFRules
-
-countRules :: CFRules -> Int
-countRules = length . allRules
-
-lhsCat :: CFRule c n t -> c
-lhsCat (CFRule c _ _) = c
-
-ruleRhs :: CFRule c n t -> [Symbol c t]
-ruleRhs (CFRule _ ss _) = ss
-
-ruleFun :: CFRule_ -> Fun
-ruleFun (CFRule _ _ t) = f t
- where f (CFObj n _) = n
- f (CFApp _ x) = f x
- f (CFAbs _ x) = f x
- f _ = IC ""
-
--- | Checks if a symbol is a non-terminal of one of the given categories.
-catElem :: Ord c => Symbol c t -> Set c -> Bool
-catElem s cs = symbol (`Set.member` cs) (const False) s
-
--- | Check if any of the categories used on the right-hand side
--- are in the given list of categories.
-anyUsedBy :: Eq c => [c] -> CFRule c n t -> Bool
-anyUsedBy cs (CFRule _ ss _) = any (`elem` cs) (filterCats ss)
-
-mkCFTerm :: String -> CFTerm
-mkCFTerm n = CFObj (IC n) []
-
-ruleIsNonRecursive :: Ord c => Set c -> CFRule c n t -> Bool
-ruleIsNonRecursive cs = noCatsInSet cs . ruleRhs
-
-noCatsInSet :: Ord c => Set c -> [Symbol c t] -> Bool
-noCatsInSet cs = not . any (`catElem` cs)
-
--- | Check if all the rules are right-linear, or all the rules are
--- left-linear, with respect to given categories.
-allXLinear :: Ord c => Set c -> [CFRule c n t] -> Bool
-allXLinear cs rs = all (isRightLinear cs) rs || all (isLeftLinear cs) rs
-
--- | Checks if a context-free rule is right-linear.
-isRightLinear :: Ord c =>
- Set c -- ^ The categories to consider
- -> CFRule c n t -- ^ The rule to check for right-linearity
- -> Bool
-isRightLinear cs = noCatsInSet cs . safeInit . ruleRhs
-
--- | Checks if a context-free rule is left-linear.
-isLeftLinear :: Ord c =>
- Set c -- ^ The categories to consider
- -> CFRule c n t -- ^ The rule to check for left-linearity
- -> Bool
-isLeftLinear cs = noCatsInSet cs . drop 1 . ruleRhs
-
-prCFRules :: CFRules -> String
-prCFRules = unlines . map prRule . allRules
- where
- prRule r = lhsCat r ++ " --> " ++ unwords (map prSym (ruleRhs r))
- prSym = symbol id (\t -> "\""++ t ++"\"")
diff --git a/src/GF/System/ATKSpeechInput.hs b/src/GF/System/ATKSpeechInput.hs
deleted file mode 100644
index 4b50293af..000000000
--- a/src/GF/System/ATKSpeechInput.hs
+++ /dev/null
@@ -1,137 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.System.ATKSpeechInput
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (non-portable)
---
--- > CVS $Date: 2005/05/10 15:04:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- Use ATK and Speech.ATKRec for speech input.
------------------------------------------------------------------------------
-
-module GF.System.ATKSpeechInput (recognizeSpeech) where
-
-import GF.Infra.Ident (Ident, prIdent)
-import GF.Infra.Option
-import GF.Conversion.Types (CGrammar)
-import GF.Speech.PrSLF
-
-import Speech.ATKRec
-
-import Control.Monad
-import Data.Maybe
-import Data.IORef
-import System.Environment
-import System.IO
-import System.IO.Unsafe
-
-data ATKLang = ATKLang {
- hmmlist :: FilePath,
- mmf0 :: FilePath,
- mmf1 :: FilePath,
- dict :: FilePath,
- opts :: [(String,String)]
- }
-
-atk_home_error = "The environment variable ATK_HOME is not set. "
- ++ "It should contain the path to your copy of ATK."
-
-gf_atk_cfg_error = "The environment variable GF_ATK_CFG is not set. "
- ++ "It should contain the path to your GF ATK configuration"
- ++ " file. A default version of this file can be found"
- ++ " in GF/src/gf_atk.cfg"
-
-getLanguage :: String -> IO ATKLang
-getLanguage l =
- case l of
- "en_UK" -> do
- atk_home <- getEnv_ "ATK_HOME" atk_home_error
- let res = atk_home ++ "/Resources"
- return $ ATKLang {
- hmmlist = res ++ "/UK_SI_ZMFCC/hmmlistbg",
- mmf0 = res ++ "/UK_SI_ZMFCC/WI4",
- mmf1 = res ++ "/UK_SI_ZMFCC/BGHMM2",
- dict = res ++ "/beep.dct",
- opts = [("TARGETKIND", "MFCC_0_D_A_Z"),
- ("HPARM:CMNDEFAULT", res ++ "/UK_SI_ZMFCC/cepmean")]
- }
- "sv_SE" -> do
- let res = "/home/bjorn/projects/atkswe/numerals-swe/final"
- return $ ATKLang {
- hmmlist = res ++ "/hmm_tri/hmmlist",
- mmf0 = res ++ "/hmm_tri/macros",
- mmf1 = res ++ "/hmm_tri/hmmdefs",
- dict = res ++ "/NumeralsSwe.dct",
- opts = [("TARGETKIND", "MFCC_0_D_A")]
- }
- _ -> fail $ "ATKSpeechInput: language " ++ l ++ " not supported"
-
--- | Current language for which we have loaded the HMM
--- and dictionary.
-{-# NOINLINE currentLang #-}
-currentLang :: IORef (Maybe String)
-currentLang = unsafePerformIO $ newIORef Nothing
-
--- | Initializes the ATK, loading the given language.
--- ATK must not be initialized when calling this function.
-loadLang :: String -> IO ()
-loadLang lang =
- do
- l <- getLanguage lang
- config <- getEnv_ "GF_ATK_CFG" gf_atk_cfg_error
- hPutStrLn stderr $ "Initializing ATK..."
- initialize (Just config) (opts l)
- let hmmName = "hmm_" ++ lang
- dictName = "dict_" ++ lang
- hPutStrLn stderr $ "Initializing ATK (" ++ lang ++ ")..."
- loadHMMSet hmmName (hmmlist l) (mmf0 l) (mmf1 l)
- loadDict dictName (dict l)
- writeIORef currentLang (Just lang)
-
-initATK :: String -> IO ()
-initATK lang =
- do
- ml <- readIORef currentLang
- case ml of
- Nothing -> loadLang lang
- Just l | l == lang -> return ()
- | otherwise -> do
- deinitialize
- loadLang lang
-
-recognizeSpeech :: Ident -- ^ Grammar name
- -> String -- ^ Language, e.g. en_UK
- -> CGrammar -- ^ Context-free grammar for input
- -> String -- ^ Start category name
- -> Int -- ^ Number of utterances
- -> IO [String]
-recognizeSpeech name language cfg start number =
- do
- let slf = slfPrinter name start cfg
- n = prIdent name
- hmmName = "hmm_" ++ language
- dictName = "dict_" ++ language
- slfName = "gram_" ++ n
- recName = "rec_" ++ language ++ "_" ++ n
- writeFile "debug.net" slf
- initATK language
- hPutStrLn stderr $ "Loading grammar " ++ n ++ " ..."
- loadGrammarString slfName slf
- createRecognizer recName hmmName dictName slfName
- hPutStrLn stderr $ "Listening in category " ++ start ++ "..."
- s <- replicateM number (recognize recName)
- return s
-
-
-getEnv_ :: String -- ^ Name of environment variable
- -> String -- ^ Message to fail with if the variable is not set.
- -> IO String
-getEnv_ e err =
- do
- env <- getEnvironment
- case lookup e env of
- Just v -> return v
- Nothing -> fail err
diff --git a/src/GF/System/Arch.hs b/src/GF/System/Arch.hs
deleted file mode 100644
index c0dac3644..000000000
--- a/src/GF/System/Arch.hs
+++ /dev/null
@@ -1,90 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Arch
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/05/10 14:55:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.8 $
---
--- architecture\/compiler dependent definitions for unix\/hbc
------------------------------------------------------------------------------
-
-module GF.System.Arch (
- myStdGen, prCPU, selectLater, modifiedFiles, ModTime, getModTime,getNowTime,
- welcomeArch, fetchCommand, laterModTime) where
-
-import System.Time
-import System.Random
-import System.CPUTime
-import Control.Monad (filterM)
-import System.Directory
-
-import GF.System.Readline (fetchCommand)
-
----- import qualified UnicodeF as U --(fudlogueWrite)
-
--- architecture/compiler dependent definitions for unix/hbc
-
-myStdGen :: Int -> IO StdGen ---
---- myStdGen _ = newStdGen --- gives always the same result
-myStdGen int0 = do
- t0 <- getClockTime
- cal <- toCalendarTime t0
- let int = int0 + ctSec cal + fromInteger (div (ctPicosec cal) 10000000)
- return $ mkStdGen int
-
-prCPU :: Integer -> IO Integer
-prCPU cpu = do
- cpu' <- getCPUTime
- putStrLn (show ((cpu' - cpu) `div` 1000000000) ++ " msec")
- return cpu'
-
-welcomeArch :: String
-welcomeArch = "This is the system compiled with ghc."
-
--- | selects the one with the later modification time of two
-selectLater :: FilePath -> FilePath -> IO FilePath
-selectLater x y = do
- ex <- doesFileExist x
- if not ex
- then return y --- which may not exist
- else do
- ey <- doesFileExist y
- if not ey
- then return x
- else do
- tx <- getModificationTime x
- ty <- getModificationTime y
- return $ if tx < ty then y else x
-
--- | a file is considered modified also if it has not been read yet
---
--- new 23\/2\/2004: the environment ofs has just module names
-modifiedFiles :: [(FilePath,ModTime)] -> [FilePath] -> IO [FilePath]
-modifiedFiles ofs fs = do
- filterM isModified fs
- where
- isModified file = case lookup (justModName file) ofs of
- Just to -> do
- t <- getModificationTime file
- return $ to < t
- _ -> return True
-
- justModName =
- reverse . takeWhile (/='/') . tail . dropWhile (/='.') . reverse
-
-type ModTime = ClockTime
-
-laterModTime :: ModTime -> ModTime -> Bool
-laterModTime = (>)
-
-getModTime :: FilePath -> IO (Maybe ModTime)
-getModTime f = do
- b <- doesFileExist f
- if b then (getModificationTime f >>= return . Just) else return Nothing
-
-getNowTime :: IO ModTime
-getNowTime = getClockTime
diff --git a/src/GF/System/ArchEdit.hs b/src/GF/System/ArchEdit.hs
deleted file mode 100644
index 39b558cef..000000000
--- a/src/GF/System/ArchEdit.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : ArchEdit
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:46:15 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.System.ArchEdit (
- fudlogueEdit, fudlogueWrite, fudlogueWriteUni
- ) where
-
-fudlogueEdit :: a -> b -> IO ()
-fudlogueEdit _ _ = do
- putStrLn "sorry no fudgets available in Hugs"
- return ()
-
-fudlogueWrite :: a -> b -> IO ()
-fudlogueWrite _ _ = do
- putStrLn "sorry no fudgets available in Hugs"
-
-fudlogueWriteUni :: a -> b -> IO ()
-fudlogueWriteUni _ _ = do
- putStrLn "sorry no fudgets available in Hugs"
diff --git a/src/GF/System/NoReadline.hs b/src/GF/System/NoReadline.hs
deleted file mode 100644
index 138ba4e28..000000000
--- a/src/GF/System/NoReadline.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.System.NoReadline
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/05/10 15:04:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.1 $
---
--- Do not use readline.
------------------------------------------------------------------------------
-
-module GF.System.NoReadline (fetchCommand) where
-
-import System.IO.Error (try)
-import System.IO (stdout,hFlush)
-
-fetchCommand :: String -> IO (String)
-fetchCommand s = do
- putStr s
- hFlush stdout
- res <- try getLine
- case res of
- Left e -> return "q"
- Right l -> return l
diff --git a/src/GF/System/NoSignal.hs b/src/GF/System/NoSignal.hs
deleted file mode 100644
index 5d82a431e..000000000
--- a/src/GF/System/NoSignal.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.System.NoSignal
--- Maintainer : Bjorn Bringert
--- Stability : (stability)
--- Portability : (portability)
---
--- > CVS $Date: 2005/11/11 11:12:50 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.1 $
---
--- Dummy implementation of signal handling.
------------------------------------------------------------------------------
-
-module GF.System.NoSignal where
-
-import Control.Exception (Exception,catch)
-import Prelude hiding (catch)
-
-{-# NOINLINE runInterruptibly #-}
-runInterruptibly :: IO a -> IO (Either Exception a)
---runInterruptibly = fmap Right
-runInterruptibly a =
- p `catch` h
- where p = a >>= \x -> return $! Right $! x
- h e = return $ Left e
-
-blockInterrupt :: IO a -> IO a
-blockInterrupt = id
diff --git a/src/GF/System/NoSpeechInput.hs b/src/GF/System/NoSpeechInput.hs
deleted file mode 100644
index 04197ce92..000000000
--- a/src/GF/System/NoSpeechInput.hs
+++ /dev/null
@@ -1,28 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.System.NoSpeechInput
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/05/10 15:04:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- Dummy speech input.
------------------------------------------------------------------------------
-
-module GF.System.NoSpeechInput (recognizeSpeech) where
-
-import GF.Infra.Ident (Ident)
-import GF.Infra.Option (Options)
-import GF.Conversion.Types (CGrammar)
-
-
-recognizeSpeech :: Ident -- ^ Grammar name
- -> String -- ^ Language, e.g. en_UK
- -> CGrammar -- ^ Context-free grammar for input
- -> String -- ^ Start category name
- -> Int -- ^ Number of utterances
- -> IO [String]
-recognizeSpeech _ _ _ _ _ = fail "No speech input available"
diff --git a/src/GF/System/Readline.hs b/src/GF/System/Readline.hs
deleted file mode 100644
index c12493f98..000000000
--- a/src/GF/System/Readline.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-# OPTIONS -cpp #-}
-
-----------------------------------------------------------------------
--- |
--- Module : GF.System.Readline
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/05/10 15:04:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- Uses the right readline library to read user input.
------------------------------------------------------------------------------
-
-module GF.System.Readline (fetchCommand) where
-
-#ifdef USE_READLINE
-
-import GF.System.UseReadline (fetchCommand)
-
-#else
-
-import GF.System.NoReadline (fetchCommand)
-
-#endif
diff --git a/src/GF/System/Signal.hs b/src/GF/System/Signal.hs
deleted file mode 100644
index fe8a12483..000000000
--- a/src/GF/System/Signal.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-# OPTIONS -cpp #-}
-
-----------------------------------------------------------------------
--- |
--- Module : GF.System.Signal
--- Maintainer : Bjorn Bringert
--- Stability : (stability)
--- Portability : (portability)
---
--- > CVS $Date: 2005/11/11 11:12:50 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.3 $
---
--- Import the right singal handling module.
------------------------------------------------------------------------------
-
-module GF.System.Signal (runInterruptibly,blockInterrupt) where
-
-#ifdef USE_INTERRUPT
-
-import GF.System.UseSignal (runInterruptibly,blockInterrupt)
-
-#else
-
-import GF.System.NoSignal (runInterruptibly,blockInterrupt)
-
-#endif
diff --git a/src/GF/System/SpeechInput.hs b/src/GF/System/SpeechInput.hs
deleted file mode 100644
index 6c2374473..000000000
--- a/src/GF/System/SpeechInput.hs
+++ /dev/null
@@ -1,27 +0,0 @@
-{-# OPTIONS -cpp #-}
-
-----------------------------------------------------------------------
--- |
--- Module : GF.System.SpeechInput
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/05/10 15:04:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- Uses the right speech recognition library for speech input.
------------------------------------------------------------------------------
-
-module GF.System.SpeechInput (recognizeSpeech) where
-
-#ifdef USE_ATK
-
-import GF.System.ATKSpeechInput (recognizeSpeech)
-
-#else
-
-import GF.System.NoSpeechInput (recognizeSpeech)
-
-#endif
diff --git a/src/GF/System/Tracing.hs b/src/GF/System/Tracing.hs
deleted file mode 100644
index 71bacfb75..000000000
--- a/src/GF/System/Tracing.hs
+++ /dev/null
@@ -1,73 +0,0 @@
-{-# OPTIONS -cpp #-}
-
-----------------------------------------------------------------------
--- |
--- Maintainer : PL
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/26 09:54:11 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.4 $
---
--- Tracing utilities for debugging purposes.
--- If the CPP symbol TRACING is set, then the debugging output is shown.
------------------------------------------------------------------------------
-
-
-module GF.System.Tracing
- (trace, trace2, traceM, traceCall, tracePrt, traceCalcFirst) where
-
-import qualified Debug.Trace as Trace
-
--- | emit a string inside braces, before(?) calculating the value:
--- @{str}@
-trace :: String -> a -> a
-
--- | emit function name and debugging output:
--- @{fun: out}@
-trace2 :: String -> String -> a -> a
-
--- | monadic version of 'trace2'
-traceM :: Monad m => String -> String -> m ()
-
--- | show when a value is starting to be calculated (with a '+'),
--- and when it is finished (with a '-')
-traceCall :: String -> String -> (a -> String) -> a -> a
-
--- | showing the resulting value (filtered through a printing function):
--- @{fun: value}@
-tracePrt :: String -> (a -> String) -> a -> a
-
--- | this is equivalent to 'seq' when tracing, but
--- just skips the first argument otherwise
-traceCalcFirst :: a -> b -> b
-
-#if TRACING
-trace str a = Trace.trace (bold ++ "{" ++ normal ++ str ++ bold ++ "}" ++ normal) a
-trace2 fun str a = trace (bold ++ fgcol 1 ++ fun ++ ": " ++ normal ++ str) a
-traceM fun str = trace2 fun str (return ())
-traceCall fun start prt val
- = trace2 ("+" ++ fun) start $
- val `seq` trace2 ("-" ++ fun) (prt val) val
-tracePrt mod prt val = val `seq` trace2 mod (prt val) val
-traceCalcFirst = seq
-
-#else
-trace _ = id
-trace2 _ _ = id
-traceM _ _ = return ()
-traceCall _ _ _ = id
-tracePrt _ _ = id
-traceCalcFirst _ = id
-
-#endif
-
-
-escape = "\ESC"
-highlight = escape ++ "[7m"
-bold = escape ++ "[1m"
-underline = escape ++ "[4m"
-normal = escape ++ "[0m"
-fgcol col = escape ++ "[0" ++ show (30+col) ++ "m"
-bgcol col = escape ++ "[0" ++ show (40+col) ++ "m"
diff --git a/src/GF/System/UseReadline.hs b/src/GF/System/UseReadline.hs
deleted file mode 100644
index c84b9d7f4..000000000
--- a/src/GF/System/UseReadline.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.System.UseReadline
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/05/10 15:04:01 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.1 $
---
--- Use GNU readline
------------------------------------------------------------------------------
-
-module GF.System.UseReadline (fetchCommand) where
-
-import System.Console.Readline (readline, addHistory)
-
-fetchCommand :: String -> IO (String)
-fetchCommand s = do
- res <- readline s
- case res of
- Nothing -> return "q"
- Just s -> do addHistory s
- return s
diff --git a/src/GF/System/UseSignal.hs b/src/GF/System/UseSignal.hs
deleted file mode 100644
index 5e6d81237..000000000
--- a/src/GF/System/UseSignal.hs
+++ /dev/null
@@ -1,58 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GF.System.UseSignal
--- Maintainer : Bjorn Bringert
--- Stability : (stability)
--- Portability : (portability)
---
--- > CVS $Date: 2005/11/11 11:12:50 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.1 $
---
--- Allows SIGINT (Ctrl-C) to interrupt computations.
------------------------------------------------------------------------------
-
-module GF.System.UseSignal where
-
-import Control.Concurrent (myThreadId, killThread)
-import Control.Exception (Exception,catch)
-import Prelude hiding (catch)
-import System.IO
-import System.Posix.Signals
-
-{-# NOINLINE runInterruptibly #-}
-
--- | Run an IO action, and allow it to be interrupted
--- by a SIGINT to the current process. Returns
--- an exception if the process did not complete
--- normally.
--- NOTES:
--- * This will replace any existing SIGINT
--- handler during the action. After the computation
--- has completed the existing handler will be restored.
--- * If the IO action is lazy (e.g. using readFile,
--- unsafeInterleaveIO etc.) the lazy computation will
--- not be interruptible, as it will be performed
--- after the signal handler has been removed.
-runInterruptibly :: IO a -> IO (Either Exception a)
-runInterruptibly a =
- do t <- myThreadId
- oldH <- installHandler sigINT (Catch (killThread t)) Nothing
- x <- p `catch` h
- installHandler sigINT oldH Nothing
- return x
- where p = a >>= \x -> return $! Right $! x
- h e = return $ Left e
-
--- | Like 'runInterruptibly', but always returns (), whether
--- the computation fails or not.
-runInterruptibly_ :: IO () -> IO ()
-runInterruptibly_ = fmap (either (const ()) id) . runInterruptibly
-
--- | Run an action with SIGINT blocked.
-blockInterrupt :: IO a -> IO a
-blockInterrupt a =
- do oldH <- installHandler sigINT Ignore Nothing
- x <- a
- installHandler sigINT oldH Nothing
- return x
diff --git a/src/GF/Text/Arabic.hs b/src/GF/Text/Arabic.hs
deleted file mode 100644
index c482b1172..000000000
--- a/src/GF/Text/Arabic.hs
+++ /dev/null
@@ -1,63 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Arabic
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:34 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.6 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Arabic (mkArabic) where
-
-mkArabic :: String -> String
-mkArabic = unwords . (map mkArabicWord) . words
-----mkArabic = reverse . unwords . (map mkArabicWord) . words
---- reverse : assumes everything's on same line
-
-type ArabicChar = Char
-
-mkArabicWord :: String -> [ArabicChar]
-mkArabicWord = map mkArabicChar . getLetterPos
-
-getLetterPos :: String -> [(Char,Int)]
-getLetterPos [] = []
-getLetterPos ('I':cs) = ('*',7) : getLetterPos cs -- 0xfe80
-getLetterPos ('O':cs) = ('*',8) : getIn cs -- 0xfe8b
-getLetterPos ('l':'a':cs) = ('*',5) : getLetterPos cs -- 0xfefb
-getLetterPos [c] = [(c,1)] -- 1=isolated
-getLetterPos (c:cs) | isReduced c = (c,1) : getLetterPos cs
-getLetterPos (c:cs) = (c,3) : getIn cs -- 3=initial
-
-
-getIn [] = []
-getIn ('I':cs) = ('*',7) : getLetterPos cs -- 0xfe80
-getIn ('O':cs) = ('*',9) : getIn cs -- 0xfe8c
-getIn ('l':'a':cs) = ('*',6) : getLetterPos cs -- 0xfefc
-getIn [c] = [(c,2)] -- 2=final
-getIn (c:cs) | isReduced c = (c,2) : getLetterPos cs
-getIn (c:cs) = (c,4) : getIn cs -- 4=medial
-
-isReduced :: Char -> Bool
-isReduced c = c `elem` "UuWiYOaAdVrzwj"
-
-mkArabicChar ('*',p) | p > 4 && p < 10 =
- (map toEnum [0xfefb,0xfefc,0xfe80,0xfe8b,0xfe8c]) !! (p-5)
-mkArabicChar cp@(c,p) = case lookup c cc of Just c' -> (c' !! (p-1)) ; _ -> c
- where
- cc = mkArabicTab allArabicCodes allArabic
-
-mkArabicTab (c:cs) as = (c,as1) : mkArabicTab cs as2 where
- (as1,as2) = if isReduced c then splitAt 2 as else splitAt 4 as
-mkArabicTab [] _ = []
-
-allArabicCodes = "UuWiYOabAtvgHCdVrzscSDTZoxfqklmnhwjy"
-
-allArabic :: String
-allArabic = (map toEnum [0xfe81 .. 0xfef4]) -- I=0xfe80
-
-
diff --git a/src/GF/Text/Devanagari.hs b/src/GF/Text/Devanagari.hs
deleted file mode 100644
index bf4343cd0..000000000
--- a/src/GF/Text/Devanagari.hs
+++ /dev/null
@@ -1,97 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Devanagari
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:34 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Devanagari (mkDevanagari) where
-
-mkDevanagari :: String -> String
-mkDevanagari = digraphWordToUnicode . adHocToDigraphWord
-
-adHocToDigraphWord :: String -> [(Char, Char)]
-adHocToDigraphWord str = case str of
- [] -> []
- '<' : cs -> ('\\', '<') : spoolMarkup cs
- ' ' : cs -> ('\\', ' ') : adHocToDigraphWord cs -- skip space
-
--- if c1 is a vowel
- -- Two of the same vowel => lengthening
- c1 : c2 : cs | c1 == c2 && isVowel c1 -> (cap c1, ':') : adHocToDigraphWord cs
- -- digraphed or long vowel
- c1 : c2 : cs | isVowel c1 && isVowel c2 -> (cap c1, cap c2) : adHocToDigraphWord cs
- c1 : cs | isVowel c1 -> (' ', cap c1) : adHocToDigraphWord cs
-
--- c1 isn't a vowel
- -- c1 : 'a' : [] -> [(' ', c1)] -- a inherent
- -- c1 : c2 : [] | isVowel c2 -> (' ', c1) : [(' ', c2)]
-
- -- c1 is aspirated
- c1 : 'H' : c2 : c3 : cs | c2 == c3 && isVowel c2 ->
- (c1, 'H') : (c2, ':') : adHocToDigraphWord cs
- c1 : 'H' : c2 : c3 : cs | isVowel c2 && isVowel c3 ->
- (c1, 'H') : (c2, c3) : adHocToDigraphWord cs
- c1 : 'H' : 'a' : cs -> (c1, 'H') : adHocToDigraphWord cs -- a inherent
- c1 : 'H' : c2 : cs | isVowel c2 -> (c1, 'H') : (' ', c2) : adHocToDigraphWord cs
- -- not vowelless at EOW
- c1 : 'H' : ' ' : cs -> (c1, 'H') : ('\\', ' ') : adHocToDigraphWord cs
- c1 : 'H' : [] -> [(c1, 'H')]
- c1 : 'H' : cs -> (c1, 'H') : (' ', '^') : adHocToDigraphWord cs -- vowelless
-
- -- c1 unasp.
- c1 : c2 : c3 : cs | c2 == c3 && isVowel c2 -> (' ', c1) : (c2, ':') : adHocToDigraphWord cs
- c1 : c2 : c3 : cs | isVowel c2 && isVowel c3 -> (' ', c1) : (c2, c3) : adHocToDigraphWord cs
- c1 : 'a' : cs -> (' ', c1) : adHocToDigraphWord cs -- a inherent
- c1 : c2 : cs | isVowel c2 -> (' ', c1) : (' ', c2) : adHocToDigraphWord cs
- -- not vowelless at EOW
- c1 : ' ' : cs -> (' ', c1) : ('\\', ' '): adHocToDigraphWord cs
- c1 : [] -> [(' ', c1)]
- 'M' : cs -> (' ', 'M') : adHocToDigraphWord cs -- vowelless but no vowelless sign for anusvara
- c1 : cs -> (' ', c1) : (' ', '^') : adHocToDigraphWord cs -- vowelless
-
-isVowel x = elem x "aeiou:"
-cap :: Char -> Char
-cap x = case x of
- 'a' -> 'A'
- 'e' -> 'E'
- 'i' -> 'I'
- 'o' -> 'O'
- 'u' -> 'U'
- c -> c
-
-spoolMarkup :: String -> [(Char, Char)]
-spoolMarkup s = case s of
- -- [] -> [] -- Shouldn't happen
- '>' : cs -> ('\\', '>') : adHocToDigraphWord cs
- c1 : cs -> ('\\', c1) : spoolMarkup cs
-
-
-digraphWordToUnicode :: [(Char, Char)] -> String
-digraphWordToUnicode = map digraphToUnicode
-
-digraphToUnicode :: (Char, Char) -> Char
-digraphToUnicode (c1, c2) = case lookup (c1, c2) cc of Just c' -> c' ; _ -> c2
- where
- cc = zip allDevanagariCodes allDevanagari
-
-digraphedDevanagari = " ~ M ;__ AA: II: UU:RoLoEvE~ EE:AvA~ OAU kkH ggHNG ccH jjH \241 TTH DDH N ttH ddH nn. ppH bbH m y rr. l LL. v \231 S s h____ .-Sa: ii: uu:ror:eve~ eaiava~ oau ^____OM | -dddu______ Q X G zD.RH fy.R:L:mrmR#I#d#0#1#2#3#4#5#6#7#8#9#o"
-
-allDevanagariCodes :: [(Char, Char)]
-allDevanagariCodes = mkPairs digraphedDevanagari
-
-allDevanagari :: String
-allDevanagari = (map toEnum [0x0901 .. 0x0970])
-
-mkPairs :: String -> [(Char, Char)]
-mkPairs str = case str of
- [] -> []
- c1 : c2 : cs -> (c1, c2) : mkPairs cs
-
diff --git a/src/GF/Text/Ethiopic.hs b/src/GF/Text/Ethiopic.hs
deleted file mode 100644
index 81abbf719..000000000
--- a/src/GF/Text/Ethiopic.hs
+++ /dev/null
@@ -1,72 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Ethiopic
--- Maintainer : HH
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:35 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.6 $
---
--- Ascii-Unicode decoding for Ethiopian.
--- Copyright (c) Harald Hammarström 2003 under Gnu General Public License
------------------------------------------------------------------------------
-
-module GF.Text.Ethiopic (mkEthiopic) where
-
-mkEthiopic :: String -> String
-mkEthiopic = digraphWordToUnicode . adHocToDigraphWord
-
--- mkEthiopic :: String -> String
--- mkEthiopic = reverse . unwords . (map (digraphWordToUnicode . adHocToDigraphWord)) . words
---- reverse : assumes everything's on same line
-
-adHocToDigraphWord :: String -> [(Char, Int)]
-adHocToDigraphWord str = case str of
- [] -> []
- '<' : cs -> ('<', -1) : spoolMarkup cs
- c1 : cs | isVowel c1 -> (')', vowelOrder c1) : adHocToDigraphWord cs
- -- c1 isn't a vowel
- c1 : cs | not (elem c1 allEthiopicCodes) -> (c1, -1) : adHocToDigraphWord cs
- c1 : c2 : cs | isVowel c2 -> (c1, vowelOrder c2) : adHocToDigraphWord cs
- c1 : cs -> (c1, 5) : adHocToDigraphWord cs
-
-spoolMarkup :: String -> [(Char, Int)]
-spoolMarkup s = case s of
- -- [] -> [] -- Shouldn't happen
- '>' : cs -> ('>', -1) : adHocToDigraphWord cs
- c1 : cs -> (c1, -1) : spoolMarkup cs
-
-isVowel x = elem x "A\228ui\239aeoI"
-
-vowelOrder :: Char -> Int
-vowelOrder x = case x of
- 'A' -> 0
- '\228' -> 0 -- ä
- 'u' -> 1
- 'i' -> 2
- 'a' -> 3
- 'e' -> 4
- 'I' -> 5
- '\239' -> 5 -- ï
- 'o' -> 6
- c -> 5 -- vowelless
-
-digraphWordToUnicode = map digraphToUnicode
-
-digraphToUnicode :: (Char, Int) -> Char
--- digraphToUnicode (c1, c2) = c1
-
-digraphToUnicode (c1, -1) = c1
-digraphToUnicode (c1, c2) = toEnum (0x1200 + c2 + 8*case lookup c1 cc of Just c' -> c')
- where
- cc = zip allEthiopicCodes allEthiopic
-
-allEthiopic :: [Int]
-allEthiopic = [0 .. 44] -- x 8
-
-allEthiopicCodes = "hlHmLrs$KQ__bBtcxXnN)kW__w(zZyd_jgG_TCPSLfp"
-
--- Q = kW, X = xW, W = kW, G = gW
-
diff --git a/src/GF/Text/ExtendedArabic.hs b/src/GF/Text/ExtendedArabic.hs
deleted file mode 100644
index d2c5faac5..000000000
--- a/src/GF/Text/ExtendedArabic.hs
+++ /dev/null
@@ -1,99 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : ExtendedArabic
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:36 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.6 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.ExtendedArabic (mkArabic0600, mkExtendedArabic) where
-
-mkArabic0600 :: String -> String
-mkArabic0600 = digraphWordToUnicode . aarnesToDigraphWord
-
-aarnesToDigraphWord :: String -> [(Char, Char)]
-aarnesToDigraphWord str = case str of
- [] -> []
- '<' : cs -> ('\\', '<') : spoolMarkup2 cs
-
- 'v' : cs -> ('T', 'H') : aarnesToDigraphWord cs
- 'a' : cs -> (' ', 'A') : aarnesToDigraphWord cs
- 'o' : cs -> (' ', '3') : aarnesToDigraphWord cs
- 'O' : cs -> ('\'', 'i') : aarnesToDigraphWord cs
-
- 'u' : cs -> ('\'', 'A') : aarnesToDigraphWord cs
- 'C' : cs -> (' ', 'X') : aarnesToDigraphWord cs
-
- 'U' : cs -> ('~', 'A') : aarnesToDigraphWord cs
- 'A' : cs -> ('"', 't') : aarnesToDigraphWord cs
- 'c' : cs -> ('s', 'h') : aarnesToDigraphWord cs
- c : cs -> (' ', c) : aarnesToDigraphWord cs
-
-mkExtendedArabic :: String -> String
-mkExtendedArabic = digraphWordToUnicode . adHocToDigraphWord
-
-adHocToDigraphWord :: String -> [(Char, Char)]
-adHocToDigraphWord str = case str of
- [] -> []
- '<' : cs -> ('\\', '<') : spoolMarkup cs
- -- Sorani
- 'W' : cs -> (':', 'w') : adHocToDigraphWord cs -- ?? Will do
- 'E' : cs -> (' ', 'i') : adHocToDigraphWord cs -- ?? Letter missing!
- 'j' : cs -> ('d', 'j') : adHocToDigraphWord cs
- 'O' : cs -> ('v', 'w') : adHocToDigraphWord cs
- 'F' : cs -> (' ', 'v') : adHocToDigraphWord cs
- 'Z' : cs -> ('z', 'h') : adHocToDigraphWord cs
- 'I' : cs -> (' ', 'i') : adHocToDigraphWord cs -- ?? Letter missing!
- 'C' : cs -> ('c', 'h') : adHocToDigraphWord cs
- -- Pashto
- 'e' : cs -> (':', 'y') : adHocToDigraphWord cs
- '$' : cs -> ('3', 'H') : adHocToDigraphWord cs
- 'X' : cs -> ('s', '.') : adHocToDigraphWord cs
- 'G' : cs -> ('z', '.') : adHocToDigraphWord cs
- 'a' : cs -> (' ', 'A') : adHocToDigraphWord cs
- 'P' : cs -> ('\'', 'H') : adHocToDigraphWord cs
- 'R' : cs -> ('o', 'r') : adHocToDigraphWord cs
- -- Shared
- 'A' : cs -> (' ', 'h') : adHocToDigraphWord cs -- ?? Maybe to "t or 0x06d5
- 'c' : cs -> ('s', 'h') : adHocToDigraphWord cs
- c : cs -> (' ', c) : adHocToDigraphWord cs
-
-
--- Beginning 0x621 up and including 0x06d1
-digraphedExtendedArabic = " '~A'A'w,A'i A b\"t tTHdj H X dDH r z ssh S D T Z 3GH__________ - f q k l m n h w i y&a&w&i/a/w/i/W/o/~/'/,/|/6/v_____________#0#1#2#3#4#5#6#7#8#9#%#,#'#*>b>q$|> A2'2,3'A'w'w&y'Tb:b:BoT3b p4b4B'H:H2H\"H3Hch4HTdod.dTD:d:D3d3D4dTrvror.rvRz.:rzh4zs.+s*S:S3S3T33>ff.f: v4f.q3q-k~kok.k3k3K gog:g:G3Gvl.l3l3L:n>nTnon3n?h4H't>Y\"Yow-wvwww|w^w:w3w>y/yvy.w:y3y____ -ae"
-
-digraphWordToUnicode = map digraphToUnicode
-
-digraphToUnicode :: (Char, Char) -> Char
-digraphToUnicode (c1, c2) = case lookup (c1, c2) cc of Just c' -> c' ; _ -> c2
- where
- cc = zip allExtendedArabicCodes allExtendedArabic
-
-allExtendedArabicCodes :: [(Char, Char)]
-allExtendedArabicCodes = mkPairs digraphedExtendedArabic
-
-allExtendedArabic :: String
-allExtendedArabic = (map toEnum [0x0621 .. 0x06d1])
-
-mkPairs :: String -> [(Char, Char)]
-mkPairs str = case str of
- [] -> []
- c1 : c2 : cs -> (c1, c2) : mkPairs cs
-
-spoolMarkup :: String -> [(Char, Char)]
-spoolMarkup s = case s of
- [] -> [] -- Shouldn't happen
- '>' : cs -> ('\\', '>') : adHocToDigraphWord cs
- c1 : cs -> ('\\', c1) : spoolMarkup cs
-
-spoolMarkup2 :: String -> [(Char, Char)]
-spoolMarkup2 s = case s of
- [] -> [] -- Shouldn't happen
- '>' : cs -> ('\\', '>') : aarnesToDigraphWord cs
- c1 : cs -> ('\\', c1) : spoolMarkup2 cs
diff --git a/src/GF/Text/ExtraDiacritics.hs b/src/GF/Text/ExtraDiacritics.hs
deleted file mode 100644
index f3d811c2c..000000000
--- a/src/GF/Text/ExtraDiacritics.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : ExtraDiacritics
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:36 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.ExtraDiacritics (mkExtraDiacritics) where
-
-mkExtraDiacritics :: String -> String
-mkExtraDiacritics = mkExtraDiacriticsWord
-
-mkExtraDiacriticsWord :: String -> String
-mkExtraDiacriticsWord str = case str of
- [] -> []
- '<' : cs -> '<' : spoolMarkup cs
- --
- '/' : cs -> toEnum 0x0301 : mkExtraDiacriticsWord cs
- '~' : cs -> toEnum 0x0306 : mkExtraDiacriticsWord cs
- ':' : cs -> toEnum 0x0304 : mkExtraDiacriticsWord cs -- some of these could be put in LatinA
- '.' : cs -> toEnum 0x0323 : mkExtraDiacriticsWord cs
- 'i' : '-' : cs -> toEnum 0x0268 : mkExtraDiacriticsWord cs -- in IPA extensions
- -- Default
- c : cs -> c : mkExtraDiacriticsWord cs
-
-spoolMarkup :: String -> String
-spoolMarkup s = case s of
- [] -> [] -- Shouldn't happen
- '>' : cs -> '>' : mkExtraDiacriticsWord cs
- c1 : cs -> c1 : spoolMarkup cs
diff --git a/src/GF/Text/Greek.hs b/src/GF/Text/Greek.hs
deleted file mode 100644
index 6b9361a29..000000000
--- a/src/GF/Text/Greek.hs
+++ /dev/null
@@ -1,172 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Greek
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:37 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Greek (mkGreek) where
-
-mkGreek :: String -> String
-mkGreek = unwords . (map mkGreekWord) . mkGravis . words
-
---- TODO : optimize character formation by factorizing the case expressions
-
-type GreekChar = Char
-
-mkGreekWord :: String -> [GreekChar]
-mkGreekWord = map (toEnum . mkGreekChar) . mkGreekSpec
-
-mkGravis :: [String] -> [String]
-mkGravis [] = []
-mkGravis [w] = [w]
-mkGravis (w1:w2:ws)
- | stressed w2 = mkG w1 : mkGravis (w2:ws)
- | otherwise = w1 : w2 : mkGravis ws
- where
- stressed w = any (`elem` "'~`") w
- mkG :: String -> String
- mkG w = let (w1,w2) = span (/='\'') w in
- case w2 of
- '\'':v:cs | not (any isVowel cs) -> w1 ++ "`" ++ [v] ++ cs
- '\'':'!':v:cs | not (any isVowel cs) -> w1 ++ "`!" ++ [v] ++ cs
- _ -> w
- isVowel c = elem c "aehiouw"
-
-mkGreekSpec :: String -> [(Char,Int)]
-mkGreekSpec str = case str of
- [] -> []
- '(' :'\'': '!' : c : cs -> (c,25) : mkGreekSpec cs
- '(' :'~' : '!' : c : cs -> (c,27) : mkGreekSpec cs
- '(' :'`' : '!' : c : cs -> (c,23) : mkGreekSpec cs
- '(' : '!' : c : cs -> (c,21) : mkGreekSpec cs
- ')' :'\'': '!' : c : cs -> (c,24) : mkGreekSpec cs
- ')' :'~' : '!' : c : cs -> (c,26) : mkGreekSpec cs
- ')' :'`' : '!' : c : cs -> (c,22) : mkGreekSpec cs
- ')' : '!' : c : cs -> (c,20) : mkGreekSpec cs
- '\'': '!' : c : cs -> (c,30) : mkGreekSpec cs
- '~' : '!' : c : cs -> (c,31) : mkGreekSpec cs
- '`' : '!' : c : cs -> (c,32) : mkGreekSpec cs
- '!' : c : cs -> (c,33) : mkGreekSpec cs
- '(' :'\'': c : cs -> (c,5) : mkGreekSpec cs
- '(' :'~' : c : cs -> (c,7) : mkGreekSpec cs
- '(' :'`' : c : cs -> (c,3) : mkGreekSpec cs
- '(' : c : cs -> (c,1) : mkGreekSpec cs
- ')' :'\'': c : cs -> (c,4) : mkGreekSpec cs
- ')' :'~' : c : cs -> (c,6) : mkGreekSpec cs
- ')' :'`' : c : cs -> (c,2) : mkGreekSpec cs
- ')' : c : cs -> (c,0) : mkGreekSpec cs
- '\'': c : cs -> (c,10) : mkGreekSpec cs
- '~' : c : cs -> (c,11) : mkGreekSpec cs
- '`' : c : cs -> (c,12) : mkGreekSpec cs
- c : cs -> (c,-1) : mkGreekSpec cs
-
-mkGreekChar (c,-1) = case lookup c cc of Just c' -> c' ; _ -> fromEnum c
- where
- cc = zip "abgdezhqiklmnxoprjstyfcuw" allGreekMin
-mkGreekChar (c,n) = case (c,n) of
- ('a',10) -> 0x03ac
- ('a',11) -> 0x1fb6
- ('a',12) -> 0x1f70
- ('a',30) -> 0x1fb4
- ('a',31) -> 0x1fb7
- ('a',32) -> 0x1fb2
- ('a',33) -> 0x1fb3
- ('a',n) | n >19 -> 0x1f80 + n - 20
- ('a',n) -> 0x1f00 + n
- ('e',10) -> 0x03ad -- '
--- ('e',11) -> 0x1fb6 -- ~ can't happen
- ('e',12) -> 0x1f72 -- `
- ('e',n) -> 0x1f10 + n
- ('h',10) -> 0x03ae -- '
- ('h',11) -> 0x1fc6 -- ~
- ('h',12) -> 0x1f74 -- `
-
- ('h',30) -> 0x1fc4
- ('h',31) -> 0x1fc7
- ('h',32) -> 0x1fc2
- ('h',33) -> 0x1fc3
- ('h',n) | n >19 -> 0x1f90 + n - 20
-
- ('h',n) -> 0x1f20 + n
- ('i',10) -> 0x03af -- '
- ('i',11) -> 0x1fd6 -- ~
- ('i',12) -> 0x1f76 -- `
- ('i',n) -> 0x1f30 + n
- ('o',10) -> 0x03cc -- '
--- ('o',11) -> 0x1fb6 -- ~ can't happen
- ('o',12) -> 0x1f78 -- `
- ('o',n) -> 0x1f40 + n
- ('y',10) -> 0x03cd -- '
- ('y',11) -> 0x1fe6 -- ~
- ('y',12) -> 0x1f7a -- `
- ('y',n) -> 0x1f50 + n
- ('w',10) -> 0x03ce -- '
- ('w',11) -> 0x1ff6 -- ~
- ('w',12) -> 0x1f7c -- `
-
- ('w',30) -> 0x1ff4
- ('w',31) -> 0x1ff7
- ('w',32) -> 0x1ff2
- ('w',33) -> 0x1ff3
- ('w',n) | n >19 -> 0x1fa0 + n - 20
-
- ('w',n) -> 0x1f60 + n
- ('r',1) -> 0x1fe5
- _ -> mkGreekChar (c,-1) --- should not happen
-
-allGreekMin :: [Int]
-allGreekMin = [0x03b1 .. 0x03c9]
-
-
-{-
-encoding of Greek writing. Those hard to guess are marked with ---
-
- maj min
-A a Alpha 0391 03b1
-B b Beta 0392 03b2
-G g Gamma 0393 03b3
-D d Delta 0394 03b4
-E e Epsilon 0395 03b5
-Z z Zeta 0396 03b6
-H h Eta --- 0397 03b7
-Q q Theta --- 0398 03b8
-I i Iota 0399 03b9
-K k Kappa 039a 03ba
-L l Lambda 039b 03bb
-M m My 039c 03bc
-N n Ny 039d 03bd
-X x Xi 039e 03be
-O o Omikron 039f 03bf
-P p Pi 03a0 03c0
-R r Rho 03a1 03c1
- j Sigma --- 03c2
-S s Sigma 03a3 03c3
-T t Tau 03a4 03c4
-Y y Ypsilon 03a5 03c5
-F f Phi 03a6 03c6
-C c Khi --- 03a7 03c7
-U u Psi 03a8 03c8
-W w Omega --- 03a9 03c9
-
-( spiritus asper
-) spiritus lenis
-! iota subscriptum
-
-' acutus
-~ circumflexus
-` gravis
-
--}
-
-
-
-
-
diff --git a/src/GF/Text/Hebrew.hs b/src/GF/Text/Hebrew.hs
deleted file mode 100644
index c7026d8da..000000000
--- a/src/GF/Text/Hebrew.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Hebrew
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:37 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.8 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Hebrew (mkHebrew) where
-
-mkHebrew :: String -> String
-mkHebrew = mkHebrewWord
-----mkHebrew = reverse . mkHebrewWord
---- reverse : assumes everything's on same line
-
-type HebrewChar = Char
-
--- HH 031103 added code for spooling the markup
--- removed reverse, words, unwords
--- (seemed obsolete and come out wrong on the screen)
--- AR 26/1/2004 put reverse back - needed in Fudgets (but not in Java?)
-
-mkHebrewWord :: String -> [HebrewChar]
--- mkHebrewWord = map mkHebrewChar
-
-mkHebrewWord s = case s of
- [] -> []
- '<' : cs -> '<' : spoolMarkup cs
- ' ' : cs -> ' ' : mkHebrewWord cs
- c1 : cs -> mkHebrewChar c1 : mkHebrewWord cs
-
-spoolMarkup :: String -> String
-spoolMarkup s = case s of
- [] -> [] -- Shouldn't happen
- '>' : cs -> '>' : mkHebrewWord cs
- c1 : cs -> c1 : spoolMarkup cs
-
-mkHebrewChar c = case lookup c cc of Just c' -> c' ; _ -> c
- where
- cc = zip allHebrewCodes allHebrew
-
-allHebrewCodes = "-abgdhwzHTyKklMmNnSoPpCcqrst"
-
-allHebrew :: String
-allHebrew = (map toEnum (0x05be : [0x05d0 .. 0x05ea]))
-
-
diff --git a/src/GF/Text/Hiragana.hs b/src/GF/Text/Hiragana.hs
deleted file mode 100644
index ba74fc83c..000000000
--- a/src/GF/Text/Hiragana.hs
+++ /dev/null
@@ -1,95 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Hiragana
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:38 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Hiragana (mkJapanese) where
-
--- long vowel romaaji must be ei, ou not ee, oo
-
-mkJapanese :: String -> String
-mkJapanese = digraphWordToUnicode . romaajiToDigraphWord
-
-romaajiToDigraphWord :: String -> [(Char, Char)]
-romaajiToDigraphWord str = case str of
- [] -> []
- '<' : cs -> ('\\', '<') : spoolMarkup cs
- ' ' : cs -> ('\\', ' ') : romaajiToDigraphWord cs
-
- c1 : cs | isVowel c1 -> (' ', cap c1) : romaajiToDigraphWord cs
-
- -- The combinations
- c1 : 'y' : c2 : cs -> (c1, 'i') : ('y', cap c2) : romaajiToDigraphWord cs
-
- 's' : 'h' : 'a' : cs -> ('S', 'i') : ('y', 'A') : romaajiToDigraphWord cs
- 'c' : 'h' : 'a' : cs -> ('C', 'i') : ('y', 'A') : romaajiToDigraphWord cs
- 'j' : 'a' : cs -> ('j', 'i') : ('y', 'A') : romaajiToDigraphWord cs
-
- 's' : 'h' : 'u' : cs -> ('S', 'i') : ('y', 'U') : romaajiToDigraphWord cs
- 'c' : 'h' : 'u' : cs -> ('C', 'i') : ('y', 'U') : romaajiToDigraphWord cs
- 'j' : 'u' : cs -> ('j', 'i') : ('y', 'U') : romaajiToDigraphWord cs
-
- 's' : 'h' : 'o' : cs -> ('S', 'i') : ('y', 'O') : romaajiToDigraphWord cs
- 'c' : 'h' : 'o' : cs -> ('C', 'i') : ('y', 'O') : romaajiToDigraphWord cs
- 'j' : 'o' : cs -> ('j', 'i') : ('y', 'O') : romaajiToDigraphWord cs
-
- 'd' : 'z' : c3 : cs -> ('D', c3) : romaajiToDigraphWord cs
- 't' : 's' : c3 : cs -> ('T', c3) : romaajiToDigraphWord cs
- 'c' : 'h' : c3 : cs -> ('C', c3) : romaajiToDigraphWord cs
- 's' : 'h' : c3 : cs -> ('S', c3) : romaajiToDigraphWord cs
- 'z' : 'h' : c3 : cs -> ('Z', c3) : romaajiToDigraphWord cs
-
- c1 : ' ' : cs -> (' ', c1) : ('\\', ' ') : romaajiToDigraphWord cs -- n
- c1 : [] -> [(' ', c1)] -- n
-
- c1 : c2 : cs | isVowel c2 -> (c1, c2) : romaajiToDigraphWord cs
- c1 : c2 : cs | c1 == c2 -> ('T', 'U') : romaajiToDigraphWord (c2 : cs) -- double cons
- c1 : cs -> (' ', c1) : romaajiToDigraphWord cs -- n
-
-isVowel x = elem x "aeiou"
-cap :: Char -> Char
-cap x = case x of
- 'a' -> 'A'
- 'e' -> 'E'
- 'i' -> 'I'
- 'o' -> 'O'
- 'u' -> 'U'
- c -> c
-
-spoolMarkup :: String -> [(Char, Char)]
-spoolMarkup s = case s of
- -- [] -> [] -- Shouldn't happen
- '>' : cs -> ('\\', '>') : romaajiToDigraphWord cs
- c1 : cs -> ('\\', c1) : spoolMarkup cs
-
-digraphWordToUnicode :: [(Char, Char)] -> String
-digraphWordToUnicode = map digraphToUnicode
-
-digraphToUnicode :: (Char, Char) -> Char
-digraphToUnicode (c1, c2) = case lookup (c1, c2) cc of Just c' -> c' ; _ -> c2
- where
- cc = zip allHiraganaCodes allHiragana
-
-allHiraganaCodes :: [(Char, Char)]
-allHiraganaCodes = mkPairs digraphedHiragana
-
-allHiragana :: String
-allHiragana = (map toEnum [0x3041 .. 0x309f])
-
-mkPairs :: String -> [(Char, Char)]
-mkPairs str = case str of
- [] -> []
- c1 : c2 : cs -> (c1, c2) : mkPairs cs
-
-digraphedHiragana = " a A i I u U e E o OkagakigikugukegekogosazaSiZisuzusezesozotadaCijiTUTuDutedetodonaninunenohabapahibipihubupuhebepehobopomamimumemoyAyayUyuyOyorarirurerowaWawiwewo nvukAkE____<< o>>o >'> b"
-
-
diff --git a/src/GF/Text/LatinASupplement.hs b/src/GF/Text/LatinASupplement.hs
deleted file mode 100644
index f42423c91..000000000
--- a/src/GF/Text/LatinASupplement.hs
+++ /dev/null
@@ -1,69 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : LatinASupplement
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:39 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.LatinASupplement (mkLatinASupplement) where
-
-mkLatinASupplement :: String -> String
-mkLatinASupplement = mkLatinASupplementWord
-
-mkLatinASupplementWord :: String -> String
-mkLatinASupplementWord str = case str of
- [] -> []
- '<' : cs -> '<' : spoolMarkup cs
- -- Romanian & partly Turkish
- 's' : ',' : cs -> toEnum 0x015f : mkLatinASupplementWord cs
- 'a' : '%' : cs -> toEnum 0x0103 : mkLatinASupplementWord cs
- -- Slavic and more
- 'c' : '^' : cs -> toEnum 0x010d : mkLatinASupplementWord cs
- 's' : '^' : cs -> toEnum 0x0161 : mkLatinASupplementWord cs
- 'c' : '\'' : cs -> toEnum 0x0107 : mkLatinASupplementWord cs
- 'z' : '^' : cs -> toEnum 0x017e : mkLatinASupplementWord cs
- -- Turkish
- 'g' : '%' : cs -> toEnum 0x011f : mkLatinASupplementWord cs
- 'I' : cs -> toEnum 0x0131 : mkLatinASupplementWord cs
- 'c' : ',' : cs -> toEnum 0x00e7 : mkLatinASupplementWord cs
- -- Polish
- 'e' : ',' : cs -> toEnum 0x0119 : mkLatinASupplementWord cs
- 'a' : ',' : cs -> toEnum 0x0105 : mkLatinASupplementWord cs
- 'l' : '/' : cs -> toEnum 0x0142 : mkLatinASupplementWord cs
- 'z' : '.' : cs -> toEnum 0x017c : mkLatinASupplementWord cs
- 'n' : '\'' : cs -> toEnum 0x0144 : mkLatinASupplementWord cs
- 's' : '\'' : cs -> toEnum 0x015b : mkLatinASupplementWord cs
--- 'c' : '\'' : cs -> toEnum 0x0107 : mkLatinASupplementWord cs
-
- -- Hungarian
- 'o' : '%' : cs -> toEnum 0x0151 : mkLatinASupplementWord cs
- 'u' : '%' : cs -> toEnum 0x0171 : mkLatinASupplementWord cs
-
- -- Mongolian
- 'j' : '^' : cs -> toEnum 0x0135 : mkLatinASupplementWord cs
-
- -- Khowar (actually in Combining diacritical marks not Latin-A Suppl.)
- 'o' : '.' : cs -> 'o' : (toEnum 0x0323 : mkLatinASupplementWord cs)
-
- -- Length bars over vowels e.g korean
- 'a' : ':' : cs -> toEnum 0x0101 : mkLatinASupplementWord cs
- 'e' : ':' : cs -> toEnum 0x0113 : mkLatinASupplementWord cs
- 'i' : ':' : cs -> toEnum 0x012b : mkLatinASupplementWord cs
- 'o' : ':' : cs -> toEnum 0x014d : mkLatinASupplementWord cs
- 'u' : ':' : cs -> toEnum 0x016b : mkLatinASupplementWord cs
-
- -- Default
- c : cs -> c : mkLatinASupplementWord cs
-
-spoolMarkup :: String -> String
-spoolMarkup s = case s of
- [] -> [] -- Shouldn't happen
- '>' : cs -> '>' : mkLatinASupplementWord cs
- c1 : cs -> c1 : spoolMarkup cs
diff --git a/src/GF/Text/OCSCyrillic.hs b/src/GF/Text/OCSCyrillic.hs
deleted file mode 100644
index 0d4696944..000000000
--- a/src/GF/Text/OCSCyrillic.hs
+++ /dev/null
@@ -1,47 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:39 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.6 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.OCSCyrillic (mkOCSCyrillic) where
-
-mkOCSCyrillic :: String -> String
-mkOCSCyrillic = mkOCSCyrillicWord
-
-mkOCSCyrillicWord :: String -> String
-mkOCSCyrillicWord str = case str of
- [] -> []
- ' ' : cs -> ' ' : mkOCSCyrillicWord cs
- '<' : cs -> '<' : spoolMarkup cs
- '\228' : cs -> toEnum 0x0463 : mkOCSCyrillicWord cs -- ä
- 'j' : 'e' : '~' : cs -> toEnum 0x0469 : mkOCSCyrillicWord cs
- 'j' : 'o' : '~' : cs -> toEnum 0x046d : mkOCSCyrillicWord cs
- 'j' : 'e' : cs -> toEnum 0x0465 : mkOCSCyrillicWord cs
- 'e' : '~' : cs -> toEnum 0x0467 : mkOCSCyrillicWord cs
- 'o' : '~' : cs -> toEnum 0x046b : mkOCSCyrillicWord cs
- 'j' : 'u' : cs -> toEnum 0x044e : mkOCSCyrillicWord cs
- 'j' : 'a' : cs -> toEnum 0x044f : mkOCSCyrillicWord cs
- 'u' : cs -> toEnum 0x0479 : mkOCSCyrillicWord cs
- c : cs -> (mkOCSCyrillicChar c) : mkOCSCyrillicWord cs
-
-spoolMarkup :: String -> String
-spoolMarkup s = case s of
- [] -> [] -- Shouldn't happen
- '>' : cs -> '>' : mkOCSCyrillicWord cs
- c1 : cs -> c1 : spoolMarkup cs
-
-mkOCSCyrillicChar :: Char -> Char
-mkOCSCyrillicChar c = case lookup c cc of Just c' -> c' ; _ -> c
- where
- cc = zip "abvgdeZziJklmnoprstYfxCqwWUyIE" allOCSCyrillic
-
-allOCSCyrillic :: String
-allOCSCyrillic = (map toEnum [0x0430 .. 0x044e])
diff --git a/src/GF/Text/Russian.hs b/src/GF/Text/Russian.hs
deleted file mode 100644
index c4f1bfd89..000000000
--- a/src/GF/Text/Russian.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Russian
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:40 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Russian (mkRussian, mkRusKOI8) where
-
--- | an ad hoc ASCII encoding. Delimiters: @\/_ _\/@
-mkRussian :: String -> String
-mkRussian = unwords . (map mkRussianWord) . words
-
--- | the KOI8 encoding, incomplete. Delimiters: @\/* *\/@
-mkRusKOI8 :: String -> String
-mkRusKOI8 = unwords . (map mkRussianKOI8) . words
-
-type RussianChar = Char
-
-mkRussianWord :: String -> [RussianChar]
-mkRussianWord = map (mkRussianChar allRussianCodes)
-
-mkRussianKOI8 :: String -> [RussianChar]
-mkRussianKOI8 = map (mkRussianChar allRussianKOI8)
-
-mkRussianChar chars c = case lookup c cc of Just c' -> c' ; _ -> c
- where
- cc = zip chars allRussian
-
-allRussianCodes :: [Char]
-allRussianCodes =
- -- changed to Ints to work with Haskell compilers e.g. GHC 6.5 CVS
- -- which expect source files to be in UTF-8
- -- /bringert 2006-05-19
- -- "ÅåABVGDEXZIJKLMNOPRSTUFHCQW£}!*ÖYÄabvgdexzijklmnoprstufhcqw#01'öyä"
- map toEnum [197,229,65,66,86,71,68,69,88,90,73,74,75,76,77,78,79,80,82,83,84,85,70,72,67,81,87,163,125,33,42,214,89,196,97,98,118,103,100,101,120,122,105,106,107,108,109,110,111,112,114,115,116,117,102,104,99,113,119,35,48,49,39,246,121,228]
-
-allRussianKOI8 :: [Char]
-allRussianKOI8 =
- -- changed to Ints to work with Haskell compilers e.g. GHC 6.5 CVS
- -- which expect source files to be in UTF-8
- -- /bringert 2006-05-19
- -- "^@áâ÷çäåöúéêëìíîïðòóôõæèãþûýøùÿüàñÁÂ×ÇÄÅÖÚÉÊËÌÍÎÏÐÒÓÔÕÆÈÃÞÛÝØÙßÜÀÑ"
- map toEnum [94,64,225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,242,243,244,245,230,232,227,254,251,253,248,249,255,252,224,241,193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,210,211,212,213,198,200,195,222,219,221,216,217,223,220,192,209]
-
-allRussian :: String
-allRussian = (map toEnum (0x0401:0x0451:[0x0410 .. 0x044f])) -- Ëë in odd places
-
-
diff --git a/src/GF/Text/Tamil.hs b/src/GF/Text/Tamil.hs
deleted file mode 100644
index 8ee171acf..000000000
--- a/src/GF/Text/Tamil.hs
+++ /dev/null
@@ -1,77 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Tamil
--- Maintainer : (Maintainer)
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:40 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Text.Tamil (mkTamil) where
-
-mkTamil :: String -> String
-mkTamil = digraphWordToUnicode . adHocToDigraphWord
-
-adHocToDigraphWord :: String -> [(Char, Char)]
-adHocToDigraphWord str = case str of
- [] -> []
- '<' : cs -> ('\\', '<') : spoolMarkup cs
- ' ' : cs -> ('\\', ' ') : adHocToDigraphWord cs -- skip space
-
--- if c1 is a vowel
- -- Two of the same vowel => lengthening
- c1 : c2 : cs | c1 == c2 && isVowel c1 -> (cap c1, ':') : adHocToDigraphWord cs
- -- digraphed or long vowel
- c1 : c2 : cs | isVowel c1 && isVowel c2 -> (cap c1, cap c2) : adHocToDigraphWord cs
- c1 : cs | isVowel c1 -> (' ', cap c1) : adHocToDigraphWord cs
-
--- c1 isn't a vowel
- c1 : c2 : c3 : cs | c2 == c3 && isVowel c2 -> (' ', c1) : (c2, ':') : adHocToDigraphWord cs
- c1 : c2 : c3 : cs | isVowel c2 && isVowel c3 -> (' ', c1) : (c2, c3) : adHocToDigraphWord cs
- c1 : 'a' : cs -> (' ', c1) : adHocToDigraphWord cs -- a inherent
- c1 : c2 : cs | isVowel c2 -> (' ', c1) : (' ', c2) : adHocToDigraphWord cs
-
- c1 : cs -> (' ', c1) : (' ', '.') : adHocToDigraphWord cs -- vowelless
-
-isVowel x = elem x "aeiou:"
-cap :: Char -> Char
-cap x = case x of
- 'a' -> 'A'
- 'e' -> 'E'
- 'i' -> 'I'
- 'o' -> 'O'
- 'u' -> 'U'
- c -> c
-
-spoolMarkup :: String -> [(Char, Char)]
-spoolMarkup s = case s of
- -- [] -> [] -- Shouldn't happen
- '>' : cs -> ('\\', '>') : adHocToDigraphWord cs
- c1 : cs -> ('\\', c1) : spoolMarkup cs
-
-digraphWordToUnicode :: [(Char, Char)] -> String
-digraphWordToUnicode = map digraphToUnicode
-
-digraphToUnicode :: (Char, Char) -> Char
-digraphToUnicode (c1, c2) = case lookup (c1, c2) cc of Just c' -> c' ; _ -> c2
- where
- cc = zip allTamilCodes allTamil
-
-mkPairs :: String -> [(Char, Char)]
-mkPairs str = case str of
- [] -> []
- c1 : c2 : cs -> (c1, c2) : mkPairs cs
-
-allTamilCodes :: [(Char, Char)]
-allTamilCodes = mkPairs digraphedTamil
-
-allTamil :: String
-allTamil = (map toEnum [0x0b85 .. 0x0bfa])
-
-digraphedTamil = " AA: II: UU:______ EE:AI__ OO:AU k______ G c__ j__ \241 T______ N t______ V n p______ m y r l L M v__ s S h________a: ii: uu:______ ee:ai__ oo:au .__________________ :______________________________#1#2#3#4#5#6#7#8#9^1^2^3=d=m=y=d=c==ru##"
-
diff --git a/src/GF/Text/Text.hs b/src/GF/Text/Text.hs
deleted file mode 100644
index b55355c20..000000000
--- a/src/GF/Text/Text.hs
+++ /dev/null
@@ -1,149 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Text
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/06/23 14:32:44 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.10 $
---
--- elementary text postprocessing. AR 21\/11\/2001.
---
--- This is very primitive indeed. The functions should work on
--- token lists and not on strings. AR 5\/12\/2002
---
--- XML hack 14\/8\/2004; not in use yet
------------------------------------------------------------------------------
-
-module GF.Text.Text (untokWithXML,
- exceptXML,
- formatAsTextLit,
- formatAsCodeLit,
- formatAsText,
- formatAsHTML,
- formatAsLatex,
- formatAsCode,
- performBinds,
- performBindsFinnish,
- unStringLit,
- concatRemSpace
- ) where
-
-import GF.Data.Operations
-import Data.Char
-
--- | does not apply untokenizer within XML tags --- heuristic "< "
--- this function is applied from top level...
-untokWithXML :: (String -> String) -> String -> String
-untokWithXML unt s = case s of
- '<':cs@(c:_) | isAlpha c -> '<':beg ++ ">" ++ unto (drop 1 rest) where
- (beg,rest) = span (/='>') cs
- '<':cs -> '<':unto cs ---
- [] -> []
- _ -> unt beg ++ unto rest where
- (beg,rest) = span (/='<') s
- where
- unto = untokWithXML unt
-
--- | ... whereas this one is embedded on a branch
-exceptXML :: (String -> String) -> String -> String
-exceptXML unt s = '<':beg ++ ">" ++ unt (drop 1 rest) where
- (beg,rest) = span (/='>') s
-
-formatAsTextLit :: String -> String
-formatAsTextLit = formatAsText . unwords . map unStringLit . words
---- hope that there will be deforestation...
-
-formatAsCodeLit :: String -> String
-formatAsCodeLit = formatAsCode . unwords . map unStringLit . words
-
-formatAsText,formatAsHTML,formatAsLatex :: String -> String
-formatAsText = formatAsTextGen (const False) (=="&-")
-formatAsHTML = formatAsTextGen (\s -> take 1 s == "<" || last s == '>') (const False)
-formatAsLatex = formatAsTextGen ((=="\\") . take 1) (const False)
-
-formatAsTextGen :: (String -> Bool) -> (String -> Bool) -> String -> String
-formatAsTextGen tag para = unwords . format . cap . words where
- format ws = case ws of
- w : ww | capit w -> format $ (cap ww)
- w : c : ww | major c -> format $ (w ++ c) :(cap ww)
- w : c : ww | minor c -> format $ (w ++ c) : ww
- p : c : ww | openp p -> format $ (p ++ c) :ww
- p : c : ww | spanish p -> format $ (p ++ concat (cap [c])) :ww
- c : ww | para c -> "\n\n" : format ww
- w : ww -> w : format ww
- [] -> []
- cap (p:ww) | tag p = p : cap ww
- cap ((c:cs):ww) = (toUpper c : cs) : ww
- cap [] = []
- capit = (=="&|")
- major = flip elem (map singleton ".!?")
- minor = flip elem (map singleton ",:;)")
- openp = all (flip elem "(")
- spanish = all (flip elem "\161\191")
-
-formatAsCode :: String -> String
-formatAsCode = rend 0 . words where
- -- render from BNF Converter
- rend i ss = case ss of
- "[" :ts -> cons "[" $ rend i ts
- "(" :ts -> cons "(" $ rend i ts
- "{" :ts -> cons "{" $ new (i+1) $ rend (i+1) ts
- "}" : ";":ts -> new (i-1) $ space "}" $ cons ";" $ new (i-1) $ rend (i-1) ts
- "}" :ts -> new (i-1) $ cons "}" $ new (i-1) $ rend (i-1) ts
- ";" :ts -> cons ";" $ new i $ rend i ts
- t : "," :ts -> cons t $ space "," $ rend i ts
- t : ")" :ts -> cons t $ cons ")" $ rend i ts
- t : "]" :ts -> cons t $ cons "]" $ rend i ts
- t :ts -> space t $ rend i ts
- _ -> ""
- cons s t = s ++ t
- new i s = '\n' : replicate (2*i) ' ' ++ dropWhile isSpace s
- space t s = if null s then t else t ++ " " ++ s
-
-performBinds :: String -> String
-performBinds = performBindsOpt (\x y -> y)
-
-
--- The function defines an effect of the former on the latter part,
--- such as in vowel harmony. It is triggered by the binder token "&*"
-
-performBindsOpt :: (String -> String -> String) -> String -> String
-performBindsOpt harm = unwords . format . words where
- format ws = case ws of
- w : "&+" : u : ws -> format ((w ++ u) : ws)
- w : "&*" : u : ws -> format ((w ++ harm w u) : ws)
- w : ws -> w : format ws
- [] -> []
-
--- unlexer for Finnish particles
--- Notice: left associativity crucial for "tie &* ko &* han" --> "tieköhän"
-
-performBindsFinnish :: String -> String
-performBindsFinnish = performBindsOpt vowelHarmony where
- vowelHarmony w p = if any (flip elem "aouAOU") w then p else map toFront p
- toFront c = case c of
- 'A' -> '\196'
- 'O' -> '\214'
- 'a' -> '\228'
- 'o' -> '\246'
- _ -> c
-
-unStringLit :: String -> String
-unStringLit s = case s of
- c : cs | strlim c && strlim (last cs) -> init cs
- _ -> s
- where
- strlim = (=='\'')
-
-concatRemSpace :: String -> String
-concatRemSpace = concat . words
-{-
-concatRemSpace s = case s of
- '<':cs -> exceptXML concatRemSpace cs
- c : cs | isSpace c -> concatRemSpace cs
- c :cs -> c : concatRemSpace cs
- _ -> s
--}
diff --git a/src/GF/Text/Thai.hs b/src/GF/Text/Thai.hs
deleted file mode 100644
index 1b186cb3a..000000000
--- a/src/GF/Text/Thai.hs
+++ /dev/null
@@ -1,368 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Thai
--- Maintainer : (Maintainer)
--- Stability : (experimental)
--- Portability : (portable)
---
---
--- Thai transliteration and other alphabet information.
------------------------------------------------------------------------------
-
--- AR 27/12/2006. Execute test2 to see the transliteration table.
-
-module GF.Text.Thai (
- mkThai,mkThaiWord,mkThaiPron,mkThaiFake,thaiFile,thaiPronFile,thaiFakeFile
- ) where
-
-import qualified Data.Map as Map
-import Data.Char
-
--- for testing
-import GF.Text.UTF8
-import Data.List
-
-import Debug.Trace
-
-
-mkThai :: String -> String
-mkThai = concat . map mkThaiWord . words
-mkThaiPron = unwords . map mkPronSyllable . words
-mkThaiFake = unwords . map (fakeEnglish . mkPronSyllable) . words
-
-
-type ThaiChar = Char
-
-mkThaiWord :: String -> [ThaiChar]
-mkThaiWord = map (toEnum . mkThaiChar) . unchar . snd . pronAndOrth
-
-mkThaiChar :: String -> Int
-mkThaiChar c = maybe 0 id $ Map.lookup c thaiMap
-
-thaiMap :: Map.Map String Int
-thaiMap = Map.fromList $ zip allThaiTrans allThaiCodes
-
--- convert all string literals in a text
-
-thaiStrings :: String -> String
-thaiStrings = convStrings mkThai
-
-thaiPronStrings :: String -> String
-thaiPronStrings = convStrings mkThaiPron
-
-convStrings conv s = case s of
- '"':cs -> let (t,_:r) = span (/='"') cs in
- '"': conv t ++ "\"" ++ convStrings conv r
- c:cs -> c : convStrings conv cs
- _ -> s
-
-
--- each character is either [letter] or [letter+nonletter]
-
-unchar :: String -> [String]
-unchar s = case s of
- c:d:cs
- | isAlpha d -> [c] : unchar (d:cs)
- | d == '?' -> unchar cs -- use "o?" to represent implicit 'o'
- | otherwise -> [c,d] : unchar cs
- [_] -> [s]
- _ -> []
-
--- you can prefix transliteration by irregular phonology in []
-
-pronAndOrth :: String -> (Maybe String, String)
-pronAndOrth s = case s of
- '[':cs -> case span (/=']') cs of
- (p,_:o) -> (Just p,o)
- _ -> (Nothing,s)
- _ -> (Nothing,s)
-
-allThaiTrans :: [String]
-allThaiTrans = words $
- "- k k1 - k2 - k3 g c c1 c2 s' c3 y' d' t' " ++
- "t1 t2 t3 n' d t t4 t5 t6 n b p p1 f p2 f' " ++
- "p3 m y r - l - w s- s. s h l' O h' - " ++
- "a. a a: a+ i i: v v: u u: - - - - - - " ++
- "e e' o: a% a& L R S T1 T2 T3 T4 K - - - " ++
- "N0 N1 N2 N3 N4 N5 N6 N7 N8 N9 - - - - - - "
-
-allThaiCodes :: [Int]
-allThaiCodes = [0x0e00 .. 0x0e7f]
-
-
----------------------
--- heuristic pronunciation of codes
----------------------
-
--- fake English for TTS, a la Teach Yourself Thai
-
-fakeEnglish :: String -> String
-fakeEnglish s = case s of
- 'a':'a':cs -> "ah" ++ fakeEnglish cs
- 'a':'y':cs -> "ai" ++ fakeEnglish cs
- 'a' :cs -> "ah" ++ fakeEnglish cs
- 'c':'h':cs -> "ch" ++ fakeEnglish cs
- 'c' :cs -> "j" ++ fakeEnglish cs
- 'e':'e':cs -> "aih" ++ fakeEnglish cs
- 'g' :cs -> "ng" ++ fakeEnglish cs
- 'i':'i':cs -> "ee" ++ fakeEnglish cs
- 'k':'h':cs -> "k" ++ fakeEnglish cs
- 'k' :cs -> "g" ++ fakeEnglish cs
- 'O':'O':cs -> "or" ++ fakeEnglish cs
- 'O' :cs -> "or" ++ fakeEnglish cs
- 'o':'o':cs -> "or" ++ fakeEnglish cs
- 'p':'h':cs -> "p" ++ fakeEnglish cs
- 'p' :cs -> "b" ++ fakeEnglish cs
- 't':'h':cs -> "t" ++ fakeEnglish cs
- 't' :cs -> "d" ++ fakeEnglish cs
- 'u':'u':cs -> "oo" ++ fakeEnglish cs
- 'u' :cs -> "oo" ++ fakeEnglish cs
- 'v':'v':cs -> "eu" ++ fakeEnglish cs
- 'v' :cs -> "eu" ++ fakeEnglish cs
- '\228':'\228':cs -> "air" ++ fakeEnglish cs
- '\228' :cs -> "a" ++ fakeEnglish cs
- '\246':'\246':cs -> "er" ++ fakeEnglish cs
- '\246' :cs -> "er" ++ fakeEnglish cs
- c:cs | isTone c -> fakeEnglish cs
- c:cs -> c : fakeEnglish cs
- _ -> s
- where
- isTone = flip elem "'`^~"
-
-
--- this works for one syllable
-
-mkPronSyllable s = case fst $ pronAndOrth s of
- Just p -> p
- _ -> pronSyllable $ getSyllable $ map mkThaiChar $ unchar s
-
-data Syllable = Syll {
- initv :: [Int],
- initc :: [Int],
- midv :: [Int],
- finalc :: [Int],
- finalv :: [Int],
- tone :: [Int],
- shorten :: Bool,
- kill :: Bool
- }
- deriving Show
-
-data Tone = TMid | TLow | THigh | TRise | TFall
- deriving Show
-
-data CClass = CLow | CMid | CHigh
- deriving Show
-
-pronSyllable :: Syllable -> String
-pronSyllable s =
- initCons ++ tonem ++ vowel ++ finalCons
- where
-
- vowel = case (initv s, midv s, finalv s, finalc s, shorten s, tone s) of
- ([0x0e40],[0x0e35],_,[0x0e22],_,_) -> "ia" -- e-i:y
- ([0x0e40],[0x0e2d,0x0e35],_,_,_,_) -> "va" -- e-i:O
- ([0x0e40],[0x0e30,0x0e35],_,[0x0e22],_,_) -> "ia" -- e-i:ya.
- ([0x0e40],[0x0e30,0x0e2d],_,_,_,_) -> "\246" -- e-Oa.
- ([0x0e40],[0x0e30,0x0e32],_,_,_,_) -> "O" -- e-a:a. -- open o
- ([0x0e40],[0x0e2d],_,_,_,_) -> "\246\246" -- e-O
- ([0x0e40],[0x0e34],_,_,_,_) -> "\246\246" -- e-i
- ([0x0e40],[0x0e30],_,_,_,_) -> "e" -- e-a.
- ([0x0e40],[0x0e32],_,_,_,_) -> "aw" -- e-a:
- ([0x0e40],[],[],[0x0e22],_,_) -> "\246\246y" -- e-y
- ([0x0e40],[],[],_,True,_) -> "e"
-
- ([0x0e41],[0x0e30],_,_,_,_) -> "\228" -- ä-a.
- ([0x0e41],[],[],_,True,_) -> "\228"
-
- ([0x0e42],[0x0e30],_,_,_,_) -> "o" -- o:-a.
-
- ([],[0x0e2d],_,[0x0e22],_,_) -> "OOy" -- Oy
- ([],[0x0e2d],_,_,_,_) -> "OO" -- O
-
- ([],[],[],_,_,_) -> "o"
-
- (i,m,f,_,_,_) -> concatMap pronThaiChar (reverse $ f ++ m ++ i) ----
-
- initCons = concatMap pronThaiChar $ case (reverse $ initc s) of
- 0x0e2b:cs@(_:_) -> cs -- high h
- 0x0e2d:cs@(_:_) -> cs -- O
- cs -> cs
-
- finalCons =
- let (c,cs) = splitAt 1 $ finalc s
- in
- case c of
- [] -> []
- [0x0e22] -> [] --- y
- [k] -> concatMap pronThaiChar (reverse cs) ++ finalThai k
-
- iclass = case take 1 (reverse $ initc s) of
- [c] -> classThai c
- [] -> CMid -- O
-
- isLong = not (shorten s) && case vowel of
- _:_:_ -> True ----
- _ -> False
-
- isLive = case finalCons of
- c | elem c ["n","m","g"] -> True
- "" -> isLong
- _ -> False
-
- tonem = case (iclass,isLive,isLong,tone s) of
- (_,_,_, [0x0e4a]) -> tHigh
- (_,_,_, [0x0e4b]) -> tRise
- (CLow,_,_,[0x0e49]) -> tRise
- (_,_,_, [0x0e49]) -> tFall
- (CLow,_,_,[0x0e48]) -> tFall
- (_, _,_,[0x0e48]) -> tLow
- (CHigh,True,_,_) -> tRise
- (_, True,_,_) -> tMid
- (CLow,False,False,_) -> tHigh
- (CLow,False,_,_) -> tFall
- _ -> tLow
-
-(tMid,tHigh,tLow,tRise,tFall) = ("-","'","`","~","^")
-
-isVowel c = 0x0e30 <= c && c <= 0x0e44 ----
-isCons c = 0x0e01 <= c && c <= 0x0e2f ----
-isTone c = 0x0e48 <= c && c <= 0x0e4b
-
-getSyllable :: [Int] -> Syllable
-getSyllable = foldl get (Syll [] [] [] [] [] [] False False) where
- get syll c = case c of
- 0x0e47 -> syll {shorten = True}
- 0x0e4c -> syll {kill = True, finalc = tail (finalc syll)} --- always last
- 0x0e2d
- | null (initc syll) -> syll {initc = [c]} -- "O"
- | otherwise -> syll {midv = c : midv syll}
- _
- | isVowel c -> if null (initc syll)
- then syll {initv = c : initv syll}
- else syll {midv = c : midv syll}
- | isCons c -> if null (initc syll) ||
- (null (midv syll) && isCluster (initc syll) c)
- then syll {initc = c : initc syll}
- else syll {finalc = c : finalc syll}
- | isTone c -> syll {tone = [c]}
- _ -> syll ---- check this
-
- isCluster s c = length s == 1 && (c == 0x0e23 || s == [0x0e2b])
-
--- to test
-
-test1 = testThai "k2wa:mrak"
-test2 = putStrLn $ thaiTable
-test3 = do
- writeFile "thai.txt" "Thai Character Coding in GF\nAR 2007\n"
- appendFile "thai.txt" thaiTable
-test4 = do
- writeFile "alphthai.txt" "Thai Characters by Pronunciation\nAR 2007\n"
- appendFile "alphthai.txt" thaiTableAlph
-
-
-testThai :: String -> IO ()
-testThai s = do
- putStrLn $ encodeUTF8 $ mkThai s
- putStrLn $ unwords $ map mkPronSyllable $ words s
-
-testSyllable s =
- let y = getSyllable $ map mkThaiChar $ unchar s
- in
- putStrLn $ pronSyllable $ trace (show y) y
-
-thaiFile :: FilePath -> Maybe FilePath -> IO ()
-thaiFile f mo = do
- s <- readFile f
- let put = maybe putStr writeFile mo
- put $ encodeUTF8 $ thaiStrings s
-
-thaiPronFile :: FilePath -> Maybe FilePath -> IO ()
-thaiPronFile f mo = do
- s <- readFile f
- let put = maybe putStr writeFile mo
- put $ encodeUTF8 $ thaiPronStrings s
-
-thaiFakeFile :: FilePath -> Maybe FilePath -> IO ()
-thaiFakeFile f mo = do
- s <- readFile f
- let put = maybe putStr writeFile mo
- put $ encodeUTF8 $ (convStrings mkThaiFake) s
-
-finalThai c = maybe "" return (Map.lookup c thaiFinalMap)
-thaiFinalMap = Map.fromList $ zip allThaiCodes finals
-
-classThai c = maybe CLow readClass (Map.lookup c thaiClassMap)
-thaiClassMap = Map.fromList $ zip allThaiCodes heights
-
-readClass s = case s of
- 'L' -> CLow
- 'M' -> CMid
- 'H' -> CHigh
-
-
-thaiTable :: String
-thaiTable = unlines $ ("\n|| hex | thai | trans | pron | fin | class |" ) : [
- "| " ++
- hex c ++ " | " ++
- encodeUTF8 (showThai s) ++ " | " ++
- s ++ " | " ++
- pronThai s ++ " | " ++
- [f] ++ " | " ++
- [q] ++ " | "
- |
- (c,q,f,s) <- zip4 allThaiCodes heights finals allThaiTrans
- ]
-
-thaiTableAlph :: String
-thaiTableAlph = unlines $ ("\n|| pron | thai | trans |" ) : [
- "| " ++ a ++
- " | " ++ unwords (map (encodeUTF8 . showThai) ss) ++
- " | " ++ unwords ss ++
- " |"
- |
- (a,ss) <- allProns
- ]
- where
- prons = sort $ nub
- [p | s <- allThaiTrans, let p = pronThai s, not (null p),isAlpha (head p)]
- allProns =
- [(a,[s | s <- allThaiTrans, pronThai s == a]) | a <- prons]
-
-showThai s = case s of
- "-" -> "-"
---- v:_ | elem v "ivu" -> map (toEnum . mkThaiChar) ["O",s]
- _ -> [toEnum $ mkThaiChar s]
-
-
-pronThaiChar = pronThai . recodeThai
-
-recodeThai c = allThaiTrans !! (c - 0x0e00)
-
-pronThai s = case s of
- [c,p]
- | c == 'N' && isDigit p -> [p]
- | c == 'T' && isDigit p -> ['\'',p]
- | isDigit p -> c:"h"
- | p==':' -> c:[c]
- | elem p "%&" -> c:"y"
- | p=='+' -> c:"m"
- | s == "e'" -> "\228\228"
- | otherwise -> [c]
- "O" -> "O"
- "e" -> "ee"
- [c] | isUpper c -> ""
- _ -> s
-
-hex = map hx . reverse . digs where
- digs 0 = [0]
- digs n = n `mod` 16 : digs (n `div` 16)
- hx d = "0123456789ABCDEF" !! d
-
-heights :: String
-finals :: String
-heights =
- " MHHLLLLMHLLLLMMHLLLMMHLLLMMHHLLLLLL-L-LHHHHLML" ++ replicate 99 ' '
-finals =
- " kkkkkkgt-tt-ntttttntttttnpp--pppmyn-n-wttt-n--" ++ replicate 99 ' '
diff --git a/src/GF/Text/UTF8.hs b/src/GF/Text/UTF8.hs
deleted file mode 100644
index 5e9687684..000000000
--- a/src/GF/Text/UTF8.hs
+++ /dev/null
@@ -1,48 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : UTF8
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:42 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- From the Char module supplied with HBC.
--- code by Thomas Hallgren (Jul 10 1999)
------------------------------------------------------------------------------
-
-module GF.Text.UTF8 (decodeUTF8, encodeUTF8) where
-
--- | Take a Unicode string and encode it as a string
--- with the UTF8 method.
-decodeUTF8 :: String -> String
-decodeUTF8 "" = ""
-decodeUTF8 (c:cs) | c < '\x80' = c : decodeUTF8 cs
-decodeUTF8 (c:c':cs) | '\xc0' <= c && c <= '\xdf' &&
- '\x80' <= c' && c' <= '\xbf' =
- toEnum ((fromEnum c `mod` 0x20) * 0x40 + fromEnum c' `mod` 0x40) : decodeUTF8 cs
-decodeUTF8 (c:c':c'':cs) | '\xe0' <= c && c <= '\xef' &&
- '\x80' <= c' && c' <= '\xbf' &&
- '\x80' <= c'' && c'' <= '\xbf' =
- toEnum ((fromEnum c `mod` 0x10 * 0x1000) + (fromEnum c' `mod` 0x40) * 0x40 + fromEnum c'' `mod` 0x40) : decodeUTF8 cs
-decodeUTF8 s = s ---- AR workaround 22/6/2006
-----decodeUTF8 _ = error "UniChar.decodeUTF8: bad data"
-
-encodeUTF8 :: String -> String
-encodeUTF8 "" = ""
-encodeUTF8 (c:cs) =
- if c > '\x0000' && c < '\x0080' then
- c : encodeUTF8 cs
- else if c < toEnum 0x0800 then
- let i = fromEnum c
- in toEnum (0xc0 + i `div` 0x40) :
- toEnum (0x80 + i `mod` 0x40) :
- encodeUTF8 cs
- else
- let i = fromEnum c
- in toEnum (0xe0 + i `div` 0x1000) :
- toEnum (0x80 + (i `mod` 0x1000) `div` 0x40) :
- toEnum (0x80 + i `mod` 0x40) :
- encodeUTF8 cs
diff --git a/src/GF/Text/Unicode.hs b/src/GF/Text/Unicode.hs
deleted file mode 100644
index 9d0b9d1a8..000000000
--- a/src/GF/Text/Unicode.hs
+++ /dev/null
@@ -1,69 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Unicode
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:42 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.12 $
---
--- ad hoc Unicode conversions from different alphabets.
--- AR 12\/4\/2000, 18\/9\/2001, 30\/5\/2002, 26\/1\/2004
------------------------------------------------------------------------------
-
-module GF.Text.Unicode (mkUnicode, treat) where
-
-import GF.Text.Greek (mkGreek)
-import GF.Text.Arabic (mkArabic)
-import GF.Text.Hebrew (mkHebrew)
-import GF.Text.Russian (mkRussian, mkRusKOI8)
-import GF.Text.Ethiopic (mkEthiopic)
-import GF.Text.Tamil (mkTamil)
-import GF.Text.OCSCyrillic (mkOCSCyrillic)
-import GF.Text.LatinASupplement (mkLatinASupplement)
-import GF.Text.Devanagari (mkDevanagari)
-import GF.Text.Hiragana (mkJapanese)
-import GF.Text.ExtendedArabic (mkArabic0600)
-import GF.Text.ExtendedArabic (mkExtendedArabic)
-import GF.Text.ExtraDiacritics (mkExtraDiacritics)
-
-import Data.Char
-
-mkUnicode :: String -> String
-mkUnicode s = case s of
- '/':'/':cs -> treat [] mkGreek unic ++ mkUnicode rest
- '/':'+':cs -> mkHebrew unic ++ mkUnicode rest
- '/':'-':cs -> mkArabic unic ++ mkUnicode rest
- '/':'_':cs -> treat [] mkRussian unic ++ mkUnicode rest
- '/':'*':cs -> mkRusKOI8 unic ++ mkUnicode rest
- '/':'E':cs -> mkEthiopic unic ++ mkUnicode rest
- '/':'T':cs -> mkTamil unic ++ mkUnicode rest
- '/':'C':cs -> mkOCSCyrillic unic ++ mkUnicode rest
- '/':'&':cs -> mkDevanagari unic ++ mkUnicode rest
- '/':'L':cs -> mkLatinASupplement unic ++ mkUnicode rest
- '/':'J':cs -> mkJapanese unic ++ mkUnicode rest
- '/':'6':cs -> mkArabic0600 unic ++ mkUnicode rest
- '/':'A':cs -> mkExtendedArabic unic ++ mkUnicode rest
- '/':'X':cs -> mkExtraDiacritics unic ++ mkUnicode rest
- c:cs -> c:mkUnicode cs
- _ -> s
- where
- (unic,rest) = remClosing [] $ dropWhile isSpace $ drop 2 s
- remClosing u s = case s of
- c:'/':s | elem c "/+-_*ETC&LJ6AX" -> (reverse u, s) --- end need not match
- c:cs -> remClosing (c:u) cs
- _ -> (reverse u,[]) -- forgiving missing end
-
--- | don't convert XML tags --- assumes \<\> always means XML tags
-treat :: String -> (String -> String) -> String -> String
-treat old mk s = case s of
- '<':cs -> mk (reverse old) ++ '<':noTreat cs
- c:cs -> treat (c:old) mk cs
- _ -> mk (reverse old)
- where
- noTreat s = case s of
- '>':cs -> '>' : treat [] mk cs
- c:cs -> c : noTreat cs
- _ -> s
diff --git a/src/GF/Translate/GFT.hs b/src/GF/Translate/GFT.hs
deleted file mode 100644
index e4a9d8193..000000000
--- a/src/GF/Translate/GFT.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:43 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.7 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.Translate.GFT (main) where
-
-import GF.Compile.ShellState
-import GF.Canon.GetGFC
-import GF.API
-
-import GF.Text.Unicode
-import GF.Text.UTF8
-import GF.Infra.UseIO
-import GF.Infra.Option
-import GF.Infra.Modules (emptyMGrammar) ----
-import GF.Data.Operations
-
-import System
-import Data.List
-
-
-main :: IO ()
-main = do
- file:_ <- getArgs
- let opts = noOptions
- can <- useIOE (error "no grammar file") $ getCanonGrammar file
- st <- err error return $
- grammar2shellState opts (can, emptyMGrammar)
- let grs = allStateGrammars st
- let cat = firstCatOpts opts (firstStateGrammar st)
-
----- interact (doTranslate grs cat)
- s <- getLine
- putStrLnFlush $ doTranslate grs cat $ drop 2 s -- to remove "n="
-
-doTranslate grs cat s =
- let ss = [l +++ ":" +++ s | (l,s) <- zip (map (prIdent . cncId) grs)
- (translateBetweenAll grs cat s)]
- in mkHTML ss
-
-mkHTML = unlines . htmlDoc . intersperse "" . map (encodeUTF8 . mkUnicode) . sort
-
-htmlDoc ss = "":metaHead:"
": ss ++ ["",""]
-
-metaHead =
- ""
-
diff --git a/src/GF/UseGrammar/Custom.hs b/src/GF/UseGrammar/Custom.hs
deleted file mode 100644
index 983b7f683..000000000
--- a/src/GF/UseGrammar/Custom.hs
+++ /dev/null
@@ -1,494 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Custom
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/16 10:21:21 $
--- > CVS $Author: peb $
--- > CVS $Revision: 1.85 $
---
--- A database for customizable GF shell commands.
---
--- databases for customizable commands. AR 21\/11\/2001.
--- for: grammar parsers, grammar printers, term commands, string commands.
--- idea: items added here are usable throughout GF; nothing else need be edited.
--- they are often usable through the API: hence API cannot be imported here!
---
--- Major redesign 3\/4\/2002: the first entry in each database is DEFAULT.
--- If no other value is given, the default is selected.
--- Because of this, two invariants have to be preserved:
---
--- - no databases may be empty
---
--- - additions are made to the end of the database
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Custom where
-
-import GF.Data.Operations
-import GF.Text.Text
-import GF.UseGrammar.Tokenize
-import GF.Grammar.Values
-import qualified GF.Grammar.Grammar as G
-import qualified GF.Canon.AbsGFC as A
-import qualified GF.Canon.GFC as C
-
-import qualified GF.Devel.GFCCtoJS as JS
-import GF.Canon.CanonToGFCC
-import qualified GF.Devel.GFCCtoHaskell as CCH
-
-import qualified GF.Source.AbsGF as GF
-import qualified GF.Grammar.MMacros as MM
-import GF.Grammar.AbsCompute
-import GF.Grammar.TypeCheck
-import GF.UseGrammar.Generate
-import GF.UseGrammar.MatchTerm
-import GF.UseGrammar.Linear (unoptimizeCanon)
-------import Compile
-import GF.Compile.ShellState
-import GF.UseGrammar.Editing
-import GF.UseGrammar.Paraphrases
-import GF.Infra.Option
-import GF.CF.CF
-import GF.CF.CFIdent
-
-import GF.Canon.CanonToGrammar
-import GF.CF.PPrCF
-import GF.CF.PrLBNF
-import GF.Grammar.PrGrammar
-import GF.Compile.PrOld
-import GF.Canon.MkGFC
-import GF.Speech.PrGSL (gslPrinter)
-import GF.Speech.PrJSGF (jsgfPrinter)
-import GF.Speech.PrSRGS
-import GF.Speech.PrSRGS_ABNF
-import qualified GF.Speech.SISR as SISR
-import GF.Speech.PrSLF
-import GF.Speech.PrFA (faGraphvizPrinter,regularPrinter,faCPrinter)
-import GF.Speech.PrRegExp (regexpPrinter,multiRegexpPrinter)
-import GF.Speech.GrammarToVoiceXML (grammar2vxml)
-
-import GF.Data.Zipper
-
-import GF.UseGrammar.Statistics
-import GF.UseGrammar.Morphology
-import GF.UseGrammar.Information
-import GF.API.GrammarToHaskell
-import GF.API.GrammarToTransfer
------import GrammarToCanon (showCanon, showCanonOpt)
------import qualified GrammarToGFC as GFC
-import GF.Probabilistic.Probabilistic (prProbs)
-
--- the cf parsing algorithms
-import GF.CF.ChartParser -- OBSOLETE
-import qualified GF.Parsing.CF as PCF
-import qualified GF.OldParsing.ParseCF as PCFOld -- OBSOLETE
-
--- grammar conversions -- peb 19/4-04
--- see also customGrammarPrinter
-import qualified GF.OldParsing.ConvertGrammar as CnvOld -- OBSOLETE
-import qualified GF.Printing.PrintParser as PrtOld -- OBSOLETE
-import qualified GF.Infra.Print as Prt
-import qualified GF.Conversion.GFC as Cnv
-import qualified GF.Conversion.Types as CnvTypes
-import qualified GF.Conversion.Haskell as CnvHaskell
-import qualified GF.Conversion.Prolog as CnvProlog
-import qualified GF.Conversion.TypeGraph as CnvTypeGraph
-import GF.Canon.Unparametrize
-import GF.Canon.Subexpressions
-import GF.Canon.AbsToBNF
-
-import GF.Canon.GFC
-import qualified GF.Canon.MkGFC as MC
-import GF.CFGM.PrintCFGrammar (prCanonAsCFGM)
-import GF.Visualization.VisualizeGrammar (visualizeCanonGrammar, visualizeSourceGrammar)
-
-import GF.API.MyParser
-
-import qualified GF.Infra.Modules as M
-import GF.Infra.UseIO
-
-import Control.Monad
-import Data.Char
-import Data.Maybe (fromMaybe)
-
--- character codings
-import GF.Text.Unicode
-import GF.Text.UTF8 (decodeUTF8)
-import GF.Text.Greek (mkGreek)
-import GF.Text.Arabic (mkArabic)
-import GF.Text.Hebrew (mkHebrew)
-import GF.Text.Russian (mkRussian, mkRusKOI8)
-import GF.Text.Ethiopic (mkEthiopic)
-import GF.Text.Tamil (mkTamil)
-import GF.Text.OCSCyrillic (mkOCSCyrillic)
-import GF.Text.LatinASupplement (mkLatinASupplement)
-import GF.Text.Devanagari (mkDevanagari)
-import GF.Text.Hiragana (mkJapanese)
-import GF.Text.ExtendedArabic (mkArabic0600)
-import GF.Text.ExtendedArabic (mkExtendedArabic)
-import GF.Text.ExtraDiacritics (mkExtraDiacritics)
-
--- minimal version also used in Hugs. AR 2/12/2002.
-
--- databases for customizable commands. AR 21/11/2001
--- for: grammar parsers, grammar printers, term commands, string commands
--- idea: items added here are usable throughout GF; nothing else need be edited
--- they are often usable through the API: hence API cannot be imported here!
-
--- Major redesign 3/4/2002: the first entry in each database is DEFAULT.
--- If no other value is given, the default is selected.
--- Because of this, two invariants have to be preserved:
--- - no databases may be empty
--- - additions are made to the end of the database
-
--- * these are the databases; the comment gives the name of the flag
-
--- | grammarFormat, \"-format=x\" or file suffix
-customGrammarParser :: CustomData (FilePath -> IOE C.CanonGrammar)
-
--- | grammarPrinter, \"-printer=x\"
-customGrammarPrinter :: CustomData (Options -> StateGrammar -> String)
-
--- | multiGrammarPrinter, \"-printer=x\"
-customMultiGrammarPrinter :: CustomData (Options -> CanonGrammar -> String)
-
--- | syntaxPrinter, \"-printer=x\"
-customSyntaxPrinter :: CustomData (GF.Grammar -> String)
-
--- | termPrinter, \"-printer=x\"
-customTermPrinter :: CustomData (StateGrammar -> Tree -> String)
-
--- | termCommand, \"-transform=x\"
-customTermCommand :: CustomData (StateGrammar -> Tree -> [Tree])
-
--- | editCommand, \"-edit=x\"
-customEditCommand :: CustomData (StateGrammar -> Action)
-
--- | filterString, \"-filter=x\"
-customStringCommand :: CustomData (StateGrammar -> String -> String)
-
--- | useParser, \"-parser=x\"
-customParser :: CustomData (StateGrammar -> CFCat -> CFParser)
-
--- | useTokenizer, \"-lexer=x\"
-customTokenizer :: CustomData (StateGrammar -> String -> [[CFTok]])
-
--- | useUntokenizer, \"-unlexer=x\" --- should be from token list to string
-customUntokenizer :: CustomData (StateGrammar -> String -> String)
-
--- | uniCoding, \"-coding=x\"
---
--- contains conversions from different codings to the internal
--- unicode coding
-customUniCoding :: CustomData (String -> String)
-
--- | this is the way of selecting an item
-customOrDefault :: Options -> OptFun -> CustomData a -> a
-customOrDefault opts optfun db = maybe (defaultCustomVal db) id $
- customAsOptVal opts optfun db
-
--- | to produce menus of custom operations
-customInfo :: CustomData a -> (String, [String])
-customInfo c = (titleCustomData c, map (ciStr . fst) (dbCustomData c))
-
--------------------------------
--- * types and stuff
-
-type CommandId = String
-
-strCI :: String -> CommandId
-strCI = id
-
-ciStr :: CommandId -> String
-ciStr = id
-
-ciOpt :: CommandId -> Option
-ciOpt = iOpt
-
-newtype CustomData a = CustomData (String, [(CommandId,a)])
-
-customData :: String -> [(CommandId, a)] -> CustomData a
-customData title db = CustomData (title,db)
-
-dbCustomData :: CustomData a -> [(CommandId, a)]
-dbCustomData (CustomData (_,db)) = db
-
-titleCustomData :: CustomData a -> String
-titleCustomData (CustomData (t,_)) = t
-
-lookupCustom :: CustomData a -> CommandId -> Maybe a
-lookupCustom = flip lookup . dbCustomData
-
-customAsOptVal :: Options -> OptFun -> CustomData a -> Maybe a
-customAsOptVal opts optfun db = do
- arg <- getOptVal opts optfun
- lookupCustom db (strCI arg)
-
--- | take the first entry from the database
-defaultCustomVal :: CustomData a -> a
-defaultCustomVal (CustomData (s,db)) =
- ifNull (error ("empty database:" +++ s)) (snd . head) db
-
--------------------------------------------------------------------------
--- * and here's the customizable part:
-
--- grammar parsers: the ID is also used as file name suffix
-customGrammarParser =
- customData "Grammar parsers, selected by file name suffix" $
- [
------- (strCI "gf", compileModule noOptions) -- DEFAULT
--- add your own grammar parsers here
- ]
-
-
-customGrammarPrinter =
- customData "Grammar printers, selected by option -printer=x" $
- [
- (strCI "gfc", \_ -> prCanon . stateGrammarST) -- DEFAULT
- ,(strCI "gf", \_ -> err id prGrammar . canon2sourceGrammar . stateGrammarST)
- ,(strCI "cf", \_ -> prCF . stateCF)
- ,(strCI "old", \_ -> printGrammarOld . stateGrammarST)
- ,(strCI "gsl", gslPrinter)
- ,(strCI "jsgf", jsgfPrinter Nothing)
- ,(strCI "jsgf_sisr_old", jsgfPrinter (Just SISR.SISROld))
- ,(strCI "srgs_xml", srgsXmlPrinter Nothing False)
- ,(strCI "srgs_xml_non_rec", srgsXmlNonRecursivePrinter)
- ,(strCI "srgs_xml_prob", srgsXmlPrinter Nothing True)
- ,(strCI "srgs_xml_sisr_old", srgsXmlPrinter (Just SISR.SISROld) False)
- ,(strCI "srgs_abnf", srgsAbnfPrinter Nothing False)
- ,(strCI "srgs_abnf_non_rec", srgsAbnfNonRecursivePrinter)
- ,(strCI "srgs_abnf_sisr_old", srgsAbnfPrinter (Just SISR.SISROld) False)
- ,(strCI "vxml", grammar2vxml)
- ,(strCI "slf", slfPrinter)
- ,(strCI "slf_graphviz", slfGraphvizPrinter)
- ,(strCI "slf_sub", slfSubPrinter)
- ,(strCI "slf_sub_graphviz", slfSubGraphvizPrinter)
- ,(strCI "fa_graphviz", faGraphvizPrinter)
- ,(strCI "fa_c", faCPrinter)
- ,(strCI "regexp", regexpPrinter)
- ,(strCI "regexps", multiRegexpPrinter)
- ,(strCI "regular", regularPrinter)
- ,(strCI "plbnf", \_ -> prLBNF True)
- ,(strCI "lbnf", \_ -> prLBNF False)
- ,(strCI "bnf", \_ -> prBNF False)
- ,(strCI "absbnf", \_ -> abstract2bnf . stateGrammarST)
- ,(strCI "haskell", \_ -> grammar2haskell . stateGrammarST)
- ,(strCI "gfcc_haskell", \opts -> CCH.grammar2haskell .
- canon2gfcc opts . stateGrammarST)
- ,(strCI "haskell_gadt", \_ -> grammar2haskellGADT . stateGrammarST)
- ,(strCI "transfer", \_ -> grammar2transfer . stateGrammarST)
- ,(strCI "morpho", \_ -> prMorpho . stateMorpho)
- ,(strCI "fullform",\_ -> prFullForm . stateMorpho)
- ,(strCI "opts", \_ -> prOpts . stateOptions)
- ,(strCI "words", \_ -> unwords . stateGrammarWords)
- ,(strCI "printnames", \_ -> C.prPrintnamesGrammar . stateGrammarST)
- ,(strCI "stat", \_ -> prStatistics . stateGrammarST)
- ,(strCI "probs", \_ -> prProbs . stateProbs)
- ,(strCI "unpar", \_ -> prCanon . unparametrizeCanon . stateGrammarST)
- ,(strCI "subs", \_ -> prSubtermStat . stateGrammarST)
-
-{- ----
- (strCI "gf", prt . st2grammar . stateGrammarST) -- DEFAULT
- ,(strCI "canon", showCanon "Lang" . stateGrammarST)
- ,(strCI "gfc", GFC.showGFC . stateGrammarST)
- ,(strCI "canonOpt",showCanonOpt "Lang" . stateGrammarST)
--}
-
--- add your own grammar printers here
-
--- grammar conversions:
- ,(strCI "mcfg", \_ -> Prt.prt . stateMCFG)
- ,(strCI "fcfg", \_ -> Prt.prt . fst . stateFCFG)
- ,(strCI "cfg", \_ -> Prt.prt . stateCFG)
- ,(strCI "pinfo", \_ -> Prt.prt . statePInfo)
- ,(strCI "abstract", \_ -> Prt.prtAfter "\n" . Cnv.gfc2abstract . stateGrammarLang)
-
- ,(strCI "functiongraph",\_ -> CnvTypeGraph.prtFunctionGraph . Cnv.gfc2simple noOptions . stateGrammarLang)
- ,(strCI "typegraph", \_ -> CnvTypeGraph.prtTypeGraph . Cnv.gfc2simple noOptions . stateGrammarLang)
-
- ,(strCI "gfc-haskell", \_ -> CnvHaskell.prtSGrammar . uncurry Cnv.gfc2simple . stateGrammarLangOpts)
- ,(strCI "mcfg-haskell", \_ -> CnvHaskell.prtMGrammar . stateMCFG)
- ,(strCI "cfg-haskell", \_ -> CnvHaskell.prtCGrammar . stateCFG)
- ,(strCI "gfc-prolog", \_ -> CnvProlog.prtSGrammar . uncurry Cnv.gfc2simple . stateGrammarLangOpts)
- ,(strCI "mcfg-prolog", \_ -> CnvProlog.prtMGrammar . stateMCFG)
- ,(strCI "cfg-prolog", \_ -> CnvProlog.prtCGrammar . stateCFG)
-
--- obsolete, or only for testing:
- ,(strCI "abs-skvatt", \_ -> Cnv.abstract2skvatt . Cnv.gfc2abstract . stateGrammarLang)
- ,(strCI "cfg-skvatt", \_ -> Cnv.cfg2skvatt . stateCFG)
- ,(strCI "simple", \_ -> Prt.prt . uncurry Cnv.gfc2simple . stateGrammarLangOpts)
- ,(strCI "mcfg-erasing", \_ -> Prt.prt . fst . snd . uncurry Cnv.convertGFC . stateGrammarLangOpts)
--- ,(strCI "mcfg-old", PrtOld.prt . CnvOld.mcfg . statePInfoOld)
--- ,(strCI "cfg-old", PrtOld.prt . CnvOld.cfg . statePInfoOld)
- ]
- where stateGrammarLangOpts s = (stateOptions s, stateGrammarLang s)
-
-customMultiGrammarPrinter =
- customData "Printers for multiple grammars, selected by option -printer=x" $
- [
- (strCI "gfcm", const MC.prCanon)
- ,(strCI "gfcc", canon2gfccPr)
- ,(strCI "js", \opts -> JS.gfcc2js . canon2gfcc opts)
- ,(strCI "header", const (MC.prCanonMGr . unoptimizeCanon))
- ,(strCI "cfgm", prCanonAsCFGM)
- ,(strCI "graph", visualizeCanonGrammar)
- ,(strCI "missing", const missingLinCanonGrammar)
-
--- to prolog format:
- ,(strCI "gfc-prolog", CnvProlog.prtSMulti)
- ,(strCI "mcfg-prolog", CnvProlog.prtMMulti)
- ,(strCI "cfg-prolog", CnvProlog.prtCMulti)
- ]
-
-
-customSyntaxPrinter =
- customData "Syntax printers, selected by option -printer=x" $
- [
--- add your own grammar printers here
- ]
-
-
-customTermPrinter =
- customData "Term printers, selected by option -printer=x" $
- [
- (strCI "gf", const prt) -- DEFAULT
--- add your own term printers here
- ]
-
-customTermCommand =
- customData "Term transformers, selected by option -transform=x" $
- [
- (strCI "identity", \_ t -> [t]) -- DEFAULT
- ,(strCI "compute", \g t -> let gr = grammar g in
- err (const [t]) return
- (exp2termCommand gr (computeAbsTerm gr) t))
- ,(strCI "nodup", \_ t -> if (hasDupIdent $ tree2exp t) then [] else [t])
- ,(strCI "nodupatom", \_ t -> if (hasDupAtom $ tree2exp t) then [] else [t])
- ,(strCI "paraphrase", \g t -> let gr = grammar g in
- exp2termlistCommand gr (mkParaphrases gr) t)
-
- ,(strCI "generate", \g t -> let gr = grammar g
- cat = actCat $ tree2loc t --- not needed
- in
- [tr | t <- generateTrees noOptions gr cat 2 Nothing (Just t),
- Ok tr <- [annotate gr $ MM.qualifTerm (absId g) t]])
- ,(strCI "typecheck", \g t -> err (const []) (return . loc2tree)
- (reCheckStateReject (grammar g) (tree2loc t)))
- ,(strCI "solve", \g t -> err (const []) (return . loc2tree)
- (solveAll (grammar g) (tree2loc t)
- >>= rejectUnsolvable))
- ,(strCI "context", \g t -> err (const [t]) (return . loc2tree)
- (contextRefinements (grammar g) (tree2loc t)))
- ,(strCI "reindex", \g t -> let gr = grammar g in
- err (const [t]) return
- (exp2termCommand gr (return . MM.reindexTerm) t))
---- ,(strCI "delete", \g t -> [MM.mExp0])
--- add your own term commands here
- ]
-
-customEditCommand =
- customData "Editor state transformers, selected by option -edit=x" $
- [
- (strCI "identity", const return) -- DEFAULT
- ,(strCI "typecheck", \g -> reCheckState (grammar g))
- ,(strCI "solve", \g -> solveAll (grammar g))
- ,(strCI "context", \g -> contextRefinements (grammar g))
- ,(strCI "compute", \g -> computeSubTree (grammar g))
- ,(strCI "paraphrase", const return) --- done ad hoc on top level
- ,(strCI "generate", const return) --- done ad hoc on top level
- ,(strCI "transfer", const return) --- done ad hoc on top level
--- add your own edit commands here
- ]
-
-customStringCommand =
- customData "String filters, selected by option -filter=x" $
- [
- (strCI "identity", const $ id) -- DEFAULT
- ,(strCI "erase", const $ const "")
- ,(strCI "take100", const $ take 100)
- ,(strCI "text", const $ formatAsText)
- ,(strCI "code", const $ formatAsCode)
----- ,(strCI "latexfile", const $ mkLatexFile)
- ,(strCI "length", const $ show . length)
--- add your own string commands here
- ]
-
-customParser =
- customData "Parsers, selected by option -parser=x" $
- [
- (strCI "chart", PCFOld.parse "ibn" . stateCF) -- DEPRECATED
- ,(strCI "bottomup", PCF.parse "gb" . stateCF)
- ,(strCI "topdown", PCF.parse "gt" . stateCF)
--- commented for now, since there's a bug in the incremental algorithm:
--- ,(strCI "incremental", PCF.parse "ib" . stateCF)
--- ,(strCI "incremental-bottomup", PCF.parse "ib" . stateCF)
--- ,(strCI "incremental-topdown", PCF.parse "it" . stateCF)
- ,(strCI "old", chartParser . stateCF) -- DEPRECATED
- ,(strCI "myparser", myParser)
--- add your own parsers here
- ]
-
-customTokenizer =
- let sg = singleton in
- customData "Tokenizers, selected by option -lexer=x" $
- [
- (strCI "words", const $ sg . tokWords)
- ,(strCI "literals", const $ sg . tokLits)
- ,(strCI "vars", const $ sg . tokVars)
- ,(strCI "chars", const $ sg . map (tS . singleton))
- ,(strCI "code", const $ sg . lexHaskell)
- ,(strCI "codevars", \gr -> sg . (lexHaskellVar $ stateIsWord gr))
- ,(strCI "textvars", \gr -> sg . (lexTextVar $ stateIsWord gr))
- ,(strCI "text", const $ sg . lexText)
- ,(strCI "unglue", \gr -> sg . map tS . decomposeWords (stateMorpho gr))
- ,(strCI "codelit", \gr -> sg . (lexHaskellLiteral $ stateIsWord gr))
- ,(strCI "textlit", \gr -> sg . (lexTextLiteral $ stateIsWord gr))
- ,(strCI "codeC", const $ sg . lexC2M)
- ,(strCI "ignore", \gr -> sg . lexIgnore (stateIsWord gr) . tokLits)
- ,(strCI "subseqs", \gr -> subSequences . lexIgnore (stateIsWord gr) . tokLits)
- ,(strCI "codeCHigh", const $ sg . lexC2M' True)
--- add your own tokenizers here
- ]
-
-customUntokenizer =
- customData "Untokenizers, selected by option -unlexer=x" $
- [
- (strCI "unwords", const $ id) -- DEFAULT
- ,(strCI "text", const $ formatAsText)
- ,(strCI "html", const $ formatAsHTML)
- ,(strCI "latex", const $ formatAsLatex)
- ,(strCI "code", const $ formatAsCode)
- ,(strCI "concat", const $ filter (not . isSpace))
- ,(strCI "textlit", const $ formatAsTextLit)
- ,(strCI "codelit", const $ formatAsCodeLit)
- ,(strCI "concat", const $ concatRemSpace)
- ,(strCI "glue", const $ performBinds)
- ,(strCI "finnish", const $ performBindsFinnish)
- ,(strCI "reverse", const $ reverse)
- ,(strCI "bind", const $ performBinds) -- backward compat
--- add your own untokenizers here
- ]
-
-customUniCoding =
- customData "Alphabet codings, selected by option -coding=x" $
- [
- (strCI "latin1", id) -- DEFAULT
- ,(strCI "utf8", decodeUTF8)
- ,(strCI "greek", treat [] mkGreek)
- ,(strCI "hebrew", mkHebrew)
- ,(strCI "arabic", mkArabic)
- ,(strCI "russian", treat [] mkRussian)
- ,(strCI "russianKOI8", mkRusKOI8)
- ,(strCI "ethiopic", mkEthiopic)
- ,(strCI "tamil", mkTamil)
- ,(strCI "OCScyrillic", mkOCSCyrillic)
- ,(strCI "devanagari", mkDevanagari)
- ,(strCI "latinasupplement", mkLatinASupplement)
- ,(strCI "japanese", mkJapanese)
- ,(strCI "arabic0600", mkArabic0600)
- ,(strCI "extendedarabic", mkExtendedArabic)
- ,(strCI "extradiacritics", mkExtraDiacritics)
- ]
diff --git a/src/GF/UseGrammar/Editing.hs b/src/GF/UseGrammar/Editing.hs
deleted file mode 100644
index 762562eb0..000000000
--- a/src/GF/UseGrammar/Editing.hs
+++ /dev/null
@@ -1,435 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Editing
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:45 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.14 $
---
--- generic tree editing, with some grammar notions assumed. AR 18\/8\/2001.
--- 19\/6\/2003 for GFC
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Editing where
-
-import GF.Grammar.Abstract
-import qualified GF.Canon.GFC as GFC
-import GF.Grammar.TypeCheck
-import GF.Grammar.LookAbs
-import GF.Grammar.AbsCompute
-import GF.Grammar.Macros (errorCat)
-
-import GF.Data.Operations
-import GF.Data.Zipper
-
--- generic tree editing, with some grammar notions assumed. AR 18/8/2001
--- 19/6/2003 for GFC
-
-type CGrammar = GFC.CanonGrammar
-
-type State = Loc TrNode
-
--- | the "empty" state
-initState :: State
-initState = tree2loc uTree
-
-isRootState :: State -> Bool
-isRootState s = case actPath s of
- Top -> True
- _ -> False
-
-actTree :: State -> Tree
-actTree (Loc (t,_)) = t
-
-actPath :: State -> Path TrNode
-actPath (Loc (_,p)) = p
-
-actVal :: State -> Val
-actVal = valNode . nodeTree . actTree
-
-actCat :: State -> Cat
-actCat = errVal errorCat . val2cat . actVal ---- undef
-
-actAtom :: State -> Atom
-actAtom = atomTree . actTree
-
-actFun :: State -> Err Fun
-actFun s = case actAtom s of
- AtC f -> return f
- t -> prtBad "active atom: expected function, found" t
-
-actExp :: State -> Exp
-actExp = tree2exp . actTree
-
--- | current local bindings
-actBinds :: State -> Binds
-actBinds = bindsNode . nodeTree . actTree
-
--- | constraints in current subtree
-actConstrs :: State -> Constraints
-actConstrs = allConstrsTree . actTree
-
--- | constraints in the whole tree
-allConstrs :: State -> Constraints
-allConstrs = allConstrsTree . loc2tree
-
--- | metas in current subtree
-actMetas :: State -> [Meta]
-actMetas = metasTree . actTree
-
--- | metas in the whole tree
-allMetas :: State -> [Meta]
-allMetas = metasTree . loc2tree
-
-actTreeBody :: State -> Tree
-actTreeBody = bodyTree . actTree
-
-allPrevBinds :: State -> Binds
-allPrevBinds = concatMap bindsNode . traverseCollect . actPath
-
-allBinds :: State -> Binds
-allBinds s = actBinds s ++ allPrevBinds s
-
-actGen :: State -> Int
-actGen = length . allBinds -- symbol generator for VGen
-
-allPrevVars :: State -> [Var]
-allPrevVars = map fst . allPrevBinds
-
-allVars :: State -> [Var]
-allVars = map fst . allBinds
-
-vGenIndex :: State -> Int
-vGenIndex = length . allBinds
-
-actIsMeta :: State -> Bool
-actIsMeta = atomIsMeta . actAtom
-
-actMeta :: State -> Err Meta
-actMeta = getMetaAtom . actAtom
-
--- | meta substs are not only on the actual path...
-entireMetaSubst :: State -> MetaSubst
-entireMetaSubst = concatMap metaSubstsNode . scanTree . loc2tree
-
-isCompleteTree :: Tree -> Bool
-isCompleteTree = null . filter atomIsMeta . map atomNode . scanTree
-
-isCompleteState :: State -> Bool
-isCompleteState = isCompleteTree . loc2tree
-
-initStateCat :: Context -> Cat -> Err State
-initStateCat cont cat = do
- return $ tree2loc (Tr (mkNode [] mAtom (cat2val cont cat) ([],[]), []))
-
--- | this function only concerns the body of an expression...
-annotateInState :: CGrammar -> Exp -> State -> Err Tree
-annotateInState gr exp state = do
- let binds = allBinds state
- val = actVal state
- annotateIn gr binds exp (Just val)
-
--- | ...whereas this one works with lambda abstractions
-annotateExpInState :: CGrammar -> Exp -> State -> Err Tree
-annotateExpInState gr exp state = do
- let cont = allPrevBinds state
- binds = actBinds state
- val = actVal state
- typ <- mkProdVal binds val
- annotateIn gr binds exp (Just typ)
-
-treeByExp :: (Exp -> Err Exp) -> CGrammar -> Exp -> State -> Err Tree
-treeByExp trans gr exp0 state = do
- exp <- trans exp0
- annotateExpInState gr exp state
-
--- * actions
-
-type Action = State -> Err State
-
-newCat :: CGrammar -> Cat -> Action
-newCat gr cat@(m,c) _ = do
- cont <- lookupCatContext gr m c
- testErr (null cont) "start cat must have null context" -- for easier meta refresh
- initStateCat cont cat
-
-newFun :: CGrammar -> Fun -> Action
-newFun gr fun@(m,c) _ = do
- typ <- lookupFunType gr m c
- cat <- valCat typ
- st1 <- newCat gr cat initState
- refineWithAtom True gr (qq fun) st1
-
-newTree :: Tree -> Action
-newTree t _ = return $ tree2loc t
-
-newExpTC :: CGrammar -> Exp -> Action
-newExpTC gr t s = annotate gr (refreshMetas [] t) >>= flip newTree s
-
-goNextMeta, goPrevMeta, goNextNewMeta, goPrevNewMeta, goNextMetaIfCan :: Action
-
-goNextMeta = repeatUntilErr actIsMeta goAhead -- can be the location itself
-goPrevMeta = repeatUntilErr actIsMeta goBack
-
-goNextNewMeta s = goAhead s >>= goNextMeta -- always goes away from location
-goPrevNewMeta s = goBack s >>= goPrevMeta
-
-goNextMetaIfCan = actionIfPossible goNextMeta
-
-actionIfPossible :: Action -> Action
-actionIfPossible a s = return $ errVal s (a s)
-
-goFirstMeta, goLastMeta :: Action
-goFirstMeta s = goNextMeta $ goRoot s
-goLastMeta s = goLast s >>= goPrevMeta
-
-noMoreMetas :: State -> Bool
-noMoreMetas = err (const True) (const False) . goNextMeta
-
-replaceSubTree :: Tree -> Action
-replaceSubTree tree state = changeLoc state tree
-
-refineOrReplaceWithTree :: Bool -> CGrammar -> Tree -> Action
-refineOrReplaceWithTree der gr tree state = case actMeta state of
- Ok m -> refineWithTreeReal der gr tree m state
- _ -> do
- let tree1 = addBinds (actBinds state) $ tree
- state' <- replaceSubTree tree1 state
- reCheckState gr state'
-
-refineWithTree :: Bool -> CGrammar -> Tree -> Action
-refineWithTree der gr tree state = do
- m <- errIn "move pointer to meta" $ actMeta state
- refineWithTreeReal der gr tree m state
-
-refineWithTreeReal :: Bool -> CGrammar -> Tree -> Meta -> Action
-refineWithTreeReal der gr tree m state = do
- state' <- replaceSubTree tree state
- let cs0 = allConstrs state'
- (cs,ms) = splitConstraints gr cs0
- v = vClos $ tree2exp (bodyTree tree)
- msubst = (m,v) : ms
- metaSubstRefinements gr msubst $
- mapLoc (reduceConstraintsNode gr . performMetaSubstNode msubst) state'
-
- -- without dep. types, no constraints, no grammar needed - simply: do
- -- testErr (actIsMeta state) "move pointer to meta"
- -- replaceSubTree tree state
-
-refineAllNodes :: Action -> Action
-refineAllNodes act state = do
- let estate0 = goFirstMeta state
- case estate0 of
- Bad _ -> return state
- Ok state0 -> do
- (state',n) <- tryRefine 0 state0
- if n==0
- then return state
- else actionIfPossible goFirstMeta state'
- where
- tryRefine n state = err (const $ return (state,n)) return $ do
- state' <- goNextMeta state
- meta <- actMeta state'
- case act state' of
- Ok state2 -> tryRefine (n+1) state2
- _ -> err (const $ return (state',n)) return $ do
- state2 <- goNextNewMeta state'
- tryRefine n state2
-
-uniqueRefinements :: CGrammar -> Action
-uniqueRefinements = refineAllNodes . uniqueRefine
-
-metaSubstRefinements :: CGrammar -> MetaSubst -> Action
-metaSubstRefinements gr = refineAllNodes . metaSubstRefine gr
-
-contextRefinements :: CGrammar -> Action
-contextRefinements gr = refineAllNodes contextRefine where
- contextRefine state = case varRefinementsState state of
- [(e,_)] -> refineWithAtom False gr e state
- _ -> Bad "no unique refinement in context"
- varRefinementsState state =
- [r | r@(e,_) <- refinementsState gr state, isVariable e]
-
-uniqueRefine :: CGrammar -> Action
-uniqueRefine gr state = case refinementsState gr state of
- [(e,(_,True))] -> Bad "only circular refinement"
- [(e,_)] -> refineWithAtom False gr e state
- _ -> Bad "no unique refinement"
-
-metaSubstRefine :: CGrammar -> MetaSubst -> Action
-metaSubstRefine gr msubst state = do
- m <- errIn "move pointer to meta" $ actMeta state
- case lookup m msubst of
- Just v -> do
- e <- val2expSafe v
- refineWithExpTC False gr e state
- _ -> Bad "no metavariable substitution available"
-
-refineWithExpTC :: Bool -> CGrammar -> Exp -> Action
-refineWithExpTC der gr exp0 state = do
- let oldmetas = allMetas state
- exp = refreshMetas oldmetas exp0
- tree0 <- annotateInState gr exp state
- let tree = addBinds (actBinds state) $ tree0
- refineWithTree der gr tree state
-
-refineWithAtom :: Bool -> CGrammar -> Ref -> Action -- function or variable
-refineWithAtom der gr at state = do
- val <- lookupRef gr (allBinds state) at
- typ <- val2exp val
- let oldvars = allVars state
- exp <- ref2exp oldvars typ at
- refineWithExpTC der gr exp state
-
--- | in this command, we know that the result is well-typed, since computation
--- rules have been type checked and the result is equal
-computeSubTree :: CGrammar -> Action
-computeSubTree gr state = do
- let exp = tree2exp (actTree state)
- tree <- treeByExp (compute gr) gr exp state
- replaceSubTree tree state
-
--- | but here we don't, since the transfer flag isn't type checked,
--- and computing the transfer function is not checked to preserve equality
-transferSubTree :: Maybe Fun -> CGrammar -> Action
-transferSubTree Nothing _ s = return s
-transferSubTree (Just fun) gr state = do
- let exp = mkApp (qq fun) [tree2exp $ actTree state]
- tree <- treeByExp (compute gr) gr exp state
- state' <- replaceSubTree tree state
- reCheckState gr state'
-
-deleteSubTree :: CGrammar -> Action
-deleteSubTree gr state =
- if isRootState state
- then do
- let cat = actCat state
- newCat gr cat state
- else do
- let metas = allMetas state
- binds = actBinds state
- exp = refreshMetas metas mExp0
- tree <- annotateInState gr exp state
- state' <- replaceSubTree (addBinds binds tree) state
- reCheckState gr state' --- must be unfortunately done. 20/11/2001
-
-wrapWithFun :: CGrammar -> (Fun,Int) -> Action
-wrapWithFun gr (f@(m,c),i) state = do
- typ <- lookupFunType gr m c
- let olds = allPrevVars state
- oldmetas = allMetas state
- exp0 <- fun2wrap olds ((f,i),typ) (tree2exp (actTreeBody state))
- let exp = refreshMetas oldmetas exp0
- tree0 <- annotateInState gr exp state
- let tree = addBinds (actBinds state) $ tree0
- state' <- replaceSubTree tree state
- reCheckState gr state' --- must be unfortunately done. 20/11/2001
-
-alphaConvert :: CGrammar -> (Var,Var) -> Action
-alphaConvert gr (x,x') state = do
- let oldvars = allPrevVars state
- testErr (notElem x' oldvars) ("clash with previous bindings" +++ show x')
- let binds0 = actBinds state
- vars0 = map fst binds0
- testErr (notElem x' vars0) ("clash with other bindings" +++ show x')
- let binds = [(if z==x then x' else z, t) | (z,t) <- binds0]
- vars = map fst binds
- exp' <- alphaConv (vars ++ oldvars) (x,x') (tree2exp (actTreeBody state))
- let exp = mkAbs vars exp'
- tree <- annotateExpInState gr exp state
- replaceSubTree tree state
-
-changeFunHead :: CGrammar -> Fun -> Action
-changeFunHead gr f state = do
- let state' = changeNode (changeAtom (const (atomC f))) state
- reCheckState gr state' --- must be done because of constraints elsewhere
-
-peelFunHead :: CGrammar -> (Fun,Int) -> Action
-peelFunHead gr (f@(m,c),i) state = do
- tree0 <- nthSubtree i $ actTree state
- let tree = addBinds (actBinds state) $ tree0
- state' <- replaceSubTree tree state
- reCheckState gr state' --- must be unfortunately done. 20/11/2001
-
--- | an expensive operation
-reCheckState :: CGrammar -> State -> Err State
-reCheckState gr st = annotate gr (tree2exp (loc2tree st)) >>= return . tree2loc
-
--- | a variant that returns Bad instead of a tree with unsolvable constraints
-reCheckStateReject :: CGrammar -> State -> Err State
-reCheckStateReject gr st = do
- st' <- reCheckState gr st
- rejectUnsolvable st'
-
-rejectUnsolvable :: State -> Err State
-rejectUnsolvable st = case (constrsNode $ nodeTree $ actTree st) of
- [] -> return st
- cs -> Bad $ "Unsolvable constraints:" +++ prConstraints cs
-
--- | extract metasubstitutions from constraints and solve them
-solveAll :: CGrammar -> State -> Err State
-solveAll gr st = solve st >>= solve where
- solve st0 = do ---- why need twice?
- st <- reCheckState gr st0
- let cs0 = allConstrs st
- (cs,ms) = splitConstraints gr cs0
- metaSubstRefinements gr ms $
- mapLoc (reduceConstraintsNode gr . performMetaSubstNode ms) st
-
--- * active refinements
-
-refinementsState :: CGrammar -> State -> [(Term,(Val,Bool))]
-refinementsState gr state =
- let filt = possibleRefVal gr state in
- if actIsMeta state
- then refsForType filt gr (allBinds state) (actVal state)
- else []
-
-wrappingsState :: CGrammar -> State -> [((Fun,Int),Type)]
-wrappingsState gr state
- | actIsMeta state = []
- | isRootState state = funs
- | otherwise = [rule | rule@(_,typ) <- funs, possibleRefVal gr state aval typ]
- where
- funs = funsOnType (possibleRefVal gr state) gr aval
- aval = actVal state
-
-peelingsState :: CGrammar -> State -> [(Fun,Int)]
-peelingsState gr state
- | actIsMeta state = []
- | isRootState state =
- err (const []) (\f -> [(f,i) | i <- [0 .. arityTree tree - 1]]) $ actFun state
- | otherwise =
- err (const [])
- (\f -> [fi | (fi@(g,_),typ) <- funs,
- possibleRefVal gr state aval typ,g==f]) $ actFun state
- where
- funs = funsOnType (possibleRefVal gr state) gr aval
- aval = actVal state
- tree = actTree state
-
-headChangesState :: CGrammar -> State -> [Fun]
-headChangesState gr state = errVal [] $ do
- f@(m,c) <- funAtom (actAtom state)
- typ0 <- lookupFunType gr m c
- return [fun | (fun,typ) <- funRulesOf gr, fun /= f, typ == typ0]
- --- alpha-conv !
-
-possibleRefVal :: CGrammar -> State -> Val -> Type -> Bool
-possibleRefVal gr state val typ = errVal True $ do --- was False
- vtyp <- valType typ
- let gen = actGen state
- cs <- return [(val, vClos vtyp)] --- eqVal gen val (vClos vtyp) --- only poss cs
- return $ possibleConstraints gr cs --- a simple heuristic
-
-possibleTreeVal :: CGrammar -> State -> Tree -> Bool
-possibleTreeVal gr state tree = errVal True $ do --- was False
- let aval = actVal state
- let gval = valTree tree
- let gen = actGen state
- cs <- return [(aval, gval)] --- eqVal gen val (vClos vtyp) --- only poss cs
- return $ possibleConstraints gr cs --- a simple heuristic
-
diff --git a/src/GF/UseGrammar/Generate.hs b/src/GF/UseGrammar/Generate.hs
deleted file mode 100644
index 5f07e0b85..000000000
--- a/src/GF/UseGrammar/Generate.hs
+++ /dev/null
@@ -1,116 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Generate
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/12 12:38:30 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.16 $
---
--- Generate all trees of given category and depth. AR 30\/4\/2004
---
--- (c) Aarne Ranta 2004 under GNU GPL
---
--- Purpose: to generate corpora. We use simple types and don't
--- guarantee the correctness of bindings\/dependences.
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Generate (generateTrees,generateAll) where
-
-import GF.Canon.GFC
-import GF.Grammar.LookAbs
-import GF.Grammar.PrGrammar
-import GF.Grammar.Macros
-import GF.Grammar.Values
-import GF.Grammar.Grammar (Cat)
-import GF.Grammar.SGrammar
-import GF.Data.Operations
-import GF.Data.Zipper
-import GF.Infra.Option
-import Data.List
-
--- Generate all trees of given category and depth. AR 30/4/2004
--- (c) Aarne Ranta 2004 under GNU GPL
---
--- Purpose: to generate corpora. We use simple types and don't
--- guarantee the correctness of bindings/dependences.
-
-
--- | the main function takes an abstract syntax and returns a list of trees
-generateTrees ::
- Options -> GFCGrammar -> Cat -> Int -> Maybe Int -> Maybe Tree -> [Exp]
-generateTrees opts gr cat n mn mt = map str2tr $ generate gr' opts cat' n mn mt'
- where
- gr' = gr2sgr opts emptyProbs gr
- cat' = prt $ snd cat
- mt' = maybe Nothing (return . tr2str) mt
---- ifm = oElem withMetas opts
- ifm = oElem showOld opts
-
-generateAll :: Options -> (Exp -> IO ()) -> GFCGrammar -> Cat -> IO ()
-generateAll opts io gr cat = mapM_ (io . str2tr) $ num $ gen cat'
- where
- num = optIntOrAll opts flagNumber
- gr' = gr2sgr opts emptyProbs gr
- cat' = prt $ snd cat
- gen c = generate gr' opts c 10 Nothing Nothing
-
-
-
-------------------------------------------
--- do the main thing with a simpler data structure
--- the first Int gives tree depth, the second constrains subtrees
--- chosen for each branch. A small number, such as 2, is a good choice
--- if the depth is large (more than 3)
--- If a tree is given as argument, generation concerns its metavariables.
-
-generate :: SGrammar -> Options -> SCat -> Int -> Maybe Int -> Maybe STree -> [STree]
-generate gr opts cat i mn mt = case mt of
- Nothing -> gen opts cat
- Just t -> genM t
- where
---- now use ifm to choose between two algorithms
- gen opts cat
- | oElem (iOpt "mem") opts = concat $ errVal [] $ lookupTree id cat $ allTrees -- -old
- | oElem (iOpt "nonub") opts = concatMap (\i -> gener i cat) [0..i-1] -- some duplicates
- | otherwise = nub $ concatMap (\i -> gener i cat) [0..i-1] -- new
-
- gener 0 c = [SApp (f, []) | (f,([],_)) <- funs c]
- gener i c = [
- tr |
- (f,(cs,_)) <- funs c,
- let alts = map (gener (i-1)) cs,
- ts <- combinations alts,
- let tr = SApp (f, ts)
--- depth tr >= i -- NO!
- ]
-
- allTrees = genAll i
-
- -- dynamic generation
- genAll :: Int -> BinTree SCat [[STree]]
- genAll i = iter i genNext (mapTree (\ (c,_) -> (c,[[]])) gr)
-
- iter 0 f tr = tr
- iter n f tr = iter (n-1) f (f tr)
-
- genNext tr = mapTree (genNew tr) tr
-
- genNew tr (cat,ts) = let size = length ts in
- (cat, [SApp (f, xs) |
- (f,(cs,_)) <- funs cat,
- xs <- combinations (map look cs),
- let fxs = SApp (f, xs),
- depth fxs == size]
- : ts)
- where
- look c = concat $ errVal [] $ lookupTree id c tr
-
- funs cat = maybe id take mn $ errVal [] $ lookupTree id cat gr
-
- genM t = case t of
- SApp (f,ts) -> [SApp (f,ts') | ts' <- combinations (map genM ts)]
- SMeta k -> gen opts k
- _ -> [t]
diff --git a/src/GF/UseGrammar/GetTree.hs b/src/GF/UseGrammar/GetTree.hs
deleted file mode 100644
index e980a3d95..000000000
--- a/src/GF/UseGrammar/GetTree.hs
+++ /dev/null
@@ -1,74 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : GetTree
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/09/15 16:22:02 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.9 $
---
--- how to form linearizable trees from strings and from terms of different levels
---
--- 'String' --> raw 'Term' --> annot, qualif 'Term' --> 'Tree'
------------------------------------------------------------------------------
-
-module GF.UseGrammar.GetTree where
-
-import GF.Canon.GFC
-import GF.Grammar.Values
-import qualified GF.Grammar.Grammar as G
-import GF.Infra.Ident
-import GF.Grammar.MMacros
-import GF.Grammar.Macros
-import GF.Compile.Rename
-import GF.Grammar.TypeCheck
-import GF.Grammar.AbsCompute (beta)
-import GF.Compile.PGrammar
-import GF.Compile.ShellState
-
-import GF.Data.Operations
-
-import Data.Char
-
--- how to form linearizable trees from strings and from terms of different levels
---
--- String --> raw Term --> annot, qualif Term --> Tree
-
-string2tree :: StateGrammar -> String -> Tree
-string2tree gr = errVal uTree . string2treeErr gr
-
-string2treeErr :: StateGrammar -> String -> Err Tree
-string2treeErr _ "" = Bad "empty string"
-string2treeErr gr s = do
- t <- pTerm s
- let t0 = beta [] t
- let t1 = refreshMetas [] t0
- let t2 = qualifTerm abstr t1
- annotate grc t2
- where
- abstr = absId gr
- grc = grammar gr
-
-string2Cat, string2Fun :: StateGrammar -> String -> (Ident,Ident)
-string2Cat gr c = (absId gr,identC c)
-string2Fun = string2Cat
-
-strings2Cat, strings2Fun :: String -> (Ident,Ident)
-strings2Cat s = (identC m, identC (drop 1 c)) where (m,c) = span (/= '.') s
-strings2Fun = strings2Cat
-
-string2ref :: StateGrammar -> String -> Err G.Term
-string2ref gr s = case s of
- 'x':'_':ds -> return $ freshAsTerm ds --- hack for generated vars
- '"':_:_ -> return $ G.K $ init $ tail s
- _:_ | all isDigit s -> return $ G.EInt $ read s
- _ | elem '.' s -> return $ uncurry G.Q $ strings2Fun s
- _ -> return $ G.Vr $ identC s
-
-string2cat :: StateGrammar -> String -> Err G.Cat
-string2cat gr s =
- if elem '.' s
- then return $ strings2Fun s
- else return $ curry id (absId gr) (identC s)
diff --git a/src/GF/UseGrammar/Information.hs b/src/GF/UseGrammar/Information.hs
deleted file mode 100644
index 4526980d6..000000000
--- a/src/GF/UseGrammar/Information.hs
+++ /dev/null
@@ -1,162 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Information
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/10/05 20:02:20 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.7 $
---
--- information on module, category, function, operation, parameter,...
--- AR 16\/9\/2003.
--- uses source grammar
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Information (
- showInformation,
- missingLinCanonGrammar
- ) where
-
-import GF.Grammar.Grammar
-import GF.Infra.Ident
-import GF.Infra.Modules
-import GF.Infra.Option
-import GF.CF.CF
-import GF.CF.PPrCF
-import GF.Compile.ShellState
-import GF.Grammar.PrGrammar
-import GF.Grammar.Lookup
-import GF.Grammar.Macros (zIdent)
-import qualified GF.Canon.GFC as GFC
-import qualified GF.Canon.AbsGFC as AbsGFC
-
-import GF.Data.Operations
-import GF.Infra.UseIO
-
--- information on module, category, function, operation, parameter,... AR 16/9/2003
--- uses source grammar
-
--- | the top level function
-showInformation :: Options -> ShellState -> Ident -> IOE ()
-showInformation opts st c = do
- is <- ioeErr $ getInformation opts st c
- if null is
- then putStrLnE "Identifier not in scope"
- else mapM_ (putStrLnE . prInformationM c) is
- where
- prInformationM c (i,m) = prInformation opts c i ++ "file:" +++ m ++ "\n"
-
--- | the data type of different kinds of information
-data Information =
- IModAbs SourceAbs
- | IModRes SourceRes
- | IModCnc SourceCnc
- | IModule SourceAbs -- ^ to be deprecated
- | ICatAbs Ident Context [Ident]
- | ICatCnc Ident Type [CFRule] Term
- | IFunAbs Ident Type (Maybe Term)
- | IFunCnc Ident Type [CFRule] Term
- | IOper Ident Type Term
- | IParam Ident [Param] [Term]
- | IValue Ident Type
-
-type CatId = AbsGFC.CIdent
-type FunId = AbsGFC.CIdent
-
-prInformation :: Options -> Ident -> Information -> String
-prInformation opts c i = unlines $ prt c : case i of
- IModule m -> [
- "module of type" +++ show (mtype m),
- "extends" +++ show (extends m),
- "opens" +++ show (opens m),
- "defines" +++ unwords (map prt (ownConstants (jments m)))
- ]
- ICatAbs m co _ -> [
- "category in abstract module" +++ prt m,
- if null co then "not a dependent type"
- else "dependent type with context" +++ prContext co
- ]
- ICatCnc m ty cfs tr -> [
- "category in concrete module" +++ prt m,
- "linearization type" +++ prt ty
- ]
- IFunAbs m ty _ -> [
- "function in abstract module" +++ prt m,
- "type" +++ prt ty
- ]
- IFunCnc m ty cfs tr -> [
- "function in concrete module" +++ prt m,
- "linearization" +++ prt tr
- --- "linearization type" +++ prt ty
- ]
- IOper m ty tr -> [
- "operation in resource module" +++ prt m,
- "type" +++ prt ty,
- "definition" +++ prt tr
- ]
- IParam m ty ts -> [
- "parameter type in resource module" +++ prt m,
- "constructors" +++ unwords (map prParam ty),
- "values" +++ unwords (map prt ts)
- ]
- IValue m ty -> [
- "parameter constructor in resource module" +++ prt m,
- "type" +++ show ty
- ]
-
--- | also finds out if an identifier is defined in many places
-getInformation :: Options -> ShellState -> Ident -> Err [(Information,FilePath)]
-getInformation opts st c = allChecks $ [
- do
- m <- lookupModule src c
- case m of
- ModMod mo -> returnm c $ IModule mo
- _ -> prtBad "not a source module" c
- ] ++ map lookInSrc ss ++ map lookInCan cs
- where
- lookInSrc (i,m) = do
- j <- lookupInfo m c
- case j of
- AbsCat (Yes co) _ -> returnm i $ ICatAbs i co [] ---
- AbsFun (Yes ty) _ -> returnm i $ IFunAbs i ty Nothing ---
- CncCat (Yes ty) _ _ -> do
- ---- let cat = ident2CFCat i c
- ---- rs <- concat [rs | (c,rs) <- cf, ]
- returnm i $ ICatCnc i ty [] ty ---
- CncFun _ (Yes tr) _ -> do
- rs <- return []
- returnm i $ IFunCnc i tr rs tr ---
- ResOper (Yes ty) (Yes tr) -> returnm i $ IOper i ty tr
- ResParam (Yes (ps,_)) -> do
- ts <- allParamValues src (QC i c)
- returnm i $ IParam i ps ts
- ResValue (Yes (ty,_)) -> returnm i $ IValue i ty ---
-
- _ -> prtBad "nothing available for" i
- lookInCan (i,m) = do
- Bad "nothing available yet in canonical"
-
- returnm m i = return (i, pathOfModule st m)
-
- src = srcModules st
- can = canModules st
- ss = [(i,m) | (i,ModMod m) <- modules src]
- cs = [(i,m) | (i,ModMod m) <- modules can]
- cf = concatMap ruleGroupsOfCF $ map snd $ cfs st
-
-ownConstants :: BinTree Ident Info -> [Ident]
-ownConstants = map fst . filter isOwn . tree2list where
- isOwn (c,i) = case i of
- AnyInd _ _ -> False
- _ -> True
-
-missingLinCanonGrammar :: GFC.CanonGrammar -> String
-missingLinCanonGrammar cgr =
- unlines $ concat [prt_ c : missing js | (c,js) <- concretes] where
- missing js = map ((" " ++) . prt_) $ filter (not . flip isInBinTree js) abstract
- abstract = err (const []) (map fst . tree2list . jments) $ lookupModMod cgr absId
- absId = maybe (zIdent "") id $ greatestAbstract cgr
- concretes = [(cnc,jments mo) |
- cnc <- allConcretes cgr absId, Ok mo <- [lookupModMod cgr cnc]]
diff --git a/src/GF/UseGrammar/Linear.hs b/src/GF/UseGrammar/Linear.hs
deleted file mode 100644
index c9b94ccb0..000000000
--- a/src/GF/UseGrammar/Linear.hs
+++ /dev/null
@@ -1,292 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Linear
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/11/14 16:03:41 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.19 $
---
--- Linearization for canonical GF. AR 7\/6\/2003
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Linear where
-
-import GF.Canon.GFC
-import GF.Canon.AbsGFC
-import qualified GF.Grammar.Abstract as A
-import GF.Canon.MkGFC (rtQIdent) ----
-import GF.Infra.Ident
-import GF.Grammar.PrGrammar
-import GF.Canon.CMacros
-import GF.Canon.Look
-import GF.Grammar.LookAbs
-import GF.Grammar.MMacros
-import GF.Grammar.TypeCheck (annotate) ----
-import GF.Data.Str
-import GF.Text.Text
-----import TypeCheck -- to annotate
-
-import GF.Data.Operations
-import GF.Data.Zipper
-import qualified GF.Infra.Modules as M
-
-import Control.Monad
-import Data.List (intersperse)
-
--- Linearization for canonical GF. AR 7/6/2003
-
--- | The worker function: linearize a Tree, return
--- a record. Possibly mark subtrees.
---
--- NB. Constants in trees are annotated by the name of the abstract module.
--- A concrete module name must be given to find (and choose) linearization rules.
---
--- - If no marking is wanted, 'noMark' :: 'Marker'.
---
--- - For xml marking, use 'markXML' :: 'Marker'
-linearizeToRecord :: CanonGrammar -> Marker -> Ident -> A.Tree -> Err Term
-linearizeToRecord gr mk m = lin [] where
-
- lin ts t@(Tr (n,xs)) = errIn ("linearization of" +++ prt t) $ do
-
- let binds = A.bindsNode n
- at = A.atomNode n
- fmk = markSubtree mk n ts (A.isFocusNode n)
- c <- A.val2cat $ A.valNode n
- xs' <- mapM (\ (i,x) -> lin (i:ts) x) $ zip [0..] xs
-
- r <- case at of
- A.AtC f -> lookf c t f >>= comp xs'
- A.AtI i -> return $ recInt i
- A.AtL s -> return $ recS $ tK $ prt at
- A.AtF i -> return $ recS $ tK $ prt at
- A.AtV x -> lookCat c >>= comp [tK (prt_ at)]
- A.AtM m -> lookCat c >>= comp [tK (prt_ at)]
-
- r' <- case r of -- to see stg in case the result is variants {}
- FV [] -> lookCat c >>= comp [tK (prt_ t)]
- _ -> return r
-
- return $ fmk $ mkBinds binds r'
-
- look = lookupLin gr . redirectIdent m . rtQIdent
- comp = ccompute gr
- mkBinds bs bdy = case bdy of
- R fs -> R $ [Ass (LV i) (tK (prt t)) | (i,(t,_)) <- zip [0..] bs] ++ fs
- FV rs -> FV $ map (mkBinds bs) rs
-
- recS t = R [Ass (L (identC "s")) t] ----
-
- recInt i = R [
- Ass (L (identC "last")) (EInt (rem i 10)),
- Ass (L (identC "s")) (tK $ show i),
- Ass (L (identC "size")) (EInt (if i > 9 then 1 else 0))
- ]
-
- lookCat = return . errVal defLindef . look
- ---- should always be given in the module
-
- -- to show missing linearization as term
- lookf c t f = case look f of
- Ok h -> return h
- _ -> lookCat c >>= comp [tK (prt_ t)]
-
-
--- | thus the special case:
-linearizeNoMark :: CanonGrammar -> Ident -> A.Tree -> Err Term
-linearizeNoMark gr = linearizeToRecord gr noMark
-
--- | expand tables in linearized term to full, normal-order tables
---
--- NB expand from inside-out so that values are not looked up in copies of branches
-
-expandLinTables :: CanonGrammar -> Term -> Err Term
-expandLinTables gr t = case t of
- R rs -> liftM (R . map (uncurry Ass)) $ mapPairsM exp [(l,r) | Ass l r <- rs]
- T ty rs -> do
- rs' <- mapPairsM exp [(l,r) | Cas l r <- rs] -- expand from inside-out
- let t' = T ty $ map (uncurry Cas) rs'
- vs <- alls ty
- ps <- mapM term2patt vs
- ts' <- mapM (comp . S t') $ vs
- return $ T ty [Cas [p] t | (p,t) <- zip ps ts']
- V ty ts0 -> do
- ts <- mapM exp ts0 -- expand from inside-out
- vs <- alls ty
- ps <- mapM term2patt vs
- return $ T ty [Cas [p] t | (p,t) <- zip ps ts]
- FV ts -> liftM FV $ mapM exp ts
- _ -> composOp exp t
- where
- alls = allParamValues gr
- exp = expandLinTables gr
- comp = ccompute gr []
-
--- Do this for an entire grammar:
-
-unoptimizeCanon :: CanonGrammar -> CanonGrammar
-unoptimizeCanon g@(M.MGrammar ms) = M.MGrammar $ map (unoptimizeCanonMod g) ms
-
-unoptimizeCanonMod :: CanonGrammar -> CanonModule -> CanonModule
-unoptimizeCanonMod g = convMod where
- convMod (m, M.ModMod (M.Module (M.MTConcrete a) x flags me os defs)) =
- (m, M.ModMod (M.Module (M.MTConcrete a) x flags me os (mapTree convDef defs)))
- convMod mm = mm
- convDef (c,CncCat ty df pr) = (c,CncCat ty (convT df) (convT pr))
- convDef (f,CncFun c xs li pr) = (f,CncFun c xs (convT li) (convT pr))
- convDef cd = cd
- convT = err error id . exp
- -- a version of expandLinTables that does not destroy share optimization
- exp t = case t of
- R rs -> liftM (R . map (uncurry Ass)) $ mapPairsM exp [(l,r) | Ass l r <- rs]
- T ty rs@[Cas [_] _] -> do
- rs' <- mapPairsM exp [(l,r) | Cas l r <- rs] -- expand from inside-out
- let t' = T ty $ map (uncurry Cas) rs'
- vs <- alls ty
- ps <- mapM term2patt vs
- ts' <- mapM (comp . S t') $ vs
- return $ T ty [Cas [p] t | (p,t) <- zip ps ts']
- V ty ts0 -> do
- ts <- mapM exp ts0 -- expand from inside-out
- vs <- alls ty
- ps <- mapM term2patt vs
- return $ T ty [Cas [p] t | (p,t) <- zip ps ts]
- FV ts -> liftM FV $ mapM exp ts
- I _ -> comp t
- _ -> composOp exp t
- where
- alls = allParamValues g
- comp = ccompute g []
-
-
--- | from records, one can get to records of tables of strings
-rec2strTables :: Term -> Err [[(Label,[([Patt],[Str])])]]
-rec2strTables r = do
- vs <- allLinValues r
- mapM (mapPairsM (mapPairsM strsFromTerm)) vs
-
--- | from these tables, one may want to extract the ones for the "s" label
-strTables2sTables :: [[(Label,[([Patt],[Str])])]] -> [[([Patt],[Str])]]
-strTables2sTables ts = [t | r <- ts, (l,t) <- r, l == linLab0]
-
-linLab0 :: Label
-linLab0 = L (identC "s")
-
--- | to get lists of token lists is easy
-sTables2strs :: [[([Patt],[Str])]] -> [[Str]]
-sTables2strs = map snd . concat
-
--- | from this, to get a list of strings
-strs2strings :: [[Str]] -> [String]
-strs2strings = map unlex
-
--- | this is just unwords; use an unlexer from Text to postprocess
-unlex :: [Str] -> String
-unlex = concat . map sstr . take 1 ----
-
--- | finally, a top-level function to get a string from an expression
-linTree2string :: Marker -> CanonGrammar -> Ident -> A.Tree -> String
-linTree2string mk gr m e = head $ linTree2strings mk gr m e -- never empty
-
--- | you can also get many strings
-linTree2strings :: Marker -> CanonGrammar -> Ident -> A.Tree -> [String]
-linTree2strings mk gr m e = err return id $ do
- t <- linearizeToRecord gr mk m e
- r <- expandLinTables gr t
- ts <- rec2strTables r
- let ss = strs2strings $ sTables2strs $ strTables2sTables ts
- ifNull (prtBad "empty linearization of" e) return ss -- thus never empty
-
--- | argument is a Tree, value is a list of strs; needed in Parsing
-allLinsOfTree :: CanonGrammar -> Ident -> A.Tree -> [Str]
-allLinsOfTree gr a e = err (singleton . str) id $ do
- e' <- return e ---- annotateExp gr e
- r <- linearizeNoMark gr a e'
- r' <- expandLinTables gr r
- ts <- rec2strTables r'
- return $ concat $ sTables2strs $ strTables2sTables ts
-
--- | the value is a list of structures arranged as records of tables of terms
-allLinsAsRec :: CanonGrammar -> Ident -> A.Tree -> Err [[(Label,[([Patt],Term)])]]
-allLinsAsRec gr c t = linearizeNoMark gr c t >>= expandLinTables gr >>= allLinValues
-
--- | the value is a list of structures arranged as records of tables of strings
--- only taking into account string fields
--- True: sep. by /, False: sep by \n
-allLinTables ::
- Bool -> CanonGrammar ->Ident ->A.Tree ->Err [[(Label,[([Patt],[String])])]]
-allLinTables slash gr c t = do
- r' <- allLinsAsRec gr c t
- mapM (mapM getS) r'
- where
- getS (lab,pss) = liftM (curry id lab) $ mapM gets pss
- gets (ps,t) = liftM (curry id ps . cc . map str2strings) $ strsFromTerm t
- cc = concat . intersperse [if slash then "/" else "\n"]
-
--- | the value is a list of strings gathered from all fields
-
-allLinBranchFields :: CanonGrammar -> Ident -> A.Tree -> Err [String]
-allLinBranchFields gr c trm = do
- r <- linearizeNoMark gr c trm >>= expandLinTables gr
- return [s | (_,t) <- allLinBranches r, s <- gets t]
- where
- gets t = concat [cc (map str2strings s) | Ok s <- [strsFromTerm t]]
- cc = concat . intersperse ["/"]
-
-prLinTable :: Bool -> [[(Label,[([Patt],[String])])]] -> [String]
-prLinTable pars = concatMap prOne . concat where
- prOne (lab,pss) = (if pars then ((prt lab) :) else id) (map pr pss) ----
- pr (ps,ss) = (if pars then ((unwords (map prt_ ps) +++ ":") +++)
- else id) (unwords ss)
-
-{-
--- the value is a list of strs
-allLinStrings :: CanonGrammar -> Tree -> [Str]
-allLinStrings gr ft = case allLinsAsStrs gr ft of
- Ok ts -> map snd $ concat $ map snd $ concat ts
- Bad s -> [str s]
-
--- the value is a list of strs, not forgetting their arguments
-allLinsAsStrs :: CanonGrammar -> Tree -> Err [[(Label,[([Patt],Str)])]]
-allLinsAsStrs gr ft = do
- lpts <- allLinearizations gr ft
- return $ concat $ mapM (mapPairsM (mapPairsM strsFromTerm)) lpts
-
-
--- to a list of strings
-linearizeToStrings :: CanonGrammar -> ([Int] ->Term -> Term) -> Tree -> Err [String]
-linearizeToStrings gr mk = liftM (map unlex) . linearizeToStrss gr mk
-
--- to a list of token lists
-linearizeToStrss :: CanonGrammar -> ([Int] -> Term -> Term) -> Tree -> Err [[Str]]
-linearizeToStrss gr mk e = do
- R rs <- linearizeToRecord gr mk e ----
- t <- lookupErr linLab0 [(r,s) | Ass r s <- rs]
- return $ map strsFromTerm $ allInTable t
--}
-
--- | the value is a list of strings, not forgetting their arguments
-allLinsOfFun :: CanonGrammar -> CIdent -> Err [[(Label,[([Patt],Term)])]]
-allLinsOfFun gr f = do
- t <- lookupLin gr f
- allAllLinValues t --- all fields, not only s. 11/12/2005
-
-
--- | returns printname if one exists; otherwise linearizes with metas
-printOrLinearize :: CanonGrammar -> Ident -> A.Fun -> String
-printOrLinearize gr c f@(m, d) = errVal (prt fq) $
- case lookupPrintname gr (CIQ c d) of
- Ok t -> do
- ss <- strsFromTerm t
- let s = strs2strings [ss]
- return $ ifNull (prt fq) head s
- _ -> do
- ty <- lookupFunType gr m d
- f' <- ref2exp [] ty (A.QC m d)
- tr <- annotate gr f'
- return $ linTree2string noMark gr c tr
- where
- fq = CIQ m d
diff --git a/src/GF/UseGrammar/MatchTerm.hs b/src/GF/UseGrammar/MatchTerm.hs
deleted file mode 100644
index 9acffd44c..000000000
--- a/src/GF/UseGrammar/MatchTerm.hs
+++ /dev/null
@@ -1,50 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : MatchTerm
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
---
--- functions for matching with terms. AR 16/3/2006
------------------------------------------------------------------------------
-
-module GF.UseGrammar.MatchTerm where
-
-import GF.Data.Operations
-import GF.Data.Zipper
-
-import GF.Grammar.Grammar
-import GF.Grammar.PrGrammar
-import GF.Infra.Ident
-import GF.Grammar.Values
-import GF.Grammar.Macros
-import GF.Grammar.MMacros
-
-import Control.Monad
-import Data.List
-
--- test if a term has duplicated idents, either any or just atoms
-
-hasDupIdent, hasDupAtom :: Exp -> Bool
-hasDupIdent = (>1) . maximum . map length . group . sort . allConstants True
-hasDupAtom = (>1) . maximum . map length . group . sort . allConstants False
-
--- test if a certain ident occurs in term
-
-grepIdent :: Ident -> Exp -> Bool
-grepIdent c = elem c . allConstants True
-
--- form the list of all constants, optionally ignoring all but atoms
-
-allConstants :: Bool -> Exp -> [Ident]
-allConstants alsoApp = err (const []) snd . flip appSTM [] . collect where
- collect e = case e of
- Q _ c -> add c e
- QC _ c -> add c e
- Cn c -> add c e
- App f a | not alsoApp -> case f of
- App g b -> collect b >> collect a
- _ -> collect a
- _ -> composOp collect e
- add c e = updateSTM (c:) >> return e
diff --git a/src/GF/UseGrammar/Morphology.hs b/src/GF/UseGrammar/Morphology.hs
deleted file mode 100644
index 3aeb08dc7..000000000
--- a/src/GF/UseGrammar/Morphology.hs
+++ /dev/null
@@ -1,140 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Morphology
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:49 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.8 $
---
--- Morphological analyser constructed from a GF grammar.
---
--- we first found the binary search tree sorted by word forms more efficient
--- than a trie, at least for grammars with 7000 word forms
--- (18\/11\/2003) but this may change since we have to use a trie
--- for decompositions and also want to use it in the parser
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Morphology where
-
-import GF.Canon.AbsGFC
-import GF.Canon.GFC
-import GF.Grammar.PrGrammar
-import GF.Canon.CMacros
-import GF.Canon.Look
-import GF.Grammar.LookAbs
-import GF.Infra.Ident
-import qualified GF.Grammar.Macros as M
-import GF.UseGrammar.Linear
-
-import GF.Data.Operations
-import GF.Data.Glue
-
-import Data.Char
-import Data.List (sortBy, intersperse)
-import Control.Monad (liftM)
-import GF.Data.Trie2
-
--- construct a morphological analyser from a GF grammar. AR 11/4/2001
-
--- we first found the binary search tree sorted by word forms more efficient
--- than a trie, at least for grammars with 7000 word forms
--- (18\/11\/2003) but this may change since we have to use a trie
--- for decompositions and also want to use it in the parser
-
-type Morpho = Trie Char String
-
-emptyMorpho :: Morpho
-emptyMorpho = emptyTrie
-
-appMorpho :: Morpho -> String -> (String,[String])
-appMorpho = appMorphoOnly
----- add lookup for literals
-
--- without literals
-appMorphoOnly :: Morpho -> String -> (String,[String])
-appMorphoOnly m s = trieLookup m s
-
--- recognize word, exluding literals
-isKnownWord :: Morpho -> String -> Bool
-isKnownWord mo = not . null . snd . appMorphoOnly mo
-
-mkMorpho :: CanonGrammar -> Ident -> Morpho
-mkMorpho gr a = tcompile $ concatMap mkOne $ allItems where
-
- comp = ccompute gr [] -- to undo 'values' optimization
-
- mkOne (Left (fun,c)) = map (prOne fun c) $ allLins fun
- mkOne (Right (fun,_)) = map (prSyn fun) $ allSyns fun
-
- -- gather forms of lexical items
- allLins fun@(m,f) = errVal [] $ do
- ts <- lookupLin gr (CIQ a f) >>= comp >>= allAllLinValues
- ss <- mapM (mapPairsM (mapPairsM (liftM wordsInTerm . comp))) ts
- return [(p,s) | (p,fs) <- concat $ map snd $ concat ss, s <- fs]
- prOne (_,f) c (ps,s) = (s, [prt f +++ tagPrt c +++ unwords (map prt_ ps)])
-
- -- gather syncategorematic words
- allSyns fun@(m,f) = errVal [] $ do
- tss <- allLinsOfFun gr (CIQ a f)
- let ss = [s | ts <- tss, (_,fs) <- ts, (_,s) <- fs]
- return $ concat $ map wordsInTerm ss
- prSyn f s = (s, ["+" ++ tagPrt f])
-
- -- all words, Left from lexical rules and Right syncategorematic
- allItems = [lexRole t (f,c) | (f,c,t) <- allFuns] where
- allFuns = [(f,c,t) | (f,t) <- funRulesOf gr, Ok c <- [M.valCat t]]
- lexRole t = case M.typeForm t of
- Ok ([],_,_) -> Left
- _ -> Right
-
--- printing full-form lexicon and results
-
-prMorpho :: Morpho -> String
-prMorpho = unlines . map prMorphoAnalysis . collapse
-
-prMorphoAnalysis :: (String,[String]) -> String
-prMorphoAnalysis (w,fs0) =
- let fs = filter (not . null) fs0 in
- if null fs then w ++++ "*" else unlines (w:fs)
-
-prMorphoAnalysisShort :: (String,[String]) -> String
-prMorphoAnalysisShort (w,fs) = prBracket (w' ++ prTList "/" fs) where
- w' = if null fs then w +++ "*" else ""
-
-tagPrt :: Print a => (a,a) -> String
-tagPrt (m,c) = "+" ++ prt c --- module name
-
--- | print all words recognized
-allMorphoWords :: Morpho -> [String]
-allMorphoWords = map fst . collapse
-
--- analyse running text and show results either in short form or on separate lines
-
--- | analyse running text and show just the word, with "*" if not found
-morphoTextStatus :: Morpho -> String -> String
-morphoTextStatus mo = unlines . map (prMark . appMorpho mo) . words where
- prMark (w,fs) = if null fs then "*" +++ w else w
-
--- | analyse running text and show results in short form, one word per line
-morphoTextShort :: Morpho -> String -> String
-morphoTextShort mo = unlines . map (prMorphoAnalysisShort . appMorpho mo) . words
-
--- | analyse running text and show results on separate lines
-morphoText :: Morpho -> String -> String
-morphoText mo = unlines . map (('\n':) . prMorphoAnalysis . appMorpho mo) . words
-
--- format used in the Italian Verb Engine
-prFullForm :: Morpho -> String
-prFullForm = unlines . map prOne . collapse where
- prOne (s,ps) = s ++ " : " ++ unwords (intersperse "/" ps)
-
--- using Huet's unglueing method to find word boundaries
----- it would be much better to use a trie also for morphological analysis,
----- so this is for the sake of experiment
----- Moreover, we should specify the cases in which this happens - not all words
-
-decomposeWords :: Morpho -> String -> [String]
-decomposeWords mo s = errVal (words s) $ decomposeSimple mo s
diff --git a/src/GF/UseGrammar/Paraphrases.hs b/src/GF/UseGrammar/Paraphrases.hs
deleted file mode 100644
index d04f22aa6..000000000
--- a/src/GF/UseGrammar/Paraphrases.hs
+++ /dev/null
@@ -1,70 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Paraphrases
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:49 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.6 $
---
--- paraphrases of GF terms. AR 6\/10\/1998 -- 24\/9\/1999 -- 5\/7\/2000 -- 5\/6\/2002
---
--- Copyright (c) Aarne Ranta 1998--99, under GNU General Public License (see GPL)
---
--- thus inherited from the old GF. Incomplete and inefficient...
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Paraphrases (mkParaphrases) where
-
-import GF.Grammar.Abstract
-import GF.Grammar.PrGrammar
-import GF.Grammar.LookAbs
-import GF.Grammar.AbsCompute
-
-import GF.Data.Operations
-
-import Data.List (nub)
-
--- paraphrases of GF terms. AR 6/10/1998 -- 24/9/1999 -- 5/7/2000 -- 5/6/2002
--- Copyright (c) Aarne Ranta 1998--99, under GNU General Public License (see GPL)
--- thus inherited from the old GF. Incomplete and inefficient...
-
-mkParaphrases :: GFCGrammar -> Term -> [Term]
-mkParaphrases st = nub . map (beta []) . paraphrases (allDefs st)
-
-type Definition = (Fun,Term)
-
-paraphrases :: [Definition] -> Term -> [Term]
-paraphrases th t =
- paraImmed th t ++
---- paraMatch th t ++
- case t of
- App c a -> [App d b | d <- paraphrases th c, b <- paraphrases th a]
- Abs x b -> [Abs x d | d <- paraphrases th b]
- c -> []
- ++ [t]
-
-paraImmed :: [Definition] -> Term -> [Term]
-paraImmed defs t =
- [Q m f | ((m,f), u) <- defs, t == u] ++ --- eqTerm
- case t of
- ---- Cn c -> [u | (f, u) <- defs, eqStrIdent f c]
- _ -> []
-
-{- ---
-paraMatch :: [Definition] -> Trm -> [Trm]
-paraMatch th@defs t =
- [mkApp (Cn f) xx | (PC f zz, u) <- defs,
- let (fs,sn) = fullApp u, fs == h, length sn == length zz] ++
- case findAMatch defs t of
- Ok (g,b) -> [substTerm [] g b]
- _ -> []
- where
- (h,xx) = fullApp t
- fullApp c = case c of
- App f a -> (f', a' ++ [a]) where (f',a') = fullApp f
- c -> (c,[])
-
--}
diff --git a/src/GF/UseGrammar/Parsing.hs b/src/GF/UseGrammar/Parsing.hs
deleted file mode 100644
index 2ca057410..000000000
--- a/src/GF/UseGrammar/Parsing.hs
+++ /dev/null
@@ -1,177 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Parsing
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/06/02 10:23:52 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.25 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Parsing where
-
-import GF.Infra.CheckM
-import qualified GF.Canon.AbsGFC as C
-import GF.Canon.GFC
-import GF.Canon.MkGFC (trExp) ----
-import GF.Canon.CMacros
-import GF.Grammar.MMacros (refreshMetas)
-import GF.UseGrammar.Linear
-import GF.Data.Str
-import GF.CF.CF
-import GF.CF.CFIdent
-import GF.Infra.Ident
-import GF.Grammar.TypeCheck
-import GF.Grammar.Values
---import CFMethod
-import GF.UseGrammar.Tokenize
-import GF.UseGrammar.Morphology (isKnownWord)
-import GF.CF.Profile
-import GF.Infra.Option
-import GF.UseGrammar.Custom
-import GF.Compile.ShellState
-
-import GF.CF.PPrCF (prCFTree)
--- import qualified GF.OldParsing.ParseGFC as NewOld -- OBSOLETE
-import qualified GF.Parsing.GFC as New
-
-import GF.Data.Operations
-
-import Data.List (nub,sortBy)
-import Data.Char (toLower)
-import Control.Monad (liftM)
-
--- AR 26/1/2000 -- 8/4 -- 28/1/2001 -- 9/12/2002
-
-parseString :: Options -> StateGrammar -> CFCat -> String -> Err [Tree]
-parseString os sg cat = liftM fst . parseStringMsg os sg cat
-
-parseStringMsg :: Options -> StateGrammar -> CFCat -> String -> Err ([Tree],String)
-parseStringMsg os sg cat s = do
- case checkStart $ parseStringC os sg cat s of
- Ok (ts,(_,ss)) -> return (ts, unlines $ reverse ss)
- Bad s -> return ([],s)
-
-parseStringC :: Options -> StateGrammar -> CFCat -> String -> Check [Tree]
-parseStringC opts0 sg cat s
- | oElem (iOpt "old") opts0 ||
- (not (oElem (iOpt "fcfg") opts0) && stateHasHOAS sg) = do
- let opts = unionOptions opts0 $ stateOptions sg
- cf = stateCF sg
- gr = stateGrammarST sg
- cn = cncId sg
- toks = customOrDefault opts useTokenizer customTokenizer sg s
- parser = customOrDefault opts useParser customParser sg cat
- if oElem (iOpt "cut") opts
- then doUntil (not . null) $ map (tokens2trms opts sg cn parser) toks
- else mapM (tokens2trms opts sg cn parser) toks >>= return . concat
-
----- | or [oElem p opts0 |
----- p <- [newCParser,newMParser,newFParser,newParser,newerParser] = do
-
- | otherwise = do
- let opts = unionOptions opts0 $ stateOptions sg
- algorithm | oElem newCParser opts0 = "c"
- | oElem newMParser opts0 = "m"
- | oElem newFParser opts0 = "f"
- | otherwise = "f" -- default algorithm: FCFG
- strategy = maybe "bottomup" id $ getOptVal opts useParser
- -- -parser=bottomup/topdown
- tokenizer = customOrDefault opts useTokenizer customTokenizer sg
- toks = case tokenizer s of
- t:_ -> t
- _ -> [] ---- no support for undet. tok.
- unknowns =
- [w | TC w <- toks, unk w && unk (uncap w)] ++ [w | TS w <- toks, unk w]
- where
- unk w = not $ isKnownWord (morpho sg) w
- uncap (c:cs) = toLower c : cs
- uncap s = s
-
- case unknowns of
- _:_ | oElem (iOpt "trynextlang") opts -> return []
- _:_ -> fail $ "Unknown words:" +++ unwords unknowns
- _ -> do
-
- ts <- checkErr $ New.parse algorithm strategy (pInfo sg) (absId sg) cat toks
- ts' <- checkErr $
- allChecks $ map (annotate (stateGrammarST sg) . refreshMetas []) ts
- return $ optIntOrAll opts flagNumber ts'
-
-
-tokens2trms :: Options ->StateGrammar ->Ident -> CFParser -> [CFTok] -> Check [Tree]
-tokens2trms opts sg cn parser toks = trees2trms opts sg cn toks trees info
- where result = parser toks
- info = snd result
- trees = {- nub $ -} cfParseResults result -- peb 25/5-04: removed nub (O(n^2))
-
-trees2trms ::
- Options -> StateGrammar -> Ident -> [CFTok] -> [CFTree] -> String -> Check [Tree]
-trees2trms opts sg cn as ts0 info = do
- let s = unwords $ map prCFTok as
- ts <- case () of
- _ | null ts0 -> checkWarn ("No success in cf parsing" +++ s) >> return []
- _ | raw -> do
- ts1 <- return (map cf2trm0 ts0) ----- should not need annot
- checks [
- mapM (checkErr . (annotate gr) . trExp) ts1 ---- complicated, often fails
- ,checkWarn (unlines ("Raw CF trees:":(map prCFTree ts0))) >> return []
- ]
- _ -> do
- let num = optIntOrN opts flagRawtrees 999999
- let (ts01,rest) = splitAt num ts0
- if null rest then return ()
- else raise ("Warning: only" +++ show num +++ "raw parses out of" +++
- show (length ts0) +++
- "considered; use -rawtrees= to see more"
- )
- (ts1,ss) <- checkErr $ mapErrN 1 postParse ts01
- if null ts1 then raise ss else return ()
- ts2 <- checkErr $
- allChecks $ map (annotate gr . refreshMetas [] . trExp) ts1 ----
- if forgive then return ts2 else do
- let tsss = [(t, allLinsOfTree gr cn t) | t <- ts2]
- ps = [t | (t,ss) <- tsss,
- any (compatToks as) (map str2cftoks ss)]
- if null ps
- then raise $ "Failure in morphology." ++
- if verb
- then "\nPossible corrections: " +++++
- unlines (nub (map sstr (concatMap snd tsss)))
- else ""
- else return ps
- if verb
- then checkWarn $ " the token list" +++ show as ++++ unknownWords sg as +++++ info
- else return ()
-
- return $ optIntOrAll opts flagNumber $ nub ts
- where
- gr = stateGrammarST sg
-
- raw = oElem rawParse opts
- verb = oElem beVerbose opts
- forgive = oElem forgiveParse opts
-
----- Operatins.allChecks :: ErrorMonad m => [m a] -> m [a]
-
-unknownWords sg ts = case filter noMatch [t | t@(TS _) <- ts] of
- [] -> "where all words are known"
- us -> "with the unknown tokens" +++ show us --- needs to be fixed for literals
- where
- terminals = map TS $ stateGrammarWords sg
- noMatch t = all (not . compatTok t) terminals
-
-
---- too much type checking in building term info? return FullTerm to save work?
-
--- | raw parsing: so simple it is for a context-free CF grammar
-cf2trm0 :: CFTree -> C.Exp
-cf2trm0 (CFTree (fun, (_, trees))) = mkAppAtom (cffun2trm fun) (map cf2trm0 trees)
- where
- cffun2trm (CFFun (fun,_)) = fun
- mkApp = foldl C.EApp
- mkAppAtom a = mkApp (C.EAtom a)
diff --git a/src/GF/UseGrammar/Randomized.hs b/src/GF/UseGrammar/Randomized.hs
deleted file mode 100644
index c1c77edb2..000000000
--- a/src/GF/UseGrammar/Randomized.hs
+++ /dev/null
@@ -1,66 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Randomized
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:51 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.8 $
---
--- random generation and refinement. AR 22\/8\/2001.
--- implemented as sequence of refinement menu selecsions, encoded as integers
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Randomized where
-
-import GF.Grammar.Abstract
-import GF.UseGrammar.Editing
-
-import GF.Data.Operations
-import GF.Data.Zipper
-
---- import Arch (myStdGen) --- circular for hbc
-import System.Random --- (mkStdGen, StdGen, randoms) --- bad import for hbc
-
--- random generation and refinement. AR 22/8/2001
--- implemented as sequence of refinement menu selecsions, encoded as integers
-
-myStdGen :: Int -> StdGen
-myStdGen = mkStdGen ---
-
--- | build one random tree; use mx to prevent infinite search
-mkRandomTree :: StdGen -> Int -> CGrammar -> Either Cat Fun -> Err Tree
-mkRandomTree gen mx gr cat = mkTreeFromInts (take mx (randoms gen)) gr cat
-
-refineRandom :: StdGen -> Int -> CGrammar -> Action
-refineRandom gen mx = mkStateFromInts $ take mx $ map abs (randoms gen)
-
--- | build a tree from a list of integers
-mkTreeFromInts :: [Int] -> CGrammar -> Either Cat Fun -> Err Tree
-mkTreeFromInts ints gr catfun = do
- st0 <- either (\cat -> newCat gr cat initState)
- (\fun -> newFun gr fun initState)
- catfun
- state <- mkStateFromInts ints gr st0
- return $ loc2tree state
-
-mkStateFromInts :: [Int] -> CGrammar -> Action
-mkStateFromInts ints gr z = mkRandomState ints z >>= reCheckState gr where
- mkRandomState [] state = do
- testErr (isCompleteState state) "not completed"
- return state
- mkRandomState (n:ns) state = do
- let refs = refinementsState gr state
- refs0 = map (not . snd . snd) refs
- testErr (not (null refs0)) $ "no nonrecursive refinements available for" +++
- prt (actVal state)
- (ref,_) <- (refs !? (n `mod` (length refs)))
- state1 <- refineWithAtom False gr ref state
- if isCompleteState state1
- then return state1
- else do
- state2 <- goNextMeta state1
- mkRandomState ns state2
-
diff --git a/src/GF/UseGrammar/Session.hs b/src/GF/UseGrammar/Session.hs
deleted file mode 100644
index e54d0e3fb..000000000
--- a/src/GF/UseGrammar/Session.hs
+++ /dev/null
@@ -1,181 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Session
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/08/17 15:13:55 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.12 $
---
--- (Description of the module)
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Session where
-
-import GF.Grammar.Abstract
-import GF.Infra.Option
-import GF.UseGrammar.Custom
-import GF.UseGrammar.Editing
-import GF.Compile.ShellState ---- grammar
-
-import GF.Data.Operations
-import GF.Data.Zipper (keepPosition) ---
-
--- First version 8/2001. Adapted to GFC with modules 19/6/2003.
--- Nothing had to be changed, which is a sign of good modularity.
-
--- keep these abstract
-
--- | 'Exp'-list: candidate refinements,clipboard
-type SState = [(State,([Exp],[Clip]),SInfo)]
-
--- | 'String' is message, 'Int' is the view
-type SInfo = ([String],(Int,Options))
-
-initSState :: SState
-initSState = [(initState, ([],[]), (["Select 'New' category to start"],(0,noOptions)))]
- -- instead of empty
-
-type Clip = Tree ---- (Exp,Type)
-
--- | (peb): Something wrong with this definition??
--- Shouldn't the result type be 'SInfo'?
---
--- > okInfo :: Int -> SInfo == ([String], (Int, Options))
-okInfo :: n -> ([s], (n, Bool))
-okInfo n = ([],(n,True))
-
-stateSState :: SState -> State
-candsSState :: SState -> [Exp]
-clipSState :: SState -> [Clip]
-infoSState :: SState -> SInfo
-msgSState :: SState -> [String]
-viewSState :: SState -> Int
-optsSState :: SState -> Options
-
-stateSState ((s,_,_):_) = s
-candsSState ((_,(ts,_),_):_)= ts
-clipSState ((_,(_,ts),_):_)= ts
-infoSState ((_,_,i):_) = i
-msgSState ((_,_,(m,_)):_) = m
-viewSState ((_,_,(_,(v,_))):_) = v
-optsSState ((_,_,(_,(_,o))):_) = o
-
-treeSState :: SState -> Tree
-treeSState = actTree . stateSState
-
-
--- | from state to state
-type ECommand = SState -> SState
-
--- * elementary commands
-
--- ** change state, drop cands, drop message, preserve options
-
-changeState :: State -> ECommand
-changeState s ss = changeMsg [] $ (s,([],clipSState ss),infoSState ss) : ss
-
-changeCands :: [Exp] -> ECommand
-changeCands ts ss@((s,(_,cb),(_,b)):_) = (s,(ts,cb),(candInfo ts,b)) : ss
-
-addtoClip :: Clip -> ECommand
-addtoClip t ss@((s,(ts,cb),(i,b)):_) = (s,(ts,t:cb),(i,b)) : ss
-
-removeClip :: Int -> ECommand
-removeClip n ss@((s,(ts,cb),(i,b)):_) = (s,(ts, drop n cb),(i,b)) : ss
-
-changeMsg :: [String] -> ECommand
-changeMsg m ((s,ts,(_,b)):ss) = (s,ts,(m,b)) : ss -- just change message
-changeMsg m _ = (s,ts,(m,b)) : [] where [(s,ts,(_,b))] = initSState
-
-changeView :: ECommand
-changeView ((s,ts,(m,(v,b))):ss) = (s,ts,(m,(v+1,b))) : ss -- toggle view
-
-withMsg :: [String] -> ECommand -> ECommand
-withMsg m c = changeMsg m . c
-
-changeStOptions :: (Options -> Options) -> ECommand
-changeStOptions f ((s,ts,(m,(v,o))):ss) = (s,ts,(m,(v, f o))) : ss
-
-noNeedForMsg :: ECommand
-noNeedForMsg = changeMsg [] -- everything's all right: no message
-
-candInfo :: [Exp] -> [String]
-candInfo ts = case length ts of
- 0 -> ["no acceptable alternative"]
- 1 -> ["just one acceptable alternative"]
- n -> [show n +++ "alternatives to select"]
-
--- * keep SState abstract from this on
-
--- ** editing commands
-
-action2command :: Action -> ECommand
-action2command act state = case act (stateSState state) of
- Ok s -> changeState s state
- Bad m -> changeMsg [m] state
-
-action2commandNext :: Action -> ECommand -- move to next meta after execution
-action2commandNext act = action2command (\s -> act s >>= goNextMetaIfCan)
-
-action2commandKeep :: Action -> ECommand -- keep old position after execution
-action2commandKeep act = action2command (\s -> keepPosition act s)
-
-undoCommand :: Int -> ECommand
-undoCommand n ss =
- let k = length ss in
- if k < n
- then changeMsg ["cannot go all the way back"] [last ss]
- else changeMsg ["successful undo"] (drop n ss)
-
-selectCand :: CGrammar -> Int -> ECommand
-selectCand gr i state = err (\m -> changeMsg [m] state) id $ do
- exp <- candsSState state !? i
- let s = stateSState state
- tree <- annotateInState gr exp s
- return $ case replaceSubTree tree s of
- Ok st' -> changeState st' state
- Bad s -> changeMsg [s] state
-
-refineByExps :: Bool -> CGrammar -> [Exp] -> ECommand
-refineByExps der gr trees = case trees of
- [t] -> action2commandNext (refineWithExpTC der gr t)
- _ -> changeCands trees
-
-refineByTrees :: Bool -> CGrammar -> [Tree] -> ECommand
-refineByTrees der gr trees = case trees of
- [t] -> action2commandNext (refineOrReplaceWithTree der gr t)
- _ -> changeCands $ map tree2exp trees
-
-replaceByTrees :: CGrammar -> [Exp] -> ECommand
-replaceByTrees gr trees = case trees of
- [t] -> action2commandNext (\s ->
- annotateExpInState gr t s >>= flip replaceSubTree s)
- _ -> changeCands trees
-
-replaceByEditCommand :: StateGrammar -> String -> ECommand
-replaceByEditCommand gr co =
- action2commandKeep $
- maybe return ($ gr) $
- lookupCustom customEditCommand (strCI co)
-
-replaceByTermCommand :: Bool -> StateGrammar -> String -> Tree -> ECommand ----
-replaceByTermCommand der gr co exp =
- let g = grammar gr in
- refineByTrees der g $ maybe [exp] (\f -> f gr exp) $
- lookupCustom customTermCommand (strCI co)
-
-possClipsSState :: StateGrammar -> SState -> [(Int,Clip)]
-possClipsSState gr s = filter poss $ zip [0..] (clipSState s)
- where
- poss = possibleTreeVal cgr st . snd
- st = stateSState s
- cgr = grammar gr
-
-getNumberedClip :: Int -> SState -> Err Clip
-getNumberedClip i s = if length cs > i then return (cs !! i)
- else Bad "not enough clips"
- where
- cs = clipSState s
diff --git a/src/GF/UseGrammar/Statistics.hs b/src/GF/UseGrammar/Statistics.hs
deleted file mode 100644
index 46e4fcc3b..000000000
--- a/src/GF/UseGrammar/Statistics.hs
+++ /dev/null
@@ -1,44 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Statistics
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/09/04 11:45:38 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.1 $
---
--- statistics on canonical grammar: amounts of generated code
--- AR 4\/9\/2005.
--- uses canonical grammar
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Statistics (prStatistics) where
-
-import GF.Infra.Modules
-import GF.Infra.Option
-import GF.Grammar.PrGrammar
-import GF.Canon.GFC
-import GF.Canon.MkGFC
-
-import GF.Data.Operations
-
-import Data.List (sortBy)
-
--- | the top level function
-prStatistics :: CanonGrammar -> String
-prStatistics can = unlines $ [
- show (length mods) ++ "\t\t modules",
- show chars ++ "\t\t gfc size",
- "",
- "Top 40 definitions"
- ] ++
- [show d ++ "\t\t " ++ f | (d,f) <- tops]
- where
- tops = take 40 $ reverse $ sortBy (\ (i,_) (j,_) -> compare i j) defs
- defs = [(length (prt (info2def j)), name m j) | (m,j) <- infos]
- infos = [(m,j) | (m,ModMod mo) <- mods, j <- tree2list (jments mo)]
- name m (f,_) = prt m ++ "." ++ prt f
- mods = modules can
- chars = length $ prCanon can
diff --git a/src/GF/UseGrammar/Tokenize.hs b/src/GF/UseGrammar/Tokenize.hs
deleted file mode 100644
index 9f1ab5449..000000000
--- a/src/GF/UseGrammar/Tokenize.hs
+++ /dev/null
@@ -1,222 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Tokenize
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/09/29 13:20:08 $
--- > CVS $Author: aarne $
--- > CVS $Revision: 1.14 $
---
--- lexers = tokenizers, to prepare input for GF grammars. AR 4\/1\/2002.
--- an entry for each is included in 'Custom.customTokenizer'
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Tokenize ( tokWords,
- tokLits,
- tokVars,
- lexHaskell,
- lexHaskellLiteral,
- lexHaskellVar,
- lexText,
- lexTextVar,
- lexC2M, lexC2M',
- lexTextLiteral,
- lexIgnore,
- wordsLits
- ) where
-
-import GF.Data.Operations
----- import UseGrammar (isLiteral,identC)
-import GF.CF.CFIdent
-
-import Data.Char
-
--- lexers = tokenizers, to prepare input for GF grammars. AR 4/1/2002
--- an entry for each is included in Custom.customTokenizer
-
--- | just words
-tokWords :: String -> [CFTok]
-tokWords = map tS . words
-
-tokLits :: String -> [CFTok]
-tokLits = map mkCFTok . mergeStr . wordsLits where
- mergeStr ss = case ss of
- w@(c:cs):rest | elem c "\'\"" && c /= last w -> getStr [w] rest
- w :rest -> w : mergeStr rest
- [] -> []
- getStr v ss = case ss of
- w@(_:_):rest | elem (last w) "\'\"" -> (unwords (reverse (w:v))) : mergeStr rest
- w :rest -> getStr (w:v) rest
- [] -> reverse v
-
-tokVars :: String -> [CFTok]
-tokVars = map mkCFTokVar . wordsLits
-
-isFloat s = case s of
- c:cs | isDigit c -> isFloat cs
- '.':cs@(_:_) -> all isDigit cs
- _ -> False
-
-isString s = case s of
- c:cs@(_:_) -> (c == '\'' && d == '\'') || (c == '"' && d == '"') where d = last cs
- _ -> False
-
-
-mkCFTok :: String -> CFTok
-mkCFTok s = case s of
- '"' :cs@(_:_) | last cs == '"' -> tL $ init cs
- '\'':cs@(_:_) | last cs == '\'' -> tL $ init cs --- 's Gravenhage
- _:_ | isFloat s -> tF s
- _:_ | all isDigit s -> tI s
- _ -> tS s
-
-mkCFTokVar :: String -> CFTok
-mkCFTokVar s = case s of
- '?':_:_ -> tM s --- "?" --- compat with prCF
- 'x':'_':_ -> tV s
- 'x':[] -> tV s
- '$':xs@(_:_) -> if last s == '$' then tV (init xs) else tS s
- _ -> tS s
-
-mkTokVars :: (String -> [CFTok]) -> String -> [CFTok]
-mkTokVars tok = map tv . tok where
- tv (TS s) = mkCFTokVar s
- tv t = t
-
-mkLit :: String -> CFTok
-mkLit s
- | isFloat s = tF s
- | all isDigit s = tI s
- | otherwise = tL s
-
--- obsolete
-mkTL :: String -> CFTok
-mkTL s
- | isFloat s = tF s
- | all isDigit s = tI s
- | otherwise = tL ("'" ++ s ++ "'")
-
-
--- | Haskell lexer, usable for much code
-lexHaskell :: String -> [CFTok]
-lexHaskell ss = case lex ss of
- [(w@(_:_),ws)] -> tS w : lexHaskell ws
- _ -> []
-
--- | somewhat shaky text lexer
-lexText :: String -> [CFTok]
-lexText = uncap . lx where
-
- lx s = case s of
- '?':'?':cs -> tS "??" : lx cs
- p : cs | isMPunct p -> tS [p] : uncap (lx cs)
- p : cs | isPunct p -> tS [p] : lx cs
- s : cs | isSpace s -> lx cs
- _ : _ -> getWord s
- _ -> []
-
- getWord s = tS w : lx ws where (w,ws) = span isNotSpec s
- isMPunct c = elem c ".!?"
- isPunct c = elem c ",:;()\""
- isNotSpec c = not (isMPunct c || isPunct c || isSpace c)
- uncap (TS (c:cs) : ws) = tC (c:cs) : ws
- uncap s = s
-
--- | lexer for C--, a mini variant of C
-lexC2M :: String -> [CFTok]
-lexC2M = lexC2M' False
-
-lexC2M' :: Bool -> String -> [CFTok]
-lexC2M' isHigherOrder s = case s of
- '#':cs -> lexC $ dropWhile (/='\n') cs
- '/':'*':cs -> lexC $ dropComment cs
- c:cs | isSpace c -> lexC cs
- c:cs | isAlpha c -> getId s
- c:cs | isDigit c -> getLit s
- c:d:cs | isSymb [c,d] -> tS [c,d] : lexC cs
- c:cs | isSymb [c] -> tS [c] : lexC cs
- _ -> [] --- covers end of file and unknown characters
- where
- lexC = lexC2M' isHigherOrder
- getId s = mkT i : lexC cs where (i,cs) = span isIdChar s
- getLit s = tI i : lexC cs where (i,cs) = span isDigit s ---- Float!
- isIdChar c = isAlpha c || isDigit c || elem c "'_"
- isSymb = reservedAnsiCSymbol
- dropComment s = case s of
- '*':'/':cs -> cs
- _:cs -> dropComment cs
- _ -> []
- mkT i = if (isRes i) then (tS i) else
- if isHigherOrder then (tV i) else (tL ("'" ++ i ++ "'"))
- isRes = reservedAnsiC
-
-
-reservedAnsiCSymbol s = case lookupTree show s ansiCtree of
- Ok True -> True
- _ -> False
-
-reservedAnsiC s = case lookupTree show s ansiCtree of
- Ok False -> True
- _ -> False
-
--- | for an efficient lexer: precompile this!
-ansiCtree = buildTree $ [(s,True) | s <- reservedAnsiCSymbols] ++
- [(s,False) | s <- reservedAnsiCWords]
-
-reservedAnsiCSymbols = words $
- "<<= >>= << >> ++ -- == <= >= *= += -= %= /= &= ^= |= " ++
- "^ { } = , ; + * - ( ) < > & % ! ~"
-
-reservedAnsiCWords = words $
- "auto break case char const continue default " ++
- "do double else enum extern float for goto if int " ++
- "long register return short signed sizeof static struct switch typedef " ++
- "union unsigned void volatile while " ++
- "main printin putchar" --- these are not ansi-C
-
--- | turn unknown tokens into string literals; not recursively for literals 123, 'foo'
-unknown2string :: (String -> Bool) -> [CFTok] -> [CFTok]
-unknown2string isKnown = map mkOne where
- mkOne t@(TS s)
- | isKnown s = t
- | isFloat s = tF s
- | all isDigit s = tI s
- | otherwise = tL s
- mkOne t@(TC s) = if isKnown s then t else mkLit s
- mkOne t = t
-
-unknown2var :: (String -> Bool) -> [CFTok] -> [CFTok]
-unknown2var isKnown = map mkOne where
- mkOne t@(TS "??") = if isKnown "??" then t else tM "??"
- mkOne t@(TS s)
- | isKnown s = t
- | isFloat s = tF s
- | isString s = tL (init (tail s))
- | all isDigit s = tI s
- | otherwise = tV s
- mkOne t@(TC s) = if isKnown s then t else tV s
- mkOne t = t
-
-lexTextLiteral, lexHaskellLiteral, lexHaskellVar :: (String -> Bool) -> String -> [CFTok]
-
-lexTextLiteral isKnown = unknown2string (eitherUpper isKnown) . lexText
-lexHaskellLiteral isKnown = unknown2string isKnown . lexHaskell
-
-lexHaskellVar isKnown = unknown2var isKnown . lexHaskell
-lexTextVar isKnown = unknown2var (eitherUpper isKnown) . lexText
-
-
-eitherUpper isKnown w@(c:cs) = isKnown (toLower c : cs) || isKnown (toUpper c : cs)
-eitherUpper isKnown w = isKnown w
-
--- ignore unknown tokens (e.g. keyword spotting)
-
-lexIgnore :: (String -> Bool) -> [CFTok] -> [CFTok]
-lexIgnore isKnown = concatMap mkOne where
- mkOne t@(TS s)
- | isKnown s = [t]
- | otherwise = []
- mkOne t = [t]
-
diff --git a/src/GF/UseGrammar/Transfer.hs b/src/GF/UseGrammar/Transfer.hs
deleted file mode 100644
index 5d62f4385..000000000
--- a/src/GF/UseGrammar/Transfer.hs
+++ /dev/null
@@ -1,79 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Transfer
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/04/21 16:23:53 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.5 $
---
--- linearize, parse, etc, by transfer. AR 9\/10\/2003
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Transfer where
-
-import GF.Grammar.Grammar
-import GF.Grammar.Values
-import GF.Grammar.AbsCompute
-import qualified GF.Canon.GFC as GFC
-import GF.Grammar.LookAbs
-import GF.Grammar.MMacros
-import GF.Grammar.Macros
-import GF.Grammar.PrGrammar
-import GF.Grammar.TypeCheck
-
-import GF.Infra.Ident
-import GF.Data.Operations
-
-import qualified Transfer.Core.Abs as T
-
-import Control.Monad
-
-
--- transfer is done in T.Exp - we only need these conversions.
-
-exp2core :: Ident -> Exp -> T.Exp
-exp2core f = T.EApp (T.EVar (var f)) . exp2c where
- exp2c e = case e of
- App f a -> T.EApp (exp2c f) (exp2c a)
- Abs x b -> T.EAbs (T.PVVar (var x)) (exp2c b) ---- should be syntactic abstr
- Q _ c -> T.EVar (var c)
- QC _ c -> T.EVar (var c)
- K s -> T.EStr s
- EInt i -> T.EInteger $ toInteger i
- Meta m -> T.EMeta (T.TMeta (prt m)) ---- which meta symbol?
- Vr x -> T.EVar (var x) ---- should be syntactic var
-
- var x = T.CIdent $ prt x
-
-core2exp :: T.Exp -> Exp
-core2exp e = case e of
- T.EApp f a -> App (core2exp f) (core2exp a)
- T.EAbs (T.PVVar x) b -> Abs (var x) (core2exp b) ---- only from syntactic abstr
- T.EVar c -> Vr (var c) -- GF annotates to Q or QC
- T.EStr s -> K s
- T.EInteger i -> EInt $ fromInteger i
- T.EMeta _ -> uExp -- meta symbol 0, refreshed by GF
- where
- var :: T.CIdent -> Ident
- var (T.CIdent x) = zIdent x
-
-
-
--- The following are now obsolete (30/11/2005)
--- linearize, parse, etc, by transfer. AR 9/10/2003
-
-doTransfer :: GFC.CanonGrammar -> Ident -> Tree -> Err Tree
-doTransfer gr tra t = do
- cat <- liftM snd $ val2cat $ valTree t
- f <- lookupTransfer gr tra cat
- e <- compute gr $ App f $ tree2exp t
- annotate gr e
-
-useByTransfer :: (Tree -> Err a) -> GFC.CanonGrammar -> Ident -> (Tree -> Err a)
-useByTransfer lin gr tra t = doTransfer gr tra t >>= lin
-
-mkByTransfer :: (a -> Err [Tree]) -> GFC.CanonGrammar -> Ident -> (a -> Err [Tree])
-mkByTransfer parse gr tra s = parse s >>= mapM (doTransfer gr tra)
diff --git a/src/GF/UseGrammar/TreeSelections.hs b/src/GF/UseGrammar/TreeSelections.hs
deleted file mode 100644
index 9bf2711be..000000000
--- a/src/GF/UseGrammar/TreeSelections.hs
+++ /dev/null
@@ -1,77 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : TreeSelections
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- choose shallowest trees, and remove an overload resolution prefix
------------------------------------------------------------------------------
-
-module GF.UseGrammar.TreeSelections (
-
- getOverloadResults, smallestTrs, sizeTr, depthTr
-
- ) where
-
-import GF.Grammar.Abstract
-import GF.Grammar.Macros
-
-import GF.Data.Operations
-import GF.Data.Zipper
-import Data.List
-
--- AR 2/7/2007
--- The top-level function takes a set of trees (typically parses)
--- and returns the list of those trees that have the minimum size.
--- In addition, the overload prefix "ovrld123_", is removed
--- from each constructor in which it appears. This is used for
--- showing the library API constructors in a parsable grammar.
--- TODO: access the generic functions smallestTrs, sizeTr, depthTr from shell
-
-getOverloadResults :: [Tree] -> [Tree]
-getOverloadResults = smallestTrs sizeTr . map (mkOverload "ovrld")
-
--- NB: this does not always give the desired result, since
--- some genuine alternatives may be deeper: now we will exclude the
--- latter of
---
--- mkCl this_NP love_V2 (mkNP that_NP here_Adv)
--- mkCl this_NP (mkVP (mkVP love_V2 that_NP) here_Adv)
---
--- A perfect method would know the definitional equivalences of constructors.
---
--- Notice also that size is a better measure than depth, because:
--- 1. Global depth does not exclude the latter of
---
--- mkCl (mkNP he_Pron) love_V2 that_NP
--- mkCl (mkNP he_Pron) (mkVP love_V2 that_NP)
---
--- 2. Length is needed to exclude the latter of
---
--- mkS (mkCl (mkNP he_Pron) love_V2 that_NP)
--- mkS presentTense (mkCl (mkNP he_Pron) love_V2 that_NP)
---
-
-smallestTrs :: (Tr a -> Int) -> [Tr a] -> [Tr a]
-smallestTrs size ts = map fst $ filter ((==mx) . snd) tds where
- tds = [(t, size t) | t <- ts]
- mx = minimum $ map snd tds
-
-depthTr :: Tr a -> Int
-depthTr (Tr (_, ts)) = case ts of
- [] -> 1
- _ -> 1 + (maximum $ map depthTr ts)
-
-sizeTr :: Tr a -> Int
-sizeTr (Tr (_, ts)) = 1 + sum (map sizeTr ts)
-
--- remove from each constant a prefix starting with "pref", up to first "_"
--- example format: ovrld123_mkNP
-
-mkOverload :: String -> Tree -> Tree
-mkOverload pref = mapTr (changeAtom overAtom) where
- overAtom a = case a of
- AtC (m, IC f) | isPrefixOf pref f ->
- AtC (m, IC (tail (dropWhile (/='_') f)))
- _ -> a
diff --git a/src/GF/UseGrammar/Treebank.hs b/src/GF/UseGrammar/Treebank.hs
deleted file mode 100644
index 841a9c6dc..000000000
--- a/src/GF/UseGrammar/Treebank.hs
+++ /dev/null
@@ -1,251 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Treebank
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- Generate multilingual treebanks. AR 8\/2\/2006
---
--- (c) Aarne Ranta 2006 under GNU GPL
---
--- Purpose: to generate treebanks.
------------------------------------------------------------------------------
-
-module GF.UseGrammar.Treebank (
- mkMultiTreebank,
- mkUniTreebank,
- multi2uniTreebank,
- uni2multiTreebank,
- testMultiTreebank,
- treesTreebank,
- getTreebank,
- getUniTreebank,
- readUniTreebanks,
- readMultiTreebank,
- lookupTreebank,
- assocsTreebank,
- isWordInTreebank,
- printAssoc,
- mkCompactTreebank
- ) where
-
-import GF.Compile.ShellState
-import GF.UseGrammar.Linear -- (linTree2string)
-import GF.UseGrammar.Custom
-import GF.UseGrammar.GetTree (string2tree)
-import GF.Grammar.TypeCheck (annotate)
-import GF.Canon.CMacros (noMark)
-import GF.Grammar.Grammar (Trm)
-import GF.Grammar.MMacros (exp2tree)
-import GF.Grammar.Macros (zIdent)
-import GF.Grammar.PrGrammar (prt_,prt)
-import GF.Grammar.Values (tree2exp)
-import GF.Data.Operations
-import GF.Infra.Option
-import GF.Infra.Ident (Ident)
-import GF.Infra.UseIO
-import qualified GF.Grammar.Abstract as A
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.List as L
-import Control.Monad (liftM)
-import System.FilePath
-
--- Generate a treebank with a multilingual grammar. AR 8/2/2006
--- (c) Aarne Ranta 2006 under GNU GPL
-
--- keys are trees; format: XML file
-type MultiTreebank = [(String,[(String,String)])] -- tree,lang,lin
-
--- keys are strings; format: string TAB tree TAB ... TAB tree
-type UniTreebank = Treebank -- M.Map String [String] -- string,tree
-
--- both formats can be read from both kinds of files
-readUniTreebanks :: FilePath -> IO [(Ident,UniTreebank)]
-readUniTreebanks file = do
- s <- readFileIf file
- return $ if isMultiTreebank s
- then multi2uniTreebank $ getTreebank $ lines s
- else
- let tb = getUniTreebank $ lines s
- in [(zIdent (dropExtension file),tb)]
-
-readMultiTreebank :: FilePath -> IO MultiTreebank
-readMultiTreebank file = do
- s <- readFileIf file
- return $ if isMultiTreebank s
- then getTreebank $ lines s
- else uni2multiTreebank (zIdent (dropExtension file)) $ getUniTreebank $ lines s
-
-isMultiTreebank :: String -> Bool
-isMultiTreebank s = take 10 s == ""
-
-multi2uniTreebank :: MultiTreebank -> [(Ident,UniTreebank)]
-multi2uniTreebank mt@((_,lls):_) = [(zIdent la, mkTb la) | (la,_) <- lls] where
- mkTb la = M.fromListWith (++) [(s,[t]) | (t,lls) <- mt, (l,s) <- lls, l==la]
-multi2uniTreebank [] = []
-
-uni2multiTreebank :: Ident -> UniTreebank -> MultiTreebank
-uni2multiTreebank la tb =
- [(t,[(prt_ la, s)]) | (s,ts) <- assocsTreebank tb, t <- ts]
-
--- | the main functions
-
--- builds a treebank where trees are the keys, and writes a file (opt. XML)
-mkMultiTreebank :: Options -> ShellState -> String -> [A.Tree] -> Res
-mkMultiTreebank opts sh com trees
- | oElem (iOpt "compact") opts = mkCompactTreebank opts sh trees
-mkMultiTreebank opts sh com trees =
- putInXML opts "treebank" comm (concatMap mkItem tris) where
- mkItem(t,i)= putInXML opts "item" (cat i) (mkTree t ++ concatMap (mkLin t) langs)
--- mkItem(t,i)= putInXML opts "item" (cat i) (mkTree t >>mapM_ (mkLin t) langs)
- mkTree t = putInXML opts "tree" [] (puts $ showTree t)
- mkLin t lg = putInXML opts "lin" (lang lg) (puts $ linearize opts sh lg t)
-
- langs = [prt_ l | l <- allLanguages sh]
- comm = "" --- " command=" ++ show com +++ "abstract=" ++ show abstr
- abstr = "" --- "Abs" ----
- cat i = " number=" ++ show (show i) --- " cat=" ++ show "S" ----
- lang lg = " lang=" ++ show (prt_ (zIdent lg))
- tris = zip trees [1..]
-
--- builds a unilingual treebank where strings are the keys into an internal treebank
-
-mkUniTreebank :: Options -> ShellState -> Language -> [A.Tree] -> Treebank
-mkUniTreebank opts sh lg trees = M.fromListWith (++) [(lin t, [prt_ t]) | t <- trees]
- where
- lang = prt_ lg
- lin t = linearize opts sh lang t
-
--- reads a treebank and linearizes its trees again, printing all differences
-testMultiTreebank :: Options -> ShellState -> String -> Res
-testMultiTreebank opts sh = putInXML opts "testtreebank" [] .
- concatMap testOne .
- getTreebanks . lines
- where
- testOne (e,lang,str0) = do
- let tr = annot gr e
- let str = linearize opts sh lang tr
- if str == str0 then ret else putInXML opts "diff" [] $ concat [
- putInXML opts "tree" [] (puts $ showTree tr),
- putInXML opts "old" (" lang=" ++ show (prt_ (zIdent lang))) $ puts str0,
- putInXML opts "new" (" lang=" ++ show (prt_ (zIdent lang))) $ puts str
- ]
- gr = firstStateGrammar sh
-
--- writes all the trees of the treebank
-treesTreebank :: Options -> String -> [String]
-treesTreebank _ = terms . getTreebank . lines where
- terms ts = [t | (t,_) <- ts]
-
--- string vs. IO
-type Res = [String] -- IO ()
-puts :: String -> Res
-puts = return -- putStrLn
-ret = [] -- return ()
---
-
--- here strings are keys
-assocsTreebank :: UniTreebank -> [(String,[String])]
-assocsTreebank = M.assocs
-
-isWordInTreebank :: UniTreebank -> String -> Bool
-isWordInTreebank tb w = S.member w (S.fromList (concatMap words (M.keys tb)))
-
-printAssoc (s, ts) = s ++ concat ["\t" ++ t | t <- ts]
-
-getTreebanks :: [String] -> [(String,String,String)]
-getTreebanks = concatMap grps . getTreebank where
- grps (t,lls) = [(t,x,y) | (x,y) <- lls]
-
-getTreebank :: [String] -> MultiTreebank
-getTreebank ll = case ll of
- l:ls@(_:_:_) ->
- let (l1,l2) = getItem ls
- (tr,lins) = getTree l1
- lglins = getLins lins
- in (tr,lglins) : getTreebank l2
- _ -> []
- where
- getItem = span ((/=" UniTreebank
-getUniTreebank ls = M.fromListWith (++) [(s, ts) | s:ts <- map chop ls] where
- chop = chunks '\t'
-
-lookupTreebank :: Treebank -> String -> [String]
-lookupTreebank tb s = maybe [] id $ M.lookup s tb
-
-annot :: StateGrammar -> String -> A.Tree
-annot gr s = errVal (error "illegal tree") $ do
- let t = tree2exp $ string2tree gr s
- annotate (grammar gr) t
-
-putInXML :: Options -> String -> String -> Res -> Res
-putInXML opts tag attrs io =
- (ifXML $ puts $ tagXML $ tag ++ attrs) ++
- io ++
- (ifXML $ puts $ tagXML $ '/':tag)
- where
- ifXML c = if oElem showXML opts then c else []
-
-
-tagXML :: String -> String
-tagXML s = "<" ++ s ++ ">"
-
--- print the treebank in a compact format:
--- first a sorted list of all words, referrable by index
--- then the linearization of each tree, as sequences of word indices
--- this format is usable in embedded translation systems.
-
-mkCompactTreebank :: Options -> ShellState -> [A.Tree] -> [String]
-mkCompactTreebank opts sh = printCompactTreebank . mkJustMultiTreebank opts sh
-
-printCompactTreebank :: (MultiTreebank,[String]) -> [String]
-printCompactTreebank (tb,lgs) = (stat:langs:unwords ws : "\n" : linss) where
- ws = L.sort $ L.nub $ concat $ map (concatMap (words . snd) . snd) tb
-
- linss = map (unwords . pad) linss0
- linss0 = map (map (show . encode) . words) allExs
- allExs = concat [[snd (ls !! i) | (_,ls) <- tb] | i <- [0..length lgs - 1]]
- encode w = maybe undefined id $ M.lookup w wmap
- wmap = M.fromAscList $ zip ws [1..]
- stat = unwords $ map show [length ws, length lgs, length tb, smax]
- langs = unwords lgs
- smax = maximum $ map length linss0
- pad ws = ws ++ replicate (smax - length ws) "0"
-
--- [(String,[(String,String)])] -- tree,lang,lin
-mkJustMultiTreebank :: Options -> ShellState -> [A.Tree] -> (MultiTreebank,[String])
-mkJustMultiTreebank opts sh ts =
- ([(prt_ t, [(la, lin la t) | la <- langs]) | t <- ts],langs) where
- langs = map prt_ $ allLanguages sh
- lin = linearize opts sh
-
-
---- these handy functions are borrowed from EmbedAPI
-
-linearize opts mgr lang = lin where
- sgr = stateGrammarOfLangOpt False mgr zlang
- cgr = canModules mgr
- zlang = zIdent lang
- untok = customOrDefault (addOptions opts (stateOptions sgr)) useUntokenizer customUntokenizer sgr
- lin
- | oElem showRecord opts = err id id . liftM prt . linearizeNoMark cgr zlang
- | oElem tableLin opts =
- err id id . liftM (unlines . map untok . prLinTable True) . allLinTables True cgr zlang
- | oElem showAll opts =
- err id id . liftM (unlines . map untok . prLinTable False) . allLinTables False cgr zlang
-
- | otherwise = untok . linTree2string noMark cgr zlang
-
-showTree t = prt_ $ tree2exp t
diff --git a/src/GF/Visualization/Graphviz.hs b/src/GF/Visualization/Graphviz.hs
deleted file mode 100644
index b59e3ecd2..000000000
--- a/src/GF/Visualization/Graphviz.hs
+++ /dev/null
@@ -1,116 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : Graphviz
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/09/15 18:10:44 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.2 $
---
--- Graphviz DOT format representation and printing.
------------------------------------------------------------------------------
-
-module GF.Visualization.Graphviz (
- Graph(..), GraphType(..),
- Node(..), Edge(..),
- Attr,
- addSubGraphs,
- setName,
- setAttr,
- prGraphviz
- ) where
-
-import Data.Char
-
-import GF.Data.Utilities
-
--- | Graph type, graph ID, graph attirbutes, graph nodes, graph edges, subgraphs
-data Graph = Graph {
- gType :: GraphType,
- gId :: Maybe String,
- gAttrs :: [Attr],
- gNodes :: [Node],
- gEdges :: [Edge],
- gSubgraphs :: [Graph]
- }
- deriving (Show)
-
-data GraphType = Directed | Undirected
- deriving (Show)
-
-data Node = Node String [Attr]
- deriving Show
-
-data Edge = Edge String String [Attr]
- deriving Show
-
-type Attr = (String,String)
-
---
--- * Graph construction
---
-
-addSubGraphs :: [Graph] -> Graph -> Graph
-addSubGraphs gs g = g { gSubgraphs = gs ++ gSubgraphs g }
-
-setName :: String -> Graph -> Graph
-setName n g = g { gId = Just n }
-
-setAttr :: String -> String -> Graph -> Graph
-setAttr n v g = g { gAttrs = tableSet n v (gAttrs g) }
-
---
--- * Pretty-printing
---
-
-prGraphviz :: Graph -> String
-prGraphviz g@(Graph t i _ _ _ _) =
- graphtype t ++ " " ++ maybe "" esc i ++ " {\n" ++ prGraph g ++ "}\n"
-
-prSubGraph :: Graph -> String
-prSubGraph g@(Graph _ i _ _ _ _) =
- "subgraph" ++ " " ++ maybe "" esc i ++ " {\n" ++ prGraph g ++ "}"
-
-prGraph :: Graph -> String
-prGraph (Graph t id at ns es ss) =
- unlines $ map (++";") (map prAttr at
- ++ map prNode ns
- ++ map (prEdge t) es
- ++ map prSubGraph ss)
-
-graphtype :: GraphType -> String
-graphtype Directed = "digraph"
-graphtype Undirected = "graph"
-
-prNode :: Node -> String
-prNode (Node n at) = esc n ++ " " ++ prAttrList at
-
-prEdge :: GraphType -> Edge -> String
-prEdge t (Edge x y at) = esc x ++ " " ++ edgeop t ++ " " ++ esc y ++ " " ++ prAttrList at
-
-edgeop :: GraphType -> String
-edgeop Directed = "->"
-edgeop Undirected = "--"
-
-prAttrList :: [Attr] -> String
-prAttrList [] = ""
-prAttrList at = "[" ++ join "," (map prAttr at) ++ "]"
-
-prAttr :: Attr -> String
-prAttr (n,v) = esc n ++ " = " ++ esc v
-
-esc :: String -> String
-esc s | needEsc s = "\"" ++ concat [ if shouldEsc c then ['\\',c] else [c] | c <- s ] ++ "\""
- | otherwise = s
- where shouldEsc = (`elem` ['"', '\\'])
-
-needEsc :: String -> Bool
-needEsc [] = True
-needEsc xs | all isDigit xs = False
-needEsc (x:xs) = not (isIDFirst x && all isIDChar xs)
-
-isIDFirst, isIDChar :: Char -> Bool
-isIDFirst c = c `elem` (['_']++['a'..'z']++['A'..'Z'])
-isIDChar c = isIDFirst c || isDigit c
diff --git a/src/GF/Visualization/VisualizeGrammar.hs b/src/GF/Visualization/VisualizeGrammar.hs
deleted file mode 100644
index b5446aec8..000000000
--- a/src/GF/Visualization/VisualizeGrammar.hs
+++ /dev/null
@@ -1,125 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : VisualizeGrammar
--- Maintainer : BB
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date: 2005/09/14 15:17:30 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.10 $
---
--- Print a graph of module dependencies in Graphviz DOT format
--- FIXME: change this to use GF.Visualization.Graphviz,
--- instead of rolling its own.
------------------------------------------------------------------------------
-
-module GF.Visualization.VisualizeGrammar ( visualizeCanonGrammar,
- visualizeSourceGrammar
- ) where
-
-import qualified GF.Infra.Modules as M
-import GF.Canon.GFC
-import GF.Infra.Ident
-import GF.Infra.Option
-import GF.Grammar.Grammar (SourceGrammar)
-
-import Data.List (intersperse, nub)
-import Data.Maybe (maybeToList)
-
-data GrType = GrAbstract
- | GrConcrete
- | GrResource
- | GrInterface
- | GrInstance
- deriving Show
-
-data Node = Node {
- label :: String,
- url :: String,
- grtype :: GrType,
- extends :: [String],
- opens :: [String],
- implements :: Maybe String
- }
- deriving Show
-
-
-visualizeCanonGrammar :: Options -> CanonGrammar -> String
-visualizeCanonGrammar opts = prGraph . canon2graph
-
-visualizeSourceGrammar :: SourceGrammar -> String
-visualizeSourceGrammar = prGraph . source2graph
-
-canon2graph :: CanonGrammar -> [Node]
-canon2graph gr = [ toNode i m | (i,M.ModMod m) <- M.modules gr ]
-
-source2graph :: SourceGrammar -> [Node]
-source2graph gr = [ toNode i m | (i,M.ModMod m) <- M.modules gr ] -- FIXME: handle ModWith?
-
-toNode :: Ident -> M.Module Ident f i -> Node
-toNode i m = Node {
- label = l,
- url = l ++ ".gf", -- FIXME: might be in a different directory
- grtype = t,
- extends = map prIdent (M.extends m),
- opens = nub $ map openName (M.opens m), -- FIXME: nub is needed because of triple open with
- -- instance modules
- implements = is
- }
- where
- l = prIdent i
- (t,is) = fromModType (M.mtype m)
-
-fromModType :: M.ModuleType Ident -> (GrType, Maybe String)
-fromModType t = case t of
- M.MTAbstract -> (GrAbstract, Nothing)
- M.MTTransfer _ _ -> error "Can't visualize transfer modules yet" -- FIXME
- M.MTConcrete i -> (GrConcrete, Just (prIdent i))
- M.MTResource -> (GrResource, Nothing)
- M.MTInterface -> (GrInterface, Nothing)
- M.MTInstance i -> (GrInstance, Just (prIdent i))
- M.MTReuse rt -> error "Can't visualize reuse modules yet" -- FIXME
- M.MTUnion _ _ -> error "Can't visualize union modules yet" -- FIXME
-
--- | FIXME: there is something odd about OQualif with 'with' modules,
--- both names seem to be the same.
-openName :: M.OpenSpec Ident -> String
-openName (M.OSimple q i) = prIdent i
-openName (M.OQualif q i _) = prIdent i
-
-prGraph :: [Node] -> String
-prGraph ns = concat $ map (++"\n") $ ["digraph {\n"] ++ map prNode ns ++ ["}"]
-
-prNode :: Node -> String
-prNode n = concat (map (++";\n") stmts)
- where
- l = label n
- t = grtype n
- stmts = [l ++ " [" ++ prAttributes attrs ++ "]"]
- ++ map (prExtend t l) (extends n)
- ++ map (prOpen l) (opens n)
- ++ map (prImplement t l) (maybeToList (implements n))
- (shape,style) = case t of
- GrAbstract -> ("ellipse","solid")
- GrConcrete -> ("box","dashed")
- GrResource -> ("ellipse","dashed")
- GrInterface -> ("ellipse","dotted")
- GrInstance -> ("diamond","dotted")
- attrs = [("style", style),("shape", shape),("URL", url n)]
-
-
-prExtend :: GrType -> String -> String -> String
-prExtend g f t = prEdge f t [("style","solid")]
-
-prOpen :: String -> String -> String
-prOpen f t = prEdge f t [("style","dotted")]
-
-prImplement :: GrType -> String -> String -> String
-prImplement g f t = prEdge f t [("arrowhead","empty"),("style","dashed")]
-
-prEdge :: String -> String -> [(String,String)] -> String
-prEdge f t as = f ++ " -> " ++ t ++ " [" ++ prAttributes as ++ "]"
-
-prAttributes :: [(String,String)] -> String
-prAttributes = concat . intersperse ", " . map (\ (n,v) -> n ++ " = " ++ show v)
diff --git a/src/GF/Visualization/VisualizeTree.hs b/src/GF/Visualization/VisualizeTree.hs
deleted file mode 100644
index 5fe740c12..000000000
--- a/src/GF/Visualization/VisualizeTree.hs
+++ /dev/null
@@ -1,58 +0,0 @@
-----------------------------------------------------------------------
--- |
--- Module : VisualizeTree
--- Maintainer : AR
--- Stability : (stable)
--- Portability : (portable)
---
--- > CVS $Date:
--- > CVS $Author:
--- > CVS $Revision:
---
--- Print a graph of an abstract syntax tree in Graphviz DOT format
--- Based on BB's VisualizeGrammar
--- FIXME: change this to use GF.Visualization.Graphviz,
--- instead of rolling its own.
------------------------------------------------------------------------------
-
-module GF.Visualization.VisualizeTree ( visualizeTrees
- ) where
-
-import GF.Infra.Ident
-import GF.Infra.Option
-import GF.Grammar.Abstract
-import GF.Data.Zipper
-import GF.Grammar.PrGrammar
-
-import Data.List (intersperse, nub)
-import Data.Maybe (maybeToList)
-
-visualizeTrees :: Options -> [Tree] -> String
-visualizeTrees opts = unlines . map (prGraph opts . tree2graph opts)
-
-tree2graph :: Options -> Tree -> [String]
-tree2graph opts = prf [] where
- prf ps t@(Tr (node, trees)) =
- let (nod,lab) = prn ps node in
- (nod ++ " [label = " ++ lab ++ ", style = \"solid\", shape = \"plaintext\"] ;") :
- [ pra (j:ps) nod t | (j,t) <- zip [0..] trees] ++
- concat [prf (j:ps) t | (j,t) <- zip [0..] trees]
- prn ps (N (bi,at,val,_,_)) =
- let
- lab =
- "\"" ++
- prb bi ++
- prc at val ++
- "\""
- in if oElem (iOpt "g") opts then (lab,lab) else (show(show (ps :: [Int])),lab)
- prb [] = ""
- prb bi = "\\" ++ concat (intersperse "," (map (prt_ . fst) bi)) ++ " -> "
- pra i nod t@(Tr (node,_)) = nod ++ arr ++ fst (prn i node) ++ " [style = \"solid\"];"
- prc a v
- | oElem (iOpt "c") opts = prt_ v
- | oElem (iOpt "f") opts = prt_ a
- | otherwise = prt_ a ++ " : " ++ prt_ v
- arr = if oElem (iOpt "g") opts then " -> " else " -- "
-
-prGraph opts ns = concat $ map (++"\n") $ [graph ++ "{\n"] ++ ns ++ ["}"] where
- graph = if oElem (iOpt "g") opts then "digraph" else "graph"
diff --git a/src/HelpFile b/src/HelpFile
deleted file mode 100644
index c6b38b313..000000000
--- a/src/HelpFile
+++ /dev/null
@@ -1,693 +0,0 @@
--- GF help file updated for GF 2.6, 17/6/2006.
--- *: Commands and options marked with * are currently not implemented.
---
--- Each command has a long and a short name, options, and zero or more
--- arguments. Commands are sorted by functionality. The short name is
--- given first.
-
--- Type "h -all" for full help file, "h " for full help on a command.
-
--- commands that change the state
-
-i, import: i File
- Reads a grammar from File and compiles it into a GF runtime grammar.
- Files "include"d in File are read recursively, nubbing repetitions.
- If a grammar with the same language name is already in the state,
- it is overwritten - but only if compilation succeeds.
- The grammar parser depends on the file name suffix:
- .gf normal GF source
- .gfc canonical GF
- .gfr precompiled GF resource
- .gfcm multilingual canonical GF
- .gfe example-based grammar files (only with the -ex option)
- .gfwl multilingual word list (preprocessed to abs + cncs)
- .ebnf Extended BNF format
- .cf Context-free (BNF) format
- .trc TransferCore format
- options:
- -old old: parse in GF<2.0 format (not necessary)
- -v verbose: give lots of messages
- -s silent: don't give error messages
- -src from source: ignore precompiled gfc and gfr files
- -gfc from gfc: use compiled modules whenever they exist
- -retain retain operations: read resource modules (needed in comm cc)
- -nocf don't build old-style context-free grammar (default without HOAS)
- -docf do build old-style context-free grammar (default with HOAS)
- -nocheckcirc don't eliminate circular rules from CF
- -cflexer build an optimized parser with separate lexer trie
- -noemit do not emit code (default with old grammar format)
- -o do emit code (default with new grammar format)
- -ex preprocess .gfe files if needed
- -prob read probabilities from top grammar file (format --# prob Fun Double)
- -treebank read a treebank file to memory (xml format)
- flags:
- -abs set the name used for abstract syntax (with -old option)
- -cnc set the name used for concrete syntax (with -old option)
- -res set the name used for resource (with -old option)
- -path use the (colon-separated) search path to find modules
- -optimize select an optimization to override file-defined flags
- -conversion select parsing method (values strict|nondet)
- -probs read probabilities from file (format (--# prob) Fun Double)
- -preproc use a preprocessor on each source file
- -noparse read nonparsable functions from file (format --# noparse Funs)
- examples:
- i English.gf -- ordinary import of Concrete
- i -retain german/ParadigmsGer.gf -- import of Resource to test
-
-r, reload: r
- Executes the previous import (i) command.
-
-rl, remove_language: rl Language
- Takes away the language from the state.
-
-e, empty: e
- Takes away all languages and resets all global flags.
-
-sf, set_flags: sf Flag*
- The values of the Flags are set for Language. If no language
- is specified, the flags are set globally.
- examples:
- sf -nocpu -- stop showing CPU time
- sf -lang=Swe -- make Swe the default concrete
-
-s, strip: s
- Prune the state by removing source and resource modules.
-
-dc, define_command Name Anything
- Add a new defined command. The Name must star with '%'. Later,
- if 'Name X' is used, it is replaced by Anything where #1 is replaced
- by X.
- Restrictions: Currently at most one argument is possible, and a defined
- command cannot appear in a pipe.
- To see what definitions are in scope, use help -defs.
- examples:
- dc %tnp p -cat=NP -lang=Eng #1 | l -lang=Swe -- translate NPs
- %tnp "this man" -- translate and parse
-
-dt, define_term Name Tree
- Add a constant for a tree. The constant can later be called by
- prefixing it with '$'.
- Restriction: These terms are not yet usable as a subterm.
- To see what definitions are in scope, use help -defs.
- examples:
- p -cat=NP "this man" | dt tm -- define tm as parse result
- l -all $tm -- linearize tm in all forms
-
--- commands that give information about the state
-
-pg, print_grammar: pg
- Prints the actual grammar (overridden by the -lang=X flag).
- The -printer=X flag sets the format in which the grammar is
- written.
- N.B. since grammars are compiled when imported, this command
- generally does not show the grammar in the same format as the
- source. In particular, the -printer=latex is not supported.
- Use the command tg -printer=latex File to print the source
- grammar in LaTeX.
- options:
- -utf8 apply UTF8-encoding to the grammar
- flags:
- -printer
- -lang
- -startcat -- The start category of the generated grammar.
- Only supported by some grammar printers.
- examples:
- pg -printer=cf -- show the context-free skeleton
-
-pm, print_multigrammar: pm
- Prints the current multilingual grammar in .gfcm form.
- (Automatically executes the strip command (s) before doing this.)
- options:
- -utf8 apply UTF8 encoding to the tokens in the grammar
- -utf8id apply UTF8 encoding to the identifiers in the grammar
- examples:
- pm | wf Letter.gfcm -- print the grammar into the file Letter.gfcm
- pm -printer=graph | wf D.dot -- then do 'dot -Tps D.dot > D.ps'
-
-vg, visualize_graph: vg
- Show the dependency graph of multilingual grammar via dot and gv.
-
-po, print_options: po
- Print what modules there are in the state. Also
- prints those flag values in the current state that differ from defaults.
-
-pl, print_languages: pl
- Prints the names of currently available languages.
-
-pi, print_info: pi Ident
- Prints information on the identifier.
-
--- commands that execute and show the session history
-
-eh, execute_history: eh File
- Executes commands in the file.
-
-ph, print_history; ph
- Prints the commands issued during the GF session.
- The result is readable by the eh command.
- examples:
- ph | wf foo.hist" -- save the history into a file
-
--- linearization, parsing, translation, and computation
-
-l, linearize: l PattList? Tree
- Shows all linearization forms of Tree by the actual grammar
- (which is overridden by the -lang flag).
- The pattern list has the form [P, ... ,Q] where P,...,Q follow GF
- syntax for patterns. All those forms are generated that match with the
- pattern list. Too short lists are filled with variables in the end.
- Only the -table flag is available if a pattern list is specified.
- HINT: see GF language specification for the syntax of Pattern and Term.
- You can also copy and past parsing results.
- options:
- -struct bracketed form
- -table show parameters (not compatible with -record, -all)
- -record record, i.e. explicit GF concrete syntax term (not compatible with -table, -all)
- -all show all forms and variants (not compatible with -record, -table)
- -multi linearize to all languages (can be combined with the other options)
- flags:
- -lang linearize in this grammar
- -number give this number of forms at most
- -unlexer filter output through unlexer
- examples:
- l -lang=Swe -table -- show full inflection table in Swe
-
-p, parse: p String
- Shows all Trees returned for String by the actual
- grammar (overridden by the -lang flag), in the category S (overridden
- by the -cat flag).
- options for batch input:
- -lines parse each line of input separately, ignoring empty lines
- -all as -lines, but also parse empty lines
- -prob rank results by probability
- -cut stop after first lexing result leading to parser success
- -fail show strings whose parse fails prefixed by #FAIL
- -ambiguous show strings that have more than one parse prefixed by #AMBIGUOUS
- options for selecting parsing method:
- -fcfg parse using a fast variant of MCFG (default is no HOAS in grammar)
- -old parse using an overgenerating CFG (default if HOAS in grammar)
- -cfg parse using a much less overgenerating CFG
- -mcfg parse using an even less overgenerating MCFG
- Note: the first time parsing with -cfg, -mcfg, and -fcfg may take a long time
- options that only work for the -old default parsing method:
- -n non-strict: tolerates morphological errors
- -ign ignore unknown words when parsing
- -raw return context-free terms in raw form
- -v verbose: give more information if parsing fails
- flags:
- -cat parse in this category
- -lang parse in this grammar
- -lexer filter input through this lexer
- -parser use this parsing strategy
- -number return this many results at most
- examples:
- p -cat=S -mcfg "jag är gammal" -- parse an S with the MCFG
- rf examples.txt | p -lines -- parse each non-empty line of the file
-
-at, apply_transfer: at (Module.Fun | Fun)
- Transfer a term using Fun from Module, or the topmost transfer
- module. Transfer modules are given in the .trc format. They are
- shown by the 'po' command.
- flags:
- -lang typecheck the result in this lang instead of default lang
- examples:
- p -lang=Cncdecimal "123" | at num2bin | l -- convert dec to bin
-
-tb, tree_bank: tb
- Generate a multilingual treebank from a list of trees (default) or compare
- to an existing treebank.
- options:
- -c compare to existing xml-formatted treebank
- -trees return the trees of the treebank
- -all show all linearization alternatives (branches and variants)
- -table show tables of linearizations with parameters
- -record show linearization records
- -xml wrap the treebank (or comparison results) with XML tags
- -mem write the treebank in memory instead of a file TODO
- examples:
- gr -cat=S -number=100 | tb -xml | wf tb.xml -- random treebank into file
- rf tb.xml | tb -c -- compare-test treebank from file
- rf old.xml | tb -trees | tb -xml -- create new treebank from old
-
-ut, use_treebank: ut String
- Lookup a string in a treebank and return the resulting trees.
- Use 'tb' to create a treebank and 'i -treebank' to read one from
- a file.
- options:
- -assocs show all string-trees associations in the treebank
- -strings show all strings in the treebank
- -trees show all trees in the treebank
- -raw return the lookup result as string, without typechecking it
- flags:
- -treebank use this treebank (instead of the latest introduced one)
- examples:
- ut "He adds this to that" | l -multi -- use treebank lookup as parser in translation
- ut -assocs | grep "ComplV2" -- show all associations with ComplV2
-
-tt, test_tokenizer: tt String
- Show the token list sent to the parser when String is parsed.
- HINT: can be useful when debugging the parser.
- flags:
- -lexer use this lexer
- examples:
- tt -lexer=codelit "2*(x + 3)" -- a favourite lexer for program code
-
-g, grep: g String1 String2
- Grep the String1 in the String2. String2 is read line by line,
- and only those lines that contain String1 are returned.
- flags:
- -v return those lines that do not contain String1.
- examples:
- pg -printer=cf | grep "mother" -- show cf rules with word mother
-
-cc, compute_concrete: cc Term
- Compute a term by concrete syntax definitions. Uses the topmost
- resource module (the last in listing by command po) to resolve
- constant names.
- N.B. You need the flag -retain when importing the grammar, if you want
- the oper definitions to be retained after compilation; otherwise this
- command does not expand oper constants.
- N.B.' The resulting Term is not a term in the sense of abstract syntax,
- and hence not a valid input to a Tree-demanding command.
- flags:
- -table show output in a similar readable format as 'l -table'
- -res use another module than the topmost one
- examples:
- cc -res=ParadigmsFin (nLukko "hyppy") -- inflect "hyppy" with nLukko
-
-so, show_operations: so Type
- Show oper operations with the given value type. Uses the topmost
- resource module to resolve constant names.
- N.B. You need the flag -retain when importing the grammar, if you want
- the oper definitions to be retained after compilation; otherwise this
- command does not find any oper constants.
- N.B.' The value type may not be defined in a supermodule of the
- topmost resource. In that case, use appropriate qualified name.
- flags:
- -res use another module than the topmost one
- examples:
- so -res=ParadigmsFin ResourceFin.N -- show N-paradigms in ParadigmsFin
-
-t, translate: t Lang Lang String
- Parses String in Lang1 and linearizes the resulting Trees in Lang2.
- flags:
- -cat
- -lexer
- -parser
- examples:
- t Eng Swe -cat=S "every number is even or odd"
-
-gr, generate_random: gr Tree?
- Generates a random Tree of a given category. If a Tree
- argument is given, the command completes the Tree with values to
- the metavariables in the tree.
- options:
- -prob use probabilities (works for nondep types only)
- -cf use a very fast method (works for nondep types only)
- flags:
- -cat generate in this category
- -lang use the abstract syntax of this grammar
- -number generate this number of trees (not impl. with Tree argument)
- -depth use this number of search steps at most
- examples:
- gr -cat=Query -- generate in category Query
- gr (PredVP ? (NegVG ?)) -- generate a random tree of this form
- gr -cat=S -tr | l -- gererate and linearize
-
-gt, generate_trees: gt Tree?
- Generates all trees up to a given depth. If the depth is large,
- a small -alts is recommended. If a Tree argument is given, the
- command completes the Tree with values to the metavariables in
- the tree.
- options:
- -metas also return trees that include metavariables
- -all generate all (can be infinitely many, lazily)
- -lin linearize result of -all (otherwise, use pipe to linearize)
- flags:
- -depth generate to this depth (default 3)
- -atoms take this number of atomic rules of each category (default unlimited)
- -alts take this number of alternatives at each branch (default unlimited)
- -cat generate in this category
- -nonub don't remove duplicates (faster, not effective with -mem)
- -mem use a memorizing algorithm (often faster, usually more memory-consuming)
- -lang use the abstract syntax of this grammar
- -number generate (at most) this number of trees (also works with -all)
- -noexpand don't expand these categories (comma-separated, e.g. -noexpand=V,CN)
- -doexpand only expand these categories (comma-separated, e.g. -doexpand=V,CN)
- examples:
- gt -depth=10 -cat=NP -- generate all NP's to depth 10
- gt (PredVP ? (NegVG ?)) -- generate all trees of this form
- gt -cat=S -tr | l -- generate and linearize
- gt -noexpand=NP | l -mark=metacat -- the only NP is meta, linearized "?0 +NP"
- gt | l | p -lines -ambiguous | grep "#AMBIGUOUS" -- show ambiguous strings
-
-ma, morphologically_analyse: ma String
- Runs morphological analysis on each word in String and displays
- the results line by line.
- options:
- -short show analyses in bracketed words, instead of separate lines
- -status show just the work at success, prefixed with "*" at failure
- flags:
- -lang
- examples:
- wf Bible.txt | ma -short | wf Bible.tagged -- analyse the Bible
-
-
--- elementary generation of Strings and Trees
-
-ps, put_string: ps String
- Returns its argument String, like Unix echo.
- HINT. The strength of ps comes from the possibility to receive the
- argument from a pipeline, and altering it by the -filter flag.
- flags:
- -filter filter the result through this string processor
- -length cut the string after this number of characters
- examples:
- gr -cat=Letter | l | ps -filter=text -- random letter as text
-
-pt, put_tree: pt Tree
- Returns its argument Tree, like a specialized Unix echo.
- HINT. The strength of pt comes from the possibility to receive
- the argument from a pipeline, and altering it by the -transform flag.
- flags:
- -transform transform the result by this term processor
- -number generate this number of terms at most
- examples:
- p "zero is even" | pt -transform=solve -- solve ?'s in parse result
-
-* st, show_tree: st Tree
- Prints the tree as a string. Unlike pt, this command cannot be
- used in a pipe to produce a tree, since its output is a string.
- flags:
- -printer show the tree in a special format (-printer=xml supported)
-
-wt, wrap_tree: wt Fun
- Wraps the tree as the sole argument of Fun.
- flags:
- -c compute the resulting new tree to normal form
-
-vt, visualize_tree: vt Tree
- Shows the abstract syntax tree via dot and gv (via temporary files
- grphtmp.dot, grphtmp.ps).
- flags:
- -c show categories only (no functions)
- -f show functions only (no categories)
- -g show as graph (sharing uses of the same function)
- -o just generate the .dot file
- examples:
- p "hello world" | vt -o | wf my.dot ;; ! open -a GraphViz my.dot
- -- This writes the parse tree into my.dot and opens the .dot file
- -- with another application without generating .ps.
-
--- subshells
-
-es, editing_session: es
- Opens an interactive editing session.
- N.B. Exit from a Fudget session is to the Unix shell, not to GF.
- options:
- -f Fudget GUI (necessary for Unicode; only available in X Window System)
-
-ts, translation_session: ts
- Translates input lines from any of the actual languages to all other ones.
- To exit, type a full stop (.) alone on a line.
- N.B. Exit from a Fudget session is to the Unix shell, not to GF.
- HINT: Set -parser and -lexer locally in each grammar.
- options:
- -f Fudget GUI (necessary for Unicode; only available in X Windows)
- -lang prepend translation results with language names
- flags:
- -cat the parser category
- examples:
- ts -cat=Numeral -lang -- translate numerals, show language names
-
-tq, translation_quiz: tq Lang Lang
- Random-generates translation exercises from Lang1 to Lang2,
- keeping score of success.
- To interrupt, type a full stop (.) alone on a line.
- HINT: Set -parser and -lexer locally in each grammar.
- flags:
- -cat
- examples:
- tq -cat=NP TestResourceEng TestResourceSwe -- quiz for NPs
-
-tl, translation_list: tl Lang Lang
- Random-generates a list of ten translation exercises from Lang1
- to Lang2. The number can be changed by a flag.
- HINT: use wf to save the exercises in a file.
- flags:
- -cat
- -number
- examples:
- tl -cat=NP TestResourceEng TestResourceSwe -- quiz list for NPs
-
-mq, morphology_quiz: mq
- Random-generates morphological exercises,
- keeping score of success.
- To interrupt, type a full stop (.) alone on a line.
- HINT: use printname judgements in your grammar to
- produce nice expressions for desired forms.
- flags:
- -cat
- -lang
- examples:
- mq -cat=N -lang=TestResourceSwe -- quiz for Swedish nouns
-
-ml, morphology_list: ml
- Random-generates a list of ten morphological exercises,
- keeping score of success. The number can be changed with a flag.
- HINT: use wf to save the exercises in a file.
- flags:
- -cat
- -lang
- -number
- examples:
- ml -cat=N -lang=TestResourceSwe -- quiz list for Swedish nouns
-
-
--- IO related commands
-
-rf, read_file: rf File
- Returns the contents of File as a String; error if File does not exist.
-
-wf, write_file: wf File String
- Writes String into File; File is created if it does not exist.
- N.B. the command overwrites File without a warning.
-
-af, append_file: af File
- Writes String into the end of File; File is created if it does not exist.
-
-* tg, transform_grammar: tg File
- Reads File, parses as a grammar,
- but instead of compiling further, prints it.
- The environment is not changed. When parsing the grammar, the same file
- name suffixes are supported as in the i command.
- HINT: use this command to print the grammar in
- another format (the -printer flag); pipe it to wf to save this format.
- flags:
- -printer (only -printer=latex supported currently)
-
-* cl, convert_latex: cl File
- Reads File, which is expected to be in LaTeX form.
- Three environments are treated in special ways:
- \begGF - \end{verbatim}, which contains GF judgements,
- \begTGF - \end{verbatim}, which contains a GF expression (displayed)
- \begInTGF - \end{verbatim}, which contains a GF expressions (inlined).
- Moreover, certain macros should be included in the file; you can
- get those macros by applying 'tg -printer=latex foo.gf' to any grammar
- foo.gf. Notice that the same File can be imported as a GF grammar,
- consisting of all the judgements in \begGF environments.
- HINT: pipe with 'wf Foo.tex' to generate a new Latex file.
-
-sa, speak_aloud: sa String
- Uses the Flite speech generator to produce speech for String.
- Works for American English spelling.
- examples:
- h | sa -- listen to the list of commands
- gr -cat=S | l | sa -- generate a random sentence and speak it aloud
-
-si, speech_input: si
- Uses an ATK speech recognizer to get speech input.
- flags:
- -lang: The grammar to use with the speech recognizer.
- -cat: The grammar category to get input in.
- -language: Use acoustic model and dictionary for this language.
- -number: The number of utterances to recognize.
-
-h, help: h Command?
- Displays the paragraph concerning the command from this help file.
- Without the argument, shows the first lines of all paragraphs.
- options
- -all show the whole help file
- -defs show user-defined commands and terms
- -FLAG show the values of FLAG (works for grammar-independent flags)
- examples:
- h print_grammar -- show all information on the pg command
-
-q, quit: q
- Exits GF.
- HINT: you can use 'ph | wf history' to save your session.
-
-!, system_command: ! String
- Issues a system command. No value is returned to GF.
- example:
- ! ls
-
-?, system_command: ? String
- Issues a system command that receives its arguments from GF pipe
- and returns a value to GF.
- example:
- h | ? 'wc -l' | p -cat=Num
-
-
--- Flags. The availability of flags is defined separately for each command.
-
--cat, category in which parsing is performed.
- The default is S.
-
--depth, the search depth in e.g. random generation.
- The default depends on application.
-
--filter, operation performed on a string. The default is identity.
- -filter=identity no change
- -filter=erase erase the text
- -filter=take100 show the first 100 characters
- -filter=length show the length of the string
- -filter=text format as text (punctuation, capitalization)
- -filter=code format as code (spacing, indentation)
-
--lang, grammar used when executing a grammar-dependent command.
- The default is the last-imported grammar.
-
--language, voice used by Festival as its --language flag in the sa command.
- The default is system-dependent.
-
--length, the maximum number of characters shown of a string.
- The default is unlimited.
-
--lexer, tokenization transforming a string into lexical units for a parser.
- The default is words.
- -lexer=words tokens are separated by spaces or newlines
- -lexer=literals like words, but GF integer and string literals recognized
- -lexer=vars like words, but "x","x_...","$...$" as vars, "?..." as meta
- -lexer=chars each character is a token
- -lexer=code use Haskell's lex
- -lexer=codevars like code, but treat unknown words as variables, ?? as meta
- -lexer=textvars like text, but treat unknown words as variables, ?? as meta
- -lexer=text with conventions on punctuation and capital letters
- -lexer=codelit like code, but treat unknown words as string literals
- -lexer=textlit like text, but treat unknown words as string literals
- -lexer=codeC use a C-like lexer
- -lexer=ignore like literals, but ignore unknown words
- -lexer=subseqs like ignore, but then try all subsequences from longest
-
--number, the maximum number of generated items in a list.
- The default is unlimited.
-
--optimize, optimization on generated code.
- The default is share for concrete, none for resource modules.
- Each of the flags can have the suffix _subs, which performs
- common subexpression elimination after the main optimization.
- Thus, -optimize=all_subs is the most aggressive one. The _subs
- strategy only works in GFC, and applies therefore in concrete but
- not in resource modules.
- -optimize=share share common branches in tables
- -optimize=parametrize first try parametrize then do share with the rest
- -optimize=values represent tables as courses-of-values
- -optimize=all first try parametrize then do values with the rest
- -optimize=none no optimization
-
--parser, parsing strategy. The default is chart. If -cfg or -mcfg are
- selected, only bottomup and topdown are recognized.
- -parser=chart bottom-up chart parsing
- -parser=bottomup a more up to date bottom-up strategy
- -parser=topdown top-down strategy
- -parser=old an old bottom-up chart parser
-
--printer, format in which the grammar is printed. The default is
- gfc. Those marked with M are (only) available for pm, the rest
- for pg.
- -printer=gfc GFC grammar
- -printer=gf GF grammar
- -printer=old old GF grammar
- -printer=cf context-free grammar, with profiles
- -printer=bnf context-free grammar, without profiles
- -printer=lbnf labelled context-free grammar for BNF Converter
- -printer=plbnf grammar for BNF Converter, with precedence levels
- *-printer=happy source file for Happy parser generator (use lbnf!)
- -printer=haskell abstract syntax in Haskell, with transl to/from GF
- -printer=haskell_gadt abstract syntax GADT in Haskell, with transl to/from GF
- -printer=morpho full-form lexicon, long format
- *-printer=latex LaTeX file (for the tg command)
- -printer=fullform full-form lexicon, short format
- *-printer=xml XML: DTD for the pg command, object for st
- -printer=old old GF: file readable by GF 1.2
- -printer=stat show some statistics of generated GFC
- -printer=probs show probabilities of all functions
- -printer=gsl Nuance GSL speech recognition grammar
- -printer=jsgf Java Speech Grammar Format
- -printer=jsgf_sisr_old Java Speech Grammar Format with semantic tags in
- SISR WD 20030401 format
- -printer=srgs_abnf SRGS ABNF format
- -printer=srgs_abnf_non_rec SRGS ABNF format, without any recursion.
- -printer=srgs_abnf_sisr_old SRGS ABNF format, with semantic tags in
- SISR WD 20030401 format
- -printer=srgs_xml SRGS XML format
- -printer=srgs_xml_non_rec SRGS XML format, without any recursion.
- -printer=srgs_xml_prob SRGS XML format, with weights
- -printer=srgs_xml_sisr_old SRGS XML format, with semantic tags in
- SISR WD 20030401 format
- -printer=vxml Generate a dialogue system in VoiceXML.
- -printer=slf a finite automaton in the HTK SLF format
- -printer=slf_graphviz the same automaton as slf, but in Graphviz format
- -printer=slf_sub a finite automaton with sub-automata in the
- HTK SLF format
- -printer=slf_sub_graphviz the same automaton as slf_sub, but in
- Graphviz format
- -printer=fa_graphviz a finite automaton with labelled edges
- -printer=regular a regular grammar in a simple BNF
- -printer=unpar a gfc grammar with parameters eliminated
- -printer=functiongraph abstract syntax functions in 'dot' format
- -printer=typegraph abstract syntax categories in 'dot' format
- -printer=transfer Transfer language datatype (.tr file format)
- -printer=cfg-prolog M cfg in prolog format (also pg)
- -printer=gfc-prolog M gfc in prolog format (also pg)
- -printer=gfcm M gfcm file (default for pm)
- -printer=graph M module dependency graph in 'dot' (graphviz) format
- -printer=header M gfcm file with header (for GF embedded in Java)
- -printer=js M JavaScript type annotator and linearizer
- -printer=mcfg-prolog M mcfg in prolog format (also pg)
- -printer=missing M the missing linearizations of each concrete
-
--startcat, like -cat, but used in grammars (to avoid clash with keyword cat)
-
--transform, transformation performed on a syntax tree. The default is identity.
- -transform=identity no change
- -transform=compute compute by using definitions in the grammar
- -transform=nodup return the term only if it has no constants duplicated
- -transform=nodupatom return the term only if it has no atomic constants duplicated
- -transform=typecheck return the term only if it is type-correct
- -transform=solve solve metavariables as derived refinements
- -transform=context solve metavariables by unique refinements as variables
- -transform=delete replace the term by metavariable
-
--unlexer, untokenization transforming linearization output into a string.
- The default is unwords.
- -unlexer=unwords space-separated token list (like unwords)
- -unlexer=text format as text: punctuation, capitals, paragraph
- -unlexer=code format as code (spacing, indentation)
- -unlexer=textlit like text, but remove string literal quotes
- -unlexer=codelit like code, but remove string literal quotes
- -unlexer=concat remove all spaces
- -unlexer=bind like identity, but bind at "&+"
-
--mark, marking of parts of tree in linearization. The default is none.
- -mark=metacat append "+CAT" to every metavariable, showing its category
- -mark=struct show tree structure with brackets
- -mark=java show tree structure with XML tags (used in gfeditor)
-
--coding, Some grammars are in UTF-8, some in isolatin-1.
- If the letters ä (a-umlaut) and ö (o-umlaut) look strange, either
- change your terminal to isolatin-1, or rewrite the grammar with
- 'pg -utf8'.
-
--- *: Commands and options marked with * are not currently implemented.
diff --git a/src/INSTALL b/src/INSTALL
deleted file mode 100644
index ef7949b07..000000000
--- a/src/INSTALL
+++ /dev/null
@@ -1,93 +0,0 @@
-To make and install GF (Updated for version 2.4).
-
-1. Unpack GF and go to the source directory (the place where this
- INSTALL file is - so you have probably done this already!)
-
- tar xvfz GF-2.4.tgz
- cd GF-2.4/src
-
-3. Make sure you have GHC (Glasgow Haskell Compiler), version 6.4 or later.
- In Windows, you also need Cygwin.
-
- ghc --version
-
-4. If you are building the darcs version, run autoconf (in src/):
-
- autoconf
-
-5. Run configure
-
- ./configure
-
- If you want to install the GF somewhere other than /usr/local, use
- the --prefix flag. E.g.
-
- ./configure --prefix=/usr
-
- To compile on Chalmers Solaris systems using VCS, use this configuration:
-
- ./configure CPPFLAGS="`lib__readline -I` `lib__ncurses -I`" LDFLAGS="`lib__readline -l` `lib__ncurses -l`"
-
- If you experience problems with readline, try:
-
- ./configure --with-readline=no
-
- You may need to run "make clean" after ./configure when you change the
- readline setting.
-
-6. Compile with GNU make:
-
- make
-
- or
-
- gmake
-
- (if your system has a proprietary make)
-
- The binary is sent to the file GF/bin/gf .
-
-7. Move files to their right places:
-
- make install
-
-8. To run GF, the following environment variables must be set:
-
- GFHOME the GF directory, e.g., "$HOME/project/GF-2.4"
- GF_LIB_PATH the GF library directory, e.g,, "$HOME/project/GF-2.4/lib"
-
- (Usually, you do this in ~/.login, if your shell is any *csh,
- or in ~/.profile, if your shell is either of sh, ksh, zsh or bash.
- Afterwards, you have to start a login shell to have the settings available.)
-
-9. For a quick test:
- Start gf, load a grammar and parse a string:
-
- cd $GFHOME/examples/tutorial/food
- gf FoodIta.gf FoodEng.gf
-
- -- when gf has started and shows the prompt >:
-
- > parse "this cheese is very very Italian" | tree_bank
-
- -- this is the response from GF:
- Is (This Cheese) (Very (Very Italian))
- this cheese is very very Italian
- questo formaggio è molto molto italiano
-
-10. If you want to run the Java GUI, go back to $GFHOME/src directory
- and also do
-
- make install-java
-
- Test the GUI with some grammars:
-
- cd ../examples/letter
- gf j) GFEditor.send("> "+String.valueOf(i-j));
- else GFEditor.send("< "+String.valueOf(j-i));
- }
- }
- });
-
- tree.setCellRenderer(new MyRenderer());
- tree.setShowsRootHandles(true);
- setPreferredSize(new Dimension(200, 100));
- JScrollPane scrollPane = new JScrollPane(tree);
- setLayout(new GridLayout(1,0));
- add(scrollPane);
- }
-
- /** Remove all nodes except the root node. */
- public void clear() {
- rootNode.removeAllChildren();
- treeModel.reload();
- }
-
- /** Remove the currently selected node. */
- public void removeCurrentNode() {
- TreePath currentSelection = tree.getSelectionPath();
- if (currentSelection != null) {
- DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
- (currentSelection.getLastPathComponent());
- MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent());
- if (parent != null) {
- treeModel.removeNodeFromParent(currentNode);
- return;
- }
- }
-
- // Either there was no selection, or the root was selected.
- toolkit.beep();
- }
-
- /** Add child to the currently selected node. */
- public DefaultMutableTreeNode addObject(Object child) {
- DefaultMutableTreeNode parentNode = null;
- TreePath parentPath = tree.getSelectionPath();
-
- if (parentPath == null) {
- parentNode = rootNode;
- } else {
- parentNode = (DefaultMutableTreeNode)
- (parentPath.getLastPathComponent());
- }
-
- return addObject(parentNode, child, true);
- }
-
- public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
- Object child) {
- return addObject(parent, child, false);
- }
-
- public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
- Object child,
- boolean shouldBeVisible) {
- DefaultMutableTreeNode childNode =
- new DefaultMutableTreeNode(child);
-
- if (parent == null) {
- parent = rootNode;
- }
-
- treeModel.insertNodeInto(childNode, parent,
- parent.getChildCount());
-
- // Make sure the user can see the lovely new node.
- if (shouldBeVisible) {
- tree.scrollPathToVisible(new TreePath(childNode.getPath()));
- }
- return childNode;
- }
-
- class MyTreeModelListener implements TreeModelListener {
- public void treeNodesChanged(TreeModelEvent e) {
- DefaultMutableTreeNode node;
- node = (DefaultMutableTreeNode)
- (e.getTreePath().getLastPathComponent());
-
- /*
- * If the event lists children, then the changed
- * node is the child of the node we've already
- * gotten. Otherwise, the changed node and the
- * specified node are the same.
- */
- try {
- int index = e.getChildIndices()[0];
- node = (DefaultMutableTreeNode)
- (node.getChildAt(index));
- } catch (NullPointerException exc) {}
-
- if (GFEditor.debug) System.out.println
- ("The user has finished editing the node.");
- if (GFEditor.debug) System.out.println(
- "New value: " + node.getUserObject());
- }
- public void treeNodesInserted(TreeModelEvent e) {
- }
- public void treeNodesRemoved(TreeModelEvent e) {
- }
- public void treeStructureChanged(TreeModelEvent e) {
- }
- }
-
- private class MyRenderer extends DefaultTreeCellRenderer {
- ImageIcon tutorialIcon;
-
- public MyRenderer() {
- tutorialIcon = new ImageIcon("images/middle.gif");
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus) {
-
- super.getTreeCellRendererComponent(
- tree, value, sel,
- expanded, leaf, row,
- hasFocus);
- if (leaf && isTutorialBook(value))
- setIcon(tutorialIcon);
-
- return this;
- }
- protected boolean isTutorialBook(Object value) {
- DefaultMutableTreeNode node =
- (DefaultMutableTreeNode)value;
- String nodeInfo =
- (String)(node.getUserObject());
-
- if (nodeInfo.indexOf("?") >= 0) {
- return true;
- }
-
- return false;
- }
-
- }//class
-
- class PopupListener extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
- int selRow = tree.getRowForLocation(e.getX(), e.getY());
- tree.setSelectionRow(selRow);
- if (GFEditor.debug) System.out.println("selection changed!");
- maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- if (GFEditor.debug) System.out.println("mouse released!");
- maybeShowPopup(e);
- }
- }
- void maybeShowPopup(MouseEvent e) {
- if (GFEditor.debug) System.out.println("may be!");
- if (e.isPopupTrigger()) {
- m=e;
- timer.start();
- }
- }
- void addMenuItem(String name){
- menuItem = new JMenuItem(name);
- menuItem.addActionListener(this);
- popup.add(menuItem);
-
- }
-
- public void actionPerformed(ActionEvent ae)
- {
- if (ae.getSource()==timer){
- if (GFEditor.debug) System.out.println("changing menu!");
- popup.removeAll();
- for (int i = 0; ij) GFEditor2.send("> "+String.valueOf(i-j));
- else GFEditor2.send("< "+String.valueOf(j-i));
- }
- }
- });
-
- tree.setCellRenderer(new MyRenderer());
- tree.setShowsRootHandles(true);
- setPreferredSize(new Dimension(200, 100));
- JScrollPane scrollPane = new JScrollPane(tree);
- setLayout(new GridLayout(1,0));
- add(scrollPane);
- }
-
- /** Remove all nodes except the root node. */
- public void clear() {
- rootNode.removeAllChildren();
- treeModel.reload();
- }
-
- /** Remove the currently selected node. */
- public void removeCurrentNode() {
- TreePath currentSelection = tree.getSelectionPath();
- if (currentSelection != null) {
- DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
- (currentSelection.getLastPathComponent());
- MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent());
- if (parent != null) {
- treeModel.removeNodeFromParent(currentNode);
- return;
- }
- }
-
- // Either there was no selection, or the root was selected.
- toolkit.beep();
- }
-
- /** Add child to the currently selected node. */
- public DefaultMutableTreeNode addObject(Object child) {
- DefaultMutableTreeNode parentNode = null;
- TreePath parentPath = tree.getSelectionPath();
-
- if (parentPath == null) {
- parentNode = rootNode;
- } else {
- parentNode = (DefaultMutableTreeNode)
- (parentPath.getLastPathComponent());
- }
-
- return addObject(parentNode, child, true);
- }
-
- public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
- Object child) {
- return addObject(parent, child, false);
- }
-
- public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
- Object child,
- boolean shouldBeVisible) {
- DefaultMutableTreeNode childNode =
- new DefaultMutableTreeNode(child);
-
- if (parent == null) {
- parent = rootNode;
- }
-
- treeModel.insertNodeInto(childNode, parent,
- parent.getChildCount());
-
- // Make sure the user can see the lovely new node.
- if (shouldBeVisible) {
- tree.scrollPathToVisible(new TreePath(childNode.getPath()));
- }
- return childNode;
- }
-
- class MyTreeModelListener implements TreeModelListener {
- public void treeNodesChanged(TreeModelEvent e) {
- DefaultMutableTreeNode node;
- node = (DefaultMutableTreeNode)
- (e.getTreePath().getLastPathComponent());
-
- /*
- * If the event lists children, then the changed
- * node is the child of the node we've already
- * gotten. Otherwise, the changed node and the
- * specified node are the same.
- */
- try {
- int index = e.getChildIndices()[0];
- node = (DefaultMutableTreeNode)
- (node.getChildAt(index));
- } catch (NullPointerException exc) {}
-
- if (GFEditor2.debug) System.out.println
- ("The user has finished editing the node.");
- if (GFEditor2.debug) System.out.println(
- "New value: " + node.getUserObject());
- }
- public void treeNodesInserted(TreeModelEvent e) {
- }
- public void treeNodesRemoved(TreeModelEvent e) {
- }
- public void treeStructureChanged(TreeModelEvent e) {
- }
- }
-
- private class MyRenderer extends DefaultTreeCellRenderer {
- ImageIcon tutorialIcon;
-
- public MyRenderer() {
- tutorialIcon = new ImageIcon("images/middle.gif");
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus) {
-
- super.getTreeCellRendererComponent(
- tree, value, sel,
- expanded, leaf, row,
- hasFocus);
- if (leaf && isTutorialBook(value))
- setIcon(tutorialIcon);
-
- return this;
- }
- protected boolean isTutorialBook(Object value) {
- DefaultMutableTreeNode node =
- (DefaultMutableTreeNode)value;
- String nodeInfo =
- (String)(node.getUserObject());
-
- if (nodeInfo.indexOf("?") >= 0) {
- return true;
- }
-
- return false;
- }
-
- }//class
-
- class PopupListener extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
- int selRow = tree.getRowForLocation(e.getX(), e.getY());
- tree.setSelectionRow(selRow);
- if (GFEditor2.debug) System.out.println("selection changed!");
- maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- if (GFEditor2.debug) System.out.println("mouse released!");
- maybeShowPopup(e);
- }
- }
- void maybeShowPopup(MouseEvent e) {
- if (GFEditor2.debug) System.out.println("may be!");
- if (e.isPopupTrigger()) {
- m = e;
- timer.start();
- }
- }
- void addMenuItem(String name){
- menuItem = new JMenuItem(name);
- menuItem.addActionListener(this);
- popup.add(menuItem);
-
- }
-
- public void actionPerformed(ActionEvent ae)
- {
- if (ae.getSource()==timer){
- if (GFEditor2.debug) System.out.println("changing menu!");
- popup.removeAll();
- for (int i = 0; i");
- private JButton rightMeta = new JButton(">?");
- private JButton read = new JButton("Read");
- // private JButton parse = new JButton("Parse");
- // private JButton term = new JButton("Term");
- private JButton alpha = new JButton("Alpha");
- private JButton random = new JButton("Random");
- private JButton undo = new JButton("Undo");
-
- private JPanel inputPanel = new JPanel();
- private JPanel inputPanel2 = new JPanel();
- private JPanel inputPanel3 = new JPanel();
- private JButton ok = new JButton("OK");
- private JButton cancel = new JButton("Cancel");
- private JTextField inputField = new JTextField();
- private JLabel inputLabel = new JLabel("Read: ");
- private JButton browse = new JButton("Browse...");
- private ButtonGroup readGroup = new ButtonGroup();
- private JRadioButton termReadButton = new JRadioButton("Term");
- private JRadioButton stringReadButton = new JRadioButton("String");
-
- private JDialog dialog;
-
- private static JComboBox menu = new JComboBox(newMenu);
- private JComboBox filter = new JComboBox(filterMenu);
- private JComboBox modify = new JComboBox(modifyMenu);
- // private JComboBox mode = new JComboBox(modeMenu);
-
- private JPanel downPanel = new JPanel();
- private JSplitPane treePanel;
- private JPanel upPanel = new JPanel();
- private JPanel middlePanel = new JPanel();
- private JPanel middlePanelUp = new JPanel();
- private JPanel middlePanelDown = new JPanel();
- private JSplitPane centerPanel;
- private static JFrame gui2 = new JFrame();
- private JPanel centerPanel2= new JPanel();
- private JPanel centerPanelDown = new JPanel();
- private JScrollPane outputPanelDown = new JScrollPane(list);
- private JScrollPane outputPanelCenter = new JScrollPane(output);
- private JPanel outputPanelUp = new JPanel();
- private JPanel statusPanel = new JPanel();
- private static JLabel statusLabel = new JLabel(status);
- private Container cp;
-
- private static JMenuBar menuBar= new JMenuBar();;
- private static ButtonGroup menuGroup = new ButtonGroup();
- private JMenu viewMenu= new JMenu("View");
- private JMenu submenu= new JMenu("language");
- private JMenu modeMenu= new JMenu("Menus");
- private static JMenu langMenu= new JMenu("Languages");
- private static JMenu fileMenu= new JMenu("File");
- private JRadioButtonMenuItem rbMenuItem;
- private JRadioButtonMenuItem rbMenuItemLong;
- // private JRadioButtonMenuItem rbMenuItemAbs;
- private JRadioButtonMenuItem rbMenuItemUnTyped;
- private static JMenuItem fileMenuItem;
- private static JCheckBoxMenuItem cbMenuItem;
- private static RadioListener myListener ;
- private static ButtonGroup group = new ButtonGroup();
- private static ButtonGroup languageGroup = new ButtonGroup();
-
- public GFEditor()
- {
- this.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- endProgram();
- }
- });
- setJMenuBar(menuBar);
- setTitle("GF Syntax Editor");
- viewMenu.setToolTipText("View settings");
- fileMenu.setToolTipText("Main operations");
- langMenu.setToolTipText("Language settings");
- menuBar.add(fileMenu);
- menuBar.add(langMenu);
- menuBar.add(viewMenu);
- menuBar.add(modeMenu);
-
- cbMenuItem = new JCheckBoxMenuItem("Tree");
- cbMenuItem.setActionCommand("showTree");
- myListener = new RadioListener();
- cbMenuItem.addActionListener(myListener);
- cbMenuItem.setSelected(true);
- viewMenu.add(cbMenuItem);
- viewMenu.addSeparator();
-
- fileMenuItem = new JMenuItem("Open...");
- fileMenuItem.setActionCommand("open");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("New Topic...");
- fileMenuItem.setActionCommand("newTopic");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("Reset");
- fileMenuItem.setActionCommand("reset");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("Save As...");
- fileMenuItem.setActionCommand("save");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenu.addSeparator();
- fileMenuItem = new JMenuItem("Exit");
- fileMenuItem.setActionCommand("quit");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem("One window");
- rbMenuItem.setActionCommand("combine");
- rbMenuItem.addActionListener(myListener);
- rbMenuItem.setSelected(true);
-/* rbMenuItem.setMnemonic(KeyEvent.VK_R);
- rbMenuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_1, ActionEvent.ALT_MASK));
- rbMenuItem.getAccessibleContext().setAccessibleDescription(
- "This doesn't really do anything");
-*/
- menuGroup.add(rbMenuItem);
- viewMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem("Split windows");
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- rbMenuItem.setActionCommand("split");
- rbMenuItem.addActionListener(myListener);
- menuGroup.add(rbMenuItem);
- viewMenu.add(rbMenuItem);
-
- modeMenu.add(submenu);
-
- /* rbMenuItemAbs = new JRadioButtonMenuItem("Abstract");
- rbMenuItemAbs.setActionCommand("Abstract");
- rbMenuItemAbs.addActionListener(myListener);
- languageGroup.add(rbMenuItemAbs);
- */
-
- modeMenu.addSeparator();
- menuGroup = new ButtonGroup();
- rbMenuItemLong = new JRadioButtonMenuItem("long");
- rbMenuItemLong.setActionCommand("long");
- rbMenuItemLong.setSelected(true);
- rbMenuItemLong.addActionListener(myListener);
- menuGroup.add(rbMenuItemLong);
- modeMenu.add(rbMenuItemLong);
- rbMenuItem = new JRadioButtonMenuItem("short");
- rbMenuItem.setActionCommand("short");
- rbMenuItem.addActionListener(myListener);
- menuGroup.add(rbMenuItem);
- modeMenu.add(rbMenuItem);
- modeMenu.addSeparator();
-
- menuGroup = new ButtonGroup();
- rbMenuItem = new JRadioButtonMenuItem("typed");
- rbMenuItem.setActionCommand("typed");
- rbMenuItem.addActionListener(myListener);
- rbMenuItem.setSelected(false);
- menuGroup.add(rbMenuItem);
- modeMenu.add(rbMenuItem);
- rbMenuItemUnTyped = new JRadioButtonMenuItem("untyped");
- rbMenuItemUnTyped.setSelected(true);
- rbMenuItemUnTyped.setActionCommand("untyped");
- rbMenuItemUnTyped.addActionListener(myListener);
- menuGroup.add(rbMenuItemUnTyped);
- modeMenu.add(rbMenuItemUnTyped);
-
- cp = getContentPane();
- cp.setLayout(new BorderLayout());
- output.setToolTipText("Linearizations' display area");
- output.setEditable(false);
- output.setLineWrap(true);
- output.setWrapStyleWord(true);
-// output.setSelectionColor(Color.green);
- output.setSelectionColor(Color.white);
-// output.setFont(new Font("Arial Unicode MS", Font.PLAIN, 17));
- output.setFont(new Font(null, Font.PLAIN, 17));
-// System.out.println(output.getFont().getFontName());
- gfCommand.setToolTipText("Sending a command to GF");
- read.setToolTipText("Refining with term or linearization from typed string or file");
- modify.setToolTipText("Choosing a linearization method");
- alpha.setToolTipText("Performing alpha-conversion");
- random.setToolTipText("Generating random refinement");
- undo.setToolTipText("Going back to the previous state");
- downPanel.add(gfCommand);
- //downPanel.add(parse);
- //downPanel.add(term);
- downPanel.add(read);
- downPanel.add(modify);
- downPanel.add(alpha);
- downPanel.add(random);
- downPanel.add(undo);
-
- leftMeta.setToolTipText("Moving the focus to the previous metavariable");
- rightMeta.setToolTipText("Moving the focus to the next metavariable");
- left.setToolTipText("Moving the focus to the previous term");
- right.setToolTipText("Moving the focus to the next term");
- top.setToolTipText("Moving the focus to the top term");
- middlePanelUp.add(leftMeta);
- middlePanelUp.add(left);
- middlePanelUp.add(top);
- middlePanelUp.add(right);
- middlePanelUp.add(rightMeta);
- middlePanelDown.add(new JLabel("Select Action on Subterm"));
- middlePanel.setLayout(new BorderLayout());
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- middlePanel.add(middlePanelDown, BorderLayout.CENTER);
-
- menu.setToolTipText("The list of available categories to start editing");
- open.setToolTipText("Reading both a new environment and an editing object from file. Current editing will be discarded");
- save.setToolTipText("Writing the current editing object to file in the term or text format");
- grammar.setToolTipText("Current Topic");
- newTopic.setToolTipText("Reading a new environment from file. Current editing will be discarded.");
- upPanel.add(grammar);
- upPanel.add(menu);
- upPanel.add(open);
- upPanel.add(save);
- upPanel.add(newTopic);
-
- filter.setToolTipText("Choosing the linearization representation format");
- modeMenu.setToolTipText("Choosing the refinement options' representation");
- statusLabel.setToolTipText("The current focus type");
- list.setToolTipText("The list of current refinment options");
- tree.setToolTipText("The abstract syntax tree representation of the current editing object");
- upPanel.add(filter);
- //upPanel.add(mode);
- populateTree(tree);
- outputPanelUp.setLayout(new BorderLayout());
- outputPanelUp.add(outputPanelCenter, BorderLayout.CENTER);
- outputPanelUp.add(statusPanel, BorderLayout.SOUTH);
- statusPanel.setLayout(new GridLayout(1,1));
- statusPanel.add(statusLabel);
- treePanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- tree, outputPanelUp);
- treePanel.setDividerSize(5);
- treePanel.setDividerLocation(100);
- centerPanel2.setLayout(new BorderLayout());
- gui2.setSize(350,150);
- gui2.setTitle("Select Action on Subterm");
- gui2.setLocationRelativeTo(treePanel);
- centerPanelDown.setLayout(new BorderLayout());
- centerPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- treePanel, centerPanelDown);
- centerPanel.addKeyListener(tree);
- centerPanel.setOneTouchExpandable(true);
- centerPanelDown.add(middlePanel, BorderLayout.NORTH);
- centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
- cp.add(centerPanel, BorderLayout.CENTER);
- cp.add(upPanel, BorderLayout.NORTH);
- cp.add(downPanel, BorderLayout.SOUTH);
-
- list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
- MouseListener mouseListener = new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- listAction(list.locationToIndex(e.getPoint()));
- }
- }
- };
- list.addMouseListener(mouseListener);
- list.addKeyListener(this);
- menu.addActionListener(this);
- save.addActionListener(this);
- open.addActionListener(this);
- newTopic.addActionListener(this);
- gfCommand.addActionListener(this);
-
- filter.addActionListener(this);
- filter.setMaximumRowCount(9);
- leftMeta.addActionListener(this);
- left.addActionListener(this);
-
- menu.setFocusable(false);
- save.setFocusable(false);
- save.setActionCommand("save");
- open.setFocusable(false);
- open.setActionCommand("open");
- newTopic.setFocusable(false);
- newTopic.setActionCommand("newTopic");
- gfCommand.setFocusable(false);
-
- filter.setFocusable(false);
- leftMeta.setFocusable(false);
- left.setFocusable(false);
-
- top.addActionListener(this);
- right.addActionListener(this);
- rightMeta.addActionListener(this);
- //parse.addActionListener(this);
- //term.addActionListener(this);
- read.addActionListener(this);
- modify.addActionListener(this);
- //mode.addActionListener(this);
- alpha.addActionListener(this);
- random.addActionListener(this);
- undo.addActionListener(this);
-
- top.setFocusable(false);
- right.setFocusable(false);
- rightMeta.setFocusable(false);
- //parse.setFocusable(false);
- //term.setFocusable(false);
- read.setFocusable(false);
- modify.setFocusable(false);
- //mode.setFocusable(false);
- alpha.setFocusable(false);
- random.setFocusable(false);
- undo.setFocusable(false);
-
- output.addKeyListener(tree);
- setSize(800,730);
- outputPanelUp.setPreferredSize(new Dimension(500,300));
- treePanel.setDividerLocation(0.3);
- nodeTable.put(new TreePath(DynamicTree.rootNode.getPath()), new Integer(0));
- setVisible(true);
-
- JRadioButton termButton = new JRadioButton("Term");
- termButton.setActionCommand("term");
- termButton.setSelected(true);
- JRadioButton linButton = new JRadioButton("Text");
- linButton.setActionCommand("lin");
- // Group the radio buttons.
- group.add(linButton);
- group.add(termButton);
- JPanel buttonPanel = new JPanel();
- buttonPanel.setPreferredSize(new Dimension(70, 70));
- buttonPanel.add(new JLabel("Format:"));
- buttonPanel.add(linButton);
- buttonPanel.add(termButton);
- fc1.setAccessory(buttonPanel);
-
- termReadButton.setActionCommand("term");
- stringReadButton.setSelected(true);
- stringReadButton.setActionCommand("lin");
- // Group the radio buttons.
- readGroup.add(stringReadButton);
- readGroup.add(termReadButton);
- JPanel readButtonPanel = new JPanel();
- readButtonPanel.setLayout(new GridLayout(3,1));
- readButtonPanel.setPreferredSize(new Dimension(70, 70));
- readButtonPanel.add(new JLabel("Format:"));
- readButtonPanel.add(stringReadButton);
- readButtonPanel.add(termReadButton);
- dialog= new JDialog(this, "Input");
- dialog.setLocationRelativeTo(this);
- dialog.getContentPane().add(inputPanel);
- inputPanel.setLayout(new BorderLayout(10,10));
- inputPanel3.setLayout(new GridLayout(2,1,5,5));
- inputPanel3.add(inputLabel);
- inputPanel3.add(inputField);
- ok.addActionListener(this);
- browse.addActionListener(this);
- cancel.addActionListener(this);
- inputField.setPreferredSize(new Dimension(300,23));
- inputPanel.add(inputPanel3, BorderLayout.CENTER);
- inputPanel.add(new JLabel(" "), BorderLayout.WEST);
- inputPanel.add(readButtonPanel, BorderLayout.EAST);
- inputPanel.add(inputPanel2, BorderLayout.SOUTH);
- inputPanel2.add(ok);
- inputPanel2.add(cancel);
- inputPanel2.add(browse);
- dialog.setSize(350,135);
-
- try {
- result = fromProc.readLine();
- while(result != null) {
- finished = false;
- if (debug) System.out.println("1 "+result);
- while (result.indexOf("gf")==-1){
- outputString +=result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("1 "+result);
- }
- output.append(outputString);
- while ((result.indexOf("newcat")==-1)&&(result.indexOf("8)
- s+=result.trim();
- else
- s+=result;
- }
- }
-// if (s.charAt(0)!='d')
-// listModel.addElement("Refine " + s);
-// else
- listModel.addElement(s);
- s="";
- //read /show
- //read send
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- saveCommand();
- // read /item
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- }
- } catch(IOException e){ }
- }
-
- public static void saveCommand(){
- if (newObject) commands.add(result);
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("9 "+result);
- } catch(IOException e){ }
- }
-
- public void readLin(){
- try {
- linearization="";
- linearization += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- while (result.indexOf("/linearization")==-1){
- linearization += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- }
- if (newObject) formLin();
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- } catch(IOException e){ }
- }
-
- public static void readTree(){
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- while (result.indexOf("/tree")==-1){
- treeString += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- }
- if (treeChanged && (newObject)) {
- formTree(tree);
- treeChanged = false;
- }
- treeString="";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- } catch(IOException e){ }
- }
-
- public static void readMessage(){
- String s ="";
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- while (result.indexOf("/message")==-1){
- s += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- }
- if (s.length()>1)
- output.append("-------------"+'\n'+s);
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- } catch(IOException e){ }
- }
-
- public void formNewMenu () {
- boolean more = true;
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
-
- while (more){
- if (result.indexOf("language")==-1) {
- menu.addItem(result.substring(6));
- }
- else
- more = false;
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- if (result.indexOf("language")!=-1)
- more = false;
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
- }
-
- more = true;
- while (more){
- if ((result.indexOf("/gf")==-1)&&(result.indexOf("lin")==-1)) {
- //form lang and Menu menu:
- cbMenuItem = new JCheckBoxMenuItem(result.substring(4));
- if (debug) System.out.println ("menu item: "+result.substring(4));
- cbMenuItem.setSelected(true);
- cbMenuItem.setActionCommand("lang");
- cbMenuItem.addActionListener(myListener);
- langMenu.add(cbMenuItem);
-/* if ((result.substring(4)).equals("Abstract"))
- {
- submenu.add(rbMenuItemAbs);
- if (selectedMenuLanguage.equals("Abstract"))
- rbMenuItemAbs.setSelected(true);
- languageGroup.add(rbMenuItemAbs);
- }
- else
- {
-*/
- rbMenuItem = new JRadioButtonMenuItem(result.substring(4));
- rbMenuItem.setActionCommand(result.substring(4));
- rbMenuItem.addActionListener(myListener);
- languageGroup.add(rbMenuItem);
- if ((result.substring(4)).equals(selectedMenuLanguage))
- {
- System.out.println("Selecting "+selectedMenuLanguage);
- rbMenuItem.setSelected(true);
- }
-
- submenu.add(rbMenuItem);
-// }
- }
- else
- more = false;
- // read
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- // read or
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- if ((result.indexOf("/gf")!=-1)||(result.indexOf("lin")!=-1))
- more = false;
- if (result.indexOf("/gf")!=-1)
- finished = true;
- // registering the file name:
- if (result.indexOf("language")!=-1) {
- String path = result.substring(result.indexOf('=')+1,
- result.indexOf('>'));
- path =path.substring(path.lastIndexOf('/')+1);
- if (debug) System.out.println("name: "+path);
- fileString +="--" + path +"\n";
- if (path.lastIndexOf('.')!=path.indexOf('.'))
- grammar.setText(path.substring(0,
- path.indexOf('.')).toUpperCase()+" ");
- }
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
- }
- System.out.println("languageGroupElement formed"+
- languageGroup.getButtonCount());
- langMenu.addSeparator();
- fileMenuItem = new JMenuItem("Add...");
- fileMenuItem.setActionCommand("import");
- fileMenuItem.addActionListener(this);
- langMenu.add(fileMenuItem);
- // in order to get back in main in the beggining of while:
- result = fromProc.readLine();
- } catch(IOException e){ }
- }
-
- public void outputAppend(){
- int i, j, k, l, l2, m;
- l = result.indexOf("',i);
- l2 = result.indexOf("focus");
- if (l2!=-1){
-
- // in case focus tag is cut into two lines:
- if (l==-1) l=l2-7;
-
- if (debug) System.out.println("form Lin1: "+result);
- statusLabel.setText(" "+result.substring(i+5,j));
- //cutting
- result= result.substring(0,l)+result.substring(j+1);
- i=result.indexOf("/focus",l);
- if (debug) System.out.println("/ is at the position"+i);
- j=result.indexOf('>',i);
- k=result.length()-j;
- if (debug) System.out.println("form Lin2: "+result);
- m = output.getText().length();
-
- //cutting
- // in case focus tag is cut into two lines:
- if (debug)
- System.out.println("char at the previous position"+result.charAt(i-1));
- if (result.charAt(i-1)!='<')
- result= result.substring(0,i-8)+result.substring(j+1);
- else
- result= result.substring(0,i-1)+result.substring(j+1);
- j= result.indexOf("');
- String s = result.substring(ind+1,ind2);
- result = lin.substring(0,lin.indexOf(""));
- lin = lin.substring(lin.indexOf(""));
- while (lin.length()>1) {
- //check if the language is on
- if (!visible) visible = true;
- // in the list?
- for (int i=0; i
- lin = lin.substring(lin.indexOf('\n')+1);
- // read lin or 'end'
- if (lin.length()<1) break;
-
- result = lin.substring(0,lin.indexOf('\n'));
- lin = lin.substring(lin.indexOf('\n')+1);
- if (result.indexOf("');
- s = result.substring(ind+1,ind2);
- result = lin.substring(0,lin.indexOf(""));
- lin = lin.substring(lin.indexOf(""));
- }
- }
- }
-
- public void actionPerformed(ActionEvent ae)
- {
- boolean abs = true;
- Object obj = ae.getSource();
- if ( obj == menu ) {
- if (!menu.getSelectedItem().equals("New"))
- {
- treeChanged = true;
- send("n " + menu.getSelectedItem());
- newObject = true;
- menu.setSelectedIndex(0);
- }
- }
- if ( obj == filter ) {
- if (!filter.getSelectedItem().equals("Filter"))
- {
- send("f " + filter.getSelectedItem());
- filter.setSelectedIndex(0);
- }
- }
- if ( obj == modify ) {
- if (!modify.getSelectedItem().equals("Modify"))
- {
- treeChanged = true;
- send("c " + modify.getSelectedItem());
- modify.setSelectedIndex(0);
- }
- }
-/* if ( obj == mode ) {
- if (!mode.getSelectedItem().equals("Menus"))
- {
- send("o " + mode.getSelectedItem());
- mode.setSelectedIndex(0);
- }
- }
-*/
- // buttons and menu items:
- try {
- if (Class.forName("javax.swing.AbstractButton").isInstance(obj)) {
- String name =((AbstractButton)obj).getActionCommand();
-
- if ( name.equals("quit")) {
- endProgram();
- }
-
- if ( name.equals("save") ) {
-
- if (fc1.getChoosableFileFilters().length<2)
- fc1.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc1.showSaveDialog(GFEditor.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc1.getSelectedFile();
- if (debug) System.out.println("saving ... ");
-
- // checking if the abstract syntax is on:
- for (int i=0; i0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
- submenu.removeAll();
-
- File file = fc1.getSelectedFile();
- // opening the file for editing :
- if (debug) System.out.println("opening: "+ file.getPath().replace('\\','/'));
- if (group.getSelection().getActionCommand().equals("term")) {
- if (debug) System.out.println(" opening as a term ");
- send("open "+ file.getPath().replace('\\','/'));
- }
- else {
- if (debug) System.out.println(" opening as a linearization ");
- send("openstring "+ file.getPath().replace('\\','/'));
- }
-
- fileString ="";
- grammar.setText("No Topic ");
- }
- }
-
- if ( name.equals("import") ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- // importing a new language :
- if (debug) System.out.println("importing: "+ file.getPath());
-
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- submenu.removeAll();
-
- menu.removeAllItems();
- menu.addItem("New");
- fileString ="";
- send("i "+ file.getPath().replace('\\','/'));
-
- }
- }
- if ( name.equals("newTopic") ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- int n = JOptionPane.showConfirmDialog(this,
- "This will dismiss the previous editing. Would you like to continue?",
- "Starting a new topic", JOptionPane.YES_NO_OPTION);
- if (n == JOptionPane.YES_OPTION){
- File file = fc.getSelectedFile();
- // importing a new grammar :
- newObject = false;
- statusLabel.setText(status);
- listModel.clear();
- tree.clear();
- populateTree(tree);
- menu.removeAllItems();
- menu.addItem("New");
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- selectedMenuLanguage = "Abstract";
- rbMenuItemLong.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
- submenu.removeAll();
-
- fileString="";
- grammar.setText("No Topic ");
- send("e "+ file.getPath().replace('\\','/'));
- }
- }
- }
-
- if ( obj == gfCommand ){
- String s = JOptionPane.showInputDialog("Command:", parseInput);
- if (s!=null) {
- parseInput = s;
- s = "gf "+s;
- //treeChanged = true;
- send(s);
- }
- }
-
- if ( name.equals("reset") ) {
- newObject = false;
- statusLabel.setText(status);
- listModel.clear();
- tree.clear();
- populateTree(tree);
- menu.removeAllItems();
- menu.addItem("New");
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- selectedMenuLanguage = "Abstract";
-
- submenu.removeAll();
- rbMenuItemLong.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
-
- fileString="";
- grammar.setText("No Topic ");
- send("e");
- }
-
- if ( obj == leftMeta ) {
- treeChanged = true;
- send("<<");
- }
- if ( obj == left ) {
- treeChanged = true;
- send("<");
- }
- if ( obj == top ) {
- treeChanged = true;
- send("'");
- }
- if ( obj == right ) {
- treeChanged = true;
- send(">");
- }
- if ( obj == rightMeta ) {
- treeChanged = true;
- send(">>");
- }
-
- if ( obj == cancel ) {
- dialog.hide();
- }
-
- if ( obj == browse ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- inputField.setText(file.getPath().replace('\\','/'));
- }
- }
-
- if ( obj == ok ) {
- treeChanged = true;
- if (termReadButton.isSelected()) {
- termInput = inputField.getText();
- if (termInput.indexOf('/')==-1){
- send("g "+termInput);
- System.out.println("sending term string");
- }
- else {
- send("tfile "+termInput);
- System.out.println("sending file term: "+termInput);
- }
- }
- else {
- parseInput = inputField.getText();
- if (parseInput.indexOf('/')==-1){
- send("p "+parseInput);
- System.out.println("sending parse string"+parseInput);
- }
- else {
- send("pfile "+parseInput);
- System.out.println("sending file parse string: "+parseInput);
- }
- }
- dialog.hide();
- }
-
- if ( obj == read ) {
- if (stringReadButton.isSelected())
- inputField.setText(parseInput);
- else
- inputField.setText(termInput);
- dialog.show();
- }
-
-/* if ( obj == term ) {
- inputLabel.setText("Term:");
- inputField.setText(termInput);
- dialog.show();
- }
- if ( obj == parse ) {
- inputLabel.setText("Parse:");
- inputField.setText(parseInput);
- dialog.show();
- }
-*/
- if ( obj == alpha){
- String s = JOptionPane.showInputDialog("Type string:", alphaInput);
- if (s!=null) {
- alphaInput = s;
- treeChanged = true;
- send("x "+s);
- }
- }
- if ( obj == random){
- treeChanged = true;
- send("a");
- }
- if ( obj == undo){
- treeChanged = true;
- send("u");
- }
- }
- } catch (Exception e){}
- }
- static void writeOutput(String str, String fileName) {
-
- try {
- FileOutputStream fos = new FileOutputStream(fileName);
- Writer out = new OutputStreamWriter(fos, "UTF8");
- out.write(str);
- out.close();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null,
- "Document is empty!","Error", JOptionPane.ERROR_MESSAGE);
- }
- }
- public static void populateTree(DynamicTree treePanel) {
- String p1Name = new String("Root");
- DefaultMutableTreeNode p1;
- p1 = treePanel.addObject(null, p1Name);
- }
-
- public static void formTree(DynamicTree treePanel) {
- Hashtable table = new Hashtable();
- TreePath path=null;
- boolean treeStarted = false, selected = false;
- String s = treeString;
- String name ="";
- treePanel.clear();
- int j, shift=0, star=0, index = 0;
- DefaultMutableTreeNode p2=null, p1=null;
- if (debug) System.out.print("treeString: "+ s);
- if (s.indexOf('*')!=-1) star = 1;
- while (s.length()>0) {
- while ((s.length()>0) && ((s.charAt(0)=='*')||(s.charAt(0)==' '))){
- if (s.charAt(0) == '*') selected = true;
- s = s.substring(1);
- shift++;
- }
- if (s.length()>0) {
- j = s.indexOf("\n");
- name = s.substring(0, j);
- index++;
- s = s.substring(j+1);
- shift = (shift - star)/2;
-
- p1 = (DefaultMutableTreeNode)table.get(new Integer(shift));
- p2 = treePanel.addObject(p1, name);
- table.put(new Integer(shift+1), p2);
- path = new TreePath(p2.getPath());
- nodeTable.put(path, new Integer(index));
- if (selected) {
- treePanel.tree.setSelectionPath(path);
- treePanel.oldSelection = index;
- if (debug) System.out.println("new selected index "+ index);
- selected = false;
- }
- treeStarted=true;
- }
- shift = 0;
- }
- if ((p2!=null)) {
- treePanel.tree.makeVisible(path);
- gui2.toFront();
- index = 0;
- }
- }
-
- /** Listens to the radio buttons. */
- class RadioListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- String action = e.getActionCommand();
- if (action.equals("split") ) {
- cp.remove(centerPanel);
- centerPanel2.add(middlePanelUp, BorderLayout.SOUTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) {
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- else {
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- cp.add(centerPanel2, BorderLayout.CENTER);
- gui2.getContentPane().add(outputPanelDown);
- gui2.setVisible(true);
- pack();
- repaint();
- }
- if (action.equals("combine") ) {
- cp.remove(centerPanel2);
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { gui2.setVisible(false);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel.setLeftComponent(outputPanelUp);
- gui2.setVisible(false);
- }
- cp.add(centerPanel, BorderLayout.CENTER);
- centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
- pack();
- repaint();
- }
- if (action.equals("showTree") ) {
- if (!((JCheckBoxMenuItem)e.getSource()).isSelected()){
- if (debug) System.out.println("was selected");
- cbMenuItem.setSelected(false);
- if (((JRadioButtonMenuItem)viewMenu.getItem(2)).isSelected()) {
- centerPanel.remove(treePanel);
- centerPanel.setLeftComponent(outputPanelUp);
- }
- else {
- centerPanel2.remove(treePanel);
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- }
- else {
- if (debug) System.out.println("was not selected");
- cbMenuItem.setSelected(true);
- if (((JRadioButtonMenuItem)viewMenu.getItem(2)).isSelected()) {
- centerPanel.remove(outputPanelUp);
- treePanel.setRightComponent(outputPanelUp);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel2.remove(outputPanelUp);
- treePanel.setRightComponent(outputPanelUp);
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- }
- pack();
- repaint();
- }
- if (action.equals("lang")) {
- if (newObject) {
- output.setText("");
- formLin();
- }
- if (debug)
- System.out.println("language option has changed "+((JCheckBoxMenuItem)e.getSource()).getText());
- if (((JCheckBoxMenuItem)e.getSource()).isSelected()){
- System.out.println("turning on");
- send("on "+((JCheckBoxMenuItem)e.getSource()).getText());
- }
- else{
- System.out.println("turning off");
- send("off "+((JCheckBoxMenuItem)e.getSource()).getText());
- }
- }
- //modeMenus actions:
- else {
- if ((action.equals("long")) || (action.equals("short")))
- {
- send("ms " + action);
- }
- else
- if ((action.equals("typed")) || (action.equals("untyped")))
- {
- send("mt " + action);
- }
- else
- {
- selectedMenuLanguage = action;
- if (action.equals("Abstract"))
- {
- send("ml Abs");
- }
- else
- {
- System.out.println("sending "+action);
- send("ml " + action);
- }
- }
- }
- }
- }
-
- /** Handle the key pressed event. */
- public void keyPressed(KeyEvent e) {
- int keyCode = e.getKeyCode();
- if (keyCode == 10) {
- listAction(list.getSelectedIndex());
- }
- }
- /** Handle the key typed event. */
- public void keyTyped(KeyEvent e) {
- }
- /** Handle the key released event. */
- public void keyReleased(KeyEvent e) {
- }
-
- public void listAction(int index) {
- if (index == -1)
- {if (debug) System.out.println("no selection");}
- else {
- treeChanged = true;
- send((String)commands.elementAt(list.getSelectedIndex()));
- }
- }
-}
diff --git a/src/JavaGUI/GFEditor2.java b/src/JavaGUI/GFEditor2.java
deleted file mode 100644
index f71210d7c..000000000
--- a/src/JavaGUI/GFEditor2.java
+++ /dev/null
@@ -1,2357 +0,0 @@
-//package javaGUI;
-
-import java.awt.*;
-import java.beans.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.text.*;
-import javax.swing.event.*;
-import javax.swing.tree.*;
-import java.io.*;
-import java.util.*;
-//import gfWindow.GrammarFilter;
-
-public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
- KeyListener, FocusListener {
-
- private static Color color = Color.green;
- private int[] sizes = {14,18,22,26,30};
- private String[] envfonts;
- private Font font;
- Font[] fontObjs;
- private static int DEFAULT_FONT_SIZE = 14;
- private JComboBox fontList;
- private JLabel fontLabel = new JLabel(" Font: ");
- private JComboBox sizeList;
- private JLabel sizeLabel = new JLabel(" Size: ");
-
- public JPopupMenu popup2 = new JPopupMenu();
- public JMenuItem menuItem2;
- public static JTextField field = new JTextField("textField!");
- public javax.swing.Timer timer2 = new javax.swing.Timer(500, this);
- public MouseEvent m2;
- public static String selectedText="";
-
- // XML parsing:
- public static boolean debug = false;
- // pop-up/mouse handling:
- public static boolean debug3 = false;
- // red mark-up && html:
- public static boolean debug4 = false;
- // linearization marking:
- public static boolean debug2 = false;
-
- public static boolean selectionCheck = false;
- public static LinPosition focusPosition ;
- public static String stringToAppend = "";
-
- //stack for storing the current position:
- public static Vector currentPosition = new Vector();
- public static int selStart = -1;
- public static int selEnd = -1;
- //public static int oldSelStart = 0;
- public static String restString = "";
- public static int currentLength = 0;
- public static int newLength = 0;
- public static int oldLength = 0;
- public static int addedLength = 0;
-
- public static boolean newObject = false;
- public static boolean finished = false;
- private String parseInput = "";
- private String alphaInput = "";
- private static String status = "status";
- private static String selectedMenuLanguage = "Abstract";
- private static String linearization = "";
- private String termInput = "";
- private static String outputString = "";
- private static String treeString = "";
- private static String fileString = "";
- public static Vector commands = new Vector();
- public static Vector outputVector = new Vector();
- public static Hashtable nodeTable = new Hashtable();
- JFileChooser fc1 = new JFileChooser("./");
- JFileChooser fc = new JFileChooser("./");
- private String [] filterMenu = {"Filter", "identity",
- "erase", "take100", "text", "code", "latexfile",
- "structured", "unstructured" };
- private String [] modifyMenu = {"Modify", "identity","transfer",
- "compute", "paraphrase", "generate","typecheck", "solve", "context" };
-// private String [] modeMenu = {"Menus", "printname",
-// "plain", "short", "long", "typed", "untyped" };
- private static String [] newMenu = {"New"};
-
- private static boolean firstLin = true;
- private static boolean waiting = false;
- public static boolean treeChanged = true;
- private static String result;
- private static BufferedReader fromProc;
- private static BufferedWriter toProc;
- private static String commandPath = new String("GF");
- private static JTextArea output = new JTextArea();
- public static DefaultListModel listModel= new DefaultListModel();
- private JList list = new JList(listModel);
- private static DynamicTree2 tree = new DynamicTree2();
-
- private JLabel grammar = new JLabel("No topic ");
- private JButton save = new JButton("Save");
- private JButton open = new JButton("Open");
- private JButton newTopic = new JButton("New Topic");
- private JButton gfCommand = new JButton("GF command");
-
- private JButton leftMeta = new JButton("?<");
- private JButton left = new JButton("<");
- private JButton top = new JButton("Top");
- private JButton right = new JButton(">");
- private JButton rightMeta = new JButton(">?");
- private JButton read = new JButton("Read");
- // private JButton parse = new JButton("Parse");
- // private JButton term = new JButton("Term");
- private JButton alpha = new JButton("Alpha");
- private JButton random = new JButton("Random");
- private JButton undo = new JButton("Undo");
- private JPanel coverPanel = new JPanel();
- private JPanel inputPanel = new JPanel();
-
- private JPanel inputPanel2 = new JPanel();
- private JPanel inputPanel3 = new JPanel();
- private JButton ok = new JButton("OK");
- private JButton cancel = new JButton("Cancel");
- private JTextField inputField = new JTextField();
- private JLabel inputLabel = new JLabel("Read: ");
- private JButton browse = new JButton("Browse...");
- private ButtonGroup readGroup = new ButtonGroup();
- private JRadioButton termReadButton = new JRadioButton("Term");
- private JRadioButton stringReadButton = new JRadioButton("String");
-
- private JDialog dialog;
-
- private static JComboBox menu = new JComboBox(newMenu);
- private JComboBox filter = new JComboBox(filterMenu);
- private JComboBox modify = new JComboBox(modifyMenu);
- // private JComboBox mode = new JComboBox(modeMenu);
-
- private JPanel downPanel = new JPanel();
- private JSplitPane treePanel;
- private JPanel upPanel = new JPanel();
- private JPanel middlePanel = new JPanel();
- private JPanel middlePanelUp = new JPanel();
- private JPanel middlePanelDown = new JPanel();
- private JSplitPane centerPanel;
- private static JFrame gui2 = new JFrame();
- private JPanel centerPanel2= new JPanel();
- private JPanel centerPanelDown = new JPanel();
- private JScrollPane outputPanelDown = new JScrollPane(list);
- private JScrollPane outputPanelCenter = new JScrollPane(output);
- private JPanel outputPanelUp = new JPanel();
- private JPanel statusPanel = new JPanel();
- private static JLabel statusLabel = new JLabel(status);
- private Container cp;
-
- private static JMenuBar menuBar= new JMenuBar();;
- private static ButtonGroup menuGroup = new ButtonGroup();
- private JMenu viewMenu= new JMenu("View");
- private JMenu submenu= new JMenu("language");
- private JMenu modeMenu= new JMenu("Menus");
- private static JMenu langMenu= new JMenu("Languages");
- private static JMenu fileMenu= new JMenu("File");
- private JRadioButtonMenuItem rbMenuItem;
- private JRadioButtonMenuItem rbMenuItemLong;
- // private JRadioButtonMenuItem rbMenuItemAbs;
- private JRadioButtonMenuItem rbMenuItemUnTyped;
- private static JMenuItem fileMenuItem;
- private static JCheckBoxMenuItem cbMenuItem;
- private static JCheckBoxMenuItem treeCbMenuItem;
- private static RadioListener myListener ;
- private static ButtonGroup group = new ButtonGroup();
- private static ButtonGroup languageGroup = new ButtonGroup();
-
- public GFEditor2()
- {
- this.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- endProgram();
- }
- });
-
-
- //Add listener to components that can bring up popup menus.
- MouseListener popupListener2 = new PopupListener();
- output.addMouseListener(popupListener2);
- timer2.setRepeats(false);
-
- setJMenuBar(menuBar);
- setTitle("GF Syntax Editor");
- viewMenu.setToolTipText("View settings");
- fileMenu.setToolTipText("Main operations");
- langMenu.setToolTipText("Language settings");
- menuBar.add(fileMenu);
- menuBar.add(langMenu);
- menuBar.add(viewMenu);
- menuBar.add(modeMenu);
-
- treeCbMenuItem = new JCheckBoxMenuItem("Tree");
- treeCbMenuItem.setActionCommand("showTree");
- myListener = new RadioListener();
- treeCbMenuItem.addActionListener(myListener);
- treeCbMenuItem.setSelected(true);
- viewMenu.add(treeCbMenuItem);
- viewMenu.addSeparator();
-
- fileMenuItem = new JMenuItem("Open...");
- fileMenuItem.setActionCommand("open");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("New Topic...");
- fileMenuItem.setActionCommand("newTopic");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("Reset");
- fileMenuItem.setActionCommand("reset");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("Save As...");
- fileMenuItem.setActionCommand("save");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenu.addSeparator();
- fileMenuItem = new JMenuItem("Exit");
- fileMenuItem.setActionCommand("quit");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem("One window");
- rbMenuItem.setActionCommand("combine");
- rbMenuItem.addActionListener(myListener);
- rbMenuItem.setSelected(true);
-/* rbMenuItem.setMnemonic(KeyEvent.VK_R);
- rbMenuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_1, ActionEvent.ALT_MASK));
- rbMenuItem.getAccessibleContext().setAccessibleDescription(
- "This doesn't really do anything");
-*/
- menuGroup.add(rbMenuItem);
- viewMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem("Split windows");
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- rbMenuItem.setActionCommand("split");
- rbMenuItem.addActionListener(myListener);
- menuGroup.add(rbMenuItem);
- viewMenu.add(rbMenuItem);
-
- modeMenu.add(submenu);
-
- /* rbMenuItemAbs = new JRadioButtonMenuItem("Abstract");
- rbMenuItemAbs.setActionCommand("Abstract");
- rbMenuItemAbs.addActionListener(myListener);
- languageGroup.add(rbMenuItemAbs);
- */
-
- modeMenu.addSeparator();
- menuGroup = new ButtonGroup();
- rbMenuItemLong = new JRadioButtonMenuItem("long");
- rbMenuItemLong.setActionCommand("long");
- rbMenuItemLong.setSelected(true);
- rbMenuItemLong.addActionListener(myListener);
- menuGroup.add(rbMenuItemLong);
- modeMenu.add(rbMenuItemLong);
- rbMenuItem = new JRadioButtonMenuItem("short");
- rbMenuItem.setActionCommand("short");
- rbMenuItem.addActionListener(myListener);
- menuGroup.add(rbMenuItem);
- modeMenu.add(rbMenuItem);
- modeMenu.addSeparator();
-
- menuGroup = new ButtonGroup();
- rbMenuItem = new JRadioButtonMenuItem("typed");
- rbMenuItem.setActionCommand("typed");
- rbMenuItem.addActionListener(myListener);
- rbMenuItem.setSelected(false);
- menuGroup.add(rbMenuItem);
- modeMenu.add(rbMenuItem);
- rbMenuItemUnTyped = new JRadioButtonMenuItem("untyped");
- rbMenuItemUnTyped.setSelected(true);
- rbMenuItemUnTyped.setActionCommand("untyped");
- rbMenuItemUnTyped.addActionListener(myListener);
- menuGroup.add(rbMenuItemUnTyped);
- modeMenu.add(rbMenuItemUnTyped);
-
- cp = getContentPane();
- JScrollPane cpPanelScroll = new JScrollPane(coverPanel);
- cp.add(cpPanelScroll);
- coverPanel.setLayout(new BorderLayout());
- output.setToolTipText("Linearizations' display area");
- output.addCaretListener(this);
- output.setEditable(false);
- output.setLineWrap(true);
- output.setWrapStyleWord(true);
- output.setSelectionColor(Color.green);
-// output.setSelectionColor(Color.white);
-// output.setFont(new Font("Arial Unicode MS", Font.PLAIN, 17));
- font = new Font(null, Font.PLAIN, DEFAULT_FONT_SIZE);
- output.setFont(font);
- field.setFont(font);
- field.setFocusable(true);
- field.addKeyListener(this);
- field.addFocusListener(this);
-// System.out.println(output.getFont().getFontName());
- gfCommand.setToolTipText("Sending a command to GF");
- read.setToolTipText("Refining with term or linearization from typed string or file");
- modify.setToolTipText("Choosing a linearization method");
- alpha.setToolTipText("Performing alpha-conversion");
- random.setToolTipText("Generating random refinement");
- undo.setToolTipText("Going back to the previous state");
- downPanel.add(gfCommand);
- //downPanel.add(parse);
- //downPanel.add(term);
- downPanel.add(read);
- downPanel.add(modify);
- downPanel.add(alpha);
- downPanel.add(random);
- downPanel.add(undo);
-
- leftMeta.setToolTipText("Moving the focus to the previous metavariable");
- rightMeta.setToolTipText("Moving the focus to the next metavariable");
- left.setToolTipText("Moving the focus to the previous term");
- right.setToolTipText("Moving the focus to the next term");
- top.setToolTipText("Moving the focus to the top term");
- middlePanelUp.add(leftMeta);
- middlePanelUp.add(left);
- middlePanelUp.add(top);
- middlePanelUp.add(right);
- middlePanelUp.add(rightMeta);
- middlePanelDown.add(new JLabel("Select Action on Subterm"));
- middlePanel.setLayout(new BorderLayout());
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- middlePanel.add(middlePanelDown, BorderLayout.CENTER);
-
- menu.setToolTipText("The list of available categories to start editing");
- open.setToolTipText("Reading both a new environment and an editing object from file. Current editing will be discarded");
- save.setToolTipText("Writing the current editing object to file in the term or text format");
- grammar.setToolTipText("Current Topic");
- newTopic.setToolTipText("Reading a new environment from file. Current editing will be discarded.");
- upPanel.add(grammar);
- upPanel.add(menu);
- upPanel.add(open);
- upPanel.add(save);
- upPanel.add(newTopic);
- upPanel.add(filter);
-
- filter.setToolTipText("Choosing the linearization representation format");
- modeMenu.setToolTipText("Choosing the refinement options' representation");
- statusLabel.setToolTipText("The current focus type");
- list.setToolTipText("The list of current refinment options");
-
- GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
- envfonts = gEnv.getAvailableFontFamilyNames();
- fontObjs = new Font[envfonts.length];
- for (int fi = 0; fi < envfonts.length; fi++) {
- fontObjs[fi] = new Font(envfonts[fi], Font.PLAIN, DEFAULT_FONT_SIZE);
- }
- fontList = new JComboBox(envfonts);
- fontList.addActionListener(this);
- fontList.setToolTipText("Changing font type");
-
- sizeList = new JComboBox();
- sizeList.setToolTipText("Changing font size");
- for (int i = 0; i and tags
- and fills the corrsponding GUI list -"Select Action".
- */
-
- public static void formSelectMenu (){
- if (debug) System.out.println("list model changing! ");
- String s ="";
- try {
- //read item
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- listModel.clear();
- commands.clear();
- while (result.indexOf("/menu")==-1){
- //read show
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- while (result.indexOf("/show")==-1){
- result = fromProc.readLine();
- if (debug) System.out.println("9 "+result);
- if (result.indexOf("/show")==-1)
- {
- if (result.length()>8)
- s+=result.trim();
- else
- s+=result;
- }
- }
-// if (s.charAt(0)!='d')
-// listModel.addElement("Refine " + s);
-// else
- listModel.addElement(s);
- s="";
- //read /show
- //read send
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- saveCommand();
- // read /item
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- }
- } catch(IOException e){ }
- }
-
- /* put the command into the list of commands */
- public static void saveCommand(){
- if (newObject) commands.add(result);
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("9 "+result);
- } catch(IOException e){ }
- }
-
- /*
- Accumulates the GF-output between tags
- */
-
- public void readLin(){
- try {
- linearization="";
- linearization += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- while ((result!=null)&&(result.indexOf("/linearization")==-1)){
- linearization += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- }
- if (newObject) formLin();
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- } catch(IOException e){ }
- }
-
- /*
- Accumulates the GF-output between tags
- */
-
- public static void readTree(){
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- while (result.indexOf("/tree")==-1){
- treeString += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- }
- if (treeChanged && (newObject)) {
- formTree(tree);
- treeChanged = false;
- }
- treeString="";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- } catch(IOException e){ }
- }
-
- /*
- Parses the GF-output between tags
- and puts it in the linearization area.
- */
-
- public static void readMessage(){
- String s ="";
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- while (result.indexOf("/message")==-1){
- s += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- }
- if (s.length()>1)
- appendMarked("-------------"+'\n'+s,-1,-1);
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- } catch(IOException e){ }
- }
- /*
- Parses the GF-output between tags
- and fill the New combobox in the GUI.
- */
-
- public void formNewMenu () {
- boolean more = true;
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
-
- while (more){
- if (result.indexOf("topic")==-1) {
- menu.addItem(result.substring(6));
- }
- else
- more = false;
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- if (result.indexOf("topic")!=-1)
- more = false;
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
- }
-
- grammar.setText(result.substring(4)+" ");
-
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
-
- more = true;
- while (more){
- if ((result.indexOf("/gfinit")==-1)&&(result.indexOf("lin")==-1)) {
- //form lang and Menu menu:
- cbMenuItem = new JCheckBoxMenuItem(result.substring(4));
- if (debug) System.out.println ("menu item: "+result.substring(4));
- if ((result.substring(4)).equals("Abstract"))
- cbMenuItem.setSelected(false);
- else
- cbMenuItem.setSelected(true);
- cbMenuItem.setActionCommand("lang");
- cbMenuItem.addActionListener(myListener);
- langMenu.add(cbMenuItem);
-/*
- {
- submenu.add(rbMenuItemAbs);
- if (selectedMenuLanguage.equals("Abstract"))
- rbMenuItemAbs.setSelected(true);
- languageGroup.add(rbMenuItemAbs);
- }
- else
- {
-*/
- rbMenuItem = new JRadioButtonMenuItem(result.substring(4));
- rbMenuItem.setActionCommand(result.substring(4));
- rbMenuItem.addActionListener(myListener);
- languageGroup.add(rbMenuItem);
- if ((result.substring(4)).equals(selectedMenuLanguage))
- {
- if (debug) System.out.println("Selecting "+selectedMenuLanguage);
- rbMenuItem.setSelected(true);
- }
-
- submenu.add(rbMenuItem);
-// }
- }
- else
- more = false;
- // read
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- // read or
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- if ((result.indexOf("/gfinit")!=-1)||(result.indexOf("lin")!=-1))
- more = false;
- if (result.indexOf("/gfinit")!=-1)
- finished = true;
- // registering the file name:
- if (result.indexOf("language")!=-1) {
- String path = result.substring(result.indexOf('=')+1,
- result.indexOf('>'));
- path =path.substring(path.lastIndexOf('/')+1);
- if (debug) System.out.println("name: "+path);
- fileString +="--" + path +"\n";
- if (path.lastIndexOf('.')!=path.indexOf('.'))
- grammar.setText(path.substring(0,
- path.indexOf('.')).toUpperCase()+" ");
- }
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
- }
- if (debug)
- System.out.println("languageGroupElement formed"+
- languageGroup.getButtonCount());
- langMenu.addSeparator();
- fileMenuItem = new JMenuItem("Add...");
- fileMenuItem.setActionCommand("import");
- fileMenuItem.addActionListener(this);
- langMenu.add(fileMenuItem);
- // in order to get back in main in the beggining of while:
- result = fromProc.readLine();
- } catch(IOException e){ }
- }
-
- /*
- Parses the GF-output between tags
- and puts the string in the linearization area on the screen
- */
-
- public void outputAppend(){
- int i, j, j2, k, l, l2, selectionLength, m=0, n=0;
- //result=result.replace('\n',' ');
- if (debug2)
- System.out.println("INPUT:"+result);
- l = result.indexOf("',i);
- // status incorrect ?:
- if (result.substring(i,j).indexOf("incorrect")!=-1)
- {
- j2 = result.indexOf("status");
- color = Color.red;
- }
- else
- {
- j2 = j;
- color = Color.green;
- }
- l2 = result.indexOf("focus");
- if (l2!=-1){
- // in case focus tag is cut into two lines:
- if (l==-1) l=l2-7;
- m=result.indexOf("position",l);
- if (debug2) System.out.println("POSITION START: "+m);
- n=result.indexOf("]",m);
- if (debug2) System.out.println("POSITION END: "+n);
- if (debug)
- System.out.println("form Lin1: "+result);
- focusPosition = new LinPosition(result.substring(m+9,n+1),
- result.substring(m,j).indexOf("incorrect")==-1);
- statusLabel.setText(" "+result.substring(i+5,j2));
- //cutting
- result= result.substring(0,l)+result.substring(j+2);
- i=result.indexOf("/focus",l);
- selectionLength = i-l-1;
- if (debug2)
- System.out.println("selection length: "+selectionLength);
- j=result.indexOf('>',i);
- k=result.length()-j-1;
- if (debug) System.out.println("form Lin2: "+result);
-
- if (debug)
- System.out.println("char at the previous position"+result.charAt(i-1));
- //cutting
- // in case focus tag is cut into two lines:
- if (result.charAt(i-1)!='<')
- // check if punktualtion marks like . ! ? are at the end of a sentence:
- if (result.charAt(j+1)==' ')
- result= result.substring(0,i-8)+result.substring(j+2);
- else
- result= result.substring(0,i-9)+result.substring(j+1);
- else
- if (result.charAt(j+1)==' ')
- result= result.substring(0,i-1)+result.substring(j+2);
- else
- result= result.substring(0,i-2)+result.substring(j+1);
- j= result.indexOf(" tags
- */
- public void formLin(){
- boolean visible=true;
- firstLin=true;
- result = linearization.substring(0,linearization.indexOf('\n'));
- String lin = linearization.substring(linearization.indexOf('\n')+1);
- //extract the language from result
- int ind = result.indexOf('=');
- int ind2 = result.indexOf('>');
- String s = result.substring(ind+1,ind2);
- result = lin.substring(0,lin.indexOf(""));
- lin = lin.substring(lin.indexOf(""));
- while (lin.length()>1) {
- //check if the language is on
- if (!visible) visible = true;
- // in the list?
- for (int i=0; i
- lin = lin.substring(lin.indexOf('\n')+1);
- // read lin or 'end'
- if (lin.length()<1) break;
-
- result = lin.substring(0,lin.indexOf('\n'));
- lin = lin.substring(lin.indexOf('\n')+1);
- if (result.indexOf("');
- s = result.substring(ind+1,ind2);
- result = lin.substring(0,lin.indexOf(""));
- lin = lin.substring(lin.indexOf(""));
- }
- }
- for (int i = 0; i0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
- submenu.removeAll();
-
-
- File file = fc1.getSelectedFile();
- // opening the file for editing :
- if (debug) System.out.println("opening: "+ file.getPath().replace('\\','/'));
- if (group.getSelection().getActionCommand().equals("term")) {
- if (debug) System.out.println(" opening as a term ");
- send("open "+ file.getPath().replace('\\','/'));
- }
- else {
- if (debug) System.out.println(" opening as a linearization ");
- send("openstring "+ file.getPath().replace('\\','/'));
- }
-
- fileString ="";
- grammar.setText("No Topic ");
- }
- }
-
- if ( name.equals("import") ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- // importing a new language :
- langMenu.removeAll();
- AbstractButton ab = null;
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- submenu.removeAll();
- while (1< menu.getItemCount())
- menu.removeItemAt(1);
- if (debug) System.out.println("importing: "+ file.getPath().replace('\\','/'));
-
- fileString ="";
- send("i "+ file.getPath().replace('\\','/'));
-
- }
- }
- if ( name.equals("newTopic") ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- int n = JOptionPane.showConfirmDialog(this,
- "This will dismiss the previous editing. Would you like to continue?",
- "Starting a new topic", JOptionPane.YES_NO_OPTION);
- if (n == JOptionPane.YES_OPTION){
- File file = fc.getSelectedFile();
- // importing a new grammar :
- newObject = false;
- statusLabel.setText(status);
- listModel.clear();
- tree.clear();
- populateTree(tree);
- while (1< menu.getItemCount())
- menu.removeItemAt(1);
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- selectedMenuLanguage = "Abstract";
- rbMenuItemLong.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
- submenu.removeAll();
-
- fileString="";
- grammar.setText("No Topic ");
- send(" e "+ file.getPath().replace('\\','/'));
- }
- }
- }
-
- if ( obj == gfCommand ){
- String s = JOptionPane.showInputDialog("Command:", parseInput);
- if (s!=null) {
- parseInput = s;
- //s = "gf "+s; This is for debugging, otherwise shift the comment to the next line.
- treeChanged = true;
- if (debug) System.out.println("sending: "+ s);
- send(s);
- }
- }
-
- if ( name.equals("reset") ) {
- newObject = false;
- statusLabel.setText(status);
- listModel.clear();
- tree.clear();
- populateTree(tree);
- while (1< menu.getItemCount())
- menu.removeItemAt(1);
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- selectedMenuLanguage = "Abstract";
-
- submenu.removeAll();
- rbMenuItemLong.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
-
- fileString="";
- grammar.setText("No Topic ");
- send("e");
- }
-
- if ( obj == leftMeta ) {
- treeChanged = true;
- send("<<");
- }
- if ( obj == left ) {
- treeChanged = true;
- send("<");
- }
- if ( obj == top ) {
- treeChanged = true;
- send("'");
- }
- if ( obj == right ) {
- treeChanged = true;
- send(">");
- }
- if ( obj == rightMeta ) {
- treeChanged = true;
- send(">>");
- }
-
- if ( obj == cancel ) {
- dialog.hide();
- }
-
- if ( obj == browse ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- inputField.setText(file.getPath().replace('\\','/'));
- }
- }
-
- if ( obj == ok ) {
- treeChanged = true;
- if (termReadButton.isSelected()) {
- termInput = inputField.getText();
- if (termInput.indexOf('/')==-1){
- send("g "+termInput);
- if (debug) System.out.println("sending term string");
- }
- else {
- send("tfile "+termInput);
- System.out.println("sending file term: "+termInput);
- }
- }
- else {
- parseInput = inputField.getText();
- if (parseInput.indexOf('/')==-1){
- send("p "+parseInput);
- if (debug) System.out.println("sending parse string: "+parseInput);
- }
- else {
- send("pfile "+parseInput);
- if (debug) System.out.println("sending file parse string: "+parseInput);
- }
- }
- dialog.hide();
- }
-
- if ( obj == read ) {
- if (stringReadButton.isSelected())
- inputField.setText(parseInput);
- else
- inputField.setText(termInput);
- dialog.show();
- }
-
-/* if ( obj == term ) {
- inputLabel.setText("Term:");
- inputField.setText(termInput);
- dialog.show();
- }
- if ( obj == parse ) {
- inputLabel.setText("Parse:");
- inputField.setText(parseInput);
- dialog.show();
- }
-*/
- if ( obj == alpha){
- String s = JOptionPane.showInputDialog("Type string:", alphaInput);
- if (s!=null) {
- alphaInput = s;
- treeChanged = true;
- send("x "+s);
- }
- }
- if ( obj == random){
- treeChanged = true;
- send("a");
- }
- if ( obj == undo){
- treeChanged = true;
- send("u");
- }
- }
- } catch (Exception e){}
- }
- static void writeOutput(String str, String fileName) {
-
- try {
- FileOutputStream fos = new FileOutputStream(fileName);
- Writer out = new OutputStreamWriter(fos, "UTF8");
- out.write(str);
- out.close();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null,
- "Document is empty!","Error", JOptionPane.ERROR_MESSAGE);
- }
- }
-
- /* Form a dummy tree in treePanel */
- public static void populateTree(DynamicTree2 treePanel) {
- String p1Name = new String("Root");
- DefaultMutableTreeNode p1;
- p1 = treePanel.addObject(null, p1Name);
- }
-
- /*
- Parses the GF-output between tags
- and build the corresponding tree.
- */
-
- public static void formTree(DynamicTree2 treePanel) {
- Hashtable table = new Hashtable();
- TreePath path=null;
- boolean treeStarted = false, selected = false;
- String s = treeString;
- String name ="";
- treePanel.clear();
- int j, shift=0, star=0, index = 0;
- DefaultMutableTreeNode p2=null, p1=null;
- if (debug) System.out.print("treeString: "+ s);
- if (s.indexOf('*')!=-1) star = 1;
- while (s.length()>0) {
- while ((s.length()>0) && ((s.charAt(0)=='*')||(s.charAt(0)==' '))){
- if (s.charAt(0) == '*') selected = true;
- s = s.substring(1);
- shift++;
- }
- if (s.length()>0) {
- j = s.indexOf("\n");
- name = s.substring(0, j);
- index++;
- s = s.substring(j+1);
- shift = (shift - star)/2;
-
- p1 = (DefaultMutableTreeNode)table.get(new Integer(shift));
- p2 = treePanel.addObject(p1, name);
- table.put(new Integer(shift+1), p2);
- path = new TreePath(p2.getPath());
- nodeTable.put(path, new Integer(index));
- if (selected) {
- treePanel.tree.setSelectionPath(path);
- treePanel.oldSelection = index;
- if (debug) System.out.println("new selected index "+ index);
- selected = false;
- }
- treeStarted=true;
- }
- shift = 0;
- }
- if ((p2!=null)) {
- treePanel.tree.makeVisible(path);
- gui2.toFront();
- index = 0;
- }
- }
-
- /** Listens to the radio buttons. */
- class RadioListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- String action = e.getActionCommand();
- if (action.equals("split") ) {
- coverPanel.remove(centerPanel);
- centerPanel2.add(middlePanelUp, BorderLayout.SOUTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) {
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- else {
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- coverPanel.add(centerPanel2, BorderLayout.CENTER);
- gui2.getContentPane().add(outputPanelDown);
- gui2.setVisible(true);
- pack();
- repaint();
- }
- if (action.equals("combine") ) {
- coverPanel.remove(centerPanel2);
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { gui2.setVisible(false);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel.setLeftComponent(outputPanelUp);
- gui2.setVisible(false);
- }
- coverPanel.add(centerPanel, BorderLayout.CENTER);
- centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
- pack();
- repaint();
- }
-
- if (action.equals("showTree") ) {
- if (!((JCheckBoxMenuItem)e.getSource()).isSelected()){
- if (debug) System.out.println("was selected");
- treeCbMenuItem.setSelected(false);
- if (((JRadioButtonMenuItem)viewMenu.getItem(2)).isSelected()) {
- centerPanel.remove(treePanel);
- centerPanel.setLeftComponent(outputPanelUp);
- }
- else {
- centerPanel2.remove(treePanel);
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- }
- else {
- if (debug) System.out.println("was not selected");
- treeCbMenuItem.setSelected(true);
- if (((JRadioButtonMenuItem)viewMenu.getItem(2)).isSelected()) {
- centerPanel.remove(outputPanelUp);
- treePanel.setRightComponent(outputPanelUp);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel2.remove(outputPanelUp);
- treePanel.setRightComponent(outputPanelUp);
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- }
- pack();
- repaint();
- }
- if (action.equals("lang")) {
- if (newObject) {
- output.setText("");
- formLin();
- }
- if (debug)
- System.out.println("language option has changed "+((JCheckBoxMenuItem)e.getSource()).getText());
- if (((JCheckBoxMenuItem)e.getSource()).isSelected()){
- if (debug) System.out.println("turning on");
- send("on "+((JCheckBoxMenuItem)e.getSource()).getText());
- }
- else{
- if (debug) System.out.println("turning off");
- send("off "+((JCheckBoxMenuItem)e.getSource()).getText());
- }
- }
- //modeMenus actions:
- else {
- if ((action.equals("long")) || (action.equals("short")))
- {
- send("ms " + action);
- }
- else
- if ((action.equals("typed")) || (action.equals("untyped")))
- {
- send("mt " + action);
- }
- else
- {
- selectedMenuLanguage = action;
- if (action.equals("Abstract"))
- {
- send("ml Abs");
- }
- else
- if (!action.equals("split")&&!action.equals("combine")&&!action.equals("showTree"))
- {
- if (debug) System.out.println("sending "+action);
- send("ml " + action);
- }
- }
- }
- }
- }
-
- /** Handle the key pressed event. */
- public void keyPressed(KeyEvent e) {
- int keyCode = e.getKeyCode();
- Object obj = e.getSource();
- if ((keyCode == 10)&&(obj==list)) {
- listAction(list.getSelectedIndex());
- }
- // Processing Enter:
- if ((keyCode == 10)&&(obj==field)) {
- getLayeredPane().remove(field);
- treeChanged = true;
- send("p "+field.getText());
- if (debug) System.out.println("sending parse string: "+field.getText());
- repaint();
- }
- // Processing Escape:
- if ((keyCode == 27)&&(obj==field)) {
- getLayeredPane().remove(field);
- repaint();
- }
-
- }
- /** Handle the key typed event. */
- public void keyTyped(KeyEvent e) {
- }
- /** Handle the key released event. */
- public void keyReleased(KeyEvent e) {
- }
-
- /**
- Returns the biggest position of first and second.
- Each word in the linearization area has the corresponding
- position in the tree. The position-notion is taken from
- GF-Haskell, where empty position ("[]")
- represents tree-root, "[0]" represents first child of the root,
- "[0,0]" represents the first grandchild of the root etc.
- So comparePositions("[0]","[0,0]")="[0]"
-
- */
- public String comparePositions(String first, String second)
- {
- String common ="[]";
- int i = 1;
- while ((i0&&(end-1)&&(start=0)&&(((MarkedArea)outputVector.elementAt(i)).begin > start))
- i--;
- if (debug2)
- System.out.println("i: "+i+" j: "+j);
- if ((j=jElement.begin)
- {
- iElement = (MarkedArea)outputVector.elementAt(0);
- iPosition = iElement.position.position;
- if (debug2)
- System.out.println("Less: "+jPosition+" and "+iPosition);
- position = findMax(0,j);
- if (debug2)
- System.out.println("SELECTEDTEXT: "+position+"\n");
- treeChanged = true;
- send("mp "+position);
- }
- // before:
- else
- if (debug2)
- System.out.println("BEFORE vector of size: "+outputVector.size());
- }
- // just:
- else
- {
- iElement = (MarkedArea)outputVector.elementAt(i);
- iPosition = iElement.position.position;
- if (debug2)
- System.out.println("SELECTED TEXT Just: "+iPosition +" and "+jPosition+"\n");
- position = findMax(i,j);
- if (debug2)
- System.out.println("SELECTEDTEXT: "+position+"\n");
- treeChanged = true;
- send("mp "+position);
- }
- }
- else
- // more && after:
- if (i>=0)
- {
- iElement = (MarkedArea)outputVector.elementAt(i);
- iPosition = iElement.position.position;
- // more
- if (start<=iElement.end)
- {
- jElement = (MarkedArea)outputVector.elementAt(outputVector.size()-1);
- jPosition = jElement.position.position;
- if (debug2)
- System.out.println("MORE: "+iPosition+ " and "+jPosition);
- position = findMax(i,outputVector.size()-1);
- if (debug2)
- System.out.println("SELECTEDTEXT: "+position+"\n");
- treeChanged = true;
- send("mp "+position);
- }
- else
- // after:
- if (debug2)
- System.out.println("AFTER vector of size: "+outputVector.size());
- }
- else
- // bigger:
- {
- iElement = (MarkedArea)outputVector.elementAt(0);
- iPosition = iElement.position.position;
- jElement = (MarkedArea)outputVector.elementAt(outputVector.size()-1);
- jPosition = jElement.position.position;
- if (debug2)
- System.out.println("BIGGER: "+iPosition +" and "+jPosition+"\n");
- if (debug2)
- System.out.println("SELECTEDTEXT: []\n");
- treeChanged = true;
- send("mp []");
- }
- }//not null selection
- }
-
- /*
- Appends the string s to the text in the linearization area
- on the screen.
- s - string to append
- selectionStart, selectionEnd - selection coordinates
- (focus tag is already cut)
- */
- public static void appendMarked(String s, int selectionStart, int selectionEnd)
- { if (s.length()>0)
- {
- if (debug2)
- {
- System.out.println("STRING: "+s);
- System.out.println("where selection start is: "+selectionStart);
- System.out.println("where selection end is: "+selectionEnd);
- if ((selectionStart>-1)&&(selectionEnd>selectionStart))
- System.out.println("where selection is: "+s.substring(selectionStart,selectionEnd));
- }
- currentLength = 0;
- newLength=0;
- oldLength = output.getText().length();
- int j, l, l2, n, pos, selStartTotal, selEndTotal, selEndT;
- restString = s;
- int m2, m1;
- LinPosition position ;
-
- if (selectionStart>-1)
- {
- selStart = selectionStart;
- selEnd = selectionEnd;
- if (debug2)
- System.out.println("SELECTION: " + selStart + " "+selEnd+ "TOTAL: "+s.length());
- if (selEnd>selStart)
- selectionCheck = (getCharacter(s.substring(selStart, selEnd),"<",0)==-1);
- l = restString.indexOf("-1)||(l>-1))
- {
- if ((l2==-1)||((l-1)))
- {
- j = restString.indexOf('>',l);
- n = getCharacter(restString,"<",j);
- m1 = restString.indexOf('[',l);
- m2 = restString.indexOf(']',l);
- //getting position:
- position = new LinPosition(restString.substring(m1,m2+1),
- restString.substring(l,j).indexOf("incorrect")==-1);
- // something before the tag:
- if (l-currentLength>1)
- {
- if (debug2)
- System.out.println("SOMETHING BEFORE THE TAG");
- if (currentPosition.size()>0)
- register(currentLength, l, (LinPosition)currentPosition.elementAt(currentPosition.size()-1));
- else
- register(currentLength, l, new LinPosition("[]",
- restString.substring(l,j).indexOf("incorrect")==-1));
- }
- // nothing before the tag:
- else
- {
- if (debug2)
- System.out.println("NOTHING BEFORE THE TAG");
- if (n>0)
- register(j+2, n, position);
- else
- register(j+2, restString.length(), position);
- removeSubTreeTag(l,j+1);
- }
- currentLength += newLength ;
- } // l tag:
- if (l2-currentLength>1)
- {
- if (debug2)
- System.out.println("SOMETHING BEFORE THE TAG");
- if (currentPosition.size()>0)
- register(currentLength, l2, (LinPosition)currentPosition.elementAt(currentPosition.size()-1));
- else
- register(currentLength, l2, new LinPosition("[]",
- restString.substring(l,l2).indexOf("incorrect")==-1));
- currentLength += newLength ;
- }
- // nothing before the tag:
- else
- // punctuation after the tag:
- if (restString.substring(l2+10,l2+11).trim().length()>0)
- {
- if (debug2)
- System.out.println("PUNCTUATION AFTER THE TAG");
- if (debug2) System.out.println("STRING: "+restString);
- //cutting the tag first!:
- if (l2>0)
- removeSubTreeTag(l2-1,l2+9);
- else
- removeSubTreeTag(l2,l2+9);
- if (debug2) System.out.println("STRING after cutting the tag: "+restString);
- // cutting the space in the last registered component:
- if (outputVector.size()>0)
- {
- ((MarkedArea)outputVector.elementAt(outputVector.size()-1)).end -=1;
- if (currentLength>0) currentLength -=1;
- }
- if (debug2) System.out.println("currentLength: "+currentLength +" old length " +oldLength);
- // register the punctuation:
- if (currentPosition.size()>0)
- register(currentLength, currentLength+2, (LinPosition)currentPosition.elementAt(currentPosition.size()-1));
- else
- register(currentLength, currentLength+2, new LinPosition("[]",
- true));
- currentLength += newLength ;
- }
- else
- // just cutting the tag:
- removeSubTreeTag(l2,l2+10);
- }
- l2 = restString.indexOf("=selStart)&&(outputVector.size()>0))
- {
- // exclamation sign etc.:
- if (currentLength>selEnd)
- selStartTotal = selStart+oldLength;
- else
- selStartTotal = currentLength+oldLength;
- selEndTotal = selEnd+oldLength;
- selEndT = selEndTotal+1;
- pos = ((MarkedArea)outputVector.elementAt(outputVector.size()-1)).end;
- if (debug2)
- System.out.print("the last registered position: "+ pos);
- if (debug2)
- System.out.println(" selStart: "+ selStartTotal+ " selEnd: "+selEndTotal);
- if (selEnd+oldLength>pos)
- {
- addedLength = selEndTotal-selStartTotal+2;
- outputVector.addElement(new MarkedArea(selStartTotal, selEndTotal+1, focusPosition,restString.substring(currentLength)));
- if (debug2)
- System.out.println("APPENDING Selection Last:"+restString.substring(currentLength)+
- "Length: "+addedLength+" POSITION: "+selStartTotal + " "+selEndT);
- }
- }
- } //if selectionStart>-1
- else
- {
- if (debug2) System.out.println("NO SELECTION IN THE TEXT TO BE APPENDED!");
- //cutting tags from previous focuses if any:
- int r = restString.indexOf("");
- while (r>-1)
- {
- // check if punktualtion marks like . ! ? are at the end of a sentence:
- if (restString.charAt(r+10)==' ')
- restString = restString.substring(0,r)+restString.substring(r+11);
- else
- restString = restString.substring(0,r)+restString.substring(r+10);
- r = restString.indexOf("");
- }
- r = restString.indexOf("-1)
- {
- int t = getCharacter(restString,">",r);
- if (t";
- String less = "\\"+"<";
- restString = replaceSubstring(restString,more,"> ");
- restString = replaceSubstring(restString,less," <");
- restString= replaceSubstring(restString,"\\\\"," \\");
- if (debug4)
- System.out.println(restString);
- output.append(restString.replaceAll("&-","\n "));
- if ((selectionEnd>=selectionStart)&&(selectionStart>-1))
- try {
- output.getHighlighter().addHighlight(selStart+oldLength, selEnd+oldLength+1, new DefaultHighlighter.DefaultHighlightPainter(color) );
- selectedText = output.getText().substring(selStart+oldLength, selEnd+oldLength+1);
- // output.getHighlighter().addHighlight(selStart+oldLength, selEnd+oldLength+1, new DefaultHighlighter.DefaultHighlightPainter(Color.white) );
- } catch (Exception e) {System.out.println("highlighting problem!");}
- }// s.length()>0
- }
-
- /*
- Replaces the occurences of old by newString in the s
- */
- public static String replaceSubstring(String s, String old, String newString)
- {
- String ss = s;
- int i =ss.indexOf(old);
- while (i!=-1)
- {
- ss = ss.substring(0,i) + newString + ss.substring(i+old.length());
- i =ss.indexOf(old);
- }
- return ss;
- }
-
- /*
- Finding position of the charactern not starting with escape symbol (//)
- in the string s from position.
- */
- public static int getCharacter(String s, String character, int position)
- {
- int t = restString.indexOf(character, position);
- int i = t-1;
- int k = 0;
- while ((i>-1)&&(restString.charAt(i)=='\\'))
- {
- k++;
- i--;
- }
- if (k % 2 == 0)
- return t;
- else
- return getCharacter(s, character, t+1);
- }
-
- /* Assigns the position to the substring from start to end in the linearization */
- public static void register(int start, int end, LinPosition position)
- {
- oldLength = output.getText().length();
- addedLength = 0;
- int resultCurrent = 0;
- int resultNew = 0;
- newLength = end-start;
- // the tag has some words to register:
- if (newLength>0)
- {
- //focus has a separate position:
- if (selectionCheck&&(end>selStart))
- {
- selectionCheck=false;
- if (debug2)
- System.out.println("SELECTION HAS A SEPARATE POSITION");
- if (debug2)
- System.out.println("SELECTION: "+ selStart+" "+selEnd);
- if (debug2)
- System.out.println("TEXT to REGISTER: "+ start+" "+end);
- if (debug2)
- System.out.println("CURRLENGTH: "+ currentLength);
-
- resultCurrent = currentLength+oldLength;
-
- if (selStart>start+1)
- {
- // register text before selection:
- addedLength = selStart - start;
- resultNew = resultCurrent+ addedLength -1;
- outputVector.addElement(new MarkedArea(resultCurrent, resultNew, position, restString.substring(start,start+addedLength)));
- if (debug2)
- System.out.println("APPENDING ZONE Before selection:"+restString.substring(start,start+addedLength)+
- "Length: "+addedLength+" POSITION: "+resultCurrent + " "+resultNew);
- }
-
- //selection:
- resultCurrent += addedLength;
- addedLength = selEnd - selStart + 2;
- resultNew = resultCurrent + addedLength - 1;
- outputVector.addElement(new MarkedArea(resultCurrent, resultNew, focusPosition,restString.substring(selStart,selEnd+2)));
- if (debug2)
- System.out.println("APPENDING SelectedZONE: "+restString.substring(selStart,selEnd+2)+
- "Length: "+newLength+" POSITION: "+resultCurrent + " "+resultNew);
-
-
- if (end>selEnd+2)
- {
- // register the rest:
- resultCurrent += addedLength;
- addedLength = end-selEnd-2;
- resultNew = resultCurrent + addedLength -1;
- outputVector.addElement(new MarkedArea(resultCurrent, resultNew, position,restString.substring(selEnd+2,end)));
- if (debug2)
- System.out.println("APPENDING ZONE after:"+
- restString.substring(selEnd+2,end)+
- "Length: "+newLength+" POSITION: "+resultCurrent + " "+resultNew);
- }
- }// focus has a separate position
- else
- {
- resultCurrent = currentLength + oldLength ;
- resultNew = newLength + resultCurrent - 1;
- if (debug2) System.out.println("Start: "+ start + " end: "+end);
- if (debug2) System.out.println("STRING: "+ restString + " which length is: "+restString.length());
- stringToAppend = restString.substring(start,end);
- if (stringToAppend.trim().length()>0)
- {
- outputVector.addElement(new MarkedArea(resultCurrent, resultNew, position,stringToAppend));
- if (debug2)
- System.out.println("APPENDING ZONE:"+stringToAppend+
- "Length: "+newLength+" POSITION: "+resultCurrent + " "+resultNew+" "+position.position);
- }
- else
- if (debug2)
- System.out.println("whiteSpaces: "+newLength);
- }
- } //some words to register
- }
-
- /* removing subtree-tag in the interval start-end
- and updating the coordinates after that
- */
- public static void removeSubTreeTag (int start, int end)
- {
- if (debug2)
- System.out.println("removing: "+ start +" to "+ end);
- int difference =end-start+1;
- int positionStart, positionEnd;
- if (difference>20)
- {
- positionStart = restString.indexOf("[", start);
- positionEnd = restString.indexOf("]", start);
-
- currentPosition.addElement(new LinPosition(
- restString.substring(positionStart, positionEnd+1),
- restString.substring(start,end).indexOf("incorrect")==-1));
- }
- else
- if (currentPosition.size()>0)
- currentPosition.removeElementAt(currentPosition.size()-1);
- if (start>0)
- restString = restString.substring(0,start)+restString.substring(end+1);
- else
- restString = restString.substring(end+1);
- if (selStart > end)
- { selStart -=difference;
- selEnd -=difference;
- }
- else
- if (selEnd < start) ;
- else selEnd -=difference;
- }
-
- /* handling the event of choosing the action at index from the list*/
- public void listAction(int index) {
- if (index == -1)
- {if (debug) System.out.println("no selection");}
- else {
- treeChanged = true;
- send((String)commands.elementAt(list.getSelectedIndex()));
- }
- }
-
- // pop-up menu (adapted from DynamicTree2):
- class PopupListener extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
-// int selStart = tree.getRowForLocation(e.getX(), e.getY());
-// output.setSelectionRow(selStart);
- if (debug3)
- System.out.println("mouse pressed2: "+output.getSelectionStart()+" "+output.getSelectionEnd());
- //maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- if (debug3) System.out.println("mouse released2!"+output.getSelectionStart()+" "+output.getSelectionEnd());
- maybeShowPopup(e);
- }
- }
- void maybeShowPopup(MouseEvent e) {
- int i=outputVector.size()-1;
- // right click:
- if (e.isPopupTrigger()) {
- m2 = e;
- timer2.start();
- }
- // middle click
- if (e.getButton() == MouseEvent.BUTTON2)
- {
- // selection Exists:
- if (!selectedText.equals(""))
- {
- if (debug3) System.out.println(e.getX() + " " + e.getY());
- if (selectedText.length()<5)
- if (treeCbMenuItem.isSelected())
- field.setBounds(e.getX()+(int)Math.round(tree.getBounds().getWidth()), e.getY()+80, 400, 40);
- else
- field.setBounds(e.getX(), e.getY()+80, 400, 40);
- else
- if (treeCbMenuItem.isSelected())
- field.setBounds(e.getX()+(int)Math.round(tree.getBounds().getWidth()), e.getY()+80, selectedText.length()*20, 40);
- else
- field.setBounds(e.getX(), e.getY()+80, selectedText.length()*20, 40);
- getLayeredPane().add(field, new Integer(1), 0);
- field.setText(selectedText);
- field.requestFocusInWindow();
- }
- }
- }
- void addMenuItem(String name){
- menuItem2 = new JMenuItem(name);
- menuItem2.setFont(font);
- menuItem2.setActionCommand("popupMenuItem");
- menuItem2.addActionListener(this);
- popup2.add(menuItem2);
-
- }
- public void focusGained(FocusEvent e)
- {
- }
- public void focusLost(FocusEvent e)
- {
- getLayeredPane().remove(field);
- repaint();
- }
-}
-
- /*focus has a separate position:
- if (selectionCheck&&(selEnd");
- private JButton rightMeta = new JButton(">?");
- private JButton read = new JButton("Read");
- // private JButton parse = new JButton("Parse");
- // private JButton term = new JButton("Term");
- private JButton alpha = new JButton("Alpha");
- private JButton random = new JButton("Random");
- private JButton undo = new JButton("Undo");
-
- private JPanel inputPanel = new JPanel();
- private JPanel inputPanel2 = new JPanel();
- private JPanel inputPanel3 = new JPanel();
- private JButton ok = new JButton("OK");
- private JButton cancel = new JButton("Cancel");
- private JTextField inputField = new JTextField();
- private JLabel inputLabel = new JLabel("Read: ");
- private JButton browse = new JButton("Browse...");
- private ButtonGroup readGroup = new ButtonGroup();
- private JRadioButton termReadButton = new JRadioButton("Term");
- private JRadioButton stringReadButton = new JRadioButton("String");
-
- private JDialog dialog;
-
- private static JComboBox menu = new JComboBox(newMenu);
- private JComboBox filter = new JComboBox(filterMenu);
- private JComboBox modify = new JComboBox(modifyMenu);
- // private JComboBox mode = new JComboBox(modeMenu);
-
- private JPanel downPanel = new JPanel();
- private JSplitPane treePanel;
- private JPanel upPanel = new JPanel();
- private JPanel middlePanel = new JPanel();
- private JPanel middlePanelUp = new JPanel();
- private JPanel middlePanelDown = new JPanel();
- private JSplitPane centerPanel;
- private static JFrame gui2 = new JFrame();
- private JPanel centerPanel2= new JPanel();
- private JPanel centerPanelDown = new JPanel();
- private JScrollPane outputPanelDown = new JScrollPane(list);
- private JScrollPane outputPanelCenter = new JScrollPane(output);
- private JPanel outputPanelUp = new JPanel();
- private JPanel statusPanel = new JPanel();
- private static JLabel statusLabel = new JLabel(status);
- private Container cp;
-
- private static JMenuBar menuBar= new JMenuBar();;
- private static ButtonGroup menuGroup = new ButtonGroup();
- private JMenu viewMenu= new JMenu("View");
- private JMenu submenu= new JMenu("Language");
- private JMenu submenuFont= new JMenu("TextSize");
- private JMenu modeMenu= new JMenu("Menus");
- private static JMenu langMenu= new JMenu("Languages");
- private static JMenu fileMenu= new JMenu("File");
- private JRadioButtonMenuItem rbMenuItem;
- private JRadioButtonMenuItem rbMenuItemLong;
- // private JRadioButtonMenuItem rbMenuItemAbs;
- private JRadioButtonMenuItem rbMenuItemUnTyped;
- private static JMenuItem fileMenuItem;
- private static JCheckBoxMenuItem cbMenuItem;
- private static RadioListener myListener ;
- private static ButtonGroup group = new ButtonGroup();
- private static ButtonGroup languageGroup = new ButtonGroup();
- private static ButtonGroup fontGroup = new ButtonGroup();
-
- public Numerals()
- {
- this.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- endProgram();
- }
- });
- setJMenuBar(menuBar);
- setTitle("Numerals");
-
- GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
- String envfonts[] = gEnv.getAvailableFontFamilyNames();
- fontList = new JComboBox(envfonts);
- fontList.addActionListener(this);
- //fontList.setFont(font);
- //fontLabel.setFont(font);
- up.add(fontLabel);
- up.add(fontList);
-
- viewMenu.setToolTipText("View settings");
- fileMenu.setToolTipText("File operations");
- langMenu.setToolTipText("Language settings");
- menuBar.add(fileMenu);
- menuBar.add(langMenu);
- menuBar.add(viewMenu);
- //menuBar.add(modeMenu);
-
- //cbMenuItem = new JCheckBoxMenuItem("Tree");
- //cbMenuItem.setActionCommand("showTree");
- myListener = new RadioListener();
- //cbMenuItem.addActionListener(myListener);
- //cbMenuItem.setSelected(true);
- //viewMenu.add(cbMenuItem);
- //viewMenu.addSeparator();
- rbMenuItem = new JRadioButtonMenuItem("large");
- rbMenuItem.setActionCommand("large");
- rbMenuItem.addActionListener(myListener);
- fontGroup.add(rbMenuItem);
- rbMenuItem.setSelected(false);
- submenuFont.add(rbMenuItem);
- rbMenuItem = new JRadioButtonMenuItem("medium");
- rbMenuItem.setActionCommand("medium");
- rbMenuItem.addActionListener(myListener);
- fontGroup.add(rbMenuItem);
- rbMenuItem.setSelected(true);
- submenuFont.add(rbMenuItem);
- rbMenuItem = new JRadioButtonMenuItem("small");
- rbMenuItem.setActionCommand("small");
- rbMenuItem.addActionListener(myListener);
- fontGroup.add(rbMenuItem);
- rbMenuItem.setSelected(false);
- submenuFont.add(rbMenuItem);
-
- viewMenu.add(submenuFont);
- //viewMenu.addSeparator();
-
- /* fileMenuItem = new JMenuItem("Open...");
- fileMenuItem.setActionCommand("open");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("New Topic...");
- fileMenuItem.setActionCommand("newTopic");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenuItem = new JMenuItem("Reset");
- fileMenuItem.setActionCommand("reset");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- */
- fileMenuItem = new JMenuItem("Save As...");
- fileMenuItem.setActionCommand("save");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
- fileMenu.addSeparator();
- fileMenuItem = new JMenuItem("Exit");
- fileMenuItem.setActionCommand("quit");
- fileMenuItem.addActionListener(this);
- fileMenu.add(fileMenuItem);
-
- // rbMenuItem = new JRadioButtonMenuItem("One window");
- // rbMenuItem.setActionCommand("combine");
- // rbMenuItem.addActionListener(myListener);
- // rbMenuItem.setSelected(true);
-/* rbMenuItem.setMnemonic(KeyEvent.VK_R);
- rbMenuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_1, ActionEvent.ALT_MASK));
- rbMenuItem.getAccessibleContext().setAccessibleDescription(
- "This doesn't really do anything");
-*/
- /* menuGroup.add(rbMenuItem);
- viewMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem("Split windows");
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- rbMenuItem.setActionCommand("split");
- rbMenuItem.addActionListener(myListener);
- menuGroup.add(rbMenuItem);
- viewMenu.add(rbMenuItem);
-
- modeMenu.add(submenu);
- */
-
- /* rbMenuItemAbs = new JRadioButtonMenuItem("Abstract");
- rbMenuItemAbs.setActionCommand("Abstract");
- rbMenuItemAbs.addActionListener(myListener);
- languageGroup.add(rbMenuItemAbs);
- */
-
- /* modeMenu.addSeparator();
- menuGroup = new ButtonGroup();
- rbMenuItemLong = new JRadioButtonMenuItem("long");
- rbMenuItemLong.setActionCommand("long");
- rbMenuItemLong.setSelected(true);
- rbMenuItemLong.addActionListener(myListener);
- menuGroup.add(rbMenuItemLong);
- modeMenu.add(rbMenuItemLong);
- rbMenuItem = new JRadioButtonMenuItem("short");
- rbMenuItem.setActionCommand("short");
- rbMenuItem.addActionListener(myListener);
- menuGroup.add(rbMenuItem);
- modeMenu.add(rbMenuItem);
- modeMenu.addSeparator();
-
- menuGroup = new ButtonGroup();
- rbMenuItem = new JRadioButtonMenuItem("typed");
- rbMenuItem.setActionCommand("typed");
- rbMenuItem.addActionListener(myListener);
- rbMenuItem.setSelected(false);
- menuGroup.add(rbMenuItem);
- modeMenu.add(rbMenuItem);
- rbMenuItemUnTyped = new JRadioButtonMenuItem("untyped");
- rbMenuItemUnTyped.setSelected(true);
- rbMenuItemUnTyped.setActionCommand("untyped");
- rbMenuItemUnTyped.addActionListener(myListener);
- menuGroup.add(rbMenuItemUnTyped);
- modeMenu.add(rbMenuItemUnTyped);
- */
- cp = getContentPane();
- cp.setLayout(new BorderLayout());
- cp.add(outputPanelCenter, BorderLayout.CENTER);
- cp.add(downPanel, BorderLayout.SOUTH);
- cp.add(up, BorderLayout.NORTH);
- downPanel.add(random);
- downPanel.add(input);
- input.addKeyListener(this);
- downPanel.add(send);
-
- // output.setToolTipText("Linearizations' display area");
- output.setEditable(false);
- output.setLineWrap(true);
- output.setWrapStyleWord(true);
-// output.setSelectionColor(Color.green);
- output.setSelectionColor(Color.white);
-// output.setFont(new Font("Arial Unicode MS", Font.PLAIN, 17));
- output.setFont(new Font(null, Font.PLAIN, 17));
-// System.out.println(output.getFont().getFontName());
- send.setToolTipText("Showing the translation of a numeral");
- random.setToolTipText("Generating a random numeral");
-/* gfCommand.setToolTipText("Sending a command to GF");
- read.setToolTipText("Refining with term or linearization from typed string or file");
- modify.setToolTipText("Choosing a linearization method");
- alpha.setToolTipText("Performing alpha-conversion");
- random.setToolTipText("Generating random refinement");
- undo.setToolTipText("Going back to the previous state");
- downPanel.add(gfCommand);
- //downPanel.add(parse);
- //downPanel.add(term);
- downPanel.add(read);
- downPanel.add(modify);
- downPanel.add(alpha);
- downPanel.add(random);
- downPanel.add(undo);
-
- leftMeta.setToolTipText("Moving the focus to the previous metavariable");
- rightMeta.setToolTipText("Moving the focus to the next metavariable");
- left.setToolTipText("Moving the focus to the previous term");
- right.setToolTipText("Moving the focus to the next term");
- top.setToolTipText("Moving the focus to the top term");
- middlePanelUp.add(leftMeta);
- middlePanelUp.add(left);
- middlePanelUp.add(top);
- middlePanelUp.add(right);
- middlePanelUp.add(rightMeta);
- middlePanelDown.add(new JLabel("Select Action on Subterm"));
- middlePanel.setLayout(new BorderLayout());
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- middlePanel.add(middlePanelDown, BorderLayout.CENTER);
-
- menu.setToolTipText("The list of available categories to start editing");
- open.setToolTipText("Reading both a new environment and an editing object from file. Current editing will be discarded");
- save.setToolTipText("Writing the current editing object to file in the term or text format");
- grammar.setToolTipText("Current Topic");
- newTopic.setToolTipText("Reading a new environment from file. Current editing will be discarded.");
- upPanel.add(grammar);
- upPanel.add(menu);
- upPanel.add(open);
- upPanel.add(save);
- upPanel.add(newTopic);
-
- filter.setToolTipText("Choosing the linearization representation format");
- modeMenu.setToolTipText("Choosing the refinement options' representation");
- statusLabel.setToolTipText("The current focus type");
- list.setToolTipText("The list of current refinment options");
- tree.setToolTipText("The abstract syntax tree representation of the current editing object");
- upPanel.add(filter);
- //upPanel.add(mode);
- populateTree(tree);
- outputPanelUp.setLayout(new BorderLayout());
- outputPanelUp.add(outputPanelCenter, BorderLayout.CENTER);
- outputPanelUp.add(statusPanel, BorderLayout.SOUTH);
- statusPanel.setLayout(new GridLayout(1,1));
- statusPanel.add(statusLabel);
- treePanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- tree, outputPanelUp);
- treePanel.setDividerSize(5);
- treePanel.setDividerLocation(100);
- centerPanel2.setLayout(new BorderLayout());
- gui2.setSize(500,150);
- gui2.setTitle("Select Action on Subterm");
- gui2.setLocationRelativeTo(treePanel);
- centerPanelDown.setLayout(new BorderLayout());
- centerPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- treePanel, centerPanelDown);
- centerPanel.addKeyListener(tree);
- centerPanel.setOneTouchExpandable(true);
- centerPanelDown.add(middlePanel, BorderLayout.NORTH);
- centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
- cp.add(centerPanel, BorderLayout.CENTER);
- cp.add(upPanel, BorderLayout.NORTH);
- cp.add(downPanel, BorderLayout.SOUTH);
-
- list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
- MouseListener mouseListener = new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- listAction(list.locationToIndex(e.getPoint()));
- }
- }
- };
- list.addMouseListener(mouseListener);
- list.addKeyListener(this);
- menu.addActionListener(this);
- save.addActionListener(this);
- open.addActionListener(this);
- newTopic.addActionListener(this);
- gfCommand.addActionListener(this);
-
- filter.addActionListener(this);
- filter.setMaximumRowCount(9);
- leftMeta.addActionListener(this);
- left.addActionListener(this);
-
- menu.setFocusable(false);
- save.setFocusable(false);
- save.setActionCommand("save");
- open.setFocusable(false);
- open.setActionCommand("open");
- newTopic.setFocusable(false);
- newTopic.setActionCommand("newTopic");
- gfCommand.setFocusable(false);
-
- filter.setFocusable(false);
- leftMeta.setFocusable(false);
- left.setFocusable(false);
-
- top.addActionListener(this);
- right.addActionListener(this);
- rightMeta.addActionListener(this);
- //parse.addActionListener(this);
- //term.addActionListener(this);
- read.addActionListener(this);
- modify.addActionListener(this);
- //mode.addActionListener(this);
- alpha.addActionListener(this);
- random.addActionListener(this);
- undo.addActionListener(this);
-
- top.setFocusable(false);
- right.setFocusable(false);
- rightMeta.setFocusable(false);
- //parse.setFocusable(false);
- //term.setFocusable(false);
- read.setFocusable(false);
- modify.setFocusable(false);
- //mode.setFocusable(false);
- alpha.setFocusable(false);
- random.setFocusable(false);
- undo.setFocusable(false);
-
- output.addKeyListener(tree);
-
- outputPanelUp.setPreferredSize(new Dimension(500,300));
- treePanel.setDividerLocation(0.3);
- nodeTable.put(new TreePath(DynamicTree.rootNode.getPath()), new Integer(0));
-
- JRadioButton termButton = new JRadioButton("Term");
- termButton.setActionCommand("term");
- termButton.setSelected(true);
- JRadioButton linButton = new JRadioButton("Text");
- linButton.setActionCommand("lin");
- // Group the radio buttons.
- group.add(linButton);
- group.add(termButton);
- JPanel buttonPanel = new JPanel();
- buttonPanel.setPreferredSize(new Dimension(70, 70));
- buttonPanel.add(new JLabel("Format:"));
- buttonPanel.add(linButton);
- buttonPanel.add(termButton);
- fc1.setAccessory(buttonPanel);
-
- termReadButton.setActionCommand("term");
- stringReadButton.setSelected(true);
- stringReadButton.setActionCommand("lin");
- // Group the radio buttons.
- readGroup.add(stringReadButton);
- readGroup.add(termReadButton);
- JPanel readButtonPanel = new JPanel();
- readButtonPanel.setLayout(new GridLayout(3,1));
- readButtonPanel.setPreferredSize(new Dimension(70, 70));
- readButtonPanel.add(new JLabel("Format:"));
- readButtonPanel.add(stringReadButton);
- readButtonPanel.add(termReadButton);
- dialog= new JDialog(this, "Input");
- dialog.setLocationRelativeTo(this);
- dialog.getContentPane().add(inputPanel);
- inputPanel.setLayout(new BorderLayout(10,10));
- inputPanel3.setLayout(new GridLayout(2,1,5,5));
- inputPanel3.add(inputLabel);
- inputPanel3.add(inputField);
- ok.addActionListener(this);
- browse.addActionListener(this);
- cancel.addActionListener(this);
- inputField.setPreferredSize(new Dimension(300,23));
- inputPanel.add(inputPanel3, BorderLayout.CENTER);
- inputPanel.add(new JLabel(" "), BorderLayout.WEST);
- inputPanel.add(readButtonPanel, BorderLayout.EAST);
- inputPanel.add(inputPanel2, BorderLayout.SOUTH);
- inputPanel2.add(ok);
- inputPanel2.add(cancel);
- inputPanel2.add(browse);
- dialog.setSize(350,135);
- */
- send.addActionListener(this);
- random.addActionListener(this);
- setSize(400,700);
- setVisible(true);
-
- try {
- result = fromProc.readLine();
- boolean firstCall = true;
- while(result != null) {
- boolean newCommand = true;
- finished = false;
- if (debug) System.out.println("01 "+result);
- while (result.indexOf("gf")==-1){
- outputString +=result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("001 "+result);
- }
- output.append(outputString);
- if (newCommand)
- {
- if (firstCall)
- {
- output.setText("Welcome to Numerals! \n Print a number in the text field below and \n press Enter or use the Random button.");
- firstCall = false;
- }
- else
- output.setText("");
- System.out.println("!!!!!!! output cleared !");
- newCommand = false;
- }
-
- while ((result.indexOf("newcat")==-1)&&(result.indexOf("8)
- s+=result.trim();
- else
- s+=result;
- }
- }
-// if (s.charAt(0)!='d')
-// listModel.addElement("Refine " + s);
-// else
- listModel.addElement(s);
- s="";
- //read /show
- //read send
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- saveCommand();
- // read /item
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("8 "+result);
- }
- } catch(IOException e){ }
- }
-
- public static void saveCommand(){
- if (newObject) commands.add(result);
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("9 "+result);
- } catch(IOException e){ }
- }
-
- public void readLin(){
- try {
- linearization="";
- linearization += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- while (result.indexOf("/linearization")==-1){
- linearization += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- }
- if (newObject) formLin();
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- } catch(IOException e){ }
- }
-
- public static void readTree(){
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- while (result.indexOf("/tree")==-1){
- treeString += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- }
- if (treeChanged && (newObject)) {
- formTree(tree);
- treeChanged = false;
- }
- treeString="";
- result = fromProc.readLine();
- if (debug) System.out.println("6 "+result);
- } catch(IOException e){ }
- }
-
- public static void readMessage(){
- String s ="";
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- while (result.indexOf("/message")==-1){
- s += result+"\n";
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- }
- if ((s.length()>1)&&(s.indexOf("to start")==-1))
- output.append("-------------"+'\n'+s);
- result = fromProc.readLine();
- if (debug) System.out.println("7 "+result);
- } catch(IOException e){ }
- }
-
- public void formNewMenu () {
- boolean more = true;
- try {
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
-
- while (more){
- if (result.indexOf("language")==-1) {
- menu.addItem(result.substring(6));
- }
- else
- more = false;
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- if (result.indexOf("language")!=-1)
- more = false;
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
- }
-
- more = true;
- while (more){
- if ((result.indexOf("/gf")==-1)&&(result.indexOf("lin")==-1)) {
- //form lang and Menu menu:
- cbMenuItem = new JCheckBoxMenuItem(result.substring(4));
- System.out.println ("menu item: "+result.substring(4));
- if (!(result.substring(4).equals("Abstract")))
- cbMenuItem.setSelected(true);
- cbMenuItem.setActionCommand("lang");
- cbMenuItem.addActionListener(myListener);
- langMenu.add(cbMenuItem);
-/* if ((result.substring(4)).equals("Abstract"))
- {
- submenu.add(rbMenuItemAbs);
- if (selectedMenuLanguage.equals("Abstract"))
- rbMenuItemAbs.setSelected(true);
- languageGroup.add(rbMenuItemAbs);
- }
- else
- {
-*/
- rbMenuItem = new JRadioButtonMenuItem(result.substring(4));
- rbMenuItem.setActionCommand("language"+result.substring(4));
- rbMenuItem.addActionListener(myListener);
- languageGroup.add(rbMenuItem);
- if ((result.substring(4)).equals(selectedMenuLanguage))
- {
- if (debug) System.out.println("Selecting "+selectedMenuLanguage);
- rbMenuItem.setSelected(true);
- }
-
- submenu.add(rbMenuItem);
-// }
- }
- else
- more = false;
- // read
- result = fromProc.readLine();
- if (debug) System.out.println("2 "+result);
- // read or
- result = fromProc.readLine();
- if (debug) System.out.println("3 "+result);
- if ((result.indexOf("/gf")!=-1)||(result.indexOf("lin")!=-1))
- more = false;
- if (result.indexOf("/gf")!=-1)
- finished = true;
- // registering the file name:
- if (result.indexOf("language")!=-1) {
- String path = result.substring(result.indexOf('=')+1,
- result.indexOf('>'));
- path =path.substring(path.lastIndexOf('/')+1);
- if (debug) System.out.println("name: "+path);
- fileString +="--" + path +"\n";
- if (path.lastIndexOf('.')!=path.indexOf('.'))
- grammar.setText(path.substring(0,
- path.indexOf('.')).toUpperCase()+" ");
- }
- result = fromProc.readLine();
- if (debug) System.out.println("4 "+result);
- }
- if (debug) System.out.println("languageGroupElement formed"+
- languageGroup.getButtonCount());
- langMenu.addSeparator();
- fileMenuItem = new JMenuItem("Add...");
- fileMenuItem.setActionCommand("import");
- fileMenuItem.addActionListener(this);
- langMenu.add(fileMenuItem);
- // in order to get back in main in the beggining of while:
- result = fromProc.readLine();
- } catch(IOException e){ }
- }
-
- public void outputAppend(){
- int i, j, k, l, l2, m;
- i=result.indexOf("type=");
- j=result.indexOf('>',i);
- l = result.indexOf("
- result= result.substring(0,l)+result.substring(j+1);
- i=result.indexOf("/f",l);
- if (debug) System.out.println("/ is at the position"+i);
- j=result.indexOf('>',i);
- k=result.length()-j;
- if (debug) System.out.println("form Lin2: "+result);
- m = output.getText().length();
-
- //cutting
- // in case focus tag is cut into two lines:
- if (debug)
- System.out.println("char at the previous position"+result.charAt(i-1));
- if (result.charAt(i-1)!='<')
- result= result.substring(0,i-8)+result.substring(j+1);
- else
- result= result.substring(0,i-1)+result.substring(j+1);
- j= result.indexOf("');
- String s = result.substring(ind+1,ind2);
- result = lin.substring(0,lin.indexOf(""));
- lin = lin.substring(lin.indexOf(""));
- while (lin.length()>1) {
- //check if the language is on
- if (!visible) visible = true;
- // in the list?
- for (int i=0; i
- lin = lin.substring(lin.indexOf('\n')+1);
- // read lin or 'end'
- if (lin.length()<1) break;
-
- result = lin.substring(0,lin.indexOf('\n'));
- lin = lin.substring(lin.indexOf('\n')+1);
- if (result.indexOf("');
- s = result.substring(ind+1,ind2);
- result = lin.substring(0,lin.indexOf(""));
- lin = lin.substring(lin.indexOf(""));
- }
- }
- }
-
- public void showAction(){
- treeChanged = true;
- send("n Numeral");
- newObject = true;
- System.out.println("!!!!!!!sending newNumeral");
- treeChanged = true;
- send("p "+ input.getText());
- System.out.println("!!!!!!!sending parse string: "+input.getText());
- }
-
- public void actionPerformed(ActionEvent ae)
- {
- boolean abs = true;
- Object obj = ae.getSource();
-
- if ( obj == fontList ) {
- Font font = new Font((String)fontList.getSelectedItem(), Font.PLAIN, 13);
- output.setFont(font);
- }
-
- if ( obj == send ) {
- showAction();
- }
-
- if ( obj == menu ) {
- if (menu.getItemCount()>0)
- if (!menu.getSelectedItem().equals("New"))
- {
- treeChanged = true;
- send("n " + menu.getSelectedItem());
- newObject = true;
- menu.setSelectedIndex(0);
- }
- }
-
- if ( obj == filter ) {
- if (!filter.getSelectedItem().equals("Filter"))
- {
- send("f " + filter.getSelectedItem());
- filter.setSelectedIndex(0);
- }
- }
- if ( obj == modify ) {
- if (!modify.getSelectedItem().equals("Modify"))
- {
- treeChanged = true;
- send("c " + modify.getSelectedItem());
- modify.setSelectedIndex(0);
- }
- }
-/* if ( obj == mode ) {
- if (!mode.getSelectedItem().equals("Menus"))
- {
- send("o " + mode.getSelectedItem());
- mode.setSelectedIndex(0);
- }
- }
-*/
- // buttons and menu items:
- boolean objectInstance = false;
- try {
- objectInstance =
- Class.forName("javax.swing.AbstractButton").isInstance(obj);
- } catch (Exception e) {System.out.println("Class not found!");}
-
- if (objectInstance) {
- String name =((AbstractButton)obj).getActionCommand();
-
- if ( name.equals("quit")) {
- endProgram();
- }
-
- if ( name.equals("save") ) {
-
- if (fc1.getChoosableFileFilters().length<2)
- fc1.addChoosableFileFilter(new GrammarFilter());
- fc1.setFileFilter(fc1.getAcceptAllFileFilter());
- int returnVal = fc1.showSaveDialog(Numerals.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc1.getSelectedFile();
- if (debug) System.out.println("saving ... ");
-
- /* // checking if the abstract syntax is on:
- for (int i=0; i0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
- submenu.removeAll();
-
- File file = fc1.getSelectedFile();
- // opening the file for editing :
- if (debug) System.out.println("opening: "+ file.getPath().replace('\\','/'));
- if (group.getSelection().getActionCommand().equals("term")) {
- if (debug) System.out.println(" opening as a term ");
- send("open "+ file.getPath().replace('\\','/'));
- }
- else {
- if (debug) System.out.println(" opening as a linearization ");
- send("openstring "+ file.getPath().replace('\\','/'));
- }
-
- fileString ="";
- grammar.setText("No Topic ");
- }
- }
- }
-
- if ( name.equals("import") ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- fc.setFileFilter(fc.getAcceptAllFileFilter());
- int returnVal = fc.showOpenDialog(Numerals.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- // importing a new language :
- if (debug) System.out.println("importing: "+ file.getPath());
-
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- submenu.removeAll();
-
- menu.removeAllItems();
- menu.addItem("New");
- fileString ="";
- send("i "+ file.getPath().replace('\\','/'));
-
- }
- }
- if ( name.equals("newTopic") ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- fc.setFileFilter(fc.getAcceptAllFileFilter());
- int returnVal = fc.showOpenDialog(Numerals.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- int n = JOptionPane.showConfirmDialog(this,
- "This will dismiss the previous editing. Would you like to continue?",
- "Starting a new topic", JOptionPane.YES_NO_OPTION);
- if (n == JOptionPane.YES_OPTION){
- File file = fc.getSelectedFile();
- // importing a new grammar :
- newObject = false;
- statusLabel.setText(status);
- listModel.clear();
- tree.clear();
- populateTree(tree);
- System.out.println("tree populated!");
- menu.removeAllItems();
- System.out.println("removed all from menu!"+menu);
- menu.addItem("New");
- System.out.println("added new!");
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- selectedMenuLanguage = "Abstract";
- rbMenuItemLong.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
- submenu.removeAll();
-
- fileString="";
- grammar.setText("No Topic ");
- System.out.println("e "+ file.getPath().replace('\\','/'));
- //send("e \""+ file.getPath().replace('\\','/')+"\"");
- send("e "+ file.getPath().replace('\\','/'));
- }
- }
- }
-
- if ( obj == gfCommand ){
- String s = JOptionPane.showInputDialog("Command:", parseInput);
- if (s!=null) {
- parseInput = s;
- s = "gf "+s;
- //treeChanged = true;
- send(s);
- }
- }
-
- if ( name.equals("reset") ) {
- newObject = false;
- statusLabel.setText(status);
- listModel.clear();
- tree.clear();
- populateTree(tree);
- menu.removeAllItems();
- menu.addItem("New");
- langMenu.removeAll();
-
- AbstractButton ab = null;
-
- while (languageGroup.getButtonCount()>0)
- {
- for (Enumeration e = languageGroup.getElements();
- e.hasMoreElements() ;)
- {
- ab = (AbstractButton)e.nextElement();
- if (debug) System.out.println("more to remove ! "+ab.getText());
- languageGroup.remove(ab);
- }
- if (debug) System.out.println("languageGroupElement after import removal "+
- languageGroup.getButtonCount());
- }
-
- selectedMenuLanguage = "Abstract";
-
- submenu.removeAll();
- rbMenuItemLong.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
-
- fileString="";
- grammar.setText("No Topic ");
- send("e");
- }
-
- if ( obj == leftMeta ) {
- treeChanged = true;
- send("<<");
- }
- if ( obj == left ) {
- treeChanged = true;
- send("<");
- }
- if ( obj == top ) {
- treeChanged = true;
- send("'");
- }
- if ( obj == right ) {
- treeChanged = true;
- send(">");
- }
- if ( obj == rightMeta ) {
- treeChanged = true;
- send(">>");
- }
-
- if ( obj == cancel ) {
- dialog.hide();
- }
-
- if ( obj == browse ) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- fc.setFileFilter(fc.getAcceptAllFileFilter());
- int returnVal = fc.showOpenDialog(Numerals.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- inputField.setText(file.getPath().replace('\\','/'));
- }
- }
-
- if ( obj == ok ) {
- treeChanged = true;
- if (termReadButton.isSelected()) {
- termInput = inputField.getText();
- if (termInput.indexOf('/')==-1){
- send("g "+termInput);
- if (debug) System.out.println("sending term string");
- }
- else {
- send("tfile "+termInput);
- if (debug) System.out.println("sending file term: "+termInput);
- }
- }
- else {
- parseInput = inputField.getText();
- if (parseInput.indexOf('/')==-1){
- send("p "+parseInput);
- if (debug) System.out.println("sending parse string"+parseInput);
- }
- else {
- send("pfile "+parseInput);
- if (debug) System.out.println("sending file parse string: "+parseInput);
- }
- }
- dialog.hide();
- }
-
- if ( obj == read ) {
- if (stringReadButton.isSelected())
- inputField.setText(parseInput);
- else
- inputField.setText(termInput);
- dialog.show();
- }
-
-/* if ( obj == term ) {
- inputLabel.setText("Term:");
- inputField.setText(termInput);
- dialog.show();
- }
- if ( obj == parse ) {
- inputLabel.setText("Parse:");
- inputField.setText(parseInput);
- dialog.show();
- }
-*/
- if ( obj == alpha){
- String s = JOptionPane.showInputDialog("Type string:", alphaInput);
- if (s!=null) {
- alphaInput = s;
- treeChanged = true;
- send("x "+s);
- }
- }
- if ( obj == random){
- treeChanged = true;
- send("n Numeral");
- newObject = true;
- System.out.println("!!!!!!!sending newNumeral");
- treeChanged = true;
- send("a");
- }
- if ( obj == undo){
- treeChanged = true;
- send("u");
- }
- }
- //} catch (Exception e) { System.out.println("exception!!!"); }
- }
- static void writeOutput(String str, String fileName) {
-
- try {
- FileOutputStream fos = new FileOutputStream(fileName);
- Writer out = new OutputStreamWriter(fos, "UTF8");
- out.write(str);
- out.close();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null,
- "Document is empty!","Error", JOptionPane.ERROR_MESSAGE);
- }
- }
- public static void populateTree(DynamicTree treePanel) {
- String p1Name = new String("Root");
- DefaultMutableTreeNode p1;
- p1 = treePanel.addObject(null, p1Name);
- }
-
- public static void formTree(DynamicTree treePanel) {
- Hashtable table = new Hashtable();
- TreePath path=null;
- boolean treeStarted = false, selected = false;
- String s = treeString;
- String name ="";
- treePanel.clear();
- int j, shift=0, star=0, index = 0;
- DefaultMutableTreeNode p2=null, p1=null;
- if (debug) System.out.print("treeString: "+ s);
- if (s.indexOf('*')!=-1) star = 1;
- while (s.length()>0) {
- while ((s.length()>0) && ((s.charAt(0)=='*')||(s.charAt(0)==' '))){
- if (s.charAt(0) == '*') selected = true;
- s = s.substring(1);
- shift++;
- }
- if (s.length()>0) {
- j = s.indexOf("\n");
- name = s.substring(0, j);
- index++;
- s = s.substring(j+1);
- shift = (shift - star)/2;
-
- p1 = (DefaultMutableTreeNode)table.get(new Integer(shift));
- p2 = treePanel.addObject(p1, name);
- table.put(new Integer(shift+1), p2);
- path = new TreePath(p2.getPath());
- nodeTable.put(path, new Integer(index));
- if (selected) {
- treePanel.tree.setSelectionPath(path);
- treePanel.oldSelection = index;
- if (debug) System.out.println("new selected index "+ index);
- selected = false;
- }
- treeStarted=true;
- }
- shift = 0;
- }
- if ((p2!=null)) {
- treePanel.tree.makeVisible(path);
- gui2.toFront();
- index = 0;
- }
- }
-
- /** Listens to the radio buttons. */
- class RadioListener implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- String action = e.getActionCommand();
- if (action.equals("large") )
- {
- output.setFont(new Font((String)fontList.getSelectedItem(), Font.PLAIN, 26));
- }
- if (action.equals("medium") )
- {
- output.setFont(new Font((String)fontList.getSelectedItem(), Font.PLAIN, 17));
- }
- if (action.equals("small") )
- {
- output.setFont(new Font((String)fontList.getSelectedItem(), Font.PLAIN, 12));
- }
-
- if (action.equals("split") ) {
- cp.remove(centerPanel);
- centerPanel2.add(middlePanelUp, BorderLayout.SOUTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) {
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- else {
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- cp.add(centerPanel2, BorderLayout.CENTER);
- gui2.getContentPane().add(outputPanelDown);
- gui2.setVisible(true);
- pack();
- repaint();
- }
-
- if (action.equals("combine") ) {
- cp.remove(centerPanel2);
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { gui2.setVisible(false);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel.setLeftComponent(outputPanelUp);
- gui2.setVisible(false);
- }
- cp.add(centerPanel, BorderLayout.CENTER);
- centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
- pack();
- repaint();
- }
-
- if (action.equals("showTree") ) {
- if (!((JCheckBoxMenuItem)e.getSource()).isSelected()){
- if (debug) System.out.println("was selected");
- cbMenuItem.setSelected(false);
- if (((JRadioButtonMenuItem)viewMenu.getItem(2)).isSelected()) {
- centerPanel.remove(treePanel);
- centerPanel.setLeftComponent(outputPanelUp);
- }
- else {
- centerPanel2.remove(treePanel);
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- }
- else {
- if (debug) System.out.println("was not selected");
- cbMenuItem.setSelected(true);
- if (((JRadioButtonMenuItem)viewMenu.getItem(2)).isSelected()) {
- centerPanel.remove(outputPanelUp);
- treePanel.setRightComponent(outputPanelUp);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel2.remove(outputPanelUp);
- treePanel.setRightComponent(outputPanelUp);
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- }
- pack();
- repaint();
- }
-
- if (action.equals("lang")) {
- if (newObject) {
- output.setText("");
- formLin();
- }
- if (debug)
- System.out.println("language option has changed "+((JCheckBoxMenuItem)e.getSource()).getText());
- if (((JCheckBoxMenuItem)e.getSource()).isSelected()){
- if (debug) System.out.println("turning on");
- send("on "+((JCheckBoxMenuItem)e.getSource()).getText());
- }
- else{
- if (debug) System.out.println("turning off");
- send("off "+((JCheckBoxMenuItem)e.getSource()).getText());
- }
- }
-
- //modeMenus actions:
-
- if ((action.equals("long")) || (action.equals("short")))
- {
- send("ms " + action);
- }
-
- if ((action.equals("typed")) || (action.equals("untyped")))
- {
- send("mt " + action);
- }
- if (action.equals("languageAbstract"))
- {
- send("ml Abs");
- }
- else if (action.length()>7)
- if (action.substring(0,8).equals("language"))
- {
- selectedMenuLanguage = action.substring(8);
- if (debug) System.out.println("sending ml "+selectedMenuLanguage);
- send("ml " + selectedMenuLanguage);
- }
- }
- }
-
- /** Handle the key pressed event. */
- public void keyPressed(KeyEvent e) {
- int keyCode = e.getKeyCode();
- if (keyCode == 10) {
- //listAction(list.getSelectedIndex());
- showAction();
- }
- }
- /** Handle the key typed event. */
- public void keyTyped(KeyEvent e) {
- }
- /** Handle the key released event. */
- public void keyReleased(KeyEvent e) {
- }
-
- public void listAction(int index) {
- if (index == -1)
- {if (debug) System.out.println("no selection");}
- else {
- treeChanged = true;
- send((String)commands.elementAt(list.getSelectedIndex()));
- }
- }
-}
diff --git a/src/JavaGUI/Utils.java b/src/JavaGUI/Utils.java
deleted file mode 100644
index b10f54712..000000000
--- a/src/JavaGUI/Utils.java
+++ /dev/null
@@ -1,22 +0,0 @@
-
-import java.io.File;
-
-public class Utils {
-
- public final static String gf = "gf";
- public final static String gfcm = "gfcm";
-
- /*
- * Get the extension of a file.
- */
- public static String getExtension(File f) {
- String ext = null;
- String s = f.getName();
- int i = s.lastIndexOf('.');
-
- if (i > 0 && i < s.length() - 1) {
- ext = s.substring(i+1).toLowerCase();
- }
- return ext;
- }
-}
diff --git a/src/JavaGUI/manifest.txt b/src/JavaGUI/manifest.txt
deleted file mode 100644
index 006d8adfd..000000000
--- a/src/JavaGUI/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: GFEditor2
diff --git a/src/JavaGUI/runNumerals b/src/JavaGUI/runNumerals
deleted file mode 100644
index 3445220cc..000000000
--- a/src/JavaGUI/runNumerals
+++ /dev/null
@@ -1 +0,0 @@
-java -cp ./ Numerals "GF +java ../../grammars/numerals/old/numerals.Ita.gf ../../grammars/numerals/old/numerals.Mag.gf ../../grammars/numerals/old/numerals.Tam.gf ../../grammars/numerals/old/numerals.Suo.gf ../../grammars/numerals/old/numerals.NorB.gf ../../grammars/numerals/old/numerals.Slo.gf ../../grammars/numerals/old/numerals.Spa.gf ../../grammars/numerals/old/numerals.Swe.gf ../../grammars/numerals/old/numerals.Deu.gf ../../grammars/numerals/old/numerals.Fra.gf ../../grammars/numerals/old/numerals.Malay.gf ../../grammars/numerals/old/numerals.Ned.gf ../../grammars/numerals/old/numerals.Pol.gf ../../grammars/numerals/old/numerals.ChiU.gf ../../grammars/numerals/old/numerals.Dec.gf "
diff --git a/src/JavaGUI2/LICENCE_jargs b/src/JavaGUI2/LICENCE_jargs
deleted file mode 100644
index 509c1b7cb..000000000
--- a/src/JavaGUI2/LICENCE_jargs
+++ /dev/null
@@ -1,29 +0,0 @@
-Copyright (c) 2001-2003 Steve Purcell.
-Copyright (c) 2002 Vidar Holen.
-Copyright (c) 2002 Michal Ceresna.
-Copyright (c) 2005 Ewan Mellor.
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met: Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer. Redistributions in
-binary form must reproduce the above copyright notice, this list of
-conditions and the following disclaimer in the documentation and/or other
-materials provided with the distribution. Neither the name of the copyright
-holder nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/JavaGUI2/ManifestMain.txt b/src/JavaGUI2/ManifestMain.txt
deleted file mode 100644
index b398ff78d..000000000
--- a/src/JavaGUI2/ManifestMain.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: de.uka.ilkd.key.ocl.gf.GFEditor2
-Class-Path: log4j-1.2.8.jar jargs-1.0.jar
diff --git a/src/JavaGUI2/de/uka/ilkd/key/ocl/gf/AbstractProber.java b/src/JavaGUI2/de/uka/ilkd/key/ocl/gf/AbstractProber.java
deleted file mode 100644
index 0439ec6a4..000000000
--- a/src/JavaGUI2/de/uka/ilkd/key/ocl/gf/AbstractProber.java
+++ /dev/null
@@ -1,182 +0,0 @@
-//Copyright (c) Hans-Joachim Daniels 2005
-//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
-//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-//GNU General Public License for more details.
-//
-//You can either finde the file LICENSE or LICENSE.TXT in the source
-//distribution or in the .jar file of this application
-
-package de.uka.ilkd.key.ocl.gf;
-
-import java.io.IOException;
-import java.util.logging.*;
-
-/**
- * A class that offers a basic readGfEdit method with a lot of
- * hot spots where subclasses can plug in
- * @author daniels
- *
- */
-abstract class AbstractProber {
- /**
- * reference to the editor whose readRefinementMenu method is used
- */
- protected final GfCapsule gfCapsule;
- protected static Logger logger = Logger.getLogger(AbstractProber.class.getName());
-
- /**
- * A constructor which sets some fields
- * @param gfCapsule The encapsulation of GF
- */
- public AbstractProber(GfCapsule gfCapsule) {
- this.gfCapsule = gfCapsule;
- }
-
- /**
- * reads the hmsg part
- * @param readresult the first line
- * @return the first line of the next XML child.
- * if no hmsg is present @see readresult is returned.
- */
- protected String readHmsg(String readresult) {
- if (readresult.equals("")) {
- gfCapsule.skipChild("");
- try {
- String next = gfCapsule.fromProc.readLine();
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("2 " + next);
- }
- return next;
- } catch (IOException e) {
- System.err.println("Could not read from external process:\n" + e);
- return "";
- }
- } else {
- return readresult;
- }
- }
-
- /**
- * reads the linearization subtree.
- * The first line should be already read
- * @param readresult the first line with the opening tag
- */
- protected void readLinearizations(String readresult) {
- gfCapsule.skipChild("");
- }
-
- /**
- * Reads the tree child of the XML from beginning to end
- */
- protected void readTree() {
- gfCapsule.skipChild("");
- }
-
- /**
- * Reads the message child of the XML from beginning to end
- */
- protected void readMessage() {
- gfCapsule.skipChild("");
- }
-
- /**
- * Reads the menu child of the XML from beginning to end
- */
- protected void readMenu() {
- gfCapsule.skipChild(" tags
- * and build the corresponding tree.
- *
- * parses the already read XML for the tree and stores the tree nodes
- * in nodeTable with their numbers as keys
- *
- * Also does some tree analyzing, if other actions have to be taken.
- *
- * @param treeString the string representation for the XML tree
- * @return null, if no commands have to be executed afterwards.
- * If the result is non-null, then result.s should be sent to GF
- * afterwards, and no other form-method on this read-run is to be executed.
- * result.i is the amount of undo steps that this command needs.
- */
- private DefaultMutableTreeNode formTree(String treeString) {
- if (treeLogger.isLoggable(Level.FINER)) {
- treeLogger.finer("treeString: "+ treeString);
- }
-
- /**
- * stores the nodes and the indention of their children.
- * When all children of a node are read,
- * the next brethren / uncle node 'registers' with the same
- * indention depth to show that the next children are his.
- */
- Hashtable parentNodes = new Hashtable();
- String s = treeString;
- /** consecutive node numbering */
- int index = 0;
- /** the node that gets created from the current line */
- DefaultMutableTreeNode newChildNode=null;
- /** is a star somewhere in treestring? 1 if so, 0 otherwise */
- int star = 0;
- if (s.indexOf('*')!=-1) {
- star = 1;
- }
- DefaultMutableTreeNode topNode = null;
- while (s.length()>0) {
- /**
- * every two ' ' indicate one tree depth level
- * shift first gets assigned the indention depth in
- * characters, later the tree depth
- */
- int shift = 0;
- boolean selected = false;
- while ((s.length()>0) && ((s.charAt(0)=='*')||(s.charAt(0)==' '))){
- if (s.charAt(0) == '*') {
- selected = true;
- }
- s = s.substring(1);
- shift++;
- }
- if (s.length()>0) {
- /** to save the top node*/
- boolean isTop = false;
- int j = s.indexOf("\n");
- //is sth like "andS : Sent ", i.e. "fun : type " before trimming
- String gfline = s.substring(0, j).trim();
- GfAstNode node = new GfAstNode(gfline);
- // use indentation to calculate the parent
- index++;
- s = s.substring(j+1);
- shift = (shift - star)/2;
-
- /**
- * we know the parent, so we can ask it for the param information
- * for the next child (the parent knows how many it has already)
- * and save it in an AstNodeData
- */
- DefaultMutableTreeNode parent = (DefaultMutableTreeNode)parentNodes.get(new Integer(shift));
-
- /** compute the now child's position */
- String newPos;
- if ((parent != null) && (parent.getUserObject() instanceof AstNodeData) && parent.getUserObject() != null) {
- AstNodeData pand = (AstNodeData)parent.getUserObject();
- newPos = LinPosition.calculateChildPosition(pand.position, pand.childNum++);
- } else {
- //only the case for the root node
- newPos = "[]";
- isTop = true;
- }
-
- //default case, if we can get more information, this is overwritten
- AstNodeData and;
- Printname childPrintname = null;
- if (!node.isMeta()) {
- childPrintname = this.printnameManager.getPrintname(node.getFun());
- }
- Printname parentPrintname = null;
- AstNodeData parentAnd = null;
- String parentConstraint = "";
- if (parent != null) {
- parentAnd = (AstNodeData)parent.getUserObject();
- if (parentAnd != null) {
- parentConstraint = parentAnd.constraint;
- }
- }
- if (childPrintname != null) {
- //we know this one
- and = new RefinedAstNodeData(childPrintname, node, newPos, selected, parentConstraint);
- } else if (parent != null && node.isMeta()) {
- //new child without refinement
- if (parentAnd != null) {
- parentPrintname = parentAnd.getPrintname();
- }
- if (parentPrintname != null) {
- int paramPosition = parent.getChildCount();
- String paramName = parentPrintname.getParamName(paramPosition);
- if (paramName == null) {
- paramName = node.getFun();
- }
- //if tooltip turns out to be null that's OK
- String paramTooltip = parentPrintname.htmlifySingleParam(paramPosition);
-// if (logger.isLoggable(Level.FINER)) {
-// logger.finer("new node-parsing: '" + name + "', fun: '" + fun + "', type: '" + paramType + "'");
-// }
- and = new UnrefinedAstNodeData(paramTooltip, node, newPos, selected, parentConstraint);
-
- } else {
- and = new RefinedAstNodeData(null, node, newPos, selected, parentConstraint);
- }
- } else {
- //something unparsable, bad luck
- //or refined and not described
- and = new RefinedAstNodeData(null, node, newPos, selected, parentConstraint);
- }
-
- //add to the parent node
- newChildNode = new DefaultMutableTreeNode(and);
- if ((parent != null) && (newChildNode != null)) {
- parent.add(newChildNode);
- }
- parentNodes.put(new Integer(shift+1), newChildNode);
- if (isTop) {
- topNode = newChildNode;
- }
- }
- }
- //to be deferred to later step in readGfEdit
- return topNode;
- }
-
- /**
- * Shows the tree, scrolls to the selected node and updates the
- * mapping table between displayed node paths and AST positions.
- * @param myTreePanel the panel of GFEditor2
- * @param topNode The root node of the tree, that has the other nodes
- * already as its children
- */
- private void showTree(DynamicTree2 myTreePanel, DefaultMutableTreeNode topNode) {
- myTreePanel.clear();
- nodeTable.clear();
- //the rootNode is not shown, therefore, a dummy node plays this role
- final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
- rootNode.add(topNode);
- ((DefaultTreeModel)(myTreePanel.tree.getModel())).setRoot(rootNode);
- /**
- * the path in the JTree (not in GF repesentation!) to the
- * current new node.
- */
- TreePath path=null;
- TreePath selectionPath = null;
- // now fill nodeTable
- for (Enumeration e = rootNode.breadthFirstEnumeration() ; e.hasMoreElements() ;) {
- DefaultMutableTreeNode currNode = (DefaultMutableTreeNode)e.nextElement();
- AstNodeData and = (AstNodeData)currNode.getUserObject();
-
- path = new TreePath(currNode.getPath());
- if (and == null) {
- //only the case for the root node
- nodeTable.put(path, "[]");
- } else {
- nodeTable.put(path, and.position);
- if (and.selected) {
- selectionPath = path;
- if (treeLogger.isLoggable(Level.FINE)) {
- treeLogger.fine("new selectionPath: " + selectionPath);
- }
-
- DefaultMutableTreeNode parent = null;
- if (currNode.getParent() instanceof DefaultMutableTreeNode) {
- parent = (DefaultMutableTreeNode)currNode.getParent();
- }
- Printname parentPrintname = null;
- //display the current refinement description
- if ((parent != null)
- && (parent.getUserObject() != null)
- && (parent.getUserObject() instanceof AstNodeData)
- ) {
- AstNodeData parentAnd = (AstNodeData)parent.getUserObject();
- parentPrintname = parentAnd.getPrintname();
- }
- // set the description of the current parameter to a more
- // prominent place
- String paramName = null;
- int paramPosition = -1;
- if (parentPrintname != null) {
- paramPosition = parent.getIndex(currNode);
- paramName = parentPrintname.getParamName(paramPosition);
- }
- if (paramName == null) {
- subtermNameLabel.setText(actionOnSubtermString);
- subtermDescLabel.setText("");
- } else {
- subtermNameLabel.setText("" + paramName + ": ");
- String paramDesc = parentPrintname.getParamDescription(paramPosition);
- if (paramDesc == null) {
- subtermDescLabel.setText("");
- } else {
- subtermDescLabel.setText("" + paramDesc + "");
- }
- }
- statusLabel.setText(and.node.getType());
- }
- }
- }
- //also set the old selectionPath since we know that we do know,
- //that the selectionChanged event is bogus.
- myTreePanel.oldSelection = selectionPath;
- myTreePanel.tree.setSelectionPath(selectionPath);
- myTreePanel.tree.scrollPathToVisible(selectionPath);
- //show the selected as the 'selected' one in the JTree
- myTreePanel.tree.makeVisible(selectionPath);
- gui2.toFront();
- }
-
-
- /**
- * Removes anything but the "new" from the new category menu
- */
- private void resetNewCategoryMenu() {
- //remove everything except "New"
- while (1< newCategoryMenu.getItemCount())
- newCategoryMenu.removeItemAt(1);
- }
-
-
- /**
- * Pops up a window for input of the wanted data and asks ic
- * afterwards, if the data has the right format.
- * Then gives that to GF.
- * TODO Is called from RefinementMenu, but uses display. Where to put?
- * @param ic the InputCommand that specifies the wanted format/type
- */
- protected void executeInputCommand(InputCommand ic) {
- String s = (String)JOptionPane.showInputDialog(
- this,
- ic.getTitleText(),
- ic.getTitleText(),
- JOptionPane.QUESTION_MESSAGE,
- null,
- null,
- "");
- StringBuffer reason = new StringBuffer();
- Object value = ic.validate(s, reason);
- if (value != null) {
- send("[t] g "+value);
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("sending string " + value);
- }
- } else {
- this.display.addToStages("\n" + reason.toString(), "" + reason.toString() + "
");
- display(true, false, false);
- }
- }
-
-
-
- /**
- * Handles the showing of the popup menu and the parse field
- * @param e the MouseEvent, that caused the call of this function
- */
- protected void maybeShowPopup(MouseEvent e) {
- //int i=outputVector.size()-1;
- // right click:
- if (e.isPopupTrigger()) {
- if (popUpLogger.isLoggable(Level.FINER)) {
- popUpLogger.finer("changing pop-up menu2!");
- }
- JPopupMenu popup2 = refinementMenu.producePopup();
- popup2.show(e.getComponent(), e.getX(), e.getY());
- }
- // middle click
- if (e.getButton() == MouseEvent.BUTTON2) {
- // selection Exists:
- if (popUpLogger.isLoggable(Level.FINER)) {
- popUpLogger.finer(e.getX() + " " + e.getY());
- }
- String selectedText;
-
- if (currentNode.isMeta()) {
- // we do not want the ?3 to be in parseField, that disturbs
- selectedText = "";
- } else {
- final String language;
- //put together the currently focused text
- if (e.getComponent() instanceof JTextComponent) {
- JTextComponent jtc = (JTextComponent)e.getComponent();
- int pos = jtc.viewToModel(e.getPoint());
- final boolean htmlClicked = (jtc instanceof JTextPane);
- language = linearization.getLanguageForPos(pos, htmlClicked);
- } else {
- language = "Abstract";
- }
- selectedText = linearization.getSelectedLinearization(language, focusPosition);
-
- }
- //compute the size of parseField
- if (selectedText.length()<5)
-// if (treeCbMenuItem.isSelected())
-// parseField.setBounds(e.getX()+(int)Math.round(tree.getBounds().getWidth()), e.getY()+80, 400, 40);
-// else
- parseField.setBounds(e.getX(), e.getY()+80, 400, 40);
- else
-// if (treeCbMenuItem.isSelected())
-// parseField.setBounds(e.getX()+(int)Math.round(tree.getBounds().getWidth()), e.getY()+80, selectedText.length()*20, 40);
-// else
- parseField.setBounds(e.getX(), e.getY()+80, selectedText.length()*20, 40);
- getLayeredPane().add(parseField, new Integer(1), 0);
- parseField.setText(selectedText);
- parseField.requestFocusInWindow();
- }
- }
-
- /**
- * Adds toHmsg to the [hmsg] part of command, if that is present.
- * If not, prepends toHmsg in square brackets to command
- * @param command The command for GF
- * @param toHmsg the text, that should occur inside [] before the command
- * @return the updated command (s.a.)
- */
- private static String addToHmsg(String command, String toHmsg) {
- command = command.trim();
- if (command.startsWith("[")) {
- command = "[" + toHmsg + command.substring(1);
- } else {
- command = "[" + toHmsg + "] " + command;
- }
- return command;
- }
-
- /**
- * pop-up menu (adapted from DynamicTree2):
- * @author janna
- */
- class PopupListener extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
- // int selStart = tree.getRowForLocation(e.getX(), e.getY());
- // output.setSelectionRow(selStart);
- if (popUpLogger.isLoggable(Level.FINER)) {
- popUpLogger.finer("mouse pressed2: "+linearizationArea.getSelectionStart()+" "+linearizationArea.getSelectionEnd());
- }
- maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- //nothing to be done here
- }
- }
-
- /**
- * Encapsulates the opening of terms or linearizations to a file.
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class OpenAction extends AbstractAction {
- public OpenAction() {
- super("Open Text", null);
- putValue(SHORT_DESCRIPTION, "Opens abstract syntax trees or linearizations for the current grammar");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_O));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- if (saveFc.getChoosableFileFilters().length<2)
- saveFc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = saveFc.showOpenDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- resetNewCategoryMenu();
- langMenuModel.resetLanguages();
-
- File file = saveFc.getSelectedFile();
- // opening the file for editing :
- if (logger.isLoggable(Level.FINER)) logger.finer("opening: "+ file.getPath().replace('\\', File.separatorChar));
- if (saveTypeGroup.getSelection().getActionCommand().equals("term")) {
- if (logger.isLoggable(Level.FINER)) logger.finer(" opening as a term ");
- send("[nt] open "+ file.getPath().replace('\\', File.separatorChar));
- }
- else {
- if (logger.isLoggable(Level.FINER)) logger.finer(" opening as a linearization ");
- send("[nt] openstring "+ file.getPath().replace('\\', File.separatorChar));
- }
-
- fileString ="";
- grammar.setText("No Topic ");
- }
- }
- }
-
- /**
- * Encapsulates the saving of terms or linearizations to a file.
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class SaveAction extends AbstractAction {
- public SaveAction() {
- super("Save As", null);
- putValue(SHORT_DESCRIPTION, "Saves either the current linearizations or the AST");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- if (saveFc.getChoosableFileFilters().length<2)
- saveFc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = saveFc.showSaveDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = saveFc.getSelectedFile();
- if (logger.isLoggable(Level.FINER)) logger.finer("saving as " + file);
- final String abstractLin = linearization.getLinearizations().get("Abstract").toString();
-
- if (saveTypeGroup.getSelection().getActionCommand().equals("term")) {
- // saving as a term
- writeOutput(removeMetavariableNumbers(abstractLin), file.getPath());
- } else {
- // saving as a linearization:
- /** collects the show linearizations */
- StringBuffer text = new StringBuffer();
- /** if sth. at all is shown already*/
- boolean sthAtAll = false;
- for (Iterator it = linearization.getLinearizations().keySet().iterator(); it.hasNext();) {
- Object key = it.next();
- if (!key.equals("Abstract")) {
- if (sthAtAll) {
- text.append("\n\n");
- }
- text.append(linearization.getLinearizations().get(key));
- sthAtAll = true;
- }
- }
- if (sthAtAll) {
- writeOutput(text.toString(), file.getPath());
- if (logger.isLoggable(Level.FINER)) logger.finer(file + " saved.");
- } else {
- if (logger.isLoggable(Level.FINER)) logger.warning("no concrete language shown, saving abstract");
- writeOutput(removeMetavariableNumbers(abstractLin), file.getPath());
- if (logger.isLoggable(Level.FINER)) logger.finer(file + " saved.");
- }
- }
- }
-
- }
- }
-
- /**
- * Encapsulates adding new languages for the current abstract grammar.
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class ImportAction extends AbstractAction {
- public ImportAction() {
- super("Add", null);
- putValue(SHORT_DESCRIPTION, "add another concrete language for the current abstract grammar");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_A));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- //add another language (Add...)
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
-
- resetNewCategoryMenu();
- langMenuModel.resetLanguages();
- // importing a new language :
- if (logger.isLoggable(Level.FINER)) logger.finer("importing: "+ file.getPath().replace('\\','/'));
- fileString ="";
- //TODO does that load paths in UNIX-notation under windows?
- send("i "+ file.getPath().replace('\\',File.separatorChar), false, 1);
- processGfinit();
- processGfedit();
- }
- }
-
- }
-
- /**
- * Encapsulates starting over with a new grammar.
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class NewTopicAction extends AbstractAction {
- public NewTopicAction() {
- super("New Grammar", null);
- putValue(SHORT_DESCRIPTION, "dismiss current editing and load a new grammar");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_N));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- if (fc.getChoosableFileFilters().length<2)
- fc.addChoosableFileFilter(new GrammarFilter());
- int returnVal = fc.showOpenDialog(GFEditor2.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- int n = JOptionPane.showConfirmDialog(GFEditor2.this,
- "This will dismiss the previous editing. Would you like to continue?",
- "Starting a new topic", JOptionPane.YES_NO_OPTION);
- if (n == JOptionPane.YES_OPTION){
- File file = fc.getSelectedFile();
- // importing a new grammar :
- newObject = false;
- statusLabel.setText(status);
- subtermDescLabel.setText("");
- subtermNameLabel.setText("");
- refinementMenu.reset();
- tree.resetTree();
- resetNewCategoryMenu();
- langMenuModel.resetLanguages();
- selectedMenuLanguage = "Abstract";
- rbMenuItemShort.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
- typedMenuItems = false;
-
- fileString="";
- grammar.setText("No Topic ");
- display.resetLin();
- display(true, true, false);
- undoStack.clear();
- send(" e "+ file.getPath().replace('\\',File.separatorChar), false, 1);
- processInit(null, false);
- processGfedit();
- resetPrintnames(true);
- }
- }
- }
-
- }
-
- /**
- * Encapsulates starting over without loading new grammars
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class ResetAction extends AbstractAction {
- public ResetAction() {
- super("Reset", null);
- putValue(SHORT_DESCRIPTION, "discard everything including the loaded grammars");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_R));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- newObject = false;
- statusLabel.setText(status);
- subtermDescLabel.setText("");
- subtermNameLabel.setText("");
- refinementMenu.reset();
- tree.resetTree();
- langMenuModel.resetLanguages();
- resetNewCategoryMenu();
- selectedMenuLanguage = "Abstract";
-
- rbMenuItemShort.setSelected(true);
- rbMenuItemUnTyped.setSelected(true);
- typedMenuItems = false;
-
- fileString="";
- grammar.setText("No Topic ");
- undoStack.clear();
- send("e", false, 1);
- processGfinit();
- }
-
- }
-
- /**
- * Encapsulates exiting the program
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class QuitAction extends AbstractAction {
- public QuitAction() {
- super("Quit", null);
- putValue(SHORT_DESCRIPTION, "exit the editor");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_Q));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- endProgram();
- }
-
- }
-
- /**
- * Encapsulates the random command for GF
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class RandomAction extends AbstractAction {
- public RandomAction() {
- super("Random", null);
- putValue(SHORT_DESCRIPTION, "build a random AST from the current cursor position");
- //putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_M));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- send("[t] a");
- }
-
- }
-
- /**
- * Encapsulates the undo command for GF
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class UndoAction extends AbstractAction {
- public UndoAction() {
- super("Undo", null);
- putValue(SHORT_DESCRIPTION, "undo the last command");
- //putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_U));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- int undoSteps = 1;
- if (!undoStack.empty()) {
- undoSteps = ((Integer)undoStack.pop()).intValue();
- }
- send("[t] u " + undoSteps, true, 0);
- }
- }
-
- /**
- * Encapsulates alpha command for GF
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class AlphaAction extends AbstractAction {
- public AlphaAction() {
- super("Alpha", null);
- putValue(SHORT_DESCRIPTION, "Performing alpha-conversion, rename bound variables");
- //putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- String s = JOptionPane.showInputDialog("Type string:", alphaInput);
- if (s!=null) {
- alphaInput = s;
- send("[t] x "+s);
- }
- }
-
- }
-
- /**
- * Encapsulates the input dialog and sending of arbitrary commands to GF
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class GfCommandAction extends AbstractAction {
- public GfCommandAction() {
- super("GF command", null);
- putValue(SHORT_DESCRIPTION, "send a command to GF");
- //putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_G));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- String s = JOptionPane.showInputDialog("Command:", commandInput);
- if (s!=null) {
- commandInput = s;
- s = addToHmsg(s, "t");
- if (logger.isLoggable(Level.FINER)) logger.finer("sending: "+ s);
- send(s);
- }
- }
- }
-
- /**
- * Encapsulates the showing of the read dialog
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class ReadAction extends AbstractAction {
- public ReadAction() {
- super("Read", null);
- putValue(SHORT_DESCRIPTION, "Refining with term or linearization from typed string or file");
- //putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- readDialog.show();
- }
-
- }
-
- /**
- * Encapsulates the splitting of the main window
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class SplitAction extends AbstractAction {
- public SplitAction() {
- super("Split Windows", null);
- putValue(SHORT_DESCRIPTION, "Splits the refinement menu into its own window");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_L));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- coverPanel.remove(centerPanel);
- centerPanel2.add(middlePanelUp, BorderLayout.SOUTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) {
- centerPanel2.add(treePanel, BorderLayout.CENTER);
- }
- else {
- centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
- }
- coverPanel.add(centerPanel2, BorderLayout.CENTER);
- gui2.getContentPane().add(refinementMenu.getRefinementListsContainer());
- gui2.setVisible(true);
- pack();
- repaint();
- }
-
- }
-
- /**
- * Encapsulates the combining of the main window
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class CombineAction extends AbstractAction {
- public CombineAction() {
- super("One Window", null);
- putValue(SHORT_DESCRIPTION, "Refinement menu and linearization areas in one window");
- putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_W));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- coverPanel.remove(centerPanel2);
- middlePanel.add(middlePanelUp, BorderLayout.NORTH);
- if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { gui2.setVisible(false);
- centerPanel.setLeftComponent(treePanel);
- }
- else {
- centerPanel.setLeftComponent(outputPanelUp);
- gui2.setVisible(false);
- }
- coverPanel.add(centerPanel, BorderLayout.CENTER);
- centerPanelDown.add(refinementMenu.getRefinementListsContainer(), BorderLayout.CENTER);
- //centerPanelDown.add(refinementMenu.refinementSubcatPanel, BorderLayout.EAST);
- pack();
- repaint();
- }
-
- }
-
- /**
- * Starts a run on the AST to hunt down open subtyping witnesses
- * Is not local in initializeGUI because jswat cannot have active breakpoints in such a class, whyever.
- * @author daniels
- */
- class SubtypeAction extends AbstractAction {
- public SubtypeAction() {
- super("Close Subtypes", null);
- putValue(SHORT_DESCRIPTION, "try to automatically refine Subtype relations");
- //putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_U));
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
- }
-
- public void actionPerformed(ActionEvent e) {
- String resetCommand;
- int usteps ;
- if (focusPosition != null) {
- //go back to where we come from
- resetCommand = "[t] mp " + focusPosition.position;
- usteps = 1;
- } else {
- resetCommand = "[t] gf";
- usteps = 0;
- }
- SubtypingProber sp = new SubtypingProber(gfCapsule);
- int undos = sp.checkSubtyping();
- send(resetCommand , true, undos + usteps);
- }
- }
-
-
-
- /**
- * Takes care, which classes are present and which states they have.
- * @author daniels
- */
- class LangMenuModel implements LanguageManager{
- Logger menuLogger = Logger.getLogger("de.uka.ilkd.key.ocl.gf.GFEditor2.MenuModel");
- /**
- * Just a mutable tuple of language name and whether this language
- * is displayed or not.
- */
- class LangActiveTuple {
- String lang;
- boolean active;
- public LangActiveTuple(String lang, boolean active) {
- this.lang = lang;
- this.active = active;
- }
- public String toString() {
- return lang + " : " + active;
- }
- }
-
- private Vector languages = new Vector();
- /** the group containing RadioButtons for the language the menus
- * should have
- */
- private ButtonGroup languageGroup = new ButtonGroup();
-
- void updateMenus() {
- for (Iterator it = this.languages.iterator(); it.hasNext(); ) {
- LangActiveTuple lat = (LangActiveTuple)it.next();
- boolean alreadyPresent = false;
- // language already in the list of available languages?
- for (int i=0; i -1) {
- this.constraint = typeString.substring(constraintIndex + 1).trim();
- this.type = typeString.substring(0, constraintIndex).trim();
- } else {
- this.constraint = "";
- this.type = typeString;
- }
- String myFun = this.line.substring(0, index);
- if (myFun.startsWith("\\(")) {
- final int end = myFun.lastIndexOf(") -> ");
- String boundPart = myFun.substring(2, end);
- String[] bounds = boundPart.split("\\)\\s*\\,\\s*\\(");
- this.boundNames = new String[bounds.length];
- this.boundTypes = new String[bounds.length];
- for (int i = 0; i < bounds.length;i++) {
- //System.out.print("+" + bounds[i] + "-");
- int colon = bounds[i].indexOf(" : ");
- this.boundNames[i] = bounds[i].substring(0, colon);
- this.boundTypes[i] = bounds[i].substring(colon + 3);
- //System.out.println(boundNames[i] + " ;; " + boundTypes[i]);
- }
- myFun = myFun.substring(end + 5);
- } else {
- this.boundNames = new String[0];
- this.boundTypes = new String[0];
- }
- this.fun = myFun;
- }
-
- public String toString() {
- return this.line;
- }
-}
diff --git a/src/JavaGUI2/de/uka/ilkd/key/ocl/gf/GfCapsule.java b/src/JavaGUI2/de/uka/ilkd/key/ocl/gf/GfCapsule.java
deleted file mode 100644
index c1d012a02..000000000
--- a/src/JavaGUI2/de/uka/ilkd/key/ocl/gf/GfCapsule.java
+++ /dev/null
@@ -1,621 +0,0 @@
-//Copyright (c) Janna Khegai 2004, Hans-Joachim Daniels 2005
-//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
-//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-//GNU General Public License for more details.
-//
-//You can either finde the file LICENSE or LICENSE.TXT in the source
-//distribution or in the .jar file of this application
-
-package de.uka.ilkd.key.ocl.gf;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.util.Vector;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.ProgressMonitor;
-
-class GfCapsule {
- /**
- * XML parsing debug messages
- */
- private static Logger xmlLogger = Logger.getLogger(GfCapsule.class.getName() + ".xml");
- /**
- * generic logging of this class
- */
- private static Logger logger = Logger.getLogger(GfCapsule.class.getName());
- /**
- * The output from GF is in here.
- * Only the read methods, initializeGF and the prober objects access this.
- */
- BufferedReader fromProc;
- /**
- * Used to leave messages for GF here.
- * But only in send and special probers that clean up with undo
- * after them (or don't change the state like PrintnameLoader).
- */
- BufferedWriter toProc;
-
- /**
- * Starts GF with the given command gfcmd in another process.
- * Sets up the reader and writer to that process.
- * Does in it self not read anything from GF.
- * @param gfcmd The complete command to start GF, including 'gf' itself.
- */
- public GfCapsule(String gfcmd){
- try {
- Process extProc = Runtime.getRuntime().exec(gfcmd);
- InputStreamReader isr = new InputStreamReader(
- extProc.getInputStream(),"UTF8");
- this.fromProc = new BufferedReader (isr);
- String defaultEncoding = isr.getEncoding();
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("encoding "+defaultEncoding);
- }
- this.toProc = new BufferedWriter(new OutputStreamWriter(extProc.getOutputStream(),"UTF8"));
- } catch (IOException e) {
- JOptionPane.showMessageDialog(new JFrame(), "Could not start " + gfcmd+
- "\nCheck your $PATH", "Error",
- JOptionPane.ERROR_MESSAGE);
- throw new RuntimeException("Could not start " + gfcmd+
- "\nCheck your $PATH");
- }
- }
-
-
- /**
- * Does the actual writing of command to the GF process via STDIN
- * @param command exactly the string that is going to be sent
- */
- protected void realSend(String command) {
- try {
- toProc.write(command, 0, command.length());
- toProc.newLine();
- toProc.flush();
- } catch (IOException e) {
- System.err.println("Could not write to external process " + e);
- }
-
- }
-
- /**
- * reads the part between >gfinit< and >/gfinit<
- * @return the data for the new category menu
- */
- protected NewCategoryMenuResult readGfinit() {
- try {
- //read or or (in case of no grammar loaded)
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("12 "+readresult);
- //when old grammars are loaded, the first line looks like
- //"reading grammar of old format letter.Abs.gfreading old file letter.Abs.gf"
- if (readresult.indexOf("") > -1) {
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("12 "+readresult);
- }
- //no command appendix expected or applicable here, so appendix is discarded
- Hmsg hmsg = readHmsg(readresult);
- String next = hmsg.lastline;
- //no hmsg supported here. Wouldn't be applicable.
- //the reading above is to silently ignore it intead of failing.
- //formHmsg(hmsg);
-
- if ((next!=null) && ((next.indexOf("newcat") > -1)
- || (next.indexOf("topic") > -1))) {
- NewCategoryMenuResult ncmr = readNewMenu();
- return ncmr;
- }
-
- } catch (IOException e) {
- System.err.println("Could not read from external process:\n" + e);
- }
- return null;
- }
-
- /**
- * reads the greeting text from GF
- * @return S tuple with first = the last read GF line,
- * which should be the first loading line
- * and second = The greetings string
- */
- protected StringTuple readGfGreetings() {
- try {
- String readresult = "";
- StringBuffer outputStringBuffer = new StringBuffer();
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("1 "+readresult);
- while ((readresult.indexOf("gf")==-1) && (readresult.trim().indexOf("<") < 0)){
- outputStringBuffer.append(readresult).append("\n");
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("1 "+readresult);
- }
- return new StringTuple(readresult, outputStringBuffer.toString());
- } catch (IOException e) {
- System.err.println("Could not read from external process:\n" + e);
- return new StringTuple("", e.getLocalizedMessage());
- }
-
- }
-
- /**
- * reads the loading and compiling messages from GF
- * @param readresult the first loading line
- * @param pm to monitor the loading progress. May be null
- * @return A tuple with first = the first line from >gfinit< or >gfedit<
- * and second = the loading message as pure text
- */
- protected StringTuple readGfLoading(String readresult, ProgressMonitor pm) {
- try {
- // in case nothing has been loaded first, the that has to be done now
- if (readresult == null) {
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("1 " + readresult);
- }
- StringBuffer textPure = new StringBuffer();
- int progress = 5300;
- while (!(readresult.indexOf("") > -1 || (readresult.indexOf("") > -1))){
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("1 "+readresult);
- textPure.append(readresult).append("\n");
- progress += 12;
- Utils.tickProgress(pm, progress, null);
- }
- //when old grammars are loaded, the first line looks like
- //"reading grammar of old format letter.Abs.gfreading old file letter.Abs.gf"
- //without newlines
- final int beginInit = readresult.indexOf("");
- if (beginInit > 0) {
- textPure.append(readresult.substring(0, beginInit)).append("\n");
- //that is the expected result
- readresult = "";
- }
- return new StringTuple(readresult, textPure.toString());
- } catch (IOException e) {
- System.err.println("Could not read from external process:\n" + e);
- return new StringTuple("", e.getLocalizedMessage());
- }
-
- }
-
-
- /**
- * Reads the <gfedit> part from GF's XML output.
- * The different subtags are put into the result
- * @param newObj If a new object in the editor has been started.
- * If the to-be-read hmsg contains the newObject flag,
- * that overwrites this parameter
- * @return the read tags, partially halfy parsed, partially raw.
- * The way the different form methods expect it.
- */
- protected GfeditResult readGfedit(boolean newObj) {
- try {
- String next = "";
- //read
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("11 "+readresult);
- //read either or
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("11 "+readresult);
-
- //hmsg stuff
- final Hmsg hmsg = readHmsg(readresult);
- next = hmsg.lastline;
-
- //reading
- //seems to be the only line read here
- //this is here to give as some sort of catch clause.
- while ((next!=null)&&((next.length()==0)||(next.indexOf("")==-1))) {
- next = fromProc.readLine();
- if (next!=null){
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("10 "+next);
- } else {
- System.exit(0);
- }
- }
- readresult = next;
- String lin = readLin();
- final String treeString = readTree();
- final String message = readMessage();
- //read the menu stuff
- Vector gfCommandVector;
- if (newObj || hmsg.newObject) {
- gfCommandVector = readRefinementMenu();
- } else {
- while(readresult.indexOf(""
- for (int i = 0; i < 3 && !readresult.equals(""); i++){
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("11 " + readresult);
- }
- //all well, return the read stuff
- return new GfeditResult(gfCommandVector, hmsg, lin, message, treeString);
-
- } catch (IOException e) {
- System.err.println("Could not read from external process:\n" + e);
- }
- //nothing well, return bogus stuff
- return new GfeditResult(new Vector(), new Hmsg("", "", false, false, false, false, true), "", "", "");
-
- }
-
- /**
- * reads the linearizations in all language.
- * seems to expect the first line of the XML structure
- * (< lin) already to be read
- * Accumulates the GF-output between tags
- */
- protected String readLin(){
- StringBuffer lins = new StringBuffer();
- try {
- //read
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("7 " + readresult);
- lins.append(readresult).append('\n');
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("6 " + readresult);
- while ((readresult != null) && (readresult.indexOf("/linearization") == -1)){
- lins.append(readresult).append('\n');
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("6 " + readresult);
- }
- } catch(IOException e){
- System.err.println(e.getMessage());
- e.printStackTrace();
- }
- return lins.toString();
- }
-
- /**
- * reads in the tree and calls formTree without start end end tag of tree
- * expects the first starting XML tag tree to be already read
- * @return the read tags for the tree or null if a read error occurs
- */
- protected String readTree(){
- String treeString = "";
- try {
- //read
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("6 " + readresult);
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("6 " + readresult);
- while (readresult.indexOf("/tree") == -1){
- treeString += readresult + "\n";
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("6 " + readresult);
- }
- return treeString;
- } catch(IOException e){
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Parses the GF-output between tags
- * and returns it.
- * @return The read message.
- */
- protected String readMessage(){
- String s ="";
- try {
- // read
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("6 " + readresult);
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("7 " + readresult);
- while (readresult.indexOf("/message") == -1){
- s += readresult + "\n";
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("7 " + readresult);
- }
- return s;
- } catch(IOException e){
- System.err.println(e.getLocalizedMessage());
- e.printStackTrace();
- return e.getLocalizedMessage();
- }
- }
-
- /**
- * reads the cat entries and puts them into result.menuContent,
- * after that reads
- * the names of the languages and puts them into the result.languages
- * The loaded grammar files are put into result.paths,
- * a guessed grammar name into result.grammarName
- * Parses the GF-output between tags
- */
- protected NewCategoryMenuResult readNewMenu () {
- //here the read stuff is sorted into
- String grammarName = "";
- final Vector languages = new Vector();
- final Vector menuContent = new Vector();
- final Vector paths = new Vector();
-
- boolean more = true;
- try {
- //read first cat
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) {
- xmlLogger.finer("2 " + readresult);
- }
- if (readresult.indexOf("(none)") > -1) {
- //no topics present
- more = false;
- }
-
- while (more){
- //adds new cat s to the menu
- if (readresult.indexOf("topic") == -1) {
- final String toAdd = readresult.substring(6);
- menuContent.add(toAdd);
- } else {
- more = false;
- }
- //read
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("2 " + readresult);
- //read
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("3 " + readresult);
- //read actual language
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("4 " + readresult);
-
- //read the languages and select the last non-abstract
- more = true;
- while (more){
- if ((readresult.indexOf("/gfinit") == -1)
- && (readresult.indexOf("lin") == -1)) {
- //form lang and Menu menu:
- final String langName = readresult.substring(4);
- languages.add(langName);
- } else {
- more = false;
- }
- // read
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("2 " + readresult);
- // read or
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("3 " + readresult);
- if ((readresult.indexOf("/gfinit") != -1)
- || (readresult.indexOf("lin") != -1)) {
- more = false;
- }
- // registering the file name:
- if (readresult.indexOf("language") != -1) {
- String path = readresult.substring(readresult.indexOf('=') + 1,
- readresult.indexOf('>'));
- path = path.substring(path.lastIndexOf(File.separatorChar) + 1);
- if (xmlLogger.isLoggable(Level.FINE)) xmlLogger.fine("language: " + path);
- paths.add(path);
- }
- // in case of finished, read the final "" after ,
- // otherwise the name of the next language
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("4 " + readresult);
- }
- } catch(IOException e){
- xmlLogger.warning(e.getMessage());
- }
- String[] menuContentArray = Utils.vector2Array(menuContent);
- String[] languagesArray = Utils.vector2Array(languages);
- String[] pathsArray = Utils.vector2Array(paths);
- NewCategoryMenuResult result = new NewCategoryMenuResult(grammarName, menuContentArray, languagesArray, pathsArray);
- return result;
- }
-
- /**
- * Reads the hmsg part of the XML that is put out from GF.
- * Everything in [] given in front of a GF command will be rewritten here.
- * This method does nothing when no hmsg part is present.
- *
- * If a '$' appears in this string, everything that comes after it
- * will be in result.second.
- * ;; and [] don't work in the [] for the hmsg,
- * therfore the following replacements are done:
- * %% for ;;
- * ( for [
- * ) for ]
- *
- * If one of the characters c,t,n comes before, the following is done:
- * c The output will be cleared before the linearization (TODO: done anyway?)
- * t The treeChanged flag will be set to true
- * n The newObject flag will be set to true
- * p No other probing run should be done (avoid cycles)
- * r To prevent the execution of automatically triggered commands to prevent recursion
- *
- * @param prevreadresult The last line read from GF
- * @return first: the last line this method has read;
- * second: the string after $, null if that is not present
- */
- protected Hmsg readHmsg(String prevreadresult){
- if ((prevreadresult!=null)&&(prevreadresult.indexOf("") > -1)) {
- StringBuffer s =new StringBuffer("");
- String commandAppendix = null;
- try {
- boolean onceAgain = true;
- boolean recurse = true;
- boolean newObj = false;
- boolean treeCh = false;
- boolean clear = false;
- String readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("7 "+readresult);
- while (readresult.indexOf("/hmsg")==-1){
- s.append(readresult).append('\n');
- readresult = fromProc.readLine();
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("7 "+readresult);
- }
- int commandAppendixStart = s.indexOf("$");
- if (commandAppendixStart > -1 && commandAppendixStart < s.length() - 1) { //present, but not the last character
- commandAppendix = s.substring(commandAppendixStart + 1, s.indexOf("\n")); //two \n trail the hmsg
- //;; and [] don't work in the [] for the hmsg
- commandAppendix = Utils.replaceAll(commandAppendix, "%%", ";;");
- commandAppendix = Utils.replaceAll(commandAppendix, "(", "[");
- commandAppendix = Utils.replaceAll(commandAppendix, ")", "]");
- } else {
- commandAppendixStart = s.length();
- }
- if (s.indexOf("c") > -1 && s.indexOf("c") < commandAppendixStart) {
- //clear output before linearization
- clear = true;
- }
- if (s.indexOf("t") > -1 && s.indexOf("t") < commandAppendixStart) {
- //tree has changed
- treeCh = true;
- }
- if (s.indexOf("p") > -1 && s.indexOf("p") < commandAppendixStart) {
- //we must not probe again
- onceAgain = false;
- }
- if (s.indexOf("r") > -1 && s.indexOf("r") < commandAppendixStart) {
- //we must not probe again
- recurse = false;
- }
-
- if (s.indexOf("n") > -1 && s.indexOf("n") < commandAppendixStart) {
- //a new object has been created
- newObj = true;
- }
- if (logger.isLoggable(Level.FINE)) {
- if (commandAppendix != null) {
- logger.fine("command appendix read: '" + commandAppendix + "'");
- }
- }
- return new Hmsg(readresult, commandAppendix, onceAgain, recurse, newObj, treeCh, clear);
- } catch(IOException e){
- System.err.println(e.getMessage());
- e.printStackTrace();
- return new Hmsg("", null, false, true, false, true, false);
- }
- } else {
- return new Hmsg(prevreadresult, null, true, true, false, true, false);
- }
- }
-
- /**
- * Parses the GF-output between tags
- * and puts a StringTuple for each show/send pair into the
- * return vector.
- * @return A Vector of StringTuple as described above
- */
- protected Vector readRefinementMenu (){
- if (xmlLogger.isLoggable(Level.FINER)) xmlLogger.finer("list model changing! ");
- String s ="";
- Vector printnameVector = new Vector();
- Vector commandVector = new Vector();
- Vector gfCommandVector = new Vector();
- try {
- //read