Author Topic: CINT  (Read 5752 times)

JRS

  • Guest
CINT
« on: February 06, 2011, 08:35:34 PM »


Code: Text
  1. #include <iostream.h>
  2. int run()
  3. {
  4. cout << " Hello" << endl;
  5. float x = 3.;
  6. float y = 5.;
  7. int
  8. i= 101;
  9. cout <<" x = "<< x <<" y = "<< y <<" i = "<< i << endl;
  10. return 0;
  11. }
  12.  

CINT Project Site

CINT is an interpreted version of C or C++, much in the way BeanShell is an interpreted version of Java. In addition to being a language interpreter, it offers certain bash-like shell features such as history and tab-completion. To accomplish the latter, it relies heavily on the reflection support built into ROOT. User classes that follow these interfaces may also take advantage of these features.

The language interpreted by CINT is actually something of a hybrid between C and C++, covering about 95% of ANSI C and 85% of C++. The syntax, however, is a bit more forgiving than either language. For example, the operator -> can be replaced by . with only an optional warning. In addition, statements on the command line do not need to end with a semi-colon, although this is necessary for statements in macros.

Note: CINT works fine as a C interpreter as well.

Code: Text
  1. #include <stdio.h>
  2. main() {
  3.   printf("Hello World");
  4. }
  5.  

(see attached image for running this in CINT)
« Last Edit: February 06, 2011, 10:13:16 PM by JRS »

JRS

  • Guest
Re: CINT
« Reply #1 on: February 13, 2011, 03:03:08 PM »
I have been playing around with ROOT:CINT a bit and discovered I can drop down into the C interpreter (CINT) from root. This makes it much easier to work with the interpreter. (commands aren't so cryptic)

Code: [Select]
CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .cint

cint : C/C++ interpreter  (mailing list 'cint@root.cern.ch')
   Copyright(c) : 1995~2005 Masaharu Goto (gotom@hanno.jp)
   revision     : 5.16.29, Jan 08, 2008 by M.Goto

No main() function found in given source file. Interactive interface started.
'?':help, '.q':quit, 'statement','{statements;}' or '.p [expr]' to evaluate

cint>

Code: Text
  1.              > [file]  : output redirection to [file]
  2.              2> [file] : error redirection to [file]
  3.              >& [file] : output&error redirection to [file]
  4. Help:        ?         : help
  5.              help      : help
  6.              /[keyword] : search keyword in help information
  7. Shell:       ![shell]  : execute shell command
  8. Source:      v <[line]>: view source code <around [line]>
  9.              V [stack] : view source code in function call stack
  10.              t         : show function call stack
  11.              f [file]  : select file to debug
  12.              T         : turn on/off trace mode for all source
  13.              J [stat]  : Set warning level [0-5]
  14.              A [1|0]   : allowing automatic variable on/off
  15.              trace <classname> : turn on trace mode for class
  16.              deltrace <classname> : turn off trace mode for class
  17. Evaluation:  p [expr]  : evaluate expression (no declaration/loop/condition)
  18. Evaluation:  s [expr]  : step into expression (no declaration/loop/condition)
  19. Evaluation:  S [expr]  : step over expression (no declaration/loop/condition)
  20.              {[statements]} : evaluate statement (any kind)
  21.              x [file]  : load [file] and execute function [file](wo extension)
  22.              X [file]  : load [file] and execute function [file](wo extension)
  23.              E <[file]>: open editor and evaluate {statements} in the file
  24. Load/Unload: L [file]  : load [file]
  25.              La [file] : reload all files loaded after [file]
  26.              U [file]  : unload [file]
  27.              C [1|0]   : copy source to $TMPDIR (on/off)
  28.              undo      : undo previous declarations
  29.              lang      : local language (EUC,SJIS,EUROPEAN,UNKNOWN)
  30. Monitor:     g <[var]> : list global variable
  31.              l <[var]> : list local variable
  32.              proto <[scope]::>[func] : show function prototype
  33.              class <[name]> : show class definition (one level)
  34.              Class <[name]> : show class definition (all level)
  35.              typedef <name> : show typedefs
  36.              function  : show interpreted functions
  37.              macro     : show macro functions
  38.              template  : show templates
  39.              include   : show include paths
  40.              file      : show loaded files
  41.              where     : show current file position
  42.              security  : show security level
  43.              refcount  : reference count control on/off
  44.              garbage   : show garbage collection buffer
  45.              Garbage   : Do garbage collection
  46.              cover [file] : save trace coverage
  47.              return [val] : return undefined symbol value
  48. Run:         S         : step over function/loop
  49.              s         : step into function/loop
  50.              i         : ignore and step over
  51.              c <[line]>: continue <to [line]>
  52.              e         : step out from function
  53.              f [file]  : select file to debug
  54.              b [line]  : set break point
  55.              db [line] : delete break point
  56.              a [assert]: break only if assertion is true
  57.              O [0~4]   : Set bytecode compiler mode
  58.              debug     : bytecode status display on/off
  59.              dasm      : disassembler
  60. Quit:        q         : quit cint
  61.              qqq       : quit cint - mandatory
  62.              qqqqq     : exit process immediately
  63.              qqqqqqq   : abort process
  64.              save      : call emergency routine to save important data
  65.  

Session Example
Code: [Select]
cint> .f cint/hello.c
1 > #include <stdio.h>
2  
3   int myvar;
4  
5- main() {
6-  myvar = 100;
7-  printf("Hello World\n");
8-  return 0;
9   }
FILE:hello.c LINE:1 cint> main()
Hello World
(int)0
FILE:hello.c LINE:1 cint> .p myvar
(int)100
FILE:hello.c LINE:1 cint>
« Last Edit: February 13, 2011, 03:49:15 PM by JRS »