12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547 |
- /* 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"
- DHCP_SOCKET_TYPE "dhcp-socket-type"
- 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. Dhcp4 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 Dhcp4 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(@3)));
- ctx.stack_.back()->set("echo-client-id", echo);
- };
- match_client_id: MATCH_CLIENT_ID COLON BOOLEAN {
- ElementPtr match(new BoolElement($3, ctx.loc2pos(@3)));
- 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 interfaces_config_params RCURLY_BRACKET {
- ctx.stack_.pop_back();
- ctx.leave();
- };
- interfaces_config_params: interfaces_config_param
- | interfaces_config_params COMMA interfaces_config_param
- ;
- interfaces_config_param: interfaces_list
- | dhcp_socket_type
- ;
- sub_interfaces4: LCURLY_BRACKET {
- // Parse the interfaces-config map
- ElementPtr m(new MapElement(ctx.loc2pos(@1)));
- ctx.stack_.push_back(m);
- } interfaces_config_params RCURLY_BRACKET {
- // parsing completed
- };
- interfaces_list: 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();
- };
- dhcp_socket_type: DHCP_SOCKET_TYPE {
- ctx.enter(ctx.NO_KEYWORD);
- } COLON STRING {
- ElementPtr type(new StringElement($4, ctx.loc2pos(@4)));
- ctx.stack_.back()->set("dhcp-socket-type", type);
- 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 "subnet4": [ ... ]
- // 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
- // subnet4 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 (Dhcp4) 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 subnet4 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(@4)));
- 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(@4)));
- 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(@4)));
- 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(@4)));
- 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);
- }
|