fbpx
Wikipedia

Ragel

Ragel is a finite-state machine compiler and a parser generator. Initially Ragel supported output for C, C++ and Assembly source code,[4] and was expanded to support several other languages including Objective-C, D, Go, Ruby, and Java.[5] Additional language support is also in development.[6] It supports the generation of table or control flow driven state machines from regular expressions[7] and/or state charts and can also build lexical analysers via the longest-match method. Ragel specifically targets text parsing and input validation.[8]

Ragel
Developer(s)Adrian Thurston[1]
Stable release
7.0.4[2]  / 15 February 2021; 3 years ago (15 February 2021)
Preview release
7.0.4 / February 16, 2021; 3 years ago (2021-02-16)
Repository
  • github.com/adrian-thurston/ragel
Written inC++
Operating systemUnix-like, Windows
TypeState machine compiler
License"Ragel 6 remains under GPL v2 [generated code] covered by the MIT (or GPL v2)".[3]
Ragel 7: MIT License
Websitewww.colm.net/open-source/ragel/

Overview edit

Ragel supports the generation of table or control flow driven state machines from regular expressions and/or state charts and can also build lexical analysers via the longest-match method. A unique feature of Ragel is that user actions can be associated with arbitrary state machine transitions using operators that are integrated into the regular expressions. Ragel also supports visualization of the generated machine via graphviz.

 

The above graph represents a state-machine that takes user input as a series of bytes representing ASCII characters and control codes. 48..57 is equivalent to the regular expression [0-9] (i.e. any digit), so only sequences beginning with a digit can be recognised. If 10 (line feed) is encountered, we're done. 46 is the decimal point ('.'), 43 and 45 are positive and negative signs ('+', '-') and 69/101 is uppercase/lowercase 'e' (to indicate a number in scientific format). As such it will recognize the following properly:

2 45 055 78.1 2e5 78.3e12 69.0e-3 3e+3 

but not:

.3 46. -5 3.e2 2e5.1 

Syntax edit

Ragel's input is a regular expression only in the sense that it describes a regular language; it is usually not written in a concise regular expression, but written out into multiple parts like in Extended Backus–Naur form. For example, instead of supporting POSIX character classes in regex syntax, Ragel implements them as built-in production rules. As with usual parser generators, Ragel allows for handling code for productions to be written with the syntax.[9] The code yielding the above example from the official website is:

action dgt { printf("DGT: %c\n", fc); } action dec { printf("DEC: .\n"); } action exp { printf("EXP: %c\n", fc); } action exp_sign { printf("SGN: %c\n", fc); } action number { /*NUMBER*/ } # A floating-point number literal. number = (  [0-9]+ $dgt ( '.' @dec [0-9]+ $dgt )?  ( [eE] ( [+\-] $exp_sign )? [0-9]+ $exp )? ) %number; main := ( number '\n' )*; 

See also edit

References edit

  1. ^ Dr. Adrian D. Thurston at complang.org Last changed: Jul 14, 2013
  2. ^ "Release 7.0.4". 15 February 2021. Retrieved 3 March 2021.
  3. ^ "Ragel State Machine Compiler". www.colm.net. Retrieved 2019-11-19.
  4. ^ Adrian D. Thurston. "Parsing Computer Languages with an Automaton Compiled from a Single Regular Expression. 2012-09-07 at the Wayback Machine" In: 11th International Conference on Implementation and Application of Automata (CIAA 2006), Lecture Notes in Computer Science, volume 4094, p. 285-286, Taipei, Taiwan, August 2006.
  5. ^ "Ragel User Guide" (PDF). March 2017.
  6. ^ "Additional Target Languages Return to Ragel 7". 18 May 2018.
  7. ^ Liqun Chen, Chris J. Mitchell, Andrew Martin (2009) Trusted Computing: Second International Conference, Trust 2009 Oxford, UK, April 6–8, 2009, Proceedings. p. 111
  8. ^ Omar Badreddin (2010) "Umple: a model-oriented programming language." Software Engineering, 2010 ACM/IEEE 32nd International Conference on. Vol. 2. IEEE, 2010.
  9. ^ "Ragel User Guide" (PDF). March 2017.

External links edit

  •   Media related to Ragel at Wikimedia Commons
  • Official website

ragel, finite, state, machine, compiler, parser, generator, initially, supported, output, assembly, source, code, expanded, support, several, other, languages, including, objective, ruby, java, additional, language, support, also, development, supports, genera. Ragel is a finite state machine compiler and a parser generator Initially Ragel supported output for C C and Assembly source code 4 and was expanded to support several other languages including Objective C D Go Ruby and Java 5 Additional language support is also in development 6 It supports the generation of table or control flow driven state machines from regular expressions 7 and or state charts and can also build lexical analysers via the longest match method Ragel specifically targets text parsing and input validation 8 RagelDeveloper s Adrian Thurston 1 Stable release7 0 4 2 15 February 2021 3 years ago 15 February 2021 Preview release7 0 4 February 16 2021 3 years ago 2021 02 16 Repositorygithub wbr com wbr adrian thurston wbr ragelWritten inC Operating systemUnix like WindowsTypeState machine compilerLicense Ragel 6 remains under GPL v2 generated code covered by the MIT or GPL v2 3 Ragel 7 MIT LicenseWebsitewww wbr colm wbr net wbr open source wbr ragel wbr Contents 1 Overview 2 Syntax 3 See also 4 References 5 External linksOverview editRagel supports the generation of table or control flow driven state machines from regular expressions and or state charts and can also build lexical analysers via the longest match method A unique feature of Ragel is that user actions can be associated with arbitrary state machine transitions using operators that are integrated into the regular expressions Ragel also supports visualization of the generated machine via graphviz nbsp The above graph represents a state machine that takes user input as a series of bytes representing ASCII characters and control codes 48 57 is equivalent to the regular expression 0 9 i e any digit so only sequences beginning with a digit can be recognised If 10 line feed is encountered we re done 46 is the decimal point 43 and 45 are positive and negative signs and 69 101 is uppercase lowercase e to indicate a number in scientific format As such it will recognize the following properly 2 45 055 78 1 2e5 78 3e12 69 0e 3 3e 3 but not 3 46 5 3 e2 2e5 1Syntax editRagel s input is a regular expression only in the sense that it describes a regular language it is usually not written in a concise regular expression but written out into multiple parts like in Extended Backus Naur form For example instead of supporting POSIX character classes in regex syntax Ragel implements them as built in production rules As with usual parser generators Ragel allows for handling code for productions to be written with the syntax 9 The code yielding the above example from the official website is action dgt printf DGT c n fc action dec printf DEC n action exp printf EXP c n fc action exp sign printf SGN c n fc action number NUMBER A floating point number literal number 0 9 dgt dec 0 9 dgt eE exp sign 0 9 exp number main number n See also edit nbsp Free and open source software portal Comparison of parser generators Executable UML Finite state machine Regular expression Thompson s construction the algorithm used by Ragel Umple Helsinki Finite State Technology HFST References edit Dr Adrian D Thurston at complang org Last changed Jul 14 2013 Release 7 0 4 15 February 2021 Retrieved 3 March 2021 Ragel State Machine Compiler www colm net Retrieved 2019 11 19 Adrian D Thurston Parsing Computer Languages with an Automaton Compiled from a Single Regular Expression Archived 2012 09 07 at the Wayback Machine In 11th International Conference on Implementation and Application of Automata CIAA 2006 Lecture Notes in Computer Science volume 4094 p 285 286 Taipei Taiwan August 2006 Ragel User Guide PDF March 2017 Additional Target Languages Return to Ragel 7 18 May 2018 Liqun Chen Chris J Mitchell Andrew Martin 2009 Trusted Computing Second International Conference Trust 2009 Oxford UK April 6 8 2009 Proceedings p 111 Omar Badreddin 2010 Umple a model oriented programming language Software Engineering 2010 ACM IEEE 32nd International Conference on Vol 2 IEEE 2010 Ragel User Guide PDF March 2017 External links edit nbsp Media related to Ragel at Wikimedia Commons Official website Retrieved from https en wikipedia org w index php title Ragel amp oldid 1210852114, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.