123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530 |
- /* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- %skeleton "lalr1.cc" /* -*- C++ -*- */
- %require "3.0.0"
- %defines
- %define parser_class_name {Dhcp4Parser}
- %define api.prefix {parser4_}
- %define api.token.constructor
- %define api.value.type variant
- %define api.namespace {isc::dhcp}
- %define parse.assert
- %code requires
- {
- #include <string>
- #include <cc/data.h>
- #include <dhcp/option.h>
- #include <boost/lexical_cast.hpp>
- #include <dhcp4/parser_context_decl.h>
- using namespace isc::dhcp;
- using namespace isc::data;
- using namespace std;
- }
- // The parsing context.
- %param { isc::dhcp::Parser4Context& ctx }
- %locations
- %define parse.trace
- %define parse.error verbose
- %code
- {
- #include <dhcp4/parser_context.h>
- }
- %define api.token.prefix {TOKEN_}
- // Tokens in an order which makes sense and related to the intented use.
- // Actual regexps for tokens are defined in dhcp4_lexer.ll.
- %token
- END 0 "end of file"
- COMMA ","
- COLON ":"
- LSQUARE_BRACKET "["
- RSQUARE_BRACKET "]"
- LCURLY_BRACKET "{"
- RCURLY_BRACKET "}"
- NULL_TYPE "null"
- DHCP4 "Dhcp4"
- INTERFACES_CONFIG "interfaces-config"
- INTERFACES "interfaces"
- ECHO_CLIENT_ID "echo-client-id"
- MATCH_CLIENT_ID "match-client-id"
- NEXT_SERVER "next-server"
- SERVER_HOSTNAME "server-hostname"
- BOOT_FILE_NAME "boot-file-name"
- LEASE_DATABASE "lease-database"
- HOSTS_DATABASE "hosts-database"
- TYPE "type"
- USER "user"
- PASSWORD "password"
- HOST "host"
- PERSIST "persist"
- LFC_INTERVAL "lfc-interval"
- READONLY "readonly"
- VALID_LIFETIME "valid-lifetime"
- RENEW_TIMER "renew-timer"
- REBIND_TIMER "rebind-timer"
- DECLINE_PROBATION_PERIOD "decline-probation-period"
- SUBNET4 "subnet4"
- SUBNET_4O6_INTERFACE "4o6-interface"
- SUBNET_4O6_INTERFACE_ID "4o6-interface-id"
- SUBNET_4O6_SUBNET "4o6-subnet"
- OPTION_DEF "option-def"
- OPTION_DATA "option-data"
- NAME "name"
- DATA "data"
- CODE "code"
- SPACE "space"
- CSV_FORMAT "csv-format"
- RECORD_TYPES "record-types"
- ENCAPSULATE "encapsulate"
- ARRAY "array"
- POOLS "pools"
- POOL "pool"
- SUBNET "subnet"
- INTERFACE "interface"
- INTERFACE_ID "interface-id"
- ID "id"
- RAPID_COMMIT "rapid-commit"
- RESERVATION_MODE "reservation-mode"
- HOST_RESERVATION_IDENTIFIERS "host-reservation-identifiers"
- CLIENT_CLASSES "client-classes"
- TEST "test"
- CLIENT_CLASS "client-class"
- RESERVATIONS "reservations"
- DUID "duid"
- HW_ADDRESS "hw-address"
- CIRCUIT_ID "circuit-id"
- CLIENT_ID "client-id"
- HOSTNAME "hostname"
- RELAY "relay"
- IP_ADDRESS "ip-address"
- HOOKS_LIBRARIES "hooks-libraries"
- LIBRARY "library"
- PARAMETERS "parameters"
- EXPIRED_LEASES_PROCESSING "expired-leases-processing"
- SERVER_ID "server-id"
- IDENTIFIER "identifier"
- HTYPE "htype"
- TIME "time"
- ENTERPRISE_ID "enterprise-id"
- DHCP4O6_PORT "dhcp4o6-port"
- VERSION "version"
- CONTROL_SOCKET "control-socket"
- SOCKET_TYPE "socket-type"
- SOCKET_NAME "socket-name"
- DHCP_DDNS "dhcp-ddns"
- /// @todo: Implement proper parsing for those parameters in Dhcp4/dhcp-ddns/*.
- /// This should be part of the #5043 ticket. Listing the keywords here for
- /// completeness.
- // These are tokens defined in Dhcp4/dhcp-ddns/*
- // They're not
- // ENABLE_UPDATES "enable-updates"
- // SERVER_IP "server-ip"
- // SENDER_IP "sender-ip"
- // SENDER_PORT "sender-port"
- // MAX_QUEUE_SIZE "max-queue-size"
- // NCR_PROTOCOL "ncr-protocol"
- // NCR_FORMAT "ncr-format"
- // ALWAYS_INCLUDE_FQDN "always-include-fqdn"
- // OVERRDIDE_NO_UPDATE "override-no-update"
- // OVERRDIDE_CLIENT_UPDATE "override-client-update"
- // REPLACE_CLIENT_NAME "replace-client-name"
- // GENERATED_PREFIX "generated-prefix"
- // QUALIFYING_SUFFIX "qualifying-suffix"
- LOGGING "Logging"
- LOGGERS "loggers"
- OUTPUT_OPTIONS "output_options"
- OUTPUT "output"
- DEBUGLEVEL "debuglevel"
- SEVERITY "severity"
- DHCP6 "Dhcp6"
- DHCPDDNS "DhcpDdns"
- // Not real tokens, just a way to signal what the parser is expected to
- // parse.
- TOPLEVEL_JSON
- TOPLEVEL_DHCP4
- SUB_DHCP4
- SUB_INTERFACES4
- SUB_SUBNET4
- SUB_POOL4
- SUB_RESERVATION
- SUB_OPTION_DEF
- SUB_OPTION_DATA
- SUB_HOOKS_LIBRARY
- ;
- %token <std::string> STRING "constant string"
- %token <int64_t> INTEGER "integer"
- %token <double> FLOAT "floating point"
- %token <bool> BOOLEAN "boolean"
- %type <ElementPtr> value
- %type <ElementPtr> version_value
- %printer { yyoutput << $$; } <*>;
- %%
- // The whole grammar starts with a map, because the config file
- // constists of Dhcp, Logger and DhcpDdns entries in one big { }.
- // We made the same for subparsers at the exception of the JSON value.
- %start start;
- start: TOPLEVEL_JSON { ctx.ctx_ = ctx.NO_KEYWORD; } sub_json
- | TOPLEVEL_DHCP4 { ctx.ctx_ = ctx.CONFIG; } syntax_map
- | SUB_DHCP4 { ctx.ctx_ = ctx.DHCP4; } sub_dhcp4
- | SUB_INTERFACES4 { ctx.ctx_ = ctx.INTERFACES_CONFIG; } sub_interfaces4
- | SUB_SUBNET4 { ctx.ctx_ = ctx.SUBNET4; } sub_subnet4
- | SUB_POOL4 { ctx.ctx_ = ctx.POOLS; } sub_pool4
- | SUB_RESERVATION { ctx.ctx_ = ctx.RESERVATIONS; } sub_reservation
- | SUB_OPTION_DEF { ctx.ctx_ = ctx.OPTION_DEF; } sub_option_def
- | SUB_OPTION_DATA { ctx.ctx_ = ctx.OPTION_DATA; } sub_option_data
- | SUB_HOOKS_LIBRARY { ctx.ctx_ = ctx.HOOKS_LIBRARIES; } sub_hooks_library
- ;
- // ---- generic JSON parser ---------------------------------
- // Note that ctx_ is NO_KEYWORD here
- // Values rule
- value: INTEGER { $$ = ElementPtr(new IntElement($1, ctx.loc2pos(@1))); }
- | FLOAT { $$ = ElementPtr(new DoubleElement($1, ctx.loc2pos(@1))); }
- | BOOLEAN { $$ = ElementPtr(new BoolElement($1, ctx.loc2pos(@1))); }
- | STRING { $$ = ElementPtr(new StringElement($1, ctx.loc2pos(@1))); }
- | NULL_TYPE { $$ = ElementPtr(new NullElement(ctx.loc2pos(@1))); }
- | map2 { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); }
- | list_generic { $$ = ctx.stack_.back(); ctx.stack_.pop_back(); }
- ;
- sub_json: value {
- // Push back the JSON value on the stack
- ctx.stack_.push_back($1);
- };
- map2: LCURLY_BRACKET {
- // This code is executed when we're about to start parsing
- // the content of the map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } map_content RCURLY_BRACKET {
- // map parsing completed. If we ever want to do any wrap up
- // (maybe some sanity checking), this would be the best place
- // for it.
- };
- // Assignments rule
- map_content: %empty // empty map
- | not_empty_map
- ;
- not_empty_map: STRING COLON value {
- // map containing a single entry
- ctx.stack_.back()->set($1, $3);
- }
- | not_empty_map COMMA STRING COLON value {
- // map consisting of a shorter map followed by
- // comma and string:value
- ctx.stack_.back()->set($3, $5);
- }
- ;
- list_generic: LSQUARE_BRACKET {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(l);
- } list_content RSQUARE_BRACKET {
- // list parsing complete. Put any sanity checking here
- };
- // This one is used in syntax parser.
- list2: LSQUARE_BRACKET {
- // List parsing about to start
- } list_content RSQUARE_BRACKET {
- // list parsing complete. Put any sanity checking here
- //ctx.stack_.pop_back();
- };
- list_content: %empty // Empty list
- | not_empty_list
- ;
- not_empty_list: value {
- // List consisting of a single element.
- ctx.stack_.back()->add($1);
- }
- | not_empty_list COMMA value {
- // List ending with , and a value.
- ctx.stack_.back()->add($3);
- }
- ;
- // ---- generic JSON parser ends here ----------------------------------
- // ---- syntax checking parser starts here -----------------------------
- // Unknown keyword in a map
- unknown_map_entry: STRING COLON {
- const std::string& where = ctx.contextName();
- const std::string& keyword = $1;
- error(@1,
- "got unexpected keyword \"" + keyword + "\" in " + where + " map.");
- };
- // This defines the top-level { } that holds Dhcp6, Dhcp4, DhcpDdns or Logging
- // objects.
- syntax_map: LCURLY_BRACKET {
- // This code is executed when we're about to start parsing
- // the content of the map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } global_objects RCURLY_BRACKET {
- // map parsing completed. If we ever want to do any wrap up
- // (maybe some sanity checking), this would be the best place
- // for it.
- };
- // This represents top-level entries: Dhcp6, Dhcp4, DhcpDdns, Logging
- global_objects: global_object
- | global_objects COMMA global_object
- ;
- // This represents a single top level entry, e.g. Dhcp6 or DhcpDdns.
- global_object: dhcp4_object
- | logging_object
- | dhcp6_json_object
- | dhcpddns_json_object
- | unknown_map_entry
- ;
- dhcp4_object: DHCP4 {
- // This code is executed when we're about to start parsing
- // the content of the map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("Dhcp4", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.DHCP4);
- } COLON LCURLY_BRACKET global_params RCURLY_BRACKET {
- // map parsing completed. If we ever want to do any wrap up
- // (maybe some sanity checking), this would be the best place
- // for it.
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // subparser: similar to the corresponding rule but without parent
- // so the stack is empty at the rule entry.
- sub_dhcp4: LCURLY_BRACKET {
- // Parse the Dhcp6 map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } global_params RCURLY_BRACKET {
- // parsing completed
- };
- global_params: global_param
- | global_params COMMA global_param
- ;
- // These are the parameters that are allowed in the top-level for
- // Dhcp4.
- global_param: valid_lifetime
- | renew_timer
- | rebind_timer
- | decline_probation_period
- | subnet4_list
- | interfaces_config
- | lease_database
- | hosts_database
- | host_reservation_identifiers
- | client_classes
- | option_def_list
- | option_data_list
- | hooks_libraries
- | expired_leases_processing
- | server_id
- | dhcp4o6_port
- | version
- | control_socket
- | dhcp_ddns
- | echo_client_id
- | match_client_id
- | next_server
- | unknown_map_entry
- ;
- valid_lifetime: VALID_LIFETIME COLON INTEGER {
- ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("valid-lifetime", prf);
- };
- renew_timer: RENEW_TIMER COLON INTEGER {
- ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("renew-timer", prf);
- };
- rebind_timer: REBIND_TIMER COLON INTEGER {
- ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("rebind-timer", prf);
- };
- decline_probation_period: DECLINE_PROBATION_PERIOD COLON INTEGER {
- ElementPtr dpp(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("decline-probation-period", dpp);
- };
- echo_client_id: ECHO_CLIENT_ID COLON BOOLEAN {
- ElementPtr echo(new BoolElement($3, ctx.loc2pos(@1)));
- ctx.stack_.back()->set("echo-client-id", echo);
- };
- match_client_id: MATCH_CLIENT_ID COLON BOOLEAN {
- ElementPtr match(new BoolElement($3, ctx.loc2pos(@1)));
- ctx.stack_.back()->set("match-client-id", match);
- };
- interfaces_config: INTERFACES_CONFIG {
- ElementPtr i(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("interfaces-config", i);
- ctx.stack_.push_back(i);
- ctx.enter(ctx.INTERFACES_CONFIG);
- } COLON LCURLY_BRACKET interface_config_map RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- sub_interfaces4: LCURLY_BRACKET {
- // Parse the interfaces-config map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } interface_config_map RCURLY_BRACKET {
- // parsing completed
- };
- interface_config_map: INTERFACES {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("interfaces", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.NO_KEYWORD);
- } COLON list2 {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- lease_database: LEASE_DATABASE {
- ElementPtr i(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("lease-database", i);
- ctx.stack_.push_back(i);
- ctx.enter(ctx.LEASE_DATABASE);
- } COLON LCURLY_BRACKET database_map_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- hosts_database: HOSTS_DATABASE {
- ElementPtr i(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("hosts-database", i);
- ctx.stack_.push_back(i);
- ctx.enter(ctx.HOSTS_DATABASE);
- } COLON LCURLY_BRACKET database_map_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- database_map_params: database_map_param
- | database_map_params COMMA database_map_param
- ;
- database_map_param: type
- | user
- | password
- | host
- | name
- | persist
- | lfc_interval
- | readonly
- | unknown_map_entry
- ;
- type: TYPE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr prf(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("type", prf);
- ctx.leave();
- };
- user: USER {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr user(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("user", user);
- ctx.leave();
- };
- password: PASSWORD {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr pwd(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("password", pwd);
- ctx.leave();
- };
- host: HOST {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr h(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("host", h);
- ctx.leave();
- };
- name: NAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("name", name);
- ctx.leave();
- };
- persist: PERSIST COLON BOOLEAN {
- ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("persist", n);
- };
- lfc_interval: LFC_INTERVAL COLON INTEGER {
- ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("lfc-interval", n);
- };
- readonly: READONLY COLON BOOLEAN {
- ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("readonly", n);
- };
- duid_id : DUID {
- ElementPtr duid(new StringElement("duid", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(duid);
- };
- host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("host-reservation-identifiers", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.HOST_RESERVATION_IDENTIFIERS);
- } COLON LSQUARE_BRACKET host_reservation_identifiers_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- host_reservation_identifiers_list: host_reservation_identifier
- | host_reservation_identifiers_list COMMA host_reservation_identifier
- ;
- host_reservation_identifier: duid_id
- | hw_address_id
- | circuit_id
- | client_id
- ;
- hw_address_id : HW_ADDRESS {
- ElementPtr hwaddr(new StringElement("hw-address", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(hwaddr);
- };
- circuit_id : CIRCUIT_ID {
- ElementPtr circuit(new StringElement("circuit-id", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(circuit);
- };
- client_id : CLIENT_ID {
- ElementPtr client(new StringElement("client-id", ctx.loc2pos(@1)));
- ctx.stack_.back()->add(client);
- };
- hooks_libraries: HOOKS_LIBRARIES {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("hooks-libraries", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.HOOKS_LIBRARIES);
- } COLON LSQUARE_BRACKET hooks_libraries_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- hooks_libraries_list: %empty
- | not_empty_hooks_libraries_list
- ;
- not_empty_hooks_libraries_list: hooks_library
- | not_empty_hooks_libraries_list COMMA hooks_library
- ;
- hooks_library: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } hooks_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- sub_hooks_library: LCURLY_BRACKET {
- // Parse the hooks-libraries list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } hooks_params RCURLY_BRACKET {
- // parsing completed
- };
- hooks_params: hooks_param
- | hooks_params COMMA hooks_param
- | unknown_map_entry
- ;
- hooks_param: library
- | parameters
- ;
- library: LIBRARY {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr lib(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("library", lib);
- ctx.leave();
- };
- parameters: PARAMETERS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("parameters", $4);
- ctx.leave();
- };
- // --- expired-leases-processing ------------------------
- expired_leases_processing: EXPIRED_LEASES_PROCESSING {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("expired-leases-processing", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.NO_KEYWORD);
- } COLON LCURLY_BRACKET expired_leases_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- expired_leases_params: expired_leases_param
- | expired_leases_params COMMA expired_leases_param
- ;
- // This is a bit of a simplification. But it can also serve as an example.
- // Instead of explicitly listing all allowed expired leases parameters, we
- // simply say that all of them as integers.
- expired_leases_param: STRING COLON INTEGER {
- ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set($1, value);
- };
- // --- subnet4 ------------------------------------------
- // This defines subnet4 as a list of maps.
- // "subnet4": [ ... ]
- subnet4_list: SUBNET4 {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("subnet4", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.SUBNET4);
- } COLON LSQUARE_BRACKET subnet4_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the ... in "subnet6": [ ... ]
- // It can either be empty (no subnets defined), have one subnet
- // or have multiple subnets separate by comma.
- subnet4_list_content: %empty
- | not_empty_subnet4_list
- ;
- not_empty_subnet4_list: subnet4
- | not_empty_subnet4_list COMMA subnet4
- ;
- // --- Subnet definitions -------------------------------
- // This defines a single subnet, i.e. a single map with
- // subnet6 array.
- subnet4: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } subnet4_params RCURLY_BRACKET {
- // Once we reached this place, the subnet parsing is now complete.
- // If we want to, we can implement default values here.
- // In particular we can do things like this:
- // if (!ctx.stack_.back()->get("interface")) {
- // ctx.stack_.back()->set("interface", StringElement("loopback"));
- // }
- //
- // We can also stack up one level (Dhcp6) and copy over whatever
- // global parameters we want to:
- // if (!ctx.stack_.back()->get("renew-timer")) {
- // ElementPtr renew = ctx_stack_[...].get("renew-timer");
- // if (renew) {
- // ctx.stack_.back()->set("renew-timer", renew);
- // }
- // }
- ctx.stack_.pop_back();
- };
- sub_subnet4: LCURLY_BRACKET {
- // Parse the subnet6 list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } subnet4_params RCURLY_BRACKET {
- // parsing completed
- };
- // This defines that subnet can have one or more parameters.
- subnet4_params: subnet4_param
- | subnet4_params COMMA subnet4_param
- ;
- // This defines a list of allowed parameters for each subnet.
- subnet4_param: valid_lifetime
- | renew_timer
- | rebind_timer
- | option_data_list
- | pools_list
- | subnet
- | interface
- | interface_id
- | id
- | rapid_commit
- | client_class
- | reservations
- | reservation_mode
- | relay
- | match_client_id
- | next_server
- | subnet_4o6_interface
- | subnet_4o6_interface_id
- | subnet_4o6_subnet
- | unknown_map_entry
- ;
- subnet: SUBNET {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr subnet(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("subnet", subnet);
- ctx.leave();
- };
- subnet_4o6_interface: SUBNET_4O6_INTERFACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("4o6-interface", iface);
- ctx.leave();
- };
- subnet_4o6_interface_id: SUBNET_4O6_INTERFACE_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("4o6-interface-id", iface);
- ctx.leave();
- };
- subnet_4o6_subnet: SUBNET_4O6_SUBNET {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("4o6-subnet", iface);
- ctx.leave();
- };
- interface: INTERFACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("interface", iface);
- ctx.leave();
- };
- interface_id: INTERFACE_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr iface(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("interface-id", iface);
- ctx.leave();
- };
- client_class: CLIENT_CLASS {
- ctx.enter(ctx.CLIENT_CLASS);
- } COLON STRING {
- ElementPtr cls(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("client-class", cls);
- ctx.leave();
- };
- reservation_mode: RESERVATION_MODE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr rm(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("reservation-mode", rm);
- ctx.leave();
- };
- id: ID COLON INTEGER {
- ElementPtr id(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("id", id);
- };
- rapid_commit: RAPID_COMMIT COLON BOOLEAN {
- ElementPtr rc(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("rapid-commit", rc);
- };
- // ---- option-def --------------------------
- // This defines the "option-def": [ ... ] entry that may appear
- // at a global option.
- option_def_list: OPTION_DEF {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("option-def", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.OPTION_DEF);
- } COLON LSQUARE_BRACKET option_def_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the content of option-def. It may be empty,
- // have one entry or multiple entries separated by comma.
- option_def_list_content: %empty
- | not_empty_option_def_list
- ;
- not_empty_option_def_list: option_def_entry
- | not_empty_option_def_list COMMA option_def_entry
- ;
- // This defines the content of a single entry { ... } within
- // option-def list.
- option_def_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } option_def_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- // This defines the top level scope when the parser is told to parse a single
- // option definition. It's almost exactly the same as option_def_entry, except
- // that it does leave its value on stack.
- sub_option_def: LCURLY_BRACKET {
- // Parse the option-def list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } option_def_params RCURLY_BRACKET {
- // parsing completed
- };
- // This defines parameters specified inside the map that itself
- // is an entry in option-def list.
- option_def_params: %empty
- | not_empty_option_def_params
- ;
- not_empty_option_def_params: option_def_param
- | not_empty_option_def_params COMMA option_def_param
- ;
- option_def_param: option_def_name
- | option_def_code
- | option_def_type
- | option_def_record_types
- | option_def_space
- | option_def_encapsulate
- | option_def_array
- | unknown_map_entry
- ;
- option_def_name: name;
- code: CODE COLON INTEGER {
- ElementPtr code(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("code", code);
- };
- option_def_code: code;
- option_def_type: type;
- option_def_record_types: RECORD_TYPES {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr rtypes(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("record-types", rtypes);
- ctx.leave();
- };
- space: SPACE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr space(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("space", space);
- ctx.leave();
- };
- option_def_space: space;
- option_def_encapsulate: ENCAPSULATE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr encap(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("encapsulate", encap);
- ctx.leave();
- };
- option_def_array: ARRAY COLON BOOLEAN {
- ElementPtr array(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("array", array);
- };
- // ---- option-data --------------------------
- // This defines the "option-data": [ ... ] entry that may appear
- // in several places, but most notably in subnet4 entries.
- option_data_list: OPTION_DATA {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("option-data", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.OPTION_DATA);
- } COLON LSQUARE_BRACKET option_data_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the content of option-data. It may be empty,
- // have one entry or multiple entries separated by comma.
- option_data_list_content: %empty
- | not_empty_option_data_list
- ;
- // This defines the content of option-data list. It can either
- // be a single value or multiple entries separated by comma.
- not_empty_option_data_list: option_data_entry
- | not_empty_option_data_list COMMA option_data_entry
- ;
- // This defines th content of a single entry { ... } within
- // option-data list.
- option_data_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } option_data_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- // This defines the top level scope when the parser is told to parse a single
- // option data. It's almost exactly the same as option_data_entry, except
- // that it does leave its value on stack.
- sub_option_data: LCURLY_BRACKET {
- // Parse the option-data list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } option_data_params RCURLY_BRACKET {
- // parsing completed
- };
- // This defines parameters specified inside the map that itself
- // is an entry in option-data list. It can either be empty
- // or have a non-empty list of parameters.
- option_data_params: %empty
- | not_empty_option_data_params
- ;
- // Those parameters can either be a single parameter or
- // a list of parameters separated by comma.
- not_empty_option_data_params: option_data_param
- | not_empty_option_data_params COMMA option_data_param
- ;
- // Each single option-data parameter can be one of the following
- // expressions.
- option_data_param: option_data_name
- | option_data_data
- | option_data_code
- | option_data_space
- | option_data_csv_format
- | unknown_map_entry
- ;
- option_data_name: name;
- option_data_data: DATA {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr data(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("data", data);
- ctx.leave();
- };
- option_data_code: code;
- option_data_space: space;
- option_data_csv_format: CSV_FORMAT COLON BOOLEAN {
- ElementPtr space(new BoolElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("csv-format", space);
- };
- // ---- pools ------------------------------------
- // This defines the "pools": [ ... ] entry that may appear in subnet4.
- pools_list: POOLS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("pools", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.POOLS);
- } COLON LSQUARE_BRACKET pools_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // Pools may be empty, contain a single pool entry or multiple entries
- // separate by commas.
- pools_list_content: %empty
- | not_empty_pools_list
- ;
- not_empty_pools_list: pool_list_entry
- | not_empty_pools_list COMMA pool_list_entry
- ;
- pool_list_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } pool_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- sub_pool4: LCURLY_BRACKET {
- // Parse the pool list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } pool_params RCURLY_BRACKET {
- // parsing completed
- };
- pool_params: pool_param
- | pool_params COMMA pool_param
- ;
- pool_param: pool_entry
- | option_data_list
- | unknown_map_entry
- ;
- pool_entry: POOL {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr pool(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("pool", pool);
- ctx.leave();
- };
- // --- end of pools definition -------------------------------
- // --- reservations ------------------------------------------
- reservations: RESERVATIONS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("reservations", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.RESERVATIONS);
- } COLON LSQUARE_BRACKET reservations_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- reservations_list: %empty
- | not_empty_reservations_list
- ;
- not_empty_reservations_list: reservation
- | not_empty_reservations_list COMMA reservation
- ;
- reservation: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } reservation_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- sub_reservation: LCURLY_BRACKET {
- // Parse the reservations list entry map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } reservation_params RCURLY_BRACKET {
- // parsing completed
- };
- reservation_params: %empty
- | not_empty_reservation_params
- ;
- not_empty_reservation_params: reservation_param
- | not_empty_reservation_params COMMA reservation_param
- ;
- // @todo probably need to add mac-address as well here
- reservation_param: duid
- | reservation_client_classes
- | client_id_value
- | circuit_id_value
- | ip_address
- | hw_address
- | hostname
- | option_data_list
- | next_server
- | server_hostname
- | boot_file_name
- | unknown_map_entry
- ;
- next_server: NEXT_SERVER {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr next_server(new StringElement($4, ctx.loc2pos(@1)));
- ctx.stack_.back()->set("next-server", next_server);
- ctx.leave();
- };
- server_hostname: SERVER_HOSTNAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr srv(new StringElement($4, ctx.loc2pos(@1)));
- ctx.stack_.back()->set("server-hostname", srv);
- ctx.leave();
- };
- boot_file_name: BOOT_FILE_NAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr bootfile(new StringElement($4, ctx.loc2pos(@1)));
- ctx.stack_.back()->set("boot-file-name", bootfile);
- ctx.leave();
- };
- ip_address: IP_ADDRESS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr addr(new StringElement($4, ctx.loc2pos(@1)));
- ctx.stack_.back()->set("ip-address", addr);
- ctx.leave();
- };
- duid: DUID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr d(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("duid", d);
- ctx.leave();
- };
- hw_address: HW_ADDRESS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("hw-address", hw);
- ctx.leave();
- };
- client_id_value: CLIENT_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("client-id", hw);
- ctx.leave();
- };
- circuit_id_value: CIRCUIT_ID {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr hw(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("circuit-id", hw);
- ctx.leave();
- };
- hostname: HOSTNAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr host(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("hostname", host);
- ctx.leave();
- };
- reservation_client_classes: CLIENT_CLASSES {
- ElementPtr c(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("client-classes", c);
- ctx.stack_.push_back(c);
- ctx.enter(ctx.NO_KEYWORD);
- } COLON list2 {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // --- end of reservations definitions -----------------------
- // --- relay -------------------------------------------------
- relay: RELAY {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("relay", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.RELAY);
- } COLON LCURLY_BRACKET relay_map RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- relay_map: IP_ADDRESS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr ip(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("ip-address", ip);
- ctx.leave();
- };
- // --- end of relay definitions ------------------------------
- // --- client classes ----------------------------------------
- client_classes: CLIENT_CLASSES {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("client-classes", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.CLIENT_CLASSES);
- } COLON LSQUARE_BRACKET client_classes_list RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- client_classes_list: client_class
- | client_classes_list COMMA client_class
- ;
- client_class: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } client_class_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- client_class_params: %empty
- | not_empty_client_class_params
- ;
- not_empty_client_class_params: client_class_param
- | not_empty_client_class_params COMMA client_class_param
- ;
- client_class_param: client_class_name
- | client_class_test
- | option_data_list
- | next_server
- | server_hostname
- | boot_file_name
- | unknown_map_entry
- ;
- client_class_name: name;
- client_class_test: TEST {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr test(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("test", test);
- ctx.leave();
- };
- // --- end of client classes ---------------------------------
- // --- server-id ---------------------------------------------
- server_id: SERVER_ID {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("server-id", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.SERVER_ID);
- } COLON LCURLY_BRACKET server_id_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- server_id_params: server_id_param
- | server_id_params COMMA server_id_param
- ;
- server_id_param: type
- | identifier
- | time
- | htype
- | enterprise_id
- | persist
- | unknown_map_entry
- ;
- htype: HTYPE COLON INTEGER {
- ElementPtr htype(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("htype", htype);
- };
- identifier: IDENTIFIER {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr id(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("identifier", id);
- ctx.leave();
- };
- time: TIME COLON INTEGER {
- ElementPtr time(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("time", time);
- };
- enterprise_id: ENTERPRISE_ID COLON INTEGER {
- ElementPtr time(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("enterprise-id", time);
- };
- // --- end of server-id --------------------------------------
- dhcp4o6_port: DHCP4O6_PORT COLON INTEGER {
- ElementPtr time(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("dhcp4o6-port", time);
- };
- // code says it is a string, unit test a number
- version: VERSION {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON version_value {
- ctx.stack_.back()->set("version", $4);
- ctx.leave();
- };
- version_value:
- INTEGER { $$ = ElementPtr(new IntElement($1, ctx.loc2pos(@1))); }
- | FLOAT { $$ = ElementPtr(new DoubleElement($1, ctx.loc2pos(@1))); }
- | STRING { $$ = ElementPtr(new StringElement($1, ctx.loc2pos(@1))); }
- ;
- // --- control socket ----------------------------------------
- control_socket: CONTROL_SOCKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("control-socket", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.CONTROL_SOCKET);
- } COLON LCURLY_BRACKET control_socket_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- control_socket_params: control_socket_param
- | control_socket_params COMMA control_socket_param
- ;
- control_socket_param: socket_type
- | socket_name
- ;
- socket_type: SOCKET_TYPE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr stype(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("socket-type", stype);
- ctx.leave();
- };
- socket_name: SOCKET_NAME {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("socket-name", name);
- ctx.leave();
- };
- // --- dhcp ddns ---------------------------------------------
- dhcp_ddns: DHCP_DDNS {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("dhcp-ddns", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.NO_KEYWORD);
- } COLON LCURLY_BRACKET not_empty_map RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // JSON entries for Dhcp4 and DhcpDdns
- dhcp6_json_object: DHCP6 {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("Dhcp6", $4);
- ctx.leave();
- };
- dhcpddns_json_object: DHCPDDNS {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON value {
- ctx.stack_.back()->set("DhcpDdns", $4);
- ctx.leave();
- };
- // --- logging entry -----------------------------------------
- // This defines the top level "Logging" object. It parses
- // the following "Logging": { ... }. The ... is defined
- // by logging_params
- logging_object: LOGGING {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("Logging", m);
- ctx.stack_.push_back(m);
- ctx.enter(ctx.LOGGING);
- } COLON LCURLY_BRACKET logging_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // This defines the list of allowed parameters that may appear
- // in the top-level Logging object. It can either be a single
- // parameter or several parameters separated by commas.
- logging_params: logging_param
- | logging_params COMMA logging_param
- ;
- // There's currently only one parameter defined, which is "loggers".
- logging_param: loggers;
- // "loggers", the only parameter currently defined in "Logging" object,
- // is "Loggers": [ ... ].
- loggers: LOGGERS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("loggers", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.LOGGERS);
- } COLON LSQUARE_BRACKET loggers_entries RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- // These are the parameters allowed in loggers: either one logger
- // entry or multiple entries separate by commas.
- loggers_entries: logger_entry
- | loggers_entries COMMA logger_entry
- ;
- // This defines a single entry defined in loggers in Logging.
- logger_entry: LCURLY_BRACKET {
- ElementPtr l(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(l);
- ctx.stack_.push_back(l);
- } logger_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- logger_params: logger_param
- | logger_params COMMA logger_param
- ;
- logger_param: name
- | output_options_list
- | debuglevel
- | severity
- | unknown_map_entry
- ;
- debuglevel: DEBUGLEVEL COLON INTEGER {
- ElementPtr dl(new IntElement($3, ctx.loc2pos(@3)));
- ctx.stack_.back()->set("debuglevel", dl);
- };
- severity: SEVERITY {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr sev(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("severity", sev);
- ctx.leave();
- };
- output_options_list: OUTPUT_OPTIONS {
- ElementPtr l(new ListElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->set("output_options", l);
- ctx.stack_.push_back(l);
- ctx.enter(ctx.OUTPUT_OPTIONS);
- } COLON LSQUARE_BRACKET output_options_list_content RSQUARE_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- output_options_list_content: output_entry
- | output_options_list_content COMMA output_entry
- ;
- output_entry: LCURLY_BRACKET {
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.back()->add(m);
- ctx.stack_.push_back(m);
- } output_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- };
- output_params: output_param
- | output_params COMMA output_param
- ;
- output_param: OUTPUT {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr sev(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("output", sev);
- ctx.leave();
- };
- %%
- void
- isc::dhcp::Dhcp4Parser::error(const location_type& loc,
- const std::string& what)
- {
- ctx.error(loc, what);
- }
|