Top 1,000 Features Creators Events Podcasts Extensions Blog Explorer CSV Download


< >

Ragel is an open source programming language created in 2007.

#627on PLDB 17Years Old 66Repos
Download source code:
git clone

Ragel is a finite-state machine compiler and a parser generator. Initially Ragel supported output for C, C++ and Assembly source code,. Although subsequently extended to support several other languages (said to be Objective C, D, Go, Ruby, and Java) this support of other languages was withdrawn . Read more on Wikipedia...

Example from the web:
=begin %%{ machine simple_scanner; action Emit { emit data[(ts+8)..(te-7)].pack('c*') } foo = 'STARTFOO' any+ :>> 'ENDFOO'; main := |* foo => Emit; any; *|; }%% =end # Scans a file for "STARTFOO[...]ENDFOO" blocks and outputs their contents. # # ENV['CHUNK_SIZE'] determines how much of the file to read in at a time, allowing you to control memory usage. # # Uses ragel's scanner functionality even though it's not strictly necessary. class SimpleScanner attr_reader :path def initialize(path) @path = path %% write data; # % (this fixes syntax highlighting) end def emit(foo) $stdout.puts foo end def perform # So that ragel doesn't try to get it from data.length pe = :ignored eof = :ignored %% write init; # % (this fixes syntax highlighting) leftover = [] do |f| while chunk =['CHUNK_SIZE'].to_i) data = leftover + chunk.unpack('c*') p ||= 0 pe = data.length %% write exec; # % (this fixes syntax highlighting) if ts leftover = data[] p = p - ts ts = 0 else leftover = [] p = 0 end end end end end s = ARGV[0] s.perform

Language features

Feature Supported Token Example
# [+-]?[0-9]+
# 0x[0-9A-Fa-f]+
# A comment
Line Comments #
# A comment
Semantic Indentation X

View source

- Build the next great programming language · About · Resources · Acknowledgements · Part of the World Wide Scroll