diff options
Diffstat (limited to 'ragel/host-crack')
-rw-r--r-- | ragel/host-crack/.gitignore | 13 | ||||
-rw-r--r-- | ragel/host-crack/CMakeLists.txt | 34 | ||||
-rw-r--r-- | ragel/host-crack/Makefile.am | 32 | ||||
-rw-r--r-- | ragel/host-crack/main.cc | 63 | ||||
-rw-r--r-- | ragel/host-crack/ragel-crack.lm | 150 | ||||
-rw-r--r-- | ragel/host-crack/rlhc.lm | 536 | ||||
-rw-r--r-- | ragel/host-crack/rlparse.lm | 202 |
7 files changed, 0 insertions, 1030 deletions
diff --git a/ragel/host-crack/.gitignore b/ragel/host-crack/.gitignore deleted file mode 100644 index a68a8a97..00000000 --- a/ragel/host-crack/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/Makefile -/Makefile.in -/.deps -/.libs -/ragel-crack -/ragel-crack.exe -/rlhc.c -/rlparse.pack -/rlparse.c -/rlreduce.cc - -/CMakeFiles -/cmake_install.cmake diff --git a/ragel/host-crack/CMakeLists.txt b/ragel/host-crack/CMakeLists.txt deleted file mode 100644 index e28b4fa7..00000000 --- a/ragel/host-crack/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -add_custom_command(OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/rlparse.c" - "${CMAKE_CURRENT_BINARY_DIR}/rlreduce.cc" - DEPENDS rlparse.lm - COMMAND colm::colm - ARGS -I.. -c -b rlparseCrack - -o "${CMAKE_CURRENT_BINARY_DIR}/rlparse.c" - -m "${CMAKE_CURRENT_BINARY_DIR}/rlreduce.cc" - rlparse.lm - WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}") - -add_custom_command(OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/rlhc.c" - DEPENDS rlhc.lm - COMMAND colm::colm - ARGS -I.. -c -b rlhcCrack - -o "${CMAKE_CURRENT_BINARY_DIR}/rlhc.c" - rlhc.lm - WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}") - -add_executable(ragel-crack main.cc - "${CMAKE_CURRENT_BINARY_DIR}/rlhc.c" - "${CMAKE_CURRENT_BINARY_DIR}/rlparse.c" - "${CMAKE_CURRENT_BINARY_DIR}/rlreduce.cc") - -target_link_libraries(ragel-crack PRIVATE libragel libfsm) - -if(${PROJECT_NAME}_MAKE_INSTALL) - install(TARGETS ragel-crack - EXPORT ${_PACKAGE_NAME}-targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") -endif() diff --git a/ragel/host-crack/Makefile.am b/ragel/host-crack/Makefile.am deleted file mode 100644 index 676c7f25..00000000 --- a/ragel/host-crack/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -COLM_BIN = ../../colm/colm -COLM_WRAP = ../../colm/colm-wrap -COLM_LA = ../../colm/libcolm.la -COLM_LIBDEP = $(COLM_LA) -COLM_BINDEP = $(COLM_BIN) $(COLM_WRAP) - -bin_PROGRAMS = ragel-crack - -ragel_crack_CPPFLAGS = -I$(top_srcdir)/aapl -I$(top_srcdir)/ragel -I$(top_srcdir)/colm/include - -dist_ragel_crack_SOURCES = main.cc rlhc.c - -nodist_ragel_crack_SOURCES = \ - rlparse.c rlreduce.cc - -ragel_crack_LDADD = ../libragel.la ../libfsm.la $(COLM_LA) - -BUILT_SOURCES = rlparse.c rlreduce.cc rlhc.c - -EXTRA_DIST = rlparse.lm rlhc.lm - -rlparse.pack: rlparse.lm $(COLM_BINDEP) - $(COLM_WRAP) -c -I .. -b rlparseCrack -o $@ -p rlparse.c -m rlreduce.cc $< - -rlparse.c: rlparse.pack - $(COLM_WRAP) -o $@ $< - -rlreduce.cc: rlparse.pack - $(COLM_WRAP) -o $@ $< - -rlhc.c: rlhc.lm ../ril.lm $(COLM_BINDEP) - $(COLM_BIN) -c -I .. -b rlhcCrack -o $@ $< diff --git a/ragel/host-crack/main.cc b/ragel/host-crack/main.cc deleted file mode 100644 index dd45fd1b..00000000 --- a/ragel/host-crack/main.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2001-2018 Adrian Thurston <thurston@colm.net> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "inputdata.h" - -extern struct colm_sections rlparseCrack; -extern struct colm_sections rlhcCrack; - -/* - * Crack - */ -const char *defaultOutFnCrack( const char *inputFileName ) -{ - return fileNameFromStem( inputFileName, ".crk" ); -} - -HostType hostTypesCrack[] = -{ - { "byte", 0, "byte", false, true, true, 0, 0, 0, UCHAR_MAX, 1 }, - { "int32", 0, "int32", true, true, false, S32BIT_MIN, S32BIT_MAX, 0, 0, 4 }, - { "uint32", 0, "uint32", false, true, false, 0, 0, 0, U32BIT_MAX, 4 }, - { "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, sizeof(int) }, - { "uint", 0, "uint", false, true, false, 0, 0, 0, UINT_MAX, sizeof(int) }, -}; - -const HostLang hostLangCrack = -{ - hostTypesCrack, - 5, - 0, - true, - false, /* loopLabels */ - Translated, - BreakFeature, - &makeCodeGen, - &defaultOutFnCrack, - &genLineDirectiveTrans -}; - -int main( int argc, const char **argv ) -{ - InputData id( &hostLangCrack, &rlparseCrack, &rlhcCrack ); - return id.rlhcMain( argc, argv ); -} diff --git a/ragel/host-crack/ragel-crack.lm b/ragel/host-crack/ragel-crack.lm deleted file mode 100644 index b6480012..00000000 --- a/ragel/host-crack/ragel-crack.lm +++ /dev/null @@ -1,150 +0,0 @@ -namespace crack_inline - lex - literal `fpc `fc `fcurs `ftargs - `fentry `fhold `fexec `fgoto `fnext - `fcall `fret `fbreak `fncall `fnret `fnbreak - - token ident /ident/ - token number /digit+/ - token hex_number /'0x' [0-9a-fA-F]+/ - - token comment - / c_comment | cpp_comment / - - token string - / s_literal | d_literal / - - token whitespace - / ( [ \t] | NL )+ / - - literal - `{ `} `:: `* `, `( `) `; - - token c_any / any / - end - - def inline_expr - [expr_item*] - - def expr_item - [expr_any] :ExprAny - | [expr_symbol] :ExprSymbol - | [expr_interpret] :ExprInterpret - - def expr_any - [whitespace] - | [comment] - | [string] - | [number] - | [hex_number] - | [ident] - | [c_any] - - def expr_symbol - [`,] | [`(] | [`)] | [`*] | [`::] - - def expr_interpret - [`fpc] :Fpc - | [`fc] :Fc - | [`fcurs] :Fcurs - | [`ftargs] :Ftargs - | [`fentry `( state_ref srlex::`)] :Fentry - - def state_ref - [opt_name_sep state_ref_names] - - def opt_name_sep - [srlex::`::] :ColonColon - | [] :Empty - - # List of names separated by :: - def state_ref_names - [state_ref_names srlex::`:: srlex::word] :Rec - | [srlex::word] :Base - - def inline_block - [block_item*] - - def block_item - [expr_any] :ExprAny - | [block_symbol] :BlockSymbol - | [block_interpret] :BlockInterpret - | [`{ inline_block `}] :RecBlock - - def block_symbol - [`,] | [`;] | [`(] | [`)] | [`*] | [`::] - - def block_interpret - [expr_interpret] :ExprInterpret - | [`fhold whitespace? `;] :Fhold - | [`fgoto whitespace? `* inline_expr `;] :FgotoExpr - | [`fnext whitespace? `* inline_expr `;] :FnextExpr - | [`fcall whitespace? `* inline_expr `;] :FcallExpr - | [`fncall whitespace? `* inline_expr `;] :FncallExpr - | [`fexec inline_expr `;] :Fexec - | [`fgoto state_ref srlex::`;] :FgotoSr - | [`fnext state_ref srlex::`;] :FnextSr - | [`fcall state_ref srlex::`;] :FcallSr - | [`fncall state_ref srlex::`;] :FncallSr - | [`fret `;] :Fret - | [`fnret `;] :Fnret - | [`fbreak `;] :Fbreak - | [`fnbreak `;] :Fnbreak -end - - -namespace crack_host - lex - literal `%%{ - - token slr /'%%' [^{] [^\n]* '\n'/ - { - input->pull( 2 ) - R: str = input->pull( match_length - 3 ) - input->push( "\n}%%" ) - input->push( R ) - input->push( "%%{" ) - } - - rl NL / '\n' / - - rl s_literal - / "'" ([^'\\\n] | '\\' (any | NL))* "'" / - - rl d_literal - / '"' ([^"\\] | NL | '\\' (any | NL))* '"' / - - rl bt_literal - / '`' ([^`\\] | NL | '\\' (any | NL))* '`' / - - token ident /ident "'"?/ - token number /digit+/ - token hex_number /'0x' [0-9a-fA-F]+/ - - token comment - /c_comment | cpp_comment/ - - token string - / s_literal | d_literal | bt_literal / - - token whitespace - / ( [ \t] | NL )+ / - - token c_any / any / - end - - def tok - [ident] - | [number] - | [hex_number] - | [comment] - | [string] - | [whitespace] - | [c_any] - - def section - [`%%{ ragel::ragel_start ragel::`}%%] :MultiLine - | [tok] :Tok -end - - diff --git a/ragel/host-crack/rlhc.lm b/ragel/host-crack/rlhc.lm deleted file mode 100644 index bebe7cd5..00000000 --- a/ragel/host-crack/rlhc.lm +++ /dev/null @@ -1,536 +0,0 @@ -include 'ril.lm' - -namespace crack_out - token _IN_ /''/ - token _EX_ /''/ - - lex - token comment / - '//' any* :> '\n' | - '/*' any* :>> '*/' - / - - token id - /[a-zA-Z_][a-zA-Z_0-9]*/ - - token number / - [0-9]+ - / - - token symbol / - '!' | '#' | '$' | '%' | '&' | '(' | ')' | '*' | - '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | - '=' | '>' | '?' | '@' | '[' | ']' | '^' | '|' | - '~' / - - literal `{ `} - - token string / - '"' ( [^"\\] | '\\' any ) * '"' | - "'" ( [^'\\] | '\\' any ) * "'" | - "`" ( [^`\\] | '\\' any ) * "`" - / - - ignore - /[ \t\v\r\n]+/ - end - - def item - [comment] - | [id] - | [number] - | [symbol] - | [string] - | [`{ _IN_ item* _EX_ `} ] - - def crack_out - [_IN_ _EX_ item*] -end - -namespace crack_gen - - global Parser: parser<crack_out::crack_out> - - void tok_list( TL: host::tok* ) - { - for Tok: host::tok in repeat(TL) { - switch Tok - case [host::`${ StmtList: stmt* host::`}$] { - send Parser - "if ( 1 ) { - " [stmt_list( StmtList )] - "} - } - case [host::`={ Expr: expr host::`}=] { - send Parser - "([expr( Expr )])" - } - case [E: escape] { - Str: str = $E - send Parser - "[Str.suffix( 1 )]" - } - default { - send Parser - [Tok] - } - } - } - - void embedded_host( EmbeddedHost: embedded_host ) - { - switch EmbeddedHost - case [`host `( string `, uint `) `={ TL: host::tok* host::`}=] - { - send Parser - "([tok_list( TL )])" - } - case [`host `( string `, uint `) `${ TL: host::tok* host::`}$] - { - send Parser - "if ( 1 ) { - " [tok_list( TL )] - "} - } - case [`host `( string `, uint `) `@{ TL: host::tok* host::`}@] - { - send Parser - [tok_list( TL )] - } - } - - void expr_factor( ExprFactor: expr_factor ) - { - switch ExprFactor - case [EH: embedded_host] - { - send Parser - [embedded_host( EH )] - } - case [`( E: expr `)] - { - send Parser - "([expr(E)])" - } - case [I: ident `[ E: expr `]] - { - send Parser - "[I]\[[expr( E )]\]" - } - case [`offset `( ident `, expr `)] - { - send Parser - [expr( ExprFactor.expr )] - } - case [`deref `( ident `, expr `)] - { - send Parser - [ ExprFactor.ident '[' expr( ExprFactor.expr ) ']'] - } - case [`TRUE] - { - send Parser "1" - } - case [`FALSE] - { - send Parser "1" - } - case [N: `nil] - { - send Parser "0" - } - case [Number: number] - { - number( Number ) - } - case [E1: embedded_host `-> E2: expr_factor] - { - # The accessor operator is contained wihtin the lhs. - embedded_host( E1 ) - expr_factor( E2 ) - } - case [`cast `( T: type `) F: expr_factor] - { - send Parser - "[type( T )] ( [expr_factor( F )] )" - } - case [I: ident `[ E: expr `] `. F: ident] { - send Parser - [^I '_' ^F '[' E ']'] - } - default { - # Catches cases not specified - send Parser [ExprFactor] - } - } - - void lvalue( ExprFactor: lvalue ) - { - switch ExprFactor - case [EH: embedded_host] - { - send Parser - [embedded_host( EH )] - } - case [ident O: `[ TL: expr C: `]] - { - send Parser - [ExprFactor.ident O expr( TL ) C] - } - case [E1: embedded_host `-> E2: lvalue] - { - # The accessor operator is contained wihtin the lhs. - embedded_host( E1 ) - lvalue( E2 ) - } - case [I: ident `[ E: expr `] `. F: ident] { - send Parser - [^I '_' ^F '[' E ']'] - } - default { - # Catches cases not specified - send Parser [ExprFactor] - } - } - - void expr_factor_op( ExprFactorOp: expr_factor_op ) - { - switch ExprFactorOp - case [B: `! expr_factor_op] - { - send Parser [B] - expr_factor_op( ExprFactorOp._expr_factor_op ) - } - case [T: `~ expr_factor_op] - { - send Parser [T] - expr_factor_op( ExprFactorOp._expr_factor_op ) - } - case [expr_factor] - { - expr_factor( ExprFactorOp.expr_factor ) - } - } - - void expr_bitwise( ExprBitwise: expr_bitwise ) - { - switch ExprBitwise - case [expr_bitwise A: `& expr_factor_op] - { - expr_bitwise( ExprBitwise._expr_bitwise ) - send Parser [A] - expr_factor_op( ExprBitwise.expr_factor_op ) - } - case [expr_factor_op] - { - expr_factor_op( ExprBitwise.expr_factor_op ) - } - } - - void expr_mult( ExprMult: expr_mult ) - { - switch ExprMult - case [expr_mult T: `* expr_bitwise] - { - expr_mult( ExprMult._expr_mult ) - send Parser [T] - expr_bitwise( ExprMult.expr_bitwise ) - } - case [expr_bitwise] - { - expr_bitwise( ExprMult.expr_bitwise ) - } - } - - void expr_add( ExprAdd: expr_add ) - { - switch ExprAdd - case [expr_add Op: add_op expr_mult] - { - expr_add( ExprAdd._expr_add ) - send Parser [Op] - expr_mult( ExprAdd.expr_mult ) - } - case [expr_mult] - { - expr_mult( ExprAdd.expr_mult ) - } - } - - void expr_shift( ExprShift: expr_shift ) - { - switch ExprShift - case [expr_shift Op: shift_op expr_add] - { - expr_shift( ExprShift._expr_shift ) - send Parser [Op] - expr_add( ExprShift.expr_add ) - } - case [expr_add] - { - expr_add( ExprShift.expr_add ) - } - } - - void expr_test( ExprTest: expr_test ) - { - switch ExprTest - case [expr_test Op: test_op expr_shift] - { - expr_test( ExprTest._expr_test ) - send Parser [Op] - expr_shift( ExprTest.expr_shift ) - } - case [expr_shift] - { - expr_shift( ExprTest.expr_shift ) - } - } - - void expr( Expr: expr ) - { - expr_test( Expr.expr_test ) - } - - void type( Type: type ) - { - switch Type - case "s8" - send Parser ['int16 '] - case "s16" - send Parser ['int16 '] - case "s32" - send Parser ['int32 '] - case "s64" - send Parser ['int64 '] - case "s128" - send Parser ['long long '] - case "uint" - send Parser ['uint32 '] - default - send Parser [Type] - } - - void number( Number: number ) - { - switch Number - case [`u `( uint `) ] - send Parser "[Number.uint]u" - case [`c `( uint `) ] - send Parser "[Number.uint]" - default - send Parser [Number] - } - - void num_list( NumList: num_list ) - { - for Number: number in NumList - send Parser "[number( Number )], " - } - - void stmt( Stmt: stmt ) - { - switch Stmt - case [EH: embedded_host] - { - send Parser - [embedded_host( EH )] - } - case [Array: static_array] { - send Parser - "const array\[[type(Array.type)]\] " - "[Array.ident] = \[ [num_list(Array.num_list)] \]; - } - case [Value: static_value] { - send Parser - "const [Value.type] [Value.ident] = [Value.number]; - } - case [ - `if `( IfExpr: expr `) IfStmt: stmt - ElseIfClauseList: else_if_clause* ElseClauseOpt: else_clause? - ] { - send Parser - "if ( [expr(IfExpr)] ) - " [flow_stmt(IfStmt)] - - for ElseIfClause: else_if_clause in repeat( ElseIfClauseList ) { - match ElseIfClause - ['else if (' ElseIfExpr: expr ')' ElseIfStmt: stmt] - - send Parser - "else if ( [expr(ElseIfExpr)] ) - " [flow_stmt(ElseIfStmt)] - } - - if ( match ElseClauseOpt ['else' ElseStmt: stmt] ) { - send Parser - "else - " [flow_stmt(ElseStmt)] - } - } - case [`while `( WhileExpr: expr `) WhileStmt: stmt] { - send Parser - "while ( [expr(WhileExpr)] ) - " [flow_stmt(WhileStmt)] - } - case [`switch `( SwitchExpr: expr `) `{ StmtList: stmt* `}] { - - require StmtList - [`case E1: expr `{ Inner: stmt* `} Rest: stmt*] - - send Parser - "if ( [expr(SwitchExpr)] == [expr(E1)] ) { - " [stmt_list(Inner)] - "} - - for S: stmt in repeat(Rest) { - switch S - case [`case E1: expr `{ Inner: stmt* `}] - { - send Parser - "else if ( [expr(SwitchExpr)] == [expr(E1)] ) { - " [stmt_list(Inner)] - "} - } - case - [`default `{ Inner: stmt* `}] - { - send Parser - "else { - " [stmt_list(Inner)] - "} - } - } - - send Parser - "; - } - case [ExprExpr: expr Semi: `;] { - send Parser - [expr(ExprExpr) Semi] - } - case [`{ TL: stmt* `}] { - send Parser - "if ( 1 ) { - " [stmt_list(TL)] - "} - } - case [ - TypeList: opt_const Type: type - Ident: ident OptInit: opt_init Semi: `; - ] - { - send Parser - [TypeList type(Type) Ident] - - if match OptInit [E: `= expr] { - send Parser - [E expr(OptInit.expr)] - } - - send Parser - [Semi] - } - case [Export: export_stmt] - { - send Parser - "#define [Export.ident] [number(Export.number)] - } - case ['fallthrough' ';'] - { - # Nothing needed here. - } - case [Index: index_stmt] - { - send Parser - "int [Index.ident] - - if match Index.opt_init [E: `= expr] { - send Parser - [E expr(Index.opt_init.expr)] - } - else { - send Parser - " = 0" - } - - send Parser "; - } - case [case_block] - { - send Parser - "case [expr( Stmt.case_block.expr )]: - "[stmt_list( Stmt.case_block._repeat_stmt )] - "break; - } - case [default_block] - { - send Parser - "default: - "[stmt_list( Stmt.default_block._repeat_stmt )] - "break; - } - case [case_label] - { - send Parser - "case [expr( Stmt.case_label.expr )]: - } - case [AS: assign_stmt] - { - send Parser - "[lvalue(AS.LValue) AS.assign_op expr(AS.expr)]; - } - default { - # catches unspecified cases - send Parser [Stmt] - } - } - - void flow_stmt( Stmt: stmt ) - { - switch Stmt - case [`{ TL: stmt* `}] { - send Parser - "{ - " [stmt_list(TL)] - "} - } - default { - stmt( Stmt ) - } - } - - void stmt_list( StmtList: stmt* ) - { - for Stmt: stmt in repeat( StmtList ) - stmt( Stmt ) - } - - void trans( Output: stream, Start: start ) - { - Parser = new parser<crack_out::crack_out>() - - if ( Start.opt_bom.bom ) - send Output [Start.opt_bom.bom] - - stmt_list( Start._repeat_stmt ) - - CO: crack_out::crack_out = Parser->finish() - - if CO { - send Output - [CO] - } - else { - send stderr - "failed to parse output: [Parser->error] - } - } -end - -void trans( Output: stream, Start: start ) -{ - crack_gen::trans( Output, Start ) -} - -include 'rlhc-main.lm' diff --git a/ragel/host-crack/rlparse.lm b/ragel/host-crack/rlparse.lm deleted file mode 100644 index 100a9223..00000000 --- a/ragel/host-crack/rlparse.lm +++ /dev/null @@ -1,202 +0,0 @@ -include 'ragel.lm' -include 'rlreduce.lm' - -namespace inline - lex - literal `fpc `fc `fcurs `ftargs - `fentry `fhold `fexec `fgoto `fnext - `fcall `fret `fbreak `fncall `fnret `fnbreak - - token ident /ident/ - token number /digit+/ - token hex_number /'0x' [0-9a-fA-F]+/ - token dec_number /'0x' [0-9a-fA-F]+/ - - token comment - / c_comment | cpp_comment / - - token string - / s_literal | d_literal / - - token whitespace - / ( [ \t] | NL )+ / - - literal - `{ `} `:: `* `, `( `) `; - - token var_ref - / "$" [a-zA-Z_][a-zA-Z_0-9]* / - { - if GblActionParams - { - input->push( make_token( - typeid<var_ref>, input->pull( match_length ) ) ) - } - else - { - # Just pull one char. Don't consume the word because it may - # be a keyword. - input->push( make_token( - typeid<c_any>, input->pull( 1 ) ) ) - } - } - - token c_any - / any / - end - -end - -namespace host - lex - literal `%%{ - - token close_inc /'}--%%'/ - { - input->push( make_token( typeid<close_inc>, input->pull( match_length ) ) ) - restoreGlobals() - } - - token close_imp /'}++%%'/ - { - input->push( make_token( typeid<close_imp>, input->pull( match_length ) ) ) - restoreGlobals() - } - - token slr / '%%' [^{] [^\n]* '\n' / - { - # Translates single line to multi-line - input->pull( 2 ) - R: str = input->pull( match_length - 3 ) - input->push( "}%%" ) - input->push( R ) - input->push( "%%{" ) - } - - rl NL / '\n' / - - rl s_literal - / "'" ([^'\\\n] | '\\' (any | NL))* "'" / - - rl d_literal - / '"' ([^"\\] | NL | '\\' (any | NL))* '"' / - - literal `define `= - - token ident /ident "'"?/ - token number /digit+/ - token hex_number /'0x' [0-9a-fA-F]+/ - - token comment - / c_comment | cpp_comment / - - token string - / s_literal | d_literal / - - token whitespace - / ( [ \t] | NL )+ / - - token c_any / any / - end - - def tok - [`define whitespace ident whitespace? number] :ImportDefNum - | [`define whitespace ident whitespace? string] :ImportDefStr - | [ident whitespace? `= whitespace? number] :ImportAssignNum - | [ident whitespace? `= whitespace? string] :ImportAssignStr - | [`define] :Def - | [`=] :Eq - | [ident] :Ident - | [number] :Number - | [hex_number] :HexNumber - | [comment] :Comment - | [string] :String - | [whitespace] :Whitespace - | [c_any] :Any -end - -reduction TopLevel - - # Pass Through. - # def tok - # [`define ident number] :Def1 - # | [`define ident string] :Def2 - # | [ident `= number] :Ass1 - # | [ident `= string] :Ass2 - # [`define whitespace ident whitespace? number] :ImportDefNum - # | [`define whitespace ident whitespace? string] :ImportDefStr - # | [ident whitespace? `= whitespace? number] :ImportAssignNum - # | [ident whitespace? `= whitespace? string] :ImportAssignStr - # | [`define] :Def - # | [`=] :Eq - # | [ident] :Ident - # | [number] :Number - # | [hex_number] :HexNumber - # | [comment] :Comment - # | [string] :String - # | [whitespace] :Whitespace - # | [c_any] :Any - - host::tok :ImportDefNum - { - if ( isImport ) - { - Literal *lit = new Literal( @number, - false /* $number->neg */, $number->data, - $number->length, Literal::Number ); - - string name( $ident->data, $ident->length ); - import( @ident, name, lit ); - } - } - host::tok :ImportDefStr - { - if ( isImport ) - { - Literal *lit = new Literal( @string, false, - $string->data, $string->length, Literal::LitString ); - string name( $ident->data, $ident->length ); - import( @ident, name, lit ); - } - } - host::tok :ImportAssignNum - { - if ( isImport ) - { - Literal *lit = new Literal( @number, - false /*$number->neg */, $number->data, - $number->length, Literal::Number ); - string name( $ident->data, $ident->length ); - import( @ident, name, lit ); - } - } - host::tok :ImportAssignStr - { - if ( isImport ) - { - Literal *lit = new Literal( @string, false, - $string->data, $string->length, Literal::LitString ); - - string name( $ident->data, $ident->length ); - import( @ident, name, lit ); - } - } - -end - -export RagelError: str - -# File name. The open is expected to succeed. It is tested before the colm -# program is called. -A: list_el<str> = argv->pop_head_el() -GblFileName = A->value - -# Remaining items are include paths. -while ( argv->length > 0 ) { - A = argv->pop_head_el() - GblIncludePaths->push_tail_el( A ) -} - -Stream: stream = open( GblFileName, "r" ) -reduce TopLevel start[ Stream ] -RagelError = error |