Code Monkey home page Code Monkey logo

cmake-ragel's Introduction

CMake module for building Ragel machine files.

2014-05-10, Georg Sauthoff [email protected]

Background

Ragel is a parser generator for regular languages with some advanced features. In some aspects it is similar to Lex/Flex but without the need to use a certain buffering scheme, more flexible, not restricted to a scanner approach and has rich support for regular language operators and user defined actions. The ragel binary takes a regular state machine description as input and generates efficient C/C++/... code.

Examples

The example CMakeLists.txt project shows how to use the FindRAGEL.cmake module (additional comments are in the module itself). It builds 2 Ragel example programs (located in the example sub-directory).

You can build them like this:

$ mkdir build
$ cd build
$ cmake ../CMakeLists.txt ..
-- The CXX compiler identification is GNU 4.8.2
-- The C compiler identification is GNU 4.8.2
-- Check for working CXX compiler: /usr/lib64/ccache/c++
-- Check for working CXX compiler: /usr/lib64/ccache/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc
-- Check for working C compiler: /usr/lib64/ccache/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Found RAGEL: /usr/bin/ragel (found suitable version "6.6", minimum required is "6.6") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gms/program/cmake_ragel/build
$ make                            
Scanning dependencies of target nested
[ 25%] Building CXX object CMakeFiles/nested.dir/nested.cc.o
Linking CXX executable nested
[ 50%] Built target nested
[ 75%] [RAGEL][number] Compiling state machine with Ragel 6.6
Scanning dependencies of target number
[100%] Building C object CMakeFiles/number.dir/number.c.o
Linking C executable number
[100%] Built target number

You can also use an alternative build file generator:

$ mkdir build
$ cd build
$ cmake ../CMakeLists.txt -G Ninja ..
-- The CXX compiler identification is GNU 4.8.2
-- The C compiler identification is GNU 4.8.2
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Found RAGEL: /usr/bin/ragel (found suitable version "6.6", minimum required is "6.6") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gms/program/cmake_ragel/build
$ ninja-build 
[6/6] Linking CXX executable nested

Usage notes for the examples are included in the source files.

See also

There is also a ticket on adding a FindRAGEL module in the cmake bug tracker.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.