"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/ragel.lm" between
ragel-7.0.0.9.tar.gz and ragel-7.0.0.10.tar.gz

About:

ragel.lm  (ragel-7.0.0.9):ragel.lm  (ragel-7.0.0.10)
global GblActionParams: bool = false global GblActionParams: bool = false
global GblSectionPass: bool = false global GblSectionPass: bool = false
struct machine
Name: str
ActionParams: map<str, str>
end
global GblMachineMap: map<str, machine> = new map<str, machine>()
global GblCurMachine: machine
global GblIncludeDepth: int = 0
global GblTargetMachine: str = ""
global GblSearchMachine: str = ""
global GblWantSection: bool = false
global GblImport: bool = false
bool action_params_find( Machine: str, Action: str ) bool action_params_find( Machine: str, Action: str )
= cc_action_params_find = cc_action_params_find
bool action_params_insert( Machine: str, Action: str ) bool action_params_insert( Machine: str, Action: str )
= cc_action_params_insert = cc_action_params_insert
rl ident rl ident
/( alpha | '_' ) ( alpha | digit | '_' )*/ /( alpha | '_' ) ( alpha | digit | '_' )*/
rl number rl number
/ digit+ / / digit+ /
rl hex_number rl hex_number
/ '0x' [0-9a-fA-F]+ / / '0x' [0-9a-fA-F]+ /
rl hex_char rl hex_char
/ '0x' [0-9a-fA-F]{2} / / '0x' [0-9a-fA-F]{2} /
## Optimization for hex chars that appear near to each other. Converts the
## string of 2-digit hex chars into a single string. The parse tree walker
## concatenates the chars.
#rl hex_string /
# hex_char
# (
# (
# [\t\n ]+ |
# [\t\n ]* '.' [\t\n ]*
# )
# hex_char
# )+
#/
rl NL / '\n' / rl NL / '\n' /
rl c_comment rl c_comment
/ '/*' ( any | NL )* :>> '*/' / / '/*' ( any | NL )* :>> '*/' /
rl cpp_comment rl cpp_comment
/ '//' [^\n]* NL / / '//' [^\n]* NL /
rl ruby_comment rl ruby_comment
/ '#' [^\n]* NL / / '#' [^\n]* NL /
rl s_literal rl s_literal
/ "'" ([^'\\\n] | '\\' (any | NL))* "'" / / "'" ([^'\\\n] | '\\' (any | NL))* "'" /
rl d_literal rl d_literal
/ '"' ([^"\\] | NL | '\\' (any | NL))* '"' / / '"' ([^"\\] | NL | '\\' (any | NL))* '"' /
rl host_re_literal rl host_re_literal
/ '/' ([^/\\] | NL | '\\' (any | NL))* '/' / / '/' ([^/\\] | NL | '\\' (any | NL))* '/' /
namespace srlex #
# Consuming ragel defintions without parsing. Used for included sections we
# don't want and import (TODO).
#
namespace consume
lex
token h_word / [a-zA-Z_][a-zA-Z0-9_]* /
token h_open /'{'/
token h_close /'}'/
token h_number /digit+/
token h_hex_number /'0x' [0-9a-fA-F]+/
token h_comment
/ c_comment | cpp_comment /
token h_string
/ s_literal | d_literal /
token h_whitespace
/ ( [ \t] | NL )+ /
token h_any / any /
end
def host_tok
[h_word]
| [h_number]
| [h_hex_number]
| [h_comment]
| [h_string]
| [h_whitespace]
| [h_open host_tok* h_close]
| [h_any]
lex lex
ignore /[\t\n ]+/ ignore /[\t\n ]+/
literal `:: `; `) ignore /'#' any* :> '\n'/
token word /[a-zA-Z_][a-zA-Z0-9_]*/
literal `}%%
token word / [a-zA-Z_][a-zA-Z0-9_]* /
token uint / number /
token hex / hex_number /
token string /
'"' ( [^"\\] | '\\' any )* '"' 'i'? |
"'" ( [^'\\] | '\\' any )* "'" 'i'? |
"[" ( [^\]\\] | '\\' any )* "]" 'i'? #|
#"/" ( [^\/\\] | '\\' any )* "/" 'i'?
/
token open /'{'/ -ni
token close ni- /'}'/
token c_any / any /
end end
end
struct machine # Garbling up a machine, no interpretation
Name: str def tok
ActionParams: map<str, str> [word]
| [uint]
| [hex]
| [string]
| [open host_tok* h_close]
| [c_any]
end end
global MachineMap: map<str, machine> = new map<str, machine>() # State reference.
global CurMachine: machine namespace state_ref
lex
ignore /[\t\n ]+/
literal `:: `; `)
token word /[a-zA-Z_][a-zA-Z0-9_]*/
end
global Lang: str def state_ref
[opt_name_sep state_ref_names] :Ref
def opt_name_sep
[`::] :ColonColon
| [] :Empty
lex # List of names separated by ::
token select /''/ def state_ref_names
{ [state_ref_names `:: word] :Rec
if Lang == "ruby" | [word] :Base
input->push( make_token( typeid<ruby_select>, '' ) )
elsif Lang == "ocaml"
input->push( make_token( typeid<ocaml_select>, '' ) )
elsif Lang == "crack"
input->push( make_token( typeid<crack_select>, '' ) )
else
input->push( make_token( typeid<c_select>, '' ) )
}
token c_select //
token ruby_select //
token ocaml_select //
token crack_select //
end end
namespace ragel namespace ragel
lex lex
literal `}%% -ni literal `}%% -ni
ignore /[\t\n ]+/ ignore /[\t\n ]+/
ignore /'#' any* :> '\n'/ ignore /'#' any* :> '\n'/
literal `^ `| `- `, `: `! `? `. literal `^ `| `- `, `: `! `? `.
skipping to change at line 131 skipping to change at line 184
`access `write `getkey `export `import `access `write `getkey `export `import
`include `prepush `postpop `nfaprepush `nfapostpo p `include `prepush `postpop `nfaprepush `nfapostpo p
literal `:nfa `:cond `:condplus `:condstar `): literal `:nfa `:cond `:condplus `:condstar `):
token string / token string /
'"' ( [^"\\] | '\\' any )* '"' 'i'? | '"' ( [^"\\] | '\\' any )* '"' 'i'? |
"'" ( [^'\\] | '\\' any )* "'" 'i'? "'" ( [^'\\] | '\\' any )* "'" 'i'?
/ /
# token hex_string / hex_string /
token lex_regex_open /'/'/ -ni token lex_regex_open /'/'/ -ni
token lex_sqopen_pos /'['/ -ni token lex_sqopen_pos /'['/ -ni
token lex_sqopen_neg /'[^'/ -ni token lex_sqopen_neg /'[^'/ -ni
token word / [a-zA-Z_][a-zA-Z0-9_]* / token word / [a-zA-Z_][a-zA-Z0-9_]* /
token uint / number / token uint / number /
token hex / hex_number / token hex / hex_number /
end end
lex lex
skipping to change at line 169 skipping to change at line 220
/[^{;] [^;]* ';'/ { /[^{;] [^;]* ';'/ {
R: str = input->pull( match_length - 1 ) R: str = input->pull( match_length - 1 )
input->pull( 1 ) input->pull( 1 )
input->push( "}" ) input->push( "}" )
input->push( R ) input->push( R )
input->push( "{" ) input->push( "{" )
} }
token variable_name /ident/ token variable_name /ident/
# This region is for deciding if we want to parse a ragel section, or if
we
# want to consume it without interpreting. Consuming is for included
# sections we don't want and all sections in an imported file.
lex
token ign_select /''/
{
if GblWantSection
input->push( make_token( typeid<ign_want>, '' ) )
else
input->push( make_token( typeid<ign_ignore>, '' )
)
}
token ign_want //
token ign_ignore //
end
#
# Machine name word. We inspect it to determine if we are interested in t
he
# section.
#
lex
token mn_word / [a-zA-Z_][a-zA-Z0-9_]* /
{
S: str = input->pull(match_length)
IgnWord: mn_word = make_token( typeid<mn_word>, S )
input->push( IgnWord )
if ( GblImport )
GblWantSection = false
else if ( GblSearchMachine != "" ) {
if ( S != GblSearchMachine )
GblWantSection = false
else
GblWantSection = true
}
else {
GblWantSection = true
}
}
end
def inline_expr_reparse def inline_expr_reparse
[_inline_expr_reparse] :Reparse [_inline_expr_reparse] :Reparse
| [action_expr] :ActionExpr | [action_expr] :ActionExpr
def join def join
[join `, expression] :Rec [join `, expression] :Rec
| [expression] :Base | [expression] :Base
def expression def expression
[expr_left expression_op_list] :Expression [expr_left expression_op_list] :Expression
skipping to change at line 224 skipping to change at line 316
def factor_ep def factor_ep
[factor_aug `-> epsilon_target] :Epsilon [factor_aug `-> epsilon_target] :Epsilon
| [factor_aug] :Base | [factor_aug] :Base
def epsilon_target def epsilon_target
[epsilon_target `:: word] :Rec [epsilon_target `:: word] :Rec
| [word] :Base | [word] :Base
def action_expr def action_expr
[`{ c_select CInlineExpr: c_inline::inline_expr c_inline::`}] [`{ CInlineExpr: inline::inline_expr inline::`}] :ActionExpr
:C
| [`{ ruby_select RubyInlineExpr: ruby_inline::inline_expr ruby_in
line::`}]
| [`{ ocaml_select OCamlInlineExpr: ocaml_inline::inline_expr ocaml
_inline::`}]
| [`{ crack_select CrackInlineExpr: crack_inline::inline_expr crack
_inline::`}]
def action_block def action_block
[`{ c_select CInlineBlock: c_inline::inline_block c_inline::` [`{ CInlineBlock: inline::inline_block inline::`}] :ActionBlock
}] :C
| [`{ ruby_select RubyInlineBlock: ruby_inline::inline_block ruby_
inline::`}]
| [`{ ocaml_select OCamlInlineBlock: ocaml_inline::inline_block oca
ml_inline::`}]
| [`{ crack_select CrackInlineBlock: crack_inline::inline_block cra
ck_inline::`}]
def action_arg_list def action_arg_list
[action_arg_list `, action_ref] :Rec [action_arg_list `, action_ref] :Rec
| [action_ref] :Base | [action_ref] :Base
def opt_action_arg_list def opt_action_arg_list
[action_arg_list] :List [action_arg_list] :List
| [] :Empty | [] :Empty
def named_action_ref def named_action_ref
[word] :Plain [word] :Plain
{ {
if ! GblSectionPass { if ! GblSectionPass {
if action_params_find( CurMachine->Name, $lhs.wor d ) if action_params_find( GblCurMachine->Name, $lhs. word )
reject reject
} }
} }
| [word `( opt_action_arg_list `)] :Args | [word `( opt_action_arg_list `)] :Args
{ {
if ! GblSectionPass { if ! GblSectionPass {
if ! action_params_find( CurMachine->Name, $lhs.w ord ) if ! action_params_find( GblCurMachine->Name, $lh s.word )
reject reject
} }
} }
def action_ref def action_ref
[named_action_ref] :NamedRef [named_action_ref] :NamedRef
| [`( named_action_ref `)] :ParenNamed | [`( named_action_ref `)] :ParenNamed
| [action_block] :Block | [action_block] :Block
def priority_name def priority_name
skipping to change at line 368 skipping to change at line 454
def colon_cond def colon_cond
[`:cond] :Cond [`:cond] :Cond
| [`:condstar] :CondStar | [`:condstar] :CondStar
| [`:condplus] :CondPlus | [`:condplus] :CondPlus
def factor def factor
[alphabet_num] :AlphabetNum [alphabet_num] :AlphabetNum
| [word] :Word | [word] :Word
| [string] :String | [string] :String
#| [hex_string] :HexString
| [lex_sqopen_pos reg_or_data re_or_sqclose] :PosOrBlock | [lex_sqopen_pos reg_or_data re_or_sqclose] :PosOrBlock
| [lex_sqopen_neg reg_or_data re_or_sqclose] :NegOrBlock | [lex_sqopen_neg reg_or_data re_or_sqclose] :NegOrBlock
| [lex_regex_open regex re_close] :Regex | [lex_regex_open regex re_close] :Regex
| [RL1: range_lit `.. RL2: range_lit] :Range | [RL1: range_lit `.. RL2: range_lit] :Range
| [RL1: range_lit `../i RL2: range_lit] :RangeIndep | [RL1: range_lit `../i RL2: range_lit] :RangeIndep
| [nfastar `( expression `, | [nfastar `( expression `,
Push: action_ref `, Pop: action_ref `, Init: action_ref ` , Stay: action_ref `, Push: action_ref `, Pop: action_ref `, Init: action_ref ` , Stay: action_ref `,
Repeat: action_ref `, Exit: action_ref `):] :Nfa Repeat: action_ref `, Exit: action_ref `):] :Nfa
| [colon_cond `( expression `, | [colon_cond `( expression `,
Init: action_ref `, Inc: action_ref `, Min: action_ref Op tMax: opt_max_arg `):] :Cond Init: action_ref `, Inc: action_ref `, Min: action_ref Op tMax: opt_max_arg `):] :Cond
skipping to change at line 463 skipping to change at line 548
GblActionParams = true GblActionParams = true
} }
def action_spec def action_spec
[`action word action_params action_block] :ActionSpecParams commi t [`action word action_params action_block] :ActionSpecParams commi t
{ {
if ! GblSectionPass { if ! GblSectionPass {
# Track that this action has params so we can par se appropriately # Track that this action has params so we can par se appropriately
# when reducing. # when reducing.
# CurMachine->ActionParams->insert( $lhs.word, $l hs.word ) # CurMachine->ActionParams->insert( $lhs.word, $l hs.word )
action_params_insert( CurMachine->Name, $lhs.word ) action_params_insert( GblCurMachine->Name, $lhs.w ord )
} }
# Reset after parsing the block. # Reset after parsing the block.
GblActionParams = false GblActionParams = false
} }
| [`action word action_block] :ActionSpec commit | [`action word action_block] :ActionSpec commit
{ {
GblActionParams = false GblActionParams = false
} }
skipping to change at line 520 skipping to change at line 605
| [word string] :MachineFile | [word string] :MachineFile
def opt_export def opt_export
[`export] :Export [`export] :Export
| [] :Base | [] :Base
def write_arg def write_arg
[word] :Word [word] :Word
def machine_name def machine_name
[`machine word `;] :MachineName [`machine mn_word `;] :MachineName
{ {
Machine: machine = MachineMap->find( $lhs.word ) Name: str = $lhs.mn_word
if GblTargetMachine != ""
Name = GblTargetMachine
Machine: machine = GblMachineMap->find( Name )
if !Machine if !Machine
{ {
Machine = new machine() Machine = new machine()
Machine->Name = $lhs.word Machine->Name = Name
Machine->ActionParams = new map<str, str>() Machine->ActionParams = new map<str, str>()
MachineMap->insert( Machine->Name, Machine ) GblMachineMap->insert( Machine->Name, Machine )
} }
CurMachine = Machine GblCurMachine = Machine
} }
def statement def statement
[assignment] :Assignment [assignment] :Assignment
| [instantiation] :Instantiation | [instantiation] :Instantiation
| [nfa_union] :NfaUnion | [nfa_union] :NfaUnion
| [action_spec] :ActionSpec | [action_spec] :ActionSpec
| [`prepush action_block] :PrePush commit | [`prepush action_block] :PrePush commit
| [`postpop action_block] :PostPop commit | [`postpop action_block] :PostPop commit
| [`variable variable_name inline_expr_reparse] :Variable commit | [`variable variable_name inline_expr_reparse] :Variable commit
skipping to change at line 557 skipping to change at line 646
| [`import string `;] :Import commit | [`import string `;] :Import commit
| [`include include_spec `;] :Include commit | [`include include_spec `;] :Include commit
| [`nfaprepush action_block] :NfaPrePush commit | [`nfaprepush action_block] :NfaPrePush commit
| [`nfapostpop action_block] :NfaPostPop commit | [`nfapostpop action_block] :NfaPostPop commit
def opt_machine_name def opt_machine_name
[machine_name] :MachineName [machine_name] :MachineName
| [] :Empty | [] :Empty
def ragel_start def ragel_start
[opt_machine_name statement*] [opt_machine_name ign_want statement*]
| [opt_machine_name ign_ignore consume::tok*]
end end
 End of changes. 25 change blocks. 
71 lines changed or deleted 156 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS