What are the lines of% lex and / lex in jison?

The code snippet below can be found at http://zaach.imtqy.com/jison/demos/calc/ , as well as on the jison documentation page. After reading the jison, lex and flex documentation, I still don't fully understand the syntax of% lex and / lex. Is this specific to the jison scanner generator? Is value the only function providing json output, which is later shown in the documentation? I only ask because the jison documentation does not explicitly explain its purpose, and the flex / lex rules do not seem to allow this syntax.

/* description: Parses end executes mathematical expressions. */

/* lexical grammar */
%lex

%%
\s+                   /* skip whitespace */
[0-9]+("."[0-9]+)?\b  return 'NUMBER';
"*"                   return '*';
"/"                   return '/';
"-"                   return '-';
"+"                   return '+';
"^"                   return '^';
"("                   return '(';
")"                   return ')';
"PI"                  return 'PI';
"E"                   return 'E';
<<EOF>>               return 'EOF';

/lex
+4
source share
1 answer

%lex /lex , . %lex /lex .

bison flex lexer ( " " Jison) .l .y. , bison flex ( yacc/lex) . ( , bison flex, , - .)

, , Jison bison flex, . , , bison flex.

+4
source

Source: https://habr.com/ru/post/1540317/


All Articles