Open-source image
open-source
Hime logo

Table of content

himecc command line

This page contains the reference documentation for the command line usage of the Hime parser generator. The command line utility, named himecc can be downloaded in the distribution, see the download page.

Arguments

  • General help: Display a help screen with the description of the options.
    • -h
    • --help
  • Input selection:
    • -g, --grammar <GRAMMAR>, Select the top grammar to compile if more than one are given. It is possible to define multiple grammar in the same file, or to give multiple files to the tool. This option is to be followed by the name of the grammar that will act as the top one to be compiled.
  • Output options:
    • -o, --output <MODE> The output mode, possible values are: sources, assembly, all.
      • sources (default value), Emit the sources for the parser.
      • assembly, Compile the generated parser code in an assembly. The exact form depends on the target platform.
      • all, Emit both the sources and the compiled assembly.
    • -t, --target <TARGET> The target runtime, possible values are: net, java, rust.
      • net (default value), Generate code for the .Net framework in C#.
      • java, Generate Java code.
      • rust, Generate Rust code.
    • -p, --path <PATH>, The path to write the output. By default, the current directory is used.
    • -a, --access <ACCESS> The access modifier for the generated code, possible values are: internal, public.
      • internal (default value), In the generated code, symbols are kept internal/private.
      • public, In the generated code, symbols are made public.
    • -n, --namespace <NMSPCE>, The namespace to use for the generated code. If none is given, and the target runtime requires one, the name of the grammar will be used.
    • -m, --method <METHOD> The parsing method to use, possible values are: lr0, lr1, lalr1, rnglr1, rnglalr1.
      • lr0, LR(0) parsing method. Use for test purposes.
      • lr1, LR(1) parsing method. Use for test purposes.
      • lalr1 (default value), LALR(1) parsing method. This is a sensible default for simple to moderately complex grammars.
      • rnglr1, RNGLR(1) parsing method. Use for test purposes.
      • rnglalr1, RNGLALR(1) parsing method. Choose this option if you want a GLR parser.

Examples

With no option set, the tool compiles the first grammar it finds in the given input,

  • it will only generate the source code (and binary resources) of the lexer and parser
  • it will output the files in the current directory with the name of the grammar as a prefix
  • it will generate a LALR parser
  • the namespace for the generated code will be the name of the grammar
  • the access modifier for the generated code will be internal
  • the compilation log will not be saved (but displayed on the console)
  • the grammar's documentation will not be generated

To output only an assembly:

MyGram.gram -o assembly

To output both the sources and the compiled assembly:

himecc MyGram.gram -o all

To produce a parser for the Java runtime:

himecc MyGram.gram -t java

It is possible to give multiple file to the tool, in which cas the top grammar to compile should be selected:

himecc MyGram1.gram MyGram2.gram -g MyGram2

To output the parser in the XXX directory:

himecc MyGram.gram -p XXX

To select the RNGLR algorithm:

himecc MyGram.gram -m rnglalr1

To specify a namespace for the generated code:

himecc MyGram.gram -n MyApp.Generated

To switch the generated code access modifiers to public in an assembly:

himecc MyGram.gram -a:public -o:nosources