<commit_before>package net.ohloh.ohcount4j.scan;

import net.ohloh.ohcount4j.Language;

public class RebolScanner extends BaseScanner{

	protected int str_nested_level = 0;

  	%%{
	    machine rebol;
	    include common "common.rl";
	    
	    action inc_str_nested_level { str_nested_level++; }
	 	action dec_str_nested_level { str_nested_level--; if(str_nested_level == 0) fret; }
	  	action is_nested { str_nested_level > 0 }

	    rebol_line_comment = ';' @comment nonnewline* @comment;
	    
	    # Anything between curly brackets { } is considered a string
	    # Brackets may be nested so string does not end until matching bracket is found
	    # If not enough terminating brackets, rest of file is considered part of the string
	    rebol_cb_string_begin = '{' @code;
	    rebol_cb_string_end = '}' @code;
	    rebol_cb_string := |*
	   		newline;
	   		spaces;
	   		(any - newline) => code;
	    	rebol_cb_string_begin @inc_str_nested_level;
	    	rebol_cb_string_end when is_nested @dec_str_nested_level;
	    *|;
	    
	  	rebol_line := |*
	  		rebol_cb_string_begin => { fhold; fcall rebol_cb_string; };
	  		string_literal_dq;
	    	rebol_line_comment;
	    	spaces;
	    	newline;
	    	(any - newline) => code;
	  	*|; 
	}%%
	
	%% write data;
	  
	@Override
	public void doScan(){
		// variables and data is set up in BaseScanner
	    %% write init;
	    init();
	    %% write exec;
	}
	  
	@Override
	public Language getLanguage() {
		return Language.LANG_REBOL;
	}
  
}
<commit_msg>Moved calling of inc/dec actions outside cs_string scanner machine to make it easier to read in Rebol Scanner.<commit_after>package net.ohloh.ohcount4j.scan;

import net.ohloh.ohcount4j.Language;

public class RebolScanner extends BaseScanner{

	protected int nested_level = 0;

  	%%{
	    machine rebol;
	    include common "common.rl";
	    
	    action inc_nested_level { nested_level++; }
	 	action dec_nested_level { nested_level--; if(nested_level == 0) fret; }
	  	action is_nested { nested_level > 0 }

	    rebol_line_comment = ';' @comment nonnewline* @comment;
	    
	    # For handeling nested nature of bracket strings { }
	    rebol_cb_string_begin = '{' @code @inc_nested_level;
	    rebol_cb_string_end = '}' @code when is_nested @dec_nested_level;
	    rebol_cb_string := |*
	   		newline;
	   		spaces;
	   		(any - newline) => code;
	    	rebol_cb_string_begin;
	    	rebol_cb_string_end;
	    *|;
	    
	  	rebol_line := |*
	  		rebol_cb_string_begin => { fcall rebol_cb_string; };
	  		string_literal_dq;
	    	rebol_line_comment;
	    	spaces;
	    	newline;
	    	(any - newline) => code;
	  	*|; 
	}%%
	
	%% write data;
	  
	@Override
	public void doScan(){
		// variables and data is set up in BaseScanner
	    %% write init;
	    init();
	    %% write exec;
	}
	  
	@Override
	public Language getLanguage() {
		return Language.LANG_REBOL;
	}
  
}

{'fraction_non_alphanumeric': 0.09596662030598054, 'fraction_numerical': 0.0034770514603616135, 'mean_word_length': 2.8669354838709675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6061300', 'n_tokens_mistral': 1110, 'n_tokens_neox': 993, 'n_words': 235}