mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-09 23:34:26 +00:00
Handle hterm preferences with better care
This commit is contained in:
parent
86151f1ac9
commit
589ec6b50a
226
.gotty
226
.gotty
@ -57,23 +57,237 @@
|
|||||||
// [bool] Accept only one client and exit gotty once the client exits
|
// [bool] Accept only one client and exit gotty once the client exits
|
||||||
// once = false
|
// once = false
|
||||||
|
|
||||||
|
// [bool] Allow clients to send command line arguments
|
||||||
|
// permit_arguments = false
|
||||||
|
|
||||||
// [object] Client terminal (hterm) preferences
|
// [object] Client terminal (hterm) preferences
|
||||||
// Examples below are some of commonly used options.
|
|
||||||
// See hterm's documentation for the complete list of preferences.
|
|
||||||
// https://chromium.googlesource.com/apps/libapps/+/master/hterm/js/hterm_preference_manager.js
|
|
||||||
// (Note that fihens `-` in preference names must be replaced by underscores `_`)
|
|
||||||
// preferences {
|
// preferences {
|
||||||
|
|
||||||
|
// [enum(null, "none", "ctrl-alt", "left-alt", "right-alt")]
|
||||||
|
// Select an AltGr detection hack^Wheuristic.
|
||||||
|
// null: Autodetect based on navigator.language: "en-us" => "none", else => "right-alt"
|
||||||
|
// "none": Disable any AltGr related munging.
|
||||||
|
// "ctrl-alt": Assume Ctrl+Alt means AltGr.
|
||||||
|
// "left-alt": Assume left Alt means AltGr.
|
||||||
|
// "right-alt": Assume right Alt means AltGr.
|
||||||
|
// alt_gr_mode = null
|
||||||
|
|
||||||
|
// [bool] If set, alt-backspace indeed is alt-backspace.
|
||||||
|
// alt_backspace_is_meta_backspace = false
|
||||||
|
|
||||||
|
// [bool] Set whether the alt key acts as a meta key or as a distinct alt key.
|
||||||
|
// alt_is_meta = false
|
||||||
|
|
||||||
|
// [enum("escape", "8-bit", "browser-key")]
|
||||||
|
// Controls how the alt key is handled.
|
||||||
|
// "escape"....... Send an ESC prefix.
|
||||||
|
// "8-bit"........ Add 128 to the unshifted character as in xterm.
|
||||||
|
// "browser-key".. Wait for the keypress event and see what the browser
|
||||||
|
// says. (This won't work well on platforms where the
|
||||||
|
// browser performs a default action for some alt sequences.)
|
||||||
|
// alt_sends_what = "escape"
|
||||||
|
|
||||||
|
// [string] URL of the terminal bell sound. Empty string for no audible bell.
|
||||||
|
// audible_bell_sound = "lib-resource:hterm/audio/bell"
|
||||||
|
|
||||||
|
// [bool] If true, terminal bells in the background will create a Web Notification. http://www.w3.org/TR/notifications/
|
||||||
|
// Displaying notifications requires permission from the user.
|
||||||
|
// When this option is set to true, hterm will attempt to ask the user for
|
||||||
|
// permission if necessary.
|
||||||
|
// Note browsers may not show this permission request
|
||||||
|
// if it did not originate from a user action.
|
||||||
|
// desktop_notification_bell = false
|
||||||
|
|
||||||
|
// [string] The background color for text with no other color attributes.
|
||||||
// background_color = "rgb(16, 16, 16)"
|
// background_color = "rgb(16, 16, 16)"
|
||||||
|
|
||||||
|
// [string] CSS value of the background image. Empty string for no image.
|
||||||
|
// For example:
|
||||||
|
// "url(https://goo.gl/anedTK) linear-gradient(top bottom, blue, red)"
|
||||||
// background_image = ""
|
// background_image = ""
|
||||||
|
|
||||||
|
// [string] CSS value of the background image size. Defaults to none.
|
||||||
|
// background_size = ""
|
||||||
|
|
||||||
|
// [string] CSS value of the background image position.
|
||||||
|
// For example:
|
||||||
|
// "10% 10% center"
|
||||||
|
// background_position = ""
|
||||||
|
|
||||||
|
// [bool] If true, the backspace should send BS ('\x08', aka ^H). Otherwise the backspace key should send '\x7f'.
|
||||||
|
// backspace_sends_backspace = false
|
||||||
|
|
||||||
|
// [map[string]map[string]string]
|
||||||
|
// A nested map where each property is the character set code and the value is a map that is a sparse array itself. In that sparse array, each property is the received character and the value is the displayed character.
|
||||||
|
// For example:
|
||||||
|
// {"0" = {"+" = "\u2192"
|
||||||
|
// "," = "\u2190"
|
||||||
|
// "-" = "\u2191"
|
||||||
|
// "." = "\u2193"
|
||||||
|
// "0" = "\u2588"}}
|
||||||
|
// character_map_overrides = null
|
||||||
|
|
||||||
|
// [bool] Whether or not to close the window when the command exits.
|
||||||
|
// close_on_exit = true
|
||||||
|
|
||||||
|
// [bool] Whether or not to blink the cursor by default.
|
||||||
// cursor_blink = false
|
// cursor_blink = false
|
||||||
|
|
||||||
|
// [2[int]] The cursor blink rate in milliseconds.
|
||||||
|
// A two element array, the first of which is how long the cursor should be on, second is how long it should be off.
|
||||||
|
// cursor_blink_cycle = [1000, 500]
|
||||||
|
|
||||||
|
// [string] The color of the visible cursor.
|
||||||
// cursor_color = "rgba(255, 0, 0, 0.5)"
|
// cursor_color = "rgba(255, 0, 0, 0.5)"
|
||||||
|
|
||||||
|
// [[]string]
|
||||||
|
// Override colors in the default palette.
|
||||||
|
// This can be specified as an array or an object.
|
||||||
|
// Values can be specified as almost any css color value.
|
||||||
|
// This includes #RGB, #RRGGBB, rgb(...), rgba(...), and any color names that are also part of the stock X11 rgb.txt file.
|
||||||
|
// You can use 'null' to specify that the default value should be not be changed.
|
||||||
|
// This is useful for skipping a small number of indicies when the value is specified as an array.
|
||||||
|
// color_palette_overrides = null
|
||||||
|
|
||||||
|
// [bool] Automatically copy mouse selection to the clipboard.
|
||||||
|
// copy_on_select = true
|
||||||
|
|
||||||
|
// [bool] Whether to use the default window copy behaviour
|
||||||
|
// use_default_window_copy = false
|
||||||
|
|
||||||
|
// [bool] Whether to clear the selection after copying.
|
||||||
|
// clear_selection_after_copy = true
|
||||||
|
|
||||||
|
// [bool] If true, Ctrl-Plus/Minus/Zero controls zoom.
|
||||||
|
// If false, Ctrl-Shift-Plus/Minus/Zero controls zoom, Ctrl-Minus sends ^_, Ctrl-Plus/Zero do nothing.
|
||||||
|
// ctrl_plus_minus_zero_zoom = true
|
||||||
|
|
||||||
|
// [bool] Ctrl+C copies if true, send ^C to host if false.
|
||||||
|
// Ctrl+Shift+C sends ^C to host if true, copies if false.
|
||||||
// ctrl_c_copy = false
|
// ctrl_c_copy = false
|
||||||
|
|
||||||
|
// [bool] Ctrl+V pastes if true, send ^V to host if false.
|
||||||
|
// Ctrl+Shift+V sends ^V to host if true, pastes if false.
|
||||||
// ctrl_v_paste = false
|
// ctrl_v_paste = false
|
||||||
|
|
||||||
|
// [bool] Set whether East Asian Ambiguous characters have two column width.
|
||||||
// east_asian_ambiguous_as_two_column = false
|
// east_asian_ambiguous_as_two_column = false
|
||||||
// font_family = "'DejaVu Sans Mono', 'Everson Mono', 'FreeMono', 'Menlo', 'Terminal', monospace"
|
|
||||||
|
// [bool] True to enable 8-bit control characters, false to ignore them.
|
||||||
|
// We'll respect the two-byte versions of these control characters regardless of this setting.
|
||||||
|
// enable_8_bit_control = false
|
||||||
|
|
||||||
|
// [enum(null, true, false)]
|
||||||
|
// True if we should use bold weight font for text with the bold/bright attribute.
|
||||||
|
// False to use the normal weight font.
|
||||||
|
// Null to autodetect.
|
||||||
|
// enable_bold = null
|
||||||
|
|
||||||
|
// [bool] True if we should use bright colors (8-15 on a 16 color palette) for any text with the bold attribute.
|
||||||
|
// False otherwise.
|
||||||
|
// enable_bold_as_bright = true
|
||||||
|
|
||||||
|
// [bool] Show a message in the terminal when the host writes to the clipboard.
|
||||||
|
// enable_clipboard_notice = true
|
||||||
|
|
||||||
|
// [bool] Allow the host to write directly to the system clipboard.
|
||||||
|
// enable_clipboard_write = true
|
||||||
|
|
||||||
|
// [bool] Respect the host's attempt to change the cursor blink status using DEC Private Mode 12.
|
||||||
|
// enable_dec12 = false
|
||||||
|
|
||||||
|
// [map[string]string] The default environment variables, as an object.
|
||||||
|
// environment = {"TERM" = "xterm-256color"}
|
||||||
|
|
||||||
|
// [string] Default font family for the terminal text.
|
||||||
|
// font_family = "'DejaVu Sans Mono', 'Everson Mono', FreeMono, 'Menlo', 'Terminal', monospace"
|
||||||
|
|
||||||
|
// [int] The default font size in pixels.
|
||||||
// font_size = 15
|
// font_size = 15
|
||||||
|
|
||||||
|
// [string] CSS font-smoothing property.
|
||||||
|
// font_smoothing = "antialiased"
|
||||||
|
|
||||||
|
// [string] The foreground color for text with no other color attributes.
|
||||||
// foreground_color = "rgb(240, 240, 240)"
|
// foreground_color = "rgb(240, 240, 240)"
|
||||||
|
|
||||||
|
// [bool] If true, home/end will control the terminal scrollbar and shift home/end will send the VT keycodes. If false then home/end sends VT codes and shift home/end scrolls.
|
||||||
|
// home_keys_scroll = false
|
||||||
|
|
||||||
|
// [map[string]string]
|
||||||
|
// A map of key sequence to key actions.
|
||||||
|
// Key sequences include zero or more modifier keys followed by a key code.
|
||||||
|
// Key codes can be decimal or hexadecimal numbers, or a key identifier.
|
||||||
|
// Key actions can be specified a string to send to the host, or an action identifier.
|
||||||
|
// For a full list of key code and action identifiers, see https://goo.gl/8AoD09.
|
||||||
|
// Sample keybindings:
|
||||||
|
// {"Ctrl-Alt-K" = "clearScrollback"
|
||||||
|
// "Ctrl-Shift-L"= "PASS"
|
||||||
|
// "Ctrl-H" = "'HELLO\n'"}
|
||||||
|
// keybindings = null
|
||||||
|
|
||||||
|
// [int] Max length of a DCS, OSC, PM, or APS sequence before we give up and ignore the code.
|
||||||
|
// max_string_sequence = 100000
|
||||||
|
|
||||||
|
// [bool] If true, convert media keys to their Fkey equivalent.
|
||||||
|
// If false, let the browser handle the keys.
|
||||||
|
// media_keys_are_fkeys = false
|
||||||
|
|
||||||
|
// [bool] Set whether the meta key sends a leading escape or not.
|
||||||
|
// meta_sends_escape = true
|
||||||
|
|
||||||
|
// [enum(null, 0, 1, 2, 3, 4, 5, 6]
|
||||||
|
// Mouse paste button, or null to autodetect.
|
||||||
|
// For autodetect, we'll try to enable middle button paste for non-X11 platforms.
|
||||||
|
// On X11 we move it to button 3.
|
||||||
|
// mouse_paste_button = null
|
||||||
|
|
||||||
|
// [bool] If true, page up/down will control the terminal scrollbar and shift page up/down will send the VT keycodes.
|
||||||
|
// If false then page up/down sends VT codes and shift page up/down scrolls.
|
||||||
|
// page_keys_scroll = false
|
||||||
|
|
||||||
|
// [enum(null, true, false)]
|
||||||
|
// Set whether we should pass Alt-1..9 to the browser.
|
||||||
|
// This is handy when running hterm in a browser tab, so that you don't lose Chrome's "switch to tab" keyboard accelerators. When not running in a tab it's better to send these keys to the host so they can be used in vim or emacs.
|
||||||
|
// If true, Alt-1..9 will be handled by the browser.
|
||||||
|
// If false, Alt-1..9 will be sent to the host.
|
||||||
|
// If null, autodetect based on browser platform and window type.
|
||||||
|
// pass_alt_number = null
|
||||||
|
|
||||||
|
// [enum(null, true, false)]
|
||||||
|
// Set whether we should pass Ctrl-1..9 to the browser.
|
||||||
|
// This is handy when running hterm in a browser tab, so that you don't lose Chrome's "switch to tab" keyboard accelerators. When not running in a tab it's better to send these keys to the host so they can be used in vim or emacs.
|
||||||
|
// If true, Ctrl-1..9 will be handled by the browser.
|
||||||
|
// If false, Ctrl-1..9 will be sent to the host.
|
||||||
|
// If null, autodetect based on browser platform and window type.
|
||||||
|
// pass_ctrl_number = null
|
||||||
|
|
||||||
|
// [enum(null, true, false)]
|
||||||
|
// Set whether we should pass Meta-1..9 to the browser.
|
||||||
|
// This is handy when running hterm in a browser tab, so that you don't lose Chrome's "switch to tab" keyboard accelerators. When not running in a tab it's better to send these keys to the host so they can be used in vim or emacs.
|
||||||
|
// If true, Meta-1..9 will be handled by the browser.
|
||||||
|
// If false, Meta-1..9 will be sent to the host. If null, autodetect based on browser platform and window type.
|
||||||
|
// pass_meta_number = null
|
||||||
|
|
||||||
|
// [bool] Set whether meta-V gets passed to host.
|
||||||
|
// pass_meta_v = true
|
||||||
|
|
||||||
|
// [bool] If true, scroll to the bottom on any keystroke.
|
||||||
|
// scroll_on_keystroke = true
|
||||||
|
|
||||||
|
// [bool] If true, scroll to the bottom on terminal output.
|
||||||
|
// scroll_on_output = false
|
||||||
|
|
||||||
|
// [bool] The vertical scrollbar mode.
|
||||||
|
// scrollbar_visible = true
|
||||||
|
|
||||||
|
// [int] The multiplier for the pixel delta in mousewheel event caused by the scroll wheel. Alters how fast the page scrolls.
|
||||||
|
// scroll_wheel_move_multiplier = 1
|
||||||
|
|
||||||
|
// [bool] Shift + Insert pastes if true, sent to host if false.
|
||||||
|
// shift_insert_paste = true
|
||||||
|
|
||||||
|
// [string] URL of user stylesheet to include in the terminal document.
|
||||||
// user_css = ""
|
// user_css = ""
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
8
Godeps/Godeps.json
generated
8
Godeps/Godeps.json
generated
@ -28,15 +28,15 @@
|
|||||||
"ImportPath": "github.com/hashicorp/go-multierror",
|
"ImportPath": "github.com/hashicorp/go-multierror",
|
||||||
"Rev": "56912fb08d85084aa318edcf2bba735b97cf35c5"
|
"Rev": "56912fb08d85084aa318edcf2bba735b97cf35c5"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ImportPath": "github.com/hashicorp/hcl",
|
|
||||||
"Rev": "54864211433d45cb780682431585b3e573b49e4a"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/kr/pty",
|
"ImportPath": "github.com/kr/pty",
|
||||||
"Comment": "release.r56-28-g5cf931e",
|
"Comment": "release.r56-28-g5cf931e",
|
||||||
"Rev": "5cf931ef8f76dccd0910001d74a58a7fca84a83d"
|
"Rev": "5cf931ef8f76dccd0910001d74a58a7fca84a83d"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/yudai/hcl",
|
||||||
|
"Rev": "7227a719113b77a78318a43dba44951556ff9e3d"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/yudai/umutex",
|
"ImportPath": "github.com/yudai/umutex",
|
||||||
"Rev": "18216d265c6bc72c3bb0ad9c8103d47d530b7003"
|
"Rev": "18216d265c6bc72c3bb0ad9c8103d47d530b7003"
|
||||||
|
1
Godeps/_workspace/src/github.com/hashicorp/hcl/hcl/test-fixtures/list.hcl
generated
vendored
1
Godeps/_workspace/src/github.com/hashicorp/hcl/hcl/test-fixtures/list.hcl
generated
vendored
@ -1 +0,0 @@
|
|||||||
foo = [1, 2, "foo"]
|
|
611
Godeps/_workspace/src/github.com/hashicorp/hcl/hcl/y.go
generated
vendored
611
Godeps/_workspace/src/github.com/hashicorp/hcl/hcl/y.go
generated
vendored
@ -1,611 +0,0 @@
|
|||||||
//line parse.y:4
|
|
||||||
package hcl
|
|
||||||
|
|
||||||
import __yyfmt__ "fmt"
|
|
||||||
|
|
||||||
//line parse.y:4
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
//line parse.y:13
|
|
||||||
type hclSymType struct {
|
|
||||||
yys int
|
|
||||||
b bool
|
|
||||||
f float64
|
|
||||||
num int
|
|
||||||
str string
|
|
||||||
obj *Object
|
|
||||||
objlist []*Object
|
|
||||||
}
|
|
||||||
|
|
||||||
const BOOL = 57346
|
|
||||||
const FLOAT = 57347
|
|
||||||
const NUMBER = 57348
|
|
||||||
const COMMA = 57349
|
|
||||||
const COMMAEND = 57350
|
|
||||||
const IDENTIFIER = 57351
|
|
||||||
const EQUAL = 57352
|
|
||||||
const NEWLINE = 57353
|
|
||||||
const STRING = 57354
|
|
||||||
const MINUS = 57355
|
|
||||||
const LEFTBRACE = 57356
|
|
||||||
const RIGHTBRACE = 57357
|
|
||||||
const LEFTBRACKET = 57358
|
|
||||||
const RIGHTBRACKET = 57359
|
|
||||||
const PERIOD = 57360
|
|
||||||
const EPLUS = 57361
|
|
||||||
const EMINUS = 57362
|
|
||||||
|
|
||||||
var hclToknames = []string{
|
|
||||||
"BOOL",
|
|
||||||
"FLOAT",
|
|
||||||
"NUMBER",
|
|
||||||
"COMMA",
|
|
||||||
"COMMAEND",
|
|
||||||
"IDENTIFIER",
|
|
||||||
"EQUAL",
|
|
||||||
"NEWLINE",
|
|
||||||
"STRING",
|
|
||||||
"MINUS",
|
|
||||||
"LEFTBRACE",
|
|
||||||
"RIGHTBRACE",
|
|
||||||
"LEFTBRACKET",
|
|
||||||
"RIGHTBRACKET",
|
|
||||||
"PERIOD",
|
|
||||||
"EPLUS",
|
|
||||||
"EMINUS",
|
|
||||||
}
|
|
||||||
var hclStatenames = []string{}
|
|
||||||
|
|
||||||
const hclEofCode = 1
|
|
||||||
const hclErrCode = 2
|
|
||||||
const hclMaxDepth = 200
|
|
||||||
|
|
||||||
//line parse.y:259
|
|
||||||
|
|
||||||
//line yacctab:1
|
|
||||||
var hclExca = []int{
|
|
||||||
-1, 1,
|
|
||||||
1, -1,
|
|
||||||
-2, 0,
|
|
||||||
-1, 6,
|
|
||||||
10, 7,
|
|
||||||
-2, 17,
|
|
||||||
-1, 7,
|
|
||||||
10, 8,
|
|
||||||
-2, 18,
|
|
||||||
}
|
|
||||||
|
|
||||||
const hclNprod = 36
|
|
||||||
const hclPrivate = 57344
|
|
||||||
|
|
||||||
var hclTokenNames []string
|
|
||||||
var hclStates []string
|
|
||||||
|
|
||||||
const hclLast = 62
|
|
||||||
|
|
||||||
var hclAct = []int{
|
|
||||||
|
|
||||||
35, 3, 21, 22, 9, 30, 31, 29, 17, 26,
|
|
||||||
25, 26, 25, 10, 26, 25, 18, 24, 13, 24,
|
|
||||||
23, 37, 24, 44, 45, 42, 34, 38, 39, 9,
|
|
||||||
32, 6, 6, 43, 7, 7, 2, 40, 28, 26,
|
|
||||||
25, 6, 41, 11, 7, 46, 37, 24, 14, 36,
|
|
||||||
27, 15, 5, 13, 19, 1, 4, 8, 33, 20,
|
|
||||||
16, 12,
|
|
||||||
}
|
|
||||||
var hclPact = []int{
|
|
||||||
|
|
||||||
32, -1000, 32, -1000, 3, -1000, -1000, -1000, 39, -1000,
|
|
||||||
4, -1000, -1000, 23, -1000, -1000, -1000, -1000, -1000, -1000,
|
|
||||||
-1000, -14, -14, 9, 6, -1000, -1000, 22, -1000, -1000,
|
|
||||||
36, 19, -1000, 16, -1000, -1000, -1000, -1000, -1000, -1000,
|
|
||||||
-1000, -1000, -1000, -1000, 34, -1000, -1000,
|
|
||||||
}
|
|
||||||
var hclPgo = []int{
|
|
||||||
|
|
||||||
0, 3, 2, 59, 58, 36, 52, 49, 43, 1,
|
|
||||||
0, 57, 7, 56, 55,
|
|
||||||
}
|
|
||||||
var hclR1 = []int{
|
|
||||||
|
|
||||||
0, 14, 14, 5, 5, 8, 8, 13, 13, 9,
|
|
||||||
9, 9, 9, 9, 9, 6, 6, 11, 11, 3,
|
|
||||||
3, 4, 4, 4, 10, 10, 7, 7, 7, 7,
|
|
||||||
2, 2, 1, 1, 12, 12,
|
|
||||||
}
|
|
||||||
var hclR2 = []int{
|
|
||||||
|
|
||||||
0, 0, 1, 1, 2, 3, 2, 1, 1, 3,
|
|
||||||
3, 3, 3, 3, 1, 2, 2, 1, 1, 3,
|
|
||||||
2, 1, 3, 2, 1, 1, 1, 1, 2, 2,
|
|
||||||
2, 1, 2, 1, 2, 2,
|
|
||||||
}
|
|
||||||
var hclChk = []int{
|
|
||||||
|
|
||||||
-1000, -14, -5, -9, -13, -6, 9, 12, -11, -9,
|
|
||||||
10, -8, -6, 14, 9, 12, -7, 4, 12, -8,
|
|
||||||
-3, -2, -1, 16, 13, 6, 5, -5, 15, -12,
|
|
||||||
19, 20, -12, -4, 17, -10, -7, 12, -2, -1,
|
|
||||||
15, 6, 6, 17, 7, 8, -10,
|
|
||||||
}
|
|
||||||
var hclDef = []int{
|
|
||||||
|
|
||||||
1, -2, 2, 3, 0, 14, -2, -2, 0, 4,
|
|
||||||
0, 15, 16, 0, 17, 18, 9, 10, 11, 12,
|
|
||||||
13, 26, 27, 0, 0, 31, 33, 0, 6, 28,
|
|
||||||
0, 0, 29, 0, 20, 21, 24, 25, 30, 32,
|
|
||||||
5, 34, 35, 19, 0, 23, 22,
|
|
||||||
}
|
|
||||||
var hclTok1 = []int{
|
|
||||||
|
|
||||||
1,
|
|
||||||
}
|
|
||||||
var hclTok2 = []int{
|
|
||||||
|
|
||||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
|
||||||
12, 13, 14, 15, 16, 17, 18, 19, 20,
|
|
||||||
}
|
|
||||||
var hclTok3 = []int{
|
|
||||||
0,
|
|
||||||
}
|
|
||||||
|
|
||||||
//line yaccpar:1
|
|
||||||
|
|
||||||
/* parser for yacc output */
|
|
||||||
|
|
||||||
var hclDebug = 0
|
|
||||||
|
|
||||||
type hclLexer interface {
|
|
||||||
Lex(lval *hclSymType) int
|
|
||||||
Error(s string)
|
|
||||||
}
|
|
||||||
|
|
||||||
const hclFlag = -1000
|
|
||||||
|
|
||||||
func hclTokname(c int) string {
|
|
||||||
// 4 is TOKSTART above
|
|
||||||
if c >= 4 && c-4 < len(hclToknames) {
|
|
||||||
if hclToknames[c-4] != "" {
|
|
||||||
return hclToknames[c-4]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return __yyfmt__.Sprintf("tok-%v", c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func hclStatname(s int) string {
|
|
||||||
if s >= 0 && s < len(hclStatenames) {
|
|
||||||
if hclStatenames[s] != "" {
|
|
||||||
return hclStatenames[s]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return __yyfmt__.Sprintf("state-%v", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func hcllex1(lex hclLexer, lval *hclSymType) int {
|
|
||||||
c := 0
|
|
||||||
char := lex.Lex(lval)
|
|
||||||
if char <= 0 {
|
|
||||||
c = hclTok1[0]
|
|
||||||
goto out
|
|
||||||
}
|
|
||||||
if char < len(hclTok1) {
|
|
||||||
c = hclTok1[char]
|
|
||||||
goto out
|
|
||||||
}
|
|
||||||
if char >= hclPrivate {
|
|
||||||
if char < hclPrivate+len(hclTok2) {
|
|
||||||
c = hclTok2[char-hclPrivate]
|
|
||||||
goto out
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i := 0; i < len(hclTok3); i += 2 {
|
|
||||||
c = hclTok3[i+0]
|
|
||||||
if c == char {
|
|
||||||
c = hclTok3[i+1]
|
|
||||||
goto out
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
if c == 0 {
|
|
||||||
c = hclTok2[1] /* unknown char */
|
|
||||||
}
|
|
||||||
if hclDebug >= 3 {
|
|
||||||
__yyfmt__.Printf("lex %s(%d)\n", hclTokname(c), uint(char))
|
|
||||||
}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func hclParse(hcllex hclLexer) int {
|
|
||||||
var hcln int
|
|
||||||
var hcllval hclSymType
|
|
||||||
var hclVAL hclSymType
|
|
||||||
hclS := make([]hclSymType, hclMaxDepth)
|
|
||||||
|
|
||||||
Nerrs := 0 /* number of errors */
|
|
||||||
Errflag := 0 /* error recovery flag */
|
|
||||||
hclstate := 0
|
|
||||||
hclchar := -1
|
|
||||||
hclp := -1
|
|
||||||
goto hclstack
|
|
||||||
|
|
||||||
ret0:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
ret1:
|
|
||||||
return 1
|
|
||||||
|
|
||||||
hclstack:
|
|
||||||
/* put a state and value onto the stack */
|
|
||||||
if hclDebug >= 4 {
|
|
||||||
__yyfmt__.Printf("char %v in %v\n", hclTokname(hclchar), hclStatname(hclstate))
|
|
||||||
}
|
|
||||||
|
|
||||||
hclp++
|
|
||||||
if hclp >= len(hclS) {
|
|
||||||
nyys := make([]hclSymType, len(hclS)*2)
|
|
||||||
copy(nyys, hclS)
|
|
||||||
hclS = nyys
|
|
||||||
}
|
|
||||||
hclS[hclp] = hclVAL
|
|
||||||
hclS[hclp].yys = hclstate
|
|
||||||
|
|
||||||
hclnewstate:
|
|
||||||
hcln = hclPact[hclstate]
|
|
||||||
if hcln <= hclFlag {
|
|
||||||
goto hcldefault /* simple state */
|
|
||||||
}
|
|
||||||
if hclchar < 0 {
|
|
||||||
hclchar = hcllex1(hcllex, &hcllval)
|
|
||||||
}
|
|
||||||
hcln += hclchar
|
|
||||||
if hcln < 0 || hcln >= hclLast {
|
|
||||||
goto hcldefault
|
|
||||||
}
|
|
||||||
hcln = hclAct[hcln]
|
|
||||||
if hclChk[hcln] == hclchar { /* valid shift */
|
|
||||||
hclchar = -1
|
|
||||||
hclVAL = hcllval
|
|
||||||
hclstate = hcln
|
|
||||||
if Errflag > 0 {
|
|
||||||
Errflag--
|
|
||||||
}
|
|
||||||
goto hclstack
|
|
||||||
}
|
|
||||||
|
|
||||||
hcldefault:
|
|
||||||
/* default state action */
|
|
||||||
hcln = hclDef[hclstate]
|
|
||||||
if hcln == -2 {
|
|
||||||
if hclchar < 0 {
|
|
||||||
hclchar = hcllex1(hcllex, &hcllval)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* look through exception table */
|
|
||||||
xi := 0
|
|
||||||
for {
|
|
||||||
if hclExca[xi+0] == -1 && hclExca[xi+1] == hclstate {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
xi += 2
|
|
||||||
}
|
|
||||||
for xi += 2; ; xi += 2 {
|
|
||||||
hcln = hclExca[xi+0]
|
|
||||||
if hcln < 0 || hcln == hclchar {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hcln = hclExca[xi+1]
|
|
||||||
if hcln < 0 {
|
|
||||||
goto ret0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if hcln == 0 {
|
|
||||||
/* error ... attempt to resume parsing */
|
|
||||||
switch Errflag {
|
|
||||||
case 0: /* brand new error */
|
|
||||||
hcllex.Error("syntax error")
|
|
||||||
Nerrs++
|
|
||||||
if hclDebug >= 1 {
|
|
||||||
__yyfmt__.Printf("%s", hclStatname(hclstate))
|
|
||||||
__yyfmt__.Printf(" saw %s\n", hclTokname(hclchar))
|
|
||||||
}
|
|
||||||
fallthrough
|
|
||||||
|
|
||||||
case 1, 2: /* incompletely recovered error ... try again */
|
|
||||||
Errflag = 3
|
|
||||||
|
|
||||||
/* find a state where "error" is a legal shift action */
|
|
||||||
for hclp >= 0 {
|
|
||||||
hcln = hclPact[hclS[hclp].yys] + hclErrCode
|
|
||||||
if hcln >= 0 && hcln < hclLast {
|
|
||||||
hclstate = hclAct[hcln] /* simulate a shift of "error" */
|
|
||||||
if hclChk[hclstate] == hclErrCode {
|
|
||||||
goto hclstack
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the current p has no shift on "error", pop stack */
|
|
||||||
if hclDebug >= 2 {
|
|
||||||
__yyfmt__.Printf("error recovery pops state %d\n", hclS[hclp].yys)
|
|
||||||
}
|
|
||||||
hclp--
|
|
||||||
}
|
|
||||||
/* there is no state on the stack with an error shift ... abort */
|
|
||||||
goto ret1
|
|
||||||
|
|
||||||
case 3: /* no shift yet; clobber input char */
|
|
||||||
if hclDebug >= 2 {
|
|
||||||
__yyfmt__.Printf("error recovery discards %s\n", hclTokname(hclchar))
|
|
||||||
}
|
|
||||||
if hclchar == hclEofCode {
|
|
||||||
goto ret1
|
|
||||||
}
|
|
||||||
hclchar = -1
|
|
||||||
goto hclnewstate /* try again in the same state */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reduction by production hcln */
|
|
||||||
if hclDebug >= 2 {
|
|
||||||
__yyfmt__.Printf("reduce %v in:\n\t%v\n", hcln, hclStatname(hclstate))
|
|
||||||
}
|
|
||||||
|
|
||||||
hclnt := hcln
|
|
||||||
hclpt := hclp
|
|
||||||
_ = hclpt // guard against "declared and not used"
|
|
||||||
|
|
||||||
hclp -= hclR2[hcln]
|
|
||||||
hclVAL = hclS[hclp+1]
|
|
||||||
|
|
||||||
/* consult goto table to find next state */
|
|
||||||
hcln = hclR1[hcln]
|
|
||||||
hclg := hclPgo[hcln]
|
|
||||||
hclj := hclg + hclS[hclp].yys + 1
|
|
||||||
|
|
||||||
if hclj >= hclLast {
|
|
||||||
hclstate = hclAct[hclg]
|
|
||||||
} else {
|
|
||||||
hclstate = hclAct[hclj]
|
|
||||||
if hclChk[hclstate] != -hcln {
|
|
||||||
hclstate = hclAct[hclg]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// dummy call; replaced with literal code
|
|
||||||
switch hclnt {
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
//line parse.y:39
|
|
||||||
{
|
|
||||||
hclResult = &Object{Type: ValueTypeObject}
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
//line parse.y:43
|
|
||||||
{
|
|
||||||
hclResult = &Object{
|
|
||||||
Type: ValueTypeObject,
|
|
||||||
Value: ObjectList(hclS[hclpt-0].objlist).Flat(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
//line parse.y:52
|
|
||||||
{
|
|
||||||
hclVAL.objlist = []*Object{hclS[hclpt-0].obj}
|
|
||||||
}
|
|
||||||
case 4:
|
|
||||||
//line parse.y:56
|
|
||||||
{
|
|
||||||
hclVAL.objlist = append(hclS[hclpt-1].objlist, hclS[hclpt-0].obj)
|
|
||||||
}
|
|
||||||
case 5:
|
|
||||||
//line parse.y:62
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeObject,
|
|
||||||
Value: ObjectList(hclS[hclpt-1].objlist).Flat(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 6:
|
|
||||||
//line parse.y:69
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeObject,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 7:
|
|
||||||
//line parse.y:77
|
|
||||||
{
|
|
||||||
hclVAL.str = hclS[hclpt-0].str
|
|
||||||
}
|
|
||||||
case 8:
|
|
||||||
//line parse.y:81
|
|
||||||
{
|
|
||||||
hclVAL.str = hclS[hclpt-0].str
|
|
||||||
}
|
|
||||||
case 9:
|
|
||||||
//line parse.y:87
|
|
||||||
{
|
|
||||||
hclVAL.obj = hclS[hclpt-0].obj
|
|
||||||
hclVAL.obj.Key = hclS[hclpt-2].str
|
|
||||||
}
|
|
||||||
case 10:
|
|
||||||
//line parse.y:92
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Key: hclS[hclpt-2].str,
|
|
||||||
Type: ValueTypeBool,
|
|
||||||
Value: hclS[hclpt-0].b,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 11:
|
|
||||||
//line parse.y:100
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Key: hclS[hclpt-2].str,
|
|
||||||
Type: ValueTypeString,
|
|
||||||
Value: hclS[hclpt-0].str,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 12:
|
|
||||||
//line parse.y:108
|
|
||||||
{
|
|
||||||
hclS[hclpt-0].obj.Key = hclS[hclpt-2].str
|
|
||||||
hclVAL.obj = hclS[hclpt-0].obj
|
|
||||||
}
|
|
||||||
case 13:
|
|
||||||
//line parse.y:113
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Key: hclS[hclpt-2].str,
|
|
||||||
Type: ValueTypeList,
|
|
||||||
Value: hclS[hclpt-0].objlist,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 14:
|
|
||||||
//line parse.y:121
|
|
||||||
{
|
|
||||||
hclVAL.obj = hclS[hclpt-0].obj
|
|
||||||
}
|
|
||||||
case 15:
|
|
||||||
//line parse.y:127
|
|
||||||
{
|
|
||||||
hclS[hclpt-0].obj.Key = hclS[hclpt-1].str
|
|
||||||
hclVAL.obj = hclS[hclpt-0].obj
|
|
||||||
}
|
|
||||||
case 16:
|
|
||||||
//line parse.y:132
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Key: hclS[hclpt-1].str,
|
|
||||||
Type: ValueTypeObject,
|
|
||||||
Value: []*Object{hclS[hclpt-0].obj},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 17:
|
|
||||||
//line parse.y:142
|
|
||||||
{
|
|
||||||
hclVAL.str = hclS[hclpt-0].str
|
|
||||||
}
|
|
||||||
case 18:
|
|
||||||
//line parse.y:146
|
|
||||||
{
|
|
||||||
hclVAL.str = hclS[hclpt-0].str
|
|
||||||
}
|
|
||||||
case 19:
|
|
||||||
//line parse.y:152
|
|
||||||
{
|
|
||||||
hclVAL.objlist = hclS[hclpt-1].objlist
|
|
||||||
}
|
|
||||||
case 20:
|
|
||||||
//line parse.y:156
|
|
||||||
{
|
|
||||||
hclVAL.objlist = nil
|
|
||||||
}
|
|
||||||
case 21:
|
|
||||||
//line parse.y:162
|
|
||||||
{
|
|
||||||
hclVAL.objlist = []*Object{hclS[hclpt-0].obj}
|
|
||||||
}
|
|
||||||
case 22:
|
|
||||||
//line parse.y:166
|
|
||||||
{
|
|
||||||
hclVAL.objlist = append(hclS[hclpt-2].objlist, hclS[hclpt-0].obj)
|
|
||||||
}
|
|
||||||
case 23:
|
|
||||||
//line parse.y:170
|
|
||||||
{
|
|
||||||
hclVAL.objlist = hclS[hclpt-1].objlist
|
|
||||||
}
|
|
||||||
case 24:
|
|
||||||
//line parse.y:176
|
|
||||||
{
|
|
||||||
hclVAL.obj = hclS[hclpt-0].obj
|
|
||||||
}
|
|
||||||
case 25:
|
|
||||||
//line parse.y:180
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeString,
|
|
||||||
Value: hclS[hclpt-0].str,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 26:
|
|
||||||
//line parse.y:189
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeInt,
|
|
||||||
Value: hclS[hclpt-0].num,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 27:
|
|
||||||
//line parse.y:196
|
|
||||||
{
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeFloat,
|
|
||||||
Value: hclS[hclpt-0].f,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 28:
|
|
||||||
//line parse.y:203
|
|
||||||
{
|
|
||||||
fs := fmt.Sprintf("%d%s", hclS[hclpt-1].num, hclS[hclpt-0].str)
|
|
||||||
f, err := strconv.ParseFloat(fs, 64)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeFloat,
|
|
||||||
Value: f,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 29:
|
|
||||||
//line parse.y:216
|
|
||||||
{
|
|
||||||
fs := fmt.Sprintf("%f%s", hclS[hclpt-1].f, hclS[hclpt-0].str)
|
|
||||||
f, err := strconv.ParseFloat(fs, 64)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
hclVAL.obj = &Object{
|
|
||||||
Type: ValueTypeFloat,
|
|
||||||
Value: f,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 30:
|
|
||||||
//line parse.y:231
|
|
||||||
{
|
|
||||||
hclVAL.num = hclS[hclpt-0].num * -1
|
|
||||||
}
|
|
||||||
case 31:
|
|
||||||
//line parse.y:235
|
|
||||||
{
|
|
||||||
hclVAL.num = hclS[hclpt-0].num
|
|
||||||
}
|
|
||||||
case 32:
|
|
||||||
//line parse.y:241
|
|
||||||
{
|
|
||||||
hclVAL.f = hclS[hclpt-0].f * -1
|
|
||||||
}
|
|
||||||
case 33:
|
|
||||||
//line parse.y:245
|
|
||||||
{
|
|
||||||
hclVAL.f = hclS[hclpt-0].f
|
|
||||||
}
|
|
||||||
case 34:
|
|
||||||
//line parse.y:251
|
|
||||||
{
|
|
||||||
hclVAL.str = "e" + strconv.FormatInt(int64(hclS[hclpt-0].num), 10)
|
|
||||||
}
|
|
||||||
case 35:
|
|
||||||
//line parse.y:255
|
|
||||||
{
|
|
||||||
hclVAL.str = "e-" + strconv.FormatInt(int64(hclS[hclpt-0].num), 10)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
goto hclstack /* stack new state and value */
|
|
||||||
}
|
|
@ -8,7 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/hcl"
|
"github.com/yudai/hcl/hcl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is the tag to use with structures to have settings for HCL
|
// This is the tag to use with structures to have settings for HCL
|
||||||
@ -173,6 +173,8 @@ func (d *decoder) decodeInterface(name string, o *hcl.Object, result reflect.Val
|
|||||||
set = reflect.Indirect(reflect.New(reflect.TypeOf(result)))
|
set = reflect.Indirect(reflect.New(reflect.TypeOf(result)))
|
||||||
case hcl.ValueTypeString:
|
case hcl.ValueTypeString:
|
||||||
set = reflect.Indirect(reflect.New(reflect.TypeOf("")))
|
set = reflect.Indirect(reflect.New(reflect.TypeOf("")))
|
||||||
|
case hcl.ValueTypeNil:
|
||||||
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"%s: cannot decode into interface: %T",
|
"%s: cannot decode into interface: %T",
|
||||||
@ -259,6 +261,10 @@ func (d *decoder) decodeMap(name string, o *hcl.Object, result reflect.Value) er
|
|||||||
func (d *decoder) decodePtr(name string, o *hcl.Object, result reflect.Value) error {
|
func (d *decoder) decodePtr(name string, o *hcl.Object, result reflect.Value) error {
|
||||||
// Create an element of the concrete (non pointer) type and decode
|
// Create an element of the concrete (non pointer) type and decode
|
||||||
// into that. Then set the value of the pointer to this type.
|
// into that. Then set the value of the pointer to this type.
|
||||||
|
switch o.Type {
|
||||||
|
case hcl.ValueTypeNil:
|
||||||
|
// NIL
|
||||||
|
default:
|
||||||
resultType := result.Type()
|
resultType := result.Type()
|
||||||
resultElemType := resultType.Elem()
|
resultElemType := resultType.Elem()
|
||||||
val := reflect.New(resultElemType)
|
val := reflect.New(resultElemType)
|
||||||
@ -267,6 +273,7 @@ func (d *decoder) decodePtr(name string, o *hcl.Object, result reflect.Value) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.Set(val)
|
result.Set(val)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
BIN
Godeps/_workspace/src/github.com/yudai/hcl/hcl/hcl.test
generated
vendored
Normal file
BIN
Godeps/_workspace/src/github.com/yudai/hcl/hcl/hcl.test
generated
vendored
Normal file
Binary file not shown.
@ -85,7 +85,7 @@ func (x *hclLex) Lex(yylval *hclSymType) int {
|
|||||||
case '-':
|
case '-':
|
||||||
return MINUS
|
return MINUS
|
||||||
case ',':
|
case ',':
|
||||||
return x.lexComma()
|
return COMMA
|
||||||
case '=':
|
case '=':
|
||||||
return EQUAL
|
return EQUAL
|
||||||
case '[':
|
case '[':
|
||||||
@ -166,27 +166,6 @@ func (x *hclLex) consumeComment(c rune) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lexComma reads the comma
|
|
||||||
func (x *hclLex) lexComma() int {
|
|
||||||
for {
|
|
||||||
c := x.peek()
|
|
||||||
|
|
||||||
// Consume space
|
|
||||||
if unicode.IsSpace(c) {
|
|
||||||
x.next()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if c == ']' {
|
|
||||||
return COMMAEND
|
|
||||||
}
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return COMMA
|
|
||||||
}
|
|
||||||
|
|
||||||
// lexId lexes an identifier
|
// lexId lexes an identifier
|
||||||
func (x *hclLex) lexId(yylval *hclSymType) int {
|
func (x *hclLex) lexId(yylval *hclSymType) int {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
@ -224,6 +203,8 @@ func (x *hclLex) lexId(yylval *hclSymType) int {
|
|||||||
case "false":
|
case "false":
|
||||||
yylval.b = false
|
yylval.b = false
|
||||||
return BOOL
|
return BOOL
|
||||||
|
case "null":
|
||||||
|
return NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
return IDENTIFIER
|
return IDENTIFIER
|
@ -36,7 +36,7 @@ func TestLex(t *testing.T) {
|
|||||||
"list.hcl",
|
"list.hcl",
|
||||||
[]int{
|
[]int{
|
||||||
IDENTIFIER, EQUAL, LEFTBRACKET,
|
IDENTIFIER, EQUAL, LEFTBRACKET,
|
||||||
NUMBER, COMMA, NUMBER, COMMA, STRING,
|
NUMBER, COMMA, NUMBER, COMMA, STRING, COMMA, BOOL,
|
||||||
RIGHTBRACKET, lexEOF,
|
RIGHTBRACKET, lexEOF,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -63,6 +63,24 @@ func TestLex(t *testing.T) {
|
|||||||
RIGHTBRACE, lexEOF,
|
RIGHTBRACE, lexEOF,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"array_comment.hcl",
|
||||||
|
[]int{
|
||||||
|
IDENTIFIER, EQUAL, LEFTBRACKET,
|
||||||
|
STRING, COMMA,
|
||||||
|
STRING, COMMA,
|
||||||
|
RIGHTBRACKET, lexEOF,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"null.hcl",
|
||||||
|
[]int{
|
||||||
|
IDENTIFIER, EQUAL, NULL,
|
||||||
|
IDENTIFIER, EQUAL, LEFTBRACKET, NUMBER, COMMA, NULL, COMMA, NUMBER, RIGHTBRACKET,
|
||||||
|
IDENTIFIER, LEFTBRACE, IDENTIFIER, EQUAL, NULL, RIGHTBRACE,
|
||||||
|
lexEOF,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
@ -29,9 +29,10 @@ import (
|
|||||||
%token <b> BOOL
|
%token <b> BOOL
|
||||||
%token <f> FLOAT
|
%token <f> FLOAT
|
||||||
%token <num> NUMBER
|
%token <num> NUMBER
|
||||||
%token <str> COMMA COMMAEND IDENTIFIER EQUAL NEWLINE STRING MINUS
|
%token <str> COMMA IDENTIFIER EQUAL NEWLINE STRING MINUS
|
||||||
%token <str> LEFTBRACE RIGHTBRACE LEFTBRACKET RIGHTBRACKET PERIOD
|
%token <str> LEFTBRACE RIGHTBRACE LEFTBRACKET RIGHTBRACKET PERIOD
|
||||||
%token <str> EPLUS EMINUS
|
%token <str> EPLUS EMINUS
|
||||||
|
%token <str> NULL
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@ -96,6 +97,13 @@ objectitem:
|
|||||||
Value: $3,
|
Value: $3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
| objectkey EQUAL NULL
|
||||||
|
{
|
||||||
|
$$ = &Object{
|
||||||
|
Key: $1,
|
||||||
|
Type: ValueTypeNil,
|
||||||
|
}
|
||||||
|
}
|
||||||
| objectkey EQUAL STRING
|
| objectkey EQUAL STRING
|
||||||
{
|
{
|
||||||
$$ = &Object{
|
$$ = &Object{
|
||||||
@ -152,6 +160,10 @@ list:
|
|||||||
{
|
{
|
||||||
$$ = $2
|
$$ = $2
|
||||||
}
|
}
|
||||||
|
| LEFTBRACKET listitems COMMA RIGHTBRACKET
|
||||||
|
{
|
||||||
|
$$ = $2
|
||||||
|
}
|
||||||
| LEFTBRACKET RIGHTBRACKET
|
| LEFTBRACKET RIGHTBRACKET
|
||||||
{
|
{
|
||||||
$$ = nil
|
$$ = nil
|
||||||
@ -166,10 +178,6 @@ listitems:
|
|||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$$ = append($1, $3)
|
||||||
}
|
}
|
||||||
| listitems COMMAEND
|
|
||||||
{
|
|
||||||
$$ = $1
|
|
||||||
}
|
|
||||||
|
|
||||||
listitem:
|
listitem:
|
||||||
number
|
number
|
||||||
@ -183,6 +191,20 @@ listitem:
|
|||||||
Value: $1,
|
Value: $1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
| BOOL
|
||||||
|
{
|
||||||
|
$$ = &Object{
|
||||||
|
Type: ValueTypeBool,
|
||||||
|
Value: $1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| NULL
|
||||||
|
{
|
||||||
|
$$ = &Object{
|
||||||
|
Type: ValueTypeNil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
number:
|
number:
|
||||||
int
|
int
|
@ -59,6 +59,14 @@ func TestParse(t *testing.T) {
|
|||||||
"types.hcl",
|
"types.hcl",
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"array_comment.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"null.hcl",
|
||||||
|
false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
4
Godeps/_workspace/src/github.com/yudai/hcl/hcl/test-fixtures/array_comment.hcl
generated
vendored
Normal file
4
Godeps/_workspace/src/github.com/yudai/hcl/hcl/test-fixtures/array_comment.hcl
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
foo = [
|
||||||
|
"1",
|
||||||
|
"2", # comment
|
||||||
|
]
|
1
Godeps/_workspace/src/github.com/yudai/hcl/hcl/test-fixtures/list.hcl
generated
vendored
Normal file
1
Godeps/_workspace/src/github.com/yudai/hcl/hcl/test-fixtures/list.hcl
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
foo = [1, 2, "foo", true]
|
5
Godeps/_workspace/src/github.com/yudai/hcl/hcl/test-fixtures/null.hcl
generated
vendored
Normal file
5
Godeps/_workspace/src/github.com/yudai/hcl/hcl/test-fixtures/null.hcl
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
foo = null
|
||||||
|
bar = [1, null, 3]
|
||||||
|
baz {
|
||||||
|
foo = null
|
||||||
|
}
|
@ -5,3 +5,4 @@ foo = -12
|
|||||||
bar = 3.14159
|
bar = 3.14159
|
||||||
foo = true
|
foo = true
|
||||||
bar = false
|
bar = false
|
||||||
|
baz = null
|
790
Godeps/_workspace/src/github.com/yudai/hcl/hcl/y.go
generated
vendored
Normal file
790
Godeps/_workspace/src/github.com/yudai/hcl/hcl/y.go
generated
vendored
Normal file
@ -0,0 +1,790 @@
|
|||||||
|
//line parse.y:4
|
||||||
|
package hcl
|
||||||
|
|
||||||
|
import __yyfmt__ "fmt"
|
||||||
|
|
||||||
|
//line parse.y:4
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
//line parse.y:13
|
||||||
|
type hclSymType struct {
|
||||||
|
yys int
|
||||||
|
b bool
|
||||||
|
f float64
|
||||||
|
num int
|
||||||
|
str string
|
||||||
|
obj *Object
|
||||||
|
objlist []*Object
|
||||||
|
}
|
||||||
|
|
||||||
|
const BOOL = 57346
|
||||||
|
const FLOAT = 57347
|
||||||
|
const NUMBER = 57348
|
||||||
|
const COMMA = 57349
|
||||||
|
const IDENTIFIER = 57350
|
||||||
|
const EQUAL = 57351
|
||||||
|
const NEWLINE = 57352
|
||||||
|
const STRING = 57353
|
||||||
|
const MINUS = 57354
|
||||||
|
const LEFTBRACE = 57355
|
||||||
|
const RIGHTBRACE = 57356
|
||||||
|
const LEFTBRACKET = 57357
|
||||||
|
const RIGHTBRACKET = 57358
|
||||||
|
const PERIOD = 57359
|
||||||
|
const EPLUS = 57360
|
||||||
|
const EMINUS = 57361
|
||||||
|
const NULL = 57362
|
||||||
|
|
||||||
|
var hclToknames = [...]string{
|
||||||
|
"$end",
|
||||||
|
"error",
|
||||||
|
"$unk",
|
||||||
|
"BOOL",
|
||||||
|
"FLOAT",
|
||||||
|
"NUMBER",
|
||||||
|
"COMMA",
|
||||||
|
"IDENTIFIER",
|
||||||
|
"EQUAL",
|
||||||
|
"NEWLINE",
|
||||||
|
"STRING",
|
||||||
|
"MINUS",
|
||||||
|
"LEFTBRACE",
|
||||||
|
"RIGHTBRACE",
|
||||||
|
"LEFTBRACKET",
|
||||||
|
"RIGHTBRACKET",
|
||||||
|
"PERIOD",
|
||||||
|
"EPLUS",
|
||||||
|
"EMINUS",
|
||||||
|
"NULL",
|
||||||
|
}
|
||||||
|
var hclStatenames = [...]string{}
|
||||||
|
|
||||||
|
const hclEofCode = 1
|
||||||
|
const hclErrCode = 2
|
||||||
|
const hclMaxDepth = 200
|
||||||
|
|
||||||
|
//line parse.y:281
|
||||||
|
|
||||||
|
//line yacctab:1
|
||||||
|
var hclExca = [...]int{
|
||||||
|
-1, 1,
|
||||||
|
1, -1,
|
||||||
|
-2, 0,
|
||||||
|
-1, 6,
|
||||||
|
9, 7,
|
||||||
|
-2, 18,
|
||||||
|
-1, 7,
|
||||||
|
9, 8,
|
||||||
|
-2, 19,
|
||||||
|
}
|
||||||
|
|
||||||
|
const hclNprod = 39
|
||||||
|
const hclPrivate = 57344
|
||||||
|
|
||||||
|
var hclTokenNames []string
|
||||||
|
var hclStates []string
|
||||||
|
|
||||||
|
const hclLast = 69
|
||||||
|
|
||||||
|
var hclAct = [...]int{
|
||||||
|
|
||||||
|
36, 3, 22, 30, 9, 17, 27, 26, 31, 32,
|
||||||
|
45, 23, 19, 25, 13, 10, 24, 39, 27, 26,
|
||||||
|
6, 18, 47, 7, 38, 25, 43, 33, 41, 48,
|
||||||
|
9, 46, 44, 40, 39, 27, 26, 42, 5, 1,
|
||||||
|
14, 38, 25, 15, 2, 13, 35, 12, 49, 6,
|
||||||
|
40, 4, 7, 27, 26, 29, 11, 37, 28, 6,
|
||||||
|
25, 8, 7, 34, 21, 0, 0, 20, 16,
|
||||||
|
}
|
||||||
|
var hclPact = [...]int{
|
||||||
|
|
||||||
|
51, -1000, 51, -1000, 6, -1000, -1000, -1000, 32, -1000,
|
||||||
|
1, -1000, -1000, 41, -1000, -1000, -1000, -1000, -1000, -1000,
|
||||||
|
-1000, -1000, -10, -10, 30, 48, -1000, -1000, 12, -1000,
|
||||||
|
-1000, 26, 4, -1000, 15, -1000, -1000, -1000, -1000, -1000,
|
||||||
|
-1000, -1000, -1000, -1000, -1000, -1000, -1000, 13, -1000, -1000,
|
||||||
|
}
|
||||||
|
var hclPgo = [...]int{
|
||||||
|
|
||||||
|
0, 11, 2, 64, 63, 44, 38, 57, 56, 1,
|
||||||
|
0, 61, 3, 51, 39,
|
||||||
|
}
|
||||||
|
var hclR1 = [...]int{
|
||||||
|
|
||||||
|
0, 14, 14, 5, 5, 8, 8, 13, 13, 9,
|
||||||
|
9, 9, 9, 9, 9, 9, 6, 6, 11, 11,
|
||||||
|
3, 3, 3, 4, 4, 10, 10, 10, 10, 7,
|
||||||
|
7, 7, 7, 2, 2, 1, 1, 12, 12,
|
||||||
|
}
|
||||||
|
var hclR2 = [...]int{
|
||||||
|
|
||||||
|
0, 0, 1, 1, 2, 3, 2, 1, 1, 3,
|
||||||
|
3, 3, 3, 3, 3, 1, 2, 2, 1, 1,
|
||||||
|
3, 4, 2, 1, 3, 1, 1, 1, 1, 1,
|
||||||
|
1, 2, 2, 2, 1, 2, 1, 2, 2,
|
||||||
|
}
|
||||||
|
var hclChk = [...]int{
|
||||||
|
|
||||||
|
-1000, -14, -5, -9, -13, -6, 8, 11, -11, -9,
|
||||||
|
9, -8, -6, 13, 8, 11, -7, 4, 20, 11,
|
||||||
|
-8, -3, -2, -1, 15, 12, 6, 5, -5, 14,
|
||||||
|
-12, 18, 19, -12, -4, 16, -10, -7, 11, 4,
|
||||||
|
20, -2, -1, 14, 6, 6, 16, 7, 16, -10,
|
||||||
|
}
|
||||||
|
var hclDef = [...]int{
|
||||||
|
|
||||||
|
1, -2, 2, 3, 0, 15, -2, -2, 0, 4,
|
||||||
|
0, 16, 17, 0, 18, 19, 9, 10, 11, 12,
|
||||||
|
13, 14, 29, 30, 0, 0, 34, 36, 0, 6,
|
||||||
|
31, 0, 0, 32, 0, 22, 23, 25, 26, 27,
|
||||||
|
28, 33, 35, 5, 37, 38, 20, 0, 21, 24,
|
||||||
|
}
|
||||||
|
var hclTok1 = [...]int{
|
||||||
|
|
||||||
|
1,
|
||||||
|
}
|
||||||
|
var hclTok2 = [...]int{
|
||||||
|
|
||||||
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||||
|
12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||||
|
}
|
||||||
|
var hclTok3 = [...]int{
|
||||||
|
0,
|
||||||
|
}
|
||||||
|
|
||||||
|
var hclErrorMessages = [...]struct {
|
||||||
|
state int
|
||||||
|
token int
|
||||||
|
msg string
|
||||||
|
}{}
|
||||||
|
|
||||||
|
//line yaccpar:1
|
||||||
|
|
||||||
|
/* parser for yacc output */
|
||||||
|
|
||||||
|
var (
|
||||||
|
hclDebug = 0
|
||||||
|
hclErrorVerbose = false
|
||||||
|
)
|
||||||
|
|
||||||
|
type hclLexer interface {
|
||||||
|
Lex(lval *hclSymType) int
|
||||||
|
Error(s string)
|
||||||
|
}
|
||||||
|
|
||||||
|
type hclParser interface {
|
||||||
|
Parse(hclLexer) int
|
||||||
|
Lookahead() int
|
||||||
|
}
|
||||||
|
|
||||||
|
type hclParserImpl struct {
|
||||||
|
lookahead func() int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *hclParserImpl) Lookahead() int {
|
||||||
|
return p.lookahead()
|
||||||
|
}
|
||||||
|
|
||||||
|
func hclNewParser() hclParser {
|
||||||
|
p := &hclParserImpl{
|
||||||
|
lookahead: func() int { return -1 },
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
const hclFlag = -1000
|
||||||
|
|
||||||
|
func hclTokname(c int) string {
|
||||||
|
if c >= 1 && c-1 < len(hclToknames) {
|
||||||
|
if hclToknames[c-1] != "" {
|
||||||
|
return hclToknames[c-1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return __yyfmt__.Sprintf("tok-%v", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hclStatname(s int) string {
|
||||||
|
if s >= 0 && s < len(hclStatenames) {
|
||||||
|
if hclStatenames[s] != "" {
|
||||||
|
return hclStatenames[s]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return __yyfmt__.Sprintf("state-%v", s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hclErrorMessage(state, lookAhead int) string {
|
||||||
|
const TOKSTART = 4
|
||||||
|
|
||||||
|
if !hclErrorVerbose {
|
||||||
|
return "syntax error"
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range hclErrorMessages {
|
||||||
|
if e.state == state && e.token == lookAhead {
|
||||||
|
return "syntax error: " + e.msg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res := "syntax error: unexpected " + hclTokname(lookAhead)
|
||||||
|
|
||||||
|
// To match Bison, suggest at most four expected tokens.
|
||||||
|
expected := make([]int, 0, 4)
|
||||||
|
|
||||||
|
// Look for shiftable tokens.
|
||||||
|
base := hclPact[state]
|
||||||
|
for tok := TOKSTART; tok-1 < len(hclToknames); tok++ {
|
||||||
|
if n := base + tok; n >= 0 && n < hclLast && hclChk[hclAct[n]] == tok {
|
||||||
|
if len(expected) == cap(expected) {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
expected = append(expected, tok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if hclDef[state] == -2 {
|
||||||
|
i := 0
|
||||||
|
for hclExca[i] != -1 || hclExca[i+1] != state {
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for tokens that we accept or reduce.
|
||||||
|
for i += 2; hclExca[i] >= 0; i += 2 {
|
||||||
|
tok := hclExca[i]
|
||||||
|
if tok < TOKSTART || hclExca[i+1] == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(expected) == cap(expected) {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
expected = append(expected, tok)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the default action is to accept or reduce, give up.
|
||||||
|
if hclExca[i+1] != 0 {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tok := range expected {
|
||||||
|
if i == 0 {
|
||||||
|
res += ", expecting "
|
||||||
|
} else {
|
||||||
|
res += " or "
|
||||||
|
}
|
||||||
|
res += hclTokname(tok)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func hcllex1(lex hclLexer, lval *hclSymType) (char, token int) {
|
||||||
|
token = 0
|
||||||
|
char = lex.Lex(lval)
|
||||||
|
if char <= 0 {
|
||||||
|
token = hclTok1[0]
|
||||||
|
goto out
|
||||||
|
}
|
||||||
|
if char < len(hclTok1) {
|
||||||
|
token = hclTok1[char]
|
||||||
|
goto out
|
||||||
|
}
|
||||||
|
if char >= hclPrivate {
|
||||||
|
if char < hclPrivate+len(hclTok2) {
|
||||||
|
token = hclTok2[char-hclPrivate]
|
||||||
|
goto out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := 0; i < len(hclTok3); i += 2 {
|
||||||
|
token = hclTok3[i+0]
|
||||||
|
if token == char {
|
||||||
|
token = hclTok3[i+1]
|
||||||
|
goto out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if token == 0 {
|
||||||
|
token = hclTok2[1] /* unknown char */
|
||||||
|
}
|
||||||
|
if hclDebug >= 3 {
|
||||||
|
__yyfmt__.Printf("lex %s(%d)\n", hclTokname(token), uint(char))
|
||||||
|
}
|
||||||
|
return char, token
|
||||||
|
}
|
||||||
|
|
||||||
|
func hclParse(hcllex hclLexer) int {
|
||||||
|
return hclNewParser().Parse(hcllex)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hclrcvr *hclParserImpl) Parse(hcllex hclLexer) int {
|
||||||
|
var hcln int
|
||||||
|
var hcllval hclSymType
|
||||||
|
var hclVAL hclSymType
|
||||||
|
var hclDollar []hclSymType
|
||||||
|
_ = hclDollar // silence set and not used
|
||||||
|
hclS := make([]hclSymType, hclMaxDepth)
|
||||||
|
|
||||||
|
Nerrs := 0 /* number of errors */
|
||||||
|
Errflag := 0 /* error recovery flag */
|
||||||
|
hclstate := 0
|
||||||
|
hclchar := -1
|
||||||
|
hcltoken := -1 // hclchar translated into internal numbering
|
||||||
|
hclrcvr.lookahead = func() int { return hclchar }
|
||||||
|
defer func() {
|
||||||
|
// Make sure we report no lookahead when not parsing.
|
||||||
|
hclstate = -1
|
||||||
|
hclchar = -1
|
||||||
|
hcltoken = -1
|
||||||
|
}()
|
||||||
|
hclp := -1
|
||||||
|
goto hclstack
|
||||||
|
|
||||||
|
ret0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
ret1:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
hclstack:
|
||||||
|
/* put a state and value onto the stack */
|
||||||
|
if hclDebug >= 4 {
|
||||||
|
__yyfmt__.Printf("char %v in %v\n", hclTokname(hcltoken), hclStatname(hclstate))
|
||||||
|
}
|
||||||
|
|
||||||
|
hclp++
|
||||||
|
if hclp >= len(hclS) {
|
||||||
|
nyys := make([]hclSymType, len(hclS)*2)
|
||||||
|
copy(nyys, hclS)
|
||||||
|
hclS = nyys
|
||||||
|
}
|
||||||
|
hclS[hclp] = hclVAL
|
||||||
|
hclS[hclp].yys = hclstate
|
||||||
|
|
||||||
|
hclnewstate:
|
||||||
|
hcln = hclPact[hclstate]
|
||||||
|
if hcln <= hclFlag {
|
||||||
|
goto hcldefault /* simple state */
|
||||||
|
}
|
||||||
|
if hclchar < 0 {
|
||||||
|
hclchar, hcltoken = hcllex1(hcllex, &hcllval)
|
||||||
|
}
|
||||||
|
hcln += hcltoken
|
||||||
|
if hcln < 0 || hcln >= hclLast {
|
||||||
|
goto hcldefault
|
||||||
|
}
|
||||||
|
hcln = hclAct[hcln]
|
||||||
|
if hclChk[hcln] == hcltoken { /* valid shift */
|
||||||
|
hclchar = -1
|
||||||
|
hcltoken = -1
|
||||||
|
hclVAL = hcllval
|
||||||
|
hclstate = hcln
|
||||||
|
if Errflag > 0 {
|
||||||
|
Errflag--
|
||||||
|
}
|
||||||
|
goto hclstack
|
||||||
|
}
|
||||||
|
|
||||||
|
hcldefault:
|
||||||
|
/* default state action */
|
||||||
|
hcln = hclDef[hclstate]
|
||||||
|
if hcln == -2 {
|
||||||
|
if hclchar < 0 {
|
||||||
|
hclchar, hcltoken = hcllex1(hcllex, &hcllval)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* look through exception table */
|
||||||
|
xi := 0
|
||||||
|
for {
|
||||||
|
if hclExca[xi+0] == -1 && hclExca[xi+1] == hclstate {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
xi += 2
|
||||||
|
}
|
||||||
|
for xi += 2; ; xi += 2 {
|
||||||
|
hcln = hclExca[xi+0]
|
||||||
|
if hcln < 0 || hcln == hcltoken {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hcln = hclExca[xi+1]
|
||||||
|
if hcln < 0 {
|
||||||
|
goto ret0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if hcln == 0 {
|
||||||
|
/* error ... attempt to resume parsing */
|
||||||
|
switch Errflag {
|
||||||
|
case 0: /* brand new error */
|
||||||
|
hcllex.Error(hclErrorMessage(hclstate, hcltoken))
|
||||||
|
Nerrs++
|
||||||
|
if hclDebug >= 1 {
|
||||||
|
__yyfmt__.Printf("%s", hclStatname(hclstate))
|
||||||
|
__yyfmt__.Printf(" saw %s\n", hclTokname(hcltoken))
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
|
||||||
|
case 1, 2: /* incompletely recovered error ... try again */
|
||||||
|
Errflag = 3
|
||||||
|
|
||||||
|
/* find a state where "error" is a legal shift action */
|
||||||
|
for hclp >= 0 {
|
||||||
|
hcln = hclPact[hclS[hclp].yys] + hclErrCode
|
||||||
|
if hcln >= 0 && hcln < hclLast {
|
||||||
|
hclstate = hclAct[hcln] /* simulate a shift of "error" */
|
||||||
|
if hclChk[hclstate] == hclErrCode {
|
||||||
|
goto hclstack
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the current p has no shift on "error", pop stack */
|
||||||
|
if hclDebug >= 2 {
|
||||||
|
__yyfmt__.Printf("error recovery pops state %d\n", hclS[hclp].yys)
|
||||||
|
}
|
||||||
|
hclp--
|
||||||
|
}
|
||||||
|
/* there is no state on the stack with an error shift ... abort */
|
||||||
|
goto ret1
|
||||||
|
|
||||||
|
case 3: /* no shift yet; clobber input char */
|
||||||
|
if hclDebug >= 2 {
|
||||||
|
__yyfmt__.Printf("error recovery discards %s\n", hclTokname(hcltoken))
|
||||||
|
}
|
||||||
|
if hcltoken == hclEofCode {
|
||||||
|
goto ret1
|
||||||
|
}
|
||||||
|
hclchar = -1
|
||||||
|
hcltoken = -1
|
||||||
|
goto hclnewstate /* try again in the same state */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reduction by production hcln */
|
||||||
|
if hclDebug >= 2 {
|
||||||
|
__yyfmt__.Printf("reduce %v in:\n\t%v\n", hcln, hclStatname(hclstate))
|
||||||
|
}
|
||||||
|
|
||||||
|
hclnt := hcln
|
||||||
|
hclpt := hclp
|
||||||
|
_ = hclpt // guard against "declared and not used"
|
||||||
|
|
||||||
|
hclp -= hclR2[hcln]
|
||||||
|
// hclp is now the index of $0. Perform the default action. Iff the
|
||||||
|
// reduced production is ε, $1 is possibly out of range.
|
||||||
|
if hclp+1 >= len(hclS) {
|
||||||
|
nyys := make([]hclSymType, len(hclS)*2)
|
||||||
|
copy(nyys, hclS)
|
||||||
|
hclS = nyys
|
||||||
|
}
|
||||||
|
hclVAL = hclS[hclp+1]
|
||||||
|
|
||||||
|
/* consult goto table to find next state */
|
||||||
|
hcln = hclR1[hcln]
|
||||||
|
hclg := hclPgo[hcln]
|
||||||
|
hclj := hclg + hclS[hclp].yys + 1
|
||||||
|
|
||||||
|
if hclj >= hclLast {
|
||||||
|
hclstate = hclAct[hclg]
|
||||||
|
} else {
|
||||||
|
hclstate = hclAct[hclj]
|
||||||
|
if hclChk[hclstate] != -hcln {
|
||||||
|
hclstate = hclAct[hclg]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dummy call; replaced with literal code
|
||||||
|
switch hclnt {
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
hclDollar = hclS[hclpt-0 : hclpt+1]
|
||||||
|
//line parse.y:40
|
||||||
|
{
|
||||||
|
hclResult = &Object{Type: ValueTypeObject}
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:44
|
||||||
|
{
|
||||||
|
hclResult = &Object{
|
||||||
|
Type: ValueTypeObject,
|
||||||
|
Value: ObjectList(hclDollar[1].objlist).Flat(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:53
|
||||||
|
{
|
||||||
|
hclVAL.objlist = []*Object{hclDollar[1].obj}
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:57
|
||||||
|
{
|
||||||
|
hclVAL.objlist = append(hclDollar[1].objlist, hclDollar[2].obj)
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:63
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeObject,
|
||||||
|
Value: ObjectList(hclDollar[2].objlist).Flat(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:70
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeObject,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:78
|
||||||
|
{
|
||||||
|
hclVAL.str = hclDollar[1].str
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:82
|
||||||
|
{
|
||||||
|
hclVAL.str = hclDollar[1].str
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:88
|
||||||
|
{
|
||||||
|
hclVAL.obj = hclDollar[3].obj
|
||||||
|
hclVAL.obj.Key = hclDollar[1].str
|
||||||
|
}
|
||||||
|
case 10:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:93
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Key: hclDollar[1].str,
|
||||||
|
Type: ValueTypeBool,
|
||||||
|
Value: hclDollar[3].b,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 11:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:101
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Key: hclDollar[1].str,
|
||||||
|
Type: ValueTypeNil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 12:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:108
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Key: hclDollar[1].str,
|
||||||
|
Type: ValueTypeString,
|
||||||
|
Value: hclDollar[3].str,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 13:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:116
|
||||||
|
{
|
||||||
|
hclDollar[3].obj.Key = hclDollar[1].str
|
||||||
|
hclVAL.obj = hclDollar[3].obj
|
||||||
|
}
|
||||||
|
case 14:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:121
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Key: hclDollar[1].str,
|
||||||
|
Type: ValueTypeList,
|
||||||
|
Value: hclDollar[3].objlist,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 15:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:129
|
||||||
|
{
|
||||||
|
hclVAL.obj = hclDollar[1].obj
|
||||||
|
}
|
||||||
|
case 16:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:135
|
||||||
|
{
|
||||||
|
hclDollar[2].obj.Key = hclDollar[1].str
|
||||||
|
hclVAL.obj = hclDollar[2].obj
|
||||||
|
}
|
||||||
|
case 17:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:140
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Key: hclDollar[1].str,
|
||||||
|
Type: ValueTypeObject,
|
||||||
|
Value: []*Object{hclDollar[2].obj},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 18:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:150
|
||||||
|
{
|
||||||
|
hclVAL.str = hclDollar[1].str
|
||||||
|
}
|
||||||
|
case 19:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:154
|
||||||
|
{
|
||||||
|
hclVAL.str = hclDollar[1].str
|
||||||
|
}
|
||||||
|
case 20:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:160
|
||||||
|
{
|
||||||
|
hclVAL.objlist = hclDollar[2].objlist
|
||||||
|
}
|
||||||
|
case 21:
|
||||||
|
hclDollar = hclS[hclpt-4 : hclpt+1]
|
||||||
|
//line parse.y:164
|
||||||
|
{
|
||||||
|
hclVAL.objlist = hclDollar[2].objlist
|
||||||
|
}
|
||||||
|
case 22:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:168
|
||||||
|
{
|
||||||
|
hclVAL.objlist = nil
|
||||||
|
}
|
||||||
|
case 23:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:174
|
||||||
|
{
|
||||||
|
hclVAL.objlist = []*Object{hclDollar[1].obj}
|
||||||
|
}
|
||||||
|
case 24:
|
||||||
|
hclDollar = hclS[hclpt-3 : hclpt+1]
|
||||||
|
//line parse.y:178
|
||||||
|
{
|
||||||
|
hclVAL.objlist = append(hclDollar[1].objlist, hclDollar[3].obj)
|
||||||
|
}
|
||||||
|
case 25:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:184
|
||||||
|
{
|
||||||
|
hclVAL.obj = hclDollar[1].obj
|
||||||
|
}
|
||||||
|
case 26:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:188
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeString,
|
||||||
|
Value: hclDollar[1].str,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 27:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:195
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeBool,
|
||||||
|
Value: hclDollar[1].b,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 28:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:202
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeNil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 29:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:211
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeInt,
|
||||||
|
Value: hclDollar[1].num,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 30:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:218
|
||||||
|
{
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeFloat,
|
||||||
|
Value: hclDollar[1].f,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 31:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:225
|
||||||
|
{
|
||||||
|
fs := fmt.Sprintf("%d%s", hclDollar[1].num, hclDollar[2].str)
|
||||||
|
f, err := strconv.ParseFloat(fs, 64)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeFloat,
|
||||||
|
Value: f,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 32:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:238
|
||||||
|
{
|
||||||
|
fs := fmt.Sprintf("%f%s", hclDollar[1].f, hclDollar[2].str)
|
||||||
|
f, err := strconv.ParseFloat(fs, 64)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hclVAL.obj = &Object{
|
||||||
|
Type: ValueTypeFloat,
|
||||||
|
Value: f,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 33:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:253
|
||||||
|
{
|
||||||
|
hclVAL.num = hclDollar[2].num * -1
|
||||||
|
}
|
||||||
|
case 34:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:257
|
||||||
|
{
|
||||||
|
hclVAL.num = hclDollar[1].num
|
||||||
|
}
|
||||||
|
case 35:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:263
|
||||||
|
{
|
||||||
|
hclVAL.f = hclDollar[2].f * -1
|
||||||
|
}
|
||||||
|
case 36:
|
||||||
|
hclDollar = hclS[hclpt-1 : hclpt+1]
|
||||||
|
//line parse.y:267
|
||||||
|
{
|
||||||
|
hclVAL.f = hclDollar[1].f
|
||||||
|
}
|
||||||
|
case 37:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:273
|
||||||
|
{
|
||||||
|
hclVAL.str = "e" + strconv.FormatInt(int64(hclDollar[2].num), 10)
|
||||||
|
}
|
||||||
|
case 38:
|
||||||
|
hclDollar = hclS[hclpt-2 : hclpt+1]
|
||||||
|
//line parse.y:277
|
||||||
|
{
|
||||||
|
hclVAL.str = "e-" + strconv.FormatInt(int64(hclDollar[2].num), 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goto hclstack /* stack new state and value */
|
||||||
|
}
|
@ -3,7 +3,7 @@ package json
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/hcl"
|
"github.com/yudai/hcl/hcl"
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
)
|
)
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/hcl"
|
"github.com/yudai/hcl/hcl"
|
||||||
)
|
)
|
||||||
|
|
||||||
//line parse.y:15
|
//line parse.y:15
|
||||||
@ -41,7 +41,10 @@ const PERIOD = 57362
|
|||||||
const EPLUS = 57363
|
const EPLUS = 57363
|
||||||
const EMINUS = 57364
|
const EMINUS = 57364
|
||||||
|
|
||||||
var jsonToknames = []string{
|
var jsonToknames = [...]string{
|
||||||
|
"$end",
|
||||||
|
"error",
|
||||||
|
"$unk",
|
||||||
"FLOAT",
|
"FLOAT",
|
||||||
"NUMBER",
|
"NUMBER",
|
||||||
"COLON",
|
"COLON",
|
||||||
@ -62,7 +65,7 @@ var jsonToknames = []string{
|
|||||||
"EPLUS",
|
"EPLUS",
|
||||||
"EMINUS",
|
"EMINUS",
|
||||||
}
|
}
|
||||||
var jsonStatenames = []string{}
|
var jsonStatenames = [...]string{}
|
||||||
|
|
||||||
const jsonEofCode = 1
|
const jsonEofCode = 1
|
||||||
const jsonErrCode = 2
|
const jsonErrCode = 2
|
||||||
@ -71,7 +74,7 @@ const jsonMaxDepth = 200
|
|||||||
//line parse.y:210
|
//line parse.y:210
|
||||||
|
|
||||||
//line yacctab:1
|
//line yacctab:1
|
||||||
var jsonExca = []int{
|
var jsonExca = [...]int{
|
||||||
-1, 1,
|
-1, 1,
|
||||||
1, -1,
|
1, -1,
|
||||||
-2, 0,
|
-2, 0,
|
||||||
@ -85,7 +88,7 @@ var jsonStates []string
|
|||||||
|
|
||||||
const jsonLast = 53
|
const jsonLast = 53
|
||||||
|
|
||||||
var jsonAct = []int{
|
var jsonAct = [...]int{
|
||||||
|
|
||||||
12, 25, 24, 3, 20, 27, 28, 7, 13, 3,
|
12, 25, 24, 3, 20, 27, 28, 7, 13, 3,
|
||||||
21, 22, 30, 17, 18, 19, 23, 25, 24, 26,
|
21, 22, 30, 17, 18, 19, 23, 25, 24, 26,
|
||||||
@ -94,76 +97,104 @@ var jsonAct = []int{
|
|||||||
5, 29, 6, 8, 37, 15, 2, 1, 4, 31,
|
5, 29, 6, 8, 37, 15, 2, 1, 4, 31,
|
||||||
16, 14, 11,
|
16, 14, 11,
|
||||||
}
|
}
|
||||||
var jsonPact = []int{
|
var jsonPact = [...]int{
|
||||||
|
|
||||||
-9, -1000, -1000, 27, 30, -1000, -1000, 20, -1000, -4,
|
-9, -1000, -1000, 27, 30, -1000, -1000, 20, -1000, -4,
|
||||||
13, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
|
13, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
|
||||||
-16, -16, -3, 16, -1000, -1000, -1000, 28, 17, -1000,
|
-16, -16, -3, 16, -1000, -1000, -1000, 28, 17, -1000,
|
||||||
-1000, 29, -1000, -1000, -1000, -1000, -1000, -1000, 13, -1000,
|
-1000, 29, -1000, -1000, -1000, -1000, -1000, -1000, 13, -1000,
|
||||||
}
|
}
|
||||||
var jsonPgo = []int{
|
var jsonPgo = [...]int{
|
||||||
|
|
||||||
0, 10, 4, 51, 45, 42, 0, 50, 49, 48,
|
0, 10, 4, 51, 45, 42, 0, 50, 49, 48,
|
||||||
19, 47,
|
19, 47,
|
||||||
}
|
}
|
||||||
var jsonR1 = []int{
|
var jsonR1 = [...]int{
|
||||||
|
|
||||||
0, 11, 4, 4, 9, 9, 5, 6, 6, 6,
|
0, 11, 4, 4, 9, 9, 5, 6, 6, 6,
|
||||||
6, 6, 6, 6, 7, 7, 8, 8, 3, 3,
|
6, 6, 6, 6, 7, 7, 8, 8, 3, 3,
|
||||||
3, 3, 2, 2, 1, 1, 10, 10,
|
3, 3, 2, 2, 1, 1, 10, 10,
|
||||||
}
|
}
|
||||||
var jsonR2 = []int{
|
var jsonR2 = [...]int{
|
||||||
|
|
||||||
0, 1, 3, 2, 1, 3, 3, 1, 1, 1,
|
0, 1, 3, 2, 1, 3, 3, 1, 1, 1,
|
||||||
1, 1, 1, 1, 2, 3, 1, 3, 1, 1,
|
1, 1, 1, 1, 2, 3, 1, 3, 1, 1,
|
||||||
2, 2, 2, 1, 2, 1, 2, 2,
|
2, 2, 2, 1, 2, 1, 2, 2,
|
||||||
}
|
}
|
||||||
var jsonChk = []int{
|
var jsonChk = [...]int{
|
||||||
|
|
||||||
-1000, -11, -4, 12, -9, 13, -5, 11, 13, 7,
|
-1000, -11, -4, 12, -9, 13, -5, 11, 13, 7,
|
||||||
6, -5, -6, 11, -3, -4, -7, 16, 17, 18,
|
6, -5, -6, 11, -3, -4, -7, 16, 17, 18,
|
||||||
-2, -1, 14, 19, 5, 4, -10, 21, 22, -10,
|
-2, -1, 14, 19, 5, 4, -10, 21, 22, -10,
|
||||||
15, -8, -6, -2, -1, 5, 5, 15, 7, -6,
|
15, -8, -6, -2, -1, 5, 5, 15, 7, -6,
|
||||||
}
|
}
|
||||||
var jsonDef = []int{
|
var jsonDef = [...]int{
|
||||||
|
|
||||||
0, -2, 1, 0, 0, 3, 4, 0, 2, 0,
|
0, -2, 1, 0, 0, 3, 4, 0, 2, 0,
|
||||||
0, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
0, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||||
18, 19, 0, 0, 23, 25, 20, 0, 0, 21,
|
18, 19, 0, 0, 23, 25, 20, 0, 0, 21,
|
||||||
14, 0, 16, 22, 24, 26, 27, 15, 0, 17,
|
14, 0, 16, 22, 24, 26, 27, 15, 0, 17,
|
||||||
}
|
}
|
||||||
var jsonTok1 = []int{
|
var jsonTok1 = [...]int{
|
||||||
|
|
||||||
1,
|
1,
|
||||||
}
|
}
|
||||||
var jsonTok2 = []int{
|
var jsonTok2 = [...]int{
|
||||||
|
|
||||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||||
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||||
22,
|
22,
|
||||||
}
|
}
|
||||||
var jsonTok3 = []int{
|
var jsonTok3 = [...]int{
|
||||||
0,
|
0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var jsonErrorMessages = [...]struct {
|
||||||
|
state int
|
||||||
|
token int
|
||||||
|
msg string
|
||||||
|
}{}
|
||||||
|
|
||||||
//line yaccpar:1
|
//line yaccpar:1
|
||||||
|
|
||||||
/* parser for yacc output */
|
/* parser for yacc output */
|
||||||
|
|
||||||
var jsonDebug = 0
|
var (
|
||||||
|
jsonDebug = 0
|
||||||
|
jsonErrorVerbose = false
|
||||||
|
)
|
||||||
|
|
||||||
type jsonLexer interface {
|
type jsonLexer interface {
|
||||||
Lex(lval *jsonSymType) int
|
Lex(lval *jsonSymType) int
|
||||||
Error(s string)
|
Error(s string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type jsonParser interface {
|
||||||
|
Parse(jsonLexer) int
|
||||||
|
Lookahead() int
|
||||||
|
}
|
||||||
|
|
||||||
|
type jsonParserImpl struct {
|
||||||
|
lookahead func() int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *jsonParserImpl) Lookahead() int {
|
||||||
|
return p.lookahead()
|
||||||
|
}
|
||||||
|
|
||||||
|
func jsonNewParser() jsonParser {
|
||||||
|
p := &jsonParserImpl{
|
||||||
|
lookahead: func() int { return -1 },
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
const jsonFlag = -1000
|
const jsonFlag = -1000
|
||||||
|
|
||||||
func jsonTokname(c int) string {
|
func jsonTokname(c int) string {
|
||||||
// 4 is TOKSTART above
|
if c >= 1 && c-1 < len(jsonToknames) {
|
||||||
if c >= 4 && c-4 < len(jsonToknames) {
|
if jsonToknames[c-1] != "" {
|
||||||
if jsonToknames[c-4] != "" {
|
return jsonToknames[c-1]
|
||||||
return jsonToknames[c-4]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return __yyfmt__.Sprintf("tok-%v", c)
|
return __yyfmt__.Sprintf("tok-%v", c)
|
||||||
@ -178,51 +209,129 @@ func jsonStatname(s int) string {
|
|||||||
return __yyfmt__.Sprintf("state-%v", s)
|
return __yyfmt__.Sprintf("state-%v", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonlex1(lex jsonLexer, lval *jsonSymType) int {
|
func jsonErrorMessage(state, lookAhead int) string {
|
||||||
c := 0
|
const TOKSTART = 4
|
||||||
char := lex.Lex(lval)
|
|
||||||
|
if !jsonErrorVerbose {
|
||||||
|
return "syntax error"
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range jsonErrorMessages {
|
||||||
|
if e.state == state && e.token == lookAhead {
|
||||||
|
return "syntax error: " + e.msg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res := "syntax error: unexpected " + jsonTokname(lookAhead)
|
||||||
|
|
||||||
|
// To match Bison, suggest at most four expected tokens.
|
||||||
|
expected := make([]int, 0, 4)
|
||||||
|
|
||||||
|
// Look for shiftable tokens.
|
||||||
|
base := jsonPact[state]
|
||||||
|
for tok := TOKSTART; tok-1 < len(jsonToknames); tok++ {
|
||||||
|
if n := base + tok; n >= 0 && n < jsonLast && jsonChk[jsonAct[n]] == tok {
|
||||||
|
if len(expected) == cap(expected) {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
expected = append(expected, tok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if jsonDef[state] == -2 {
|
||||||
|
i := 0
|
||||||
|
for jsonExca[i] != -1 || jsonExca[i+1] != state {
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for tokens that we accept or reduce.
|
||||||
|
for i += 2; jsonExca[i] >= 0; i += 2 {
|
||||||
|
tok := jsonExca[i]
|
||||||
|
if tok < TOKSTART || jsonExca[i+1] == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(expected) == cap(expected) {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
expected = append(expected, tok)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the default action is to accept or reduce, give up.
|
||||||
|
if jsonExca[i+1] != 0 {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, tok := range expected {
|
||||||
|
if i == 0 {
|
||||||
|
res += ", expecting "
|
||||||
|
} else {
|
||||||
|
res += " or "
|
||||||
|
}
|
||||||
|
res += jsonTokname(tok)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func jsonlex1(lex jsonLexer, lval *jsonSymType) (char, token int) {
|
||||||
|
token = 0
|
||||||
|
char = lex.Lex(lval)
|
||||||
if char <= 0 {
|
if char <= 0 {
|
||||||
c = jsonTok1[0]
|
token = jsonTok1[0]
|
||||||
goto out
|
goto out
|
||||||
}
|
}
|
||||||
if char < len(jsonTok1) {
|
if char < len(jsonTok1) {
|
||||||
c = jsonTok1[char]
|
token = jsonTok1[char]
|
||||||
goto out
|
goto out
|
||||||
}
|
}
|
||||||
if char >= jsonPrivate {
|
if char >= jsonPrivate {
|
||||||
if char < jsonPrivate+len(jsonTok2) {
|
if char < jsonPrivate+len(jsonTok2) {
|
||||||
c = jsonTok2[char-jsonPrivate]
|
token = jsonTok2[char-jsonPrivate]
|
||||||
goto out
|
goto out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := 0; i < len(jsonTok3); i += 2 {
|
for i := 0; i < len(jsonTok3); i += 2 {
|
||||||
c = jsonTok3[i+0]
|
token = jsonTok3[i+0]
|
||||||
if c == char {
|
if token == char {
|
||||||
c = jsonTok3[i+1]
|
token = jsonTok3[i+1]
|
||||||
goto out
|
goto out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if c == 0 {
|
if token == 0 {
|
||||||
c = jsonTok2[1] /* unknown char */
|
token = jsonTok2[1] /* unknown char */
|
||||||
}
|
}
|
||||||
if jsonDebug >= 3 {
|
if jsonDebug >= 3 {
|
||||||
__yyfmt__.Printf("lex %s(%d)\n", jsonTokname(c), uint(char))
|
__yyfmt__.Printf("lex %s(%d)\n", jsonTokname(token), uint(char))
|
||||||
}
|
}
|
||||||
return c
|
return char, token
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonParse(jsonlex jsonLexer) int {
|
func jsonParse(jsonlex jsonLexer) int {
|
||||||
|
return jsonNewParser().Parse(jsonlex)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jsonrcvr *jsonParserImpl) Parse(jsonlex jsonLexer) int {
|
||||||
var jsonn int
|
var jsonn int
|
||||||
var jsonlval jsonSymType
|
var jsonlval jsonSymType
|
||||||
var jsonVAL jsonSymType
|
var jsonVAL jsonSymType
|
||||||
|
var jsonDollar []jsonSymType
|
||||||
|
_ = jsonDollar // silence set and not used
|
||||||
jsonS := make([]jsonSymType, jsonMaxDepth)
|
jsonS := make([]jsonSymType, jsonMaxDepth)
|
||||||
|
|
||||||
Nerrs := 0 /* number of errors */
|
Nerrs := 0 /* number of errors */
|
||||||
Errflag := 0 /* error recovery flag */
|
Errflag := 0 /* error recovery flag */
|
||||||
jsonstate := 0
|
jsonstate := 0
|
||||||
jsonchar := -1
|
jsonchar := -1
|
||||||
|
jsontoken := -1 // jsonchar translated into internal numbering
|
||||||
|
jsonrcvr.lookahead = func() int { return jsonchar }
|
||||||
|
defer func() {
|
||||||
|
// Make sure we report no lookahead when not parsing.
|
||||||
|
jsonstate = -1
|
||||||
|
jsonchar = -1
|
||||||
|
jsontoken = -1
|
||||||
|
}()
|
||||||
jsonp := -1
|
jsonp := -1
|
||||||
goto jsonstack
|
goto jsonstack
|
||||||
|
|
||||||
@ -235,7 +344,7 @@ ret1:
|
|||||||
jsonstack:
|
jsonstack:
|
||||||
/* put a state and value onto the stack */
|
/* put a state and value onto the stack */
|
||||||
if jsonDebug >= 4 {
|
if jsonDebug >= 4 {
|
||||||
__yyfmt__.Printf("char %v in %v\n", jsonTokname(jsonchar), jsonStatname(jsonstate))
|
__yyfmt__.Printf("char %v in %v\n", jsonTokname(jsontoken), jsonStatname(jsonstate))
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonp++
|
jsonp++
|
||||||
@ -253,15 +362,16 @@ jsonnewstate:
|
|||||||
goto jsondefault /* simple state */
|
goto jsondefault /* simple state */
|
||||||
}
|
}
|
||||||
if jsonchar < 0 {
|
if jsonchar < 0 {
|
||||||
jsonchar = jsonlex1(jsonlex, &jsonlval)
|
jsonchar, jsontoken = jsonlex1(jsonlex, &jsonlval)
|
||||||
}
|
}
|
||||||
jsonn += jsonchar
|
jsonn += jsontoken
|
||||||
if jsonn < 0 || jsonn >= jsonLast {
|
if jsonn < 0 || jsonn >= jsonLast {
|
||||||
goto jsondefault
|
goto jsondefault
|
||||||
}
|
}
|
||||||
jsonn = jsonAct[jsonn]
|
jsonn = jsonAct[jsonn]
|
||||||
if jsonChk[jsonn] == jsonchar { /* valid shift */
|
if jsonChk[jsonn] == jsontoken { /* valid shift */
|
||||||
jsonchar = -1
|
jsonchar = -1
|
||||||
|
jsontoken = -1
|
||||||
jsonVAL = jsonlval
|
jsonVAL = jsonlval
|
||||||
jsonstate = jsonn
|
jsonstate = jsonn
|
||||||
if Errflag > 0 {
|
if Errflag > 0 {
|
||||||
@ -275,7 +385,7 @@ jsondefault:
|
|||||||
jsonn = jsonDef[jsonstate]
|
jsonn = jsonDef[jsonstate]
|
||||||
if jsonn == -2 {
|
if jsonn == -2 {
|
||||||
if jsonchar < 0 {
|
if jsonchar < 0 {
|
||||||
jsonchar = jsonlex1(jsonlex, &jsonlval)
|
jsonchar, jsontoken = jsonlex1(jsonlex, &jsonlval)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look through exception table */
|
/* look through exception table */
|
||||||
@ -288,7 +398,7 @@ jsondefault:
|
|||||||
}
|
}
|
||||||
for xi += 2; ; xi += 2 {
|
for xi += 2; ; xi += 2 {
|
||||||
jsonn = jsonExca[xi+0]
|
jsonn = jsonExca[xi+0]
|
||||||
if jsonn < 0 || jsonn == jsonchar {
|
if jsonn < 0 || jsonn == jsontoken {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,11 +411,11 @@ jsondefault:
|
|||||||
/* error ... attempt to resume parsing */
|
/* error ... attempt to resume parsing */
|
||||||
switch Errflag {
|
switch Errflag {
|
||||||
case 0: /* brand new error */
|
case 0: /* brand new error */
|
||||||
jsonlex.Error("syntax error")
|
jsonlex.Error(jsonErrorMessage(jsonstate, jsontoken))
|
||||||
Nerrs++
|
Nerrs++
|
||||||
if jsonDebug >= 1 {
|
if jsonDebug >= 1 {
|
||||||
__yyfmt__.Printf("%s", jsonStatname(jsonstate))
|
__yyfmt__.Printf("%s", jsonStatname(jsonstate))
|
||||||
__yyfmt__.Printf(" saw %s\n", jsonTokname(jsonchar))
|
__yyfmt__.Printf(" saw %s\n", jsonTokname(jsontoken))
|
||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
||||||
@ -333,12 +443,13 @@ jsondefault:
|
|||||||
|
|
||||||
case 3: /* no shift yet; clobber input char */
|
case 3: /* no shift yet; clobber input char */
|
||||||
if jsonDebug >= 2 {
|
if jsonDebug >= 2 {
|
||||||
__yyfmt__.Printf("error recovery discards %s\n", jsonTokname(jsonchar))
|
__yyfmt__.Printf("error recovery discards %s\n", jsonTokname(jsontoken))
|
||||||
}
|
}
|
||||||
if jsonchar == jsonEofCode {
|
if jsontoken == jsonEofCode {
|
||||||
goto ret1
|
goto ret1
|
||||||
}
|
}
|
||||||
jsonchar = -1
|
jsonchar = -1
|
||||||
|
jsontoken = -1
|
||||||
goto jsonnewstate /* try again in the same state */
|
goto jsonnewstate /* try again in the same state */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,6 +464,13 @@ jsondefault:
|
|||||||
_ = jsonpt // guard against "declared and not used"
|
_ = jsonpt // guard against "declared and not used"
|
||||||
|
|
||||||
jsonp -= jsonR2[jsonn]
|
jsonp -= jsonR2[jsonn]
|
||||||
|
// jsonp is now the index of $0. Perform the default action. Iff the
|
||||||
|
// reduced production is ε, $1 is possibly out of range.
|
||||||
|
if jsonp+1 >= len(jsonS) {
|
||||||
|
nyys := make([]jsonSymType, len(jsonS)*2)
|
||||||
|
copy(nyys, jsonS)
|
||||||
|
jsonS = nyys
|
||||||
|
}
|
||||||
jsonVAL = jsonS[jsonp+1]
|
jsonVAL = jsonS[jsonp+1]
|
||||||
|
|
||||||
/* consult goto table to find next state */
|
/* consult goto table to find next state */
|
||||||
@ -372,66 +490,77 @@ jsondefault:
|
|||||||
switch jsonnt {
|
switch jsonnt {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:39
|
//line parse.y:39
|
||||||
{
|
{
|
||||||
jsonResult = jsonS[jsonpt-0].obj
|
jsonResult = jsonDollar[1].obj
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
|
jsonDollar = jsonS[jsonpt-3 : jsonpt+1]
|
||||||
//line parse.y:45
|
//line parse.y:45
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
Type: hcl.ValueTypeObject,
|
Type: hcl.ValueTypeObject,
|
||||||
Value: hcl.ObjectList(jsonS[jsonpt-1].objlist).Flat(),
|
Value: hcl.ObjectList(jsonDollar[2].objlist).Flat(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:52
|
//line parse.y:52
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{Type: hcl.ValueTypeObject}
|
jsonVAL.obj = &hcl.Object{Type: hcl.ValueTypeObject}
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:58
|
//line parse.y:58
|
||||||
{
|
{
|
||||||
jsonVAL.objlist = []*hcl.Object{jsonS[jsonpt-0].obj}
|
jsonVAL.objlist = []*hcl.Object{jsonDollar[1].obj}
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
|
jsonDollar = jsonS[jsonpt-3 : jsonpt+1]
|
||||||
//line parse.y:62
|
//line parse.y:62
|
||||||
{
|
{
|
||||||
jsonVAL.objlist = append(jsonS[jsonpt-2].objlist, jsonS[jsonpt-0].obj)
|
jsonVAL.objlist = append(jsonDollar[1].objlist, jsonDollar[3].obj)
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
|
jsonDollar = jsonS[jsonpt-3 : jsonpt+1]
|
||||||
//line parse.y:68
|
//line parse.y:68
|
||||||
{
|
{
|
||||||
jsonS[jsonpt-0].obj.Key = jsonS[jsonpt-2].str
|
jsonDollar[3].obj.Key = jsonDollar[1].str
|
||||||
jsonVAL.obj = jsonS[jsonpt-0].obj
|
jsonVAL.obj = jsonDollar[3].obj
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:75
|
//line parse.y:75
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
Type: hcl.ValueTypeString,
|
Type: hcl.ValueTypeString,
|
||||||
Value: jsonS[jsonpt-0].str,
|
Value: jsonDollar[1].str,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:82
|
//line parse.y:82
|
||||||
{
|
{
|
||||||
jsonVAL.obj = jsonS[jsonpt-0].obj
|
jsonVAL.obj = jsonDollar[1].obj
|
||||||
}
|
}
|
||||||
case 9:
|
case 9:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:86
|
//line parse.y:86
|
||||||
{
|
{
|
||||||
jsonVAL.obj = jsonS[jsonpt-0].obj
|
jsonVAL.obj = jsonDollar[1].obj
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:90
|
//line parse.y:90
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
Type: hcl.ValueTypeList,
|
Type: hcl.ValueTypeList,
|
||||||
Value: jsonS[jsonpt-0].objlist,
|
Value: jsonDollar[1].objlist,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 11:
|
case 11:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:97
|
//line parse.y:97
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
@ -440,6 +569,7 @@ jsondefault:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 12:
|
case 12:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:104
|
//line parse.y:104
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
@ -448,6 +578,7 @@ jsondefault:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 13:
|
case 13:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:111
|
//line parse.y:111
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
@ -456,45 +587,52 @@ jsondefault:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 14:
|
case 14:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:120
|
//line parse.y:120
|
||||||
{
|
{
|
||||||
jsonVAL.objlist = nil
|
jsonVAL.objlist = nil
|
||||||
}
|
}
|
||||||
case 15:
|
case 15:
|
||||||
|
jsonDollar = jsonS[jsonpt-3 : jsonpt+1]
|
||||||
//line parse.y:124
|
//line parse.y:124
|
||||||
{
|
{
|
||||||
jsonVAL.objlist = jsonS[jsonpt-1].objlist
|
jsonVAL.objlist = jsonDollar[2].objlist
|
||||||
}
|
}
|
||||||
case 16:
|
case 16:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:130
|
//line parse.y:130
|
||||||
{
|
{
|
||||||
jsonVAL.objlist = []*hcl.Object{jsonS[jsonpt-0].obj}
|
jsonVAL.objlist = []*hcl.Object{jsonDollar[1].obj}
|
||||||
}
|
}
|
||||||
case 17:
|
case 17:
|
||||||
|
jsonDollar = jsonS[jsonpt-3 : jsonpt+1]
|
||||||
//line parse.y:134
|
//line parse.y:134
|
||||||
{
|
{
|
||||||
jsonVAL.objlist = append(jsonS[jsonpt-2].objlist, jsonS[jsonpt-0].obj)
|
jsonVAL.objlist = append(jsonDollar[1].objlist, jsonDollar[3].obj)
|
||||||
}
|
}
|
||||||
case 18:
|
case 18:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:140
|
//line parse.y:140
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
Type: hcl.ValueTypeInt,
|
Type: hcl.ValueTypeInt,
|
||||||
Value: jsonS[jsonpt-0].num,
|
Value: jsonDollar[1].num,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 19:
|
case 19:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:147
|
//line parse.y:147
|
||||||
{
|
{
|
||||||
jsonVAL.obj = &hcl.Object{
|
jsonVAL.obj = &hcl.Object{
|
||||||
Type: hcl.ValueTypeFloat,
|
Type: hcl.ValueTypeFloat,
|
||||||
Value: jsonS[jsonpt-0].f,
|
Value: jsonDollar[1].f,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 20:
|
case 20:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:154
|
//line parse.y:154
|
||||||
{
|
{
|
||||||
fs := fmt.Sprintf("%d%s", jsonS[jsonpt-1].num, jsonS[jsonpt-0].str)
|
fs := fmt.Sprintf("%d%s", jsonDollar[1].num, jsonDollar[2].str)
|
||||||
f, err := strconv.ParseFloat(fs, 64)
|
f, err := strconv.ParseFloat(fs, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -506,9 +644,10 @@ jsondefault:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 21:
|
case 21:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:167
|
//line parse.y:167
|
||||||
{
|
{
|
||||||
fs := fmt.Sprintf("%f%s", jsonS[jsonpt-1].f, jsonS[jsonpt-0].str)
|
fs := fmt.Sprintf("%f%s", jsonDollar[1].f, jsonDollar[2].str)
|
||||||
f, err := strconv.ParseFloat(fs, 64)
|
f, err := strconv.ParseFloat(fs, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -520,34 +659,40 @@ jsondefault:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 22:
|
case 22:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:182
|
//line parse.y:182
|
||||||
{
|
{
|
||||||
jsonVAL.num = jsonS[jsonpt-0].num * -1
|
jsonVAL.num = jsonDollar[2].num * -1
|
||||||
}
|
}
|
||||||
case 23:
|
case 23:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:186
|
//line parse.y:186
|
||||||
{
|
{
|
||||||
jsonVAL.num = jsonS[jsonpt-0].num
|
jsonVAL.num = jsonDollar[1].num
|
||||||
}
|
}
|
||||||
case 24:
|
case 24:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:192
|
//line parse.y:192
|
||||||
{
|
{
|
||||||
jsonVAL.f = jsonS[jsonpt-0].f * -1
|
jsonVAL.f = jsonDollar[2].f * -1
|
||||||
}
|
}
|
||||||
case 25:
|
case 25:
|
||||||
|
jsonDollar = jsonS[jsonpt-1 : jsonpt+1]
|
||||||
//line parse.y:196
|
//line parse.y:196
|
||||||
{
|
{
|
||||||
jsonVAL.f = jsonS[jsonpt-0].f
|
jsonVAL.f = jsonDollar[1].f
|
||||||
}
|
}
|
||||||
case 26:
|
case 26:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:202
|
//line parse.y:202
|
||||||
{
|
{
|
||||||
jsonVAL.str = "e" + strconv.FormatInt(int64(jsonS[jsonpt-0].num), 10)
|
jsonVAL.str = "e" + strconv.FormatInt(int64(jsonDollar[2].num), 10)
|
||||||
}
|
}
|
||||||
case 27:
|
case 27:
|
||||||
|
jsonDollar = jsonS[jsonpt-2 : jsonpt+1]
|
||||||
//line parse.y:206
|
//line parse.y:206
|
||||||
{
|
{
|
||||||
jsonVAL.str = "e-" + strconv.FormatInt(int64(jsonS[jsonpt-0].num), 10)
|
jsonVAL.str = "e-" + strconv.FormatInt(int64(jsonDollar[2].num), 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto jsonstack /* stack new state and value */
|
goto jsonstack /* stack new state and value */
|
@ -3,8 +3,8 @@ package hcl
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/hcl"
|
"github.com/yudai/hcl/hcl"
|
||||||
"github.com/hashicorp/hcl/json"
|
"github.com/yudai/hcl/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse parses the given input and returns the root object.
|
// Parse parses the given input and returns the root object.
|
1
Godeps/_workspace/src/github.com/yudai/hcl/test-fixtures/null.hcl
generated
vendored
Normal file
1
Godeps/_workspace/src/github.com/yudai/hcl/test-fixtures/null.hcl
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
foo = null
|
@ -23,8 +23,8 @@ import (
|
|||||||
"github.com/braintree/manners"
|
"github.com/braintree/manners"
|
||||||
"github.com/elazarl/go-bindata-assetfs"
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/hashicorp/hcl"
|
|
||||||
"github.com/kr/pty"
|
"github.com/kr/pty"
|
||||||
|
"github.com/yudai/hcl"
|
||||||
"github.com/yudai/umutex"
|
"github.com/yudai/umutex"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -64,7 +64,8 @@ type Options struct {
|
|||||||
ReconnectTime int `hcl:"reconnect_time"`
|
ReconnectTime int `hcl:"reconnect_time"`
|
||||||
Once bool `hcl:"once"`
|
Once bool `hcl:"once"`
|
||||||
PermitArguments bool `hcl:"permit_arguments"`
|
PermitArguments bool `hcl:"permit_arguments"`
|
||||||
Preferences map[string]interface{} `hcl:"preferences"`
|
Preferences HtermPrefernces `hcl:"preferences"`
|
||||||
|
RawPreferences map[string]interface{} `hcl:"preferences"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var Version = "0.0.11"
|
var Version = "0.0.11"
|
||||||
@ -87,7 +88,7 @@ var DefaultOptions = Options{
|
|||||||
EnableReconnect: false,
|
EnableReconnect: false,
|
||||||
ReconnectTime: 10,
|
ReconnectTime: 10,
|
||||||
Once: false,
|
Once: false,
|
||||||
Preferences: make(map[string]interface{}),
|
Preferences: HtermPrefernces{},
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(command []string, options *Options) (*App, error) {
|
func New(command []string, options *Options) (*App, error) {
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/fatih/structs"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -128,11 +129,20 @@ func (context *clientContext) sendInitialize() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefStruct := structs.New(context.app.options.Preferences)
|
||||||
|
prefMap := prefStruct.Map()
|
||||||
htermPrefs := make(map[string]interface{})
|
htermPrefs := make(map[string]interface{})
|
||||||
for key, value := range context.app.options.Preferences {
|
for key, value := range prefMap {
|
||||||
htermPrefs[strings.Replace(key, "_", "-", -1)] = value
|
rawKey := prefStruct.Field(key).Tag("hcl")
|
||||||
|
if _, ok := context.app.options.RawPreferences[rawKey]; ok {
|
||||||
|
htermPrefs[strings.Replace(rawKey, "_", "-", -1)] = value
|
||||||
}
|
}
|
||||||
prefs, _ := json.Marshal(htermPrefs)
|
}
|
||||||
|
prefs, err := json.Marshal(htermPrefs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := context.write(append([]byte{SetPreferences}, prefs...)); err != nil {
|
if err := context.write(append([]byte{SetPreferences}, prefs...)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
58
app/hterm_preferences.go
Normal file
58
app/hterm_preferences.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
type HtermPrefernces struct {
|
||||||
|
AltGrMode *string `hcl:"alt_gr_mode"`
|
||||||
|
AltBackspaceIsMetaBackspace bool `hcl:"alt_backspace_is_meta_backspace"`
|
||||||
|
AltIsMeta bool `hcl:"alt_is_meta"`
|
||||||
|
AltSendsWhat string `hcl:"alt_sends_what"`
|
||||||
|
AudibleBellSound string `hcl:"audible_bell_sound"`
|
||||||
|
DesktopNotificationBell bool `hcl:"desktop_notification_bell"`
|
||||||
|
BackgroundColor string `hcl:"background_color"`
|
||||||
|
BackgroundImage string `hcl:"background_image"`
|
||||||
|
BackgroundSize string `hcl:"background_size"`
|
||||||
|
BackgroundPosition string `hcl:"background_position"`
|
||||||
|
BackspaceSendsBackspace bool `hcl:"backspace_sends_backspace"`
|
||||||
|
CharacterMapOverrides map[string]map[string]string `hcl:"character_map_overrides"`
|
||||||
|
CloseOnExit bool `hcl:"close_on_exit"`
|
||||||
|
CursorBlink bool `hcl:"cursor_blink"`
|
||||||
|
CursorBlinkCycle [2]int `hcl:"cursor_blink_cycle"`
|
||||||
|
CursorColor string `hcl:"cursor_color"`
|
||||||
|
ColorPaletteOverrides []*string `hcl:"color_palette_overrides"`
|
||||||
|
CopyOnSelect bool `hcl:"copy_on_select"`
|
||||||
|
UseDefaultWindowCopy bool `hcl:"use_default_window_copy"`
|
||||||
|
ClearSelectionAfterCopy bool `hcl:"clear_selection_after_copy"`
|
||||||
|
CtrlPlusMinusZeroZoom bool `hcl:"ctrl_plus_minus_zero_zoom"`
|
||||||
|
CtrlCCopy bool `hcl:"ctrl_c_copy"`
|
||||||
|
CtrlVPaste bool `hcl:"ctrl_v_paste"`
|
||||||
|
EastAsianAmbiguousAsTwoColumn bool `hcl:"east_asian_ambiguous_as_two_column"`
|
||||||
|
Enable8BitControl *bool `hcl:"enable_8_bit_control"`
|
||||||
|
EnableBold *bool `hcl:"enable_bold"`
|
||||||
|
EnableBoldAsBright bool `hcl:"enable_bold_as_bright"`
|
||||||
|
EnableClipboardNotice bool `hcl:"enable_clipboard_notice"`
|
||||||
|
EnableClipboardWrite bool `hcl:"enable_clipboard_write"`
|
||||||
|
EnableDec12 bool `hcl:"enable_dec12"`
|
||||||
|
Environment map[string]string `hcl:"environment"`
|
||||||
|
FontFamily string `hcl:"font_family"`
|
||||||
|
FontSize int `hcl:"font_size"`
|
||||||
|
FontSmoothing string `hcl:"font_smoothing"`
|
||||||
|
ForegroundColor string `hcl:"foreground_color"`
|
||||||
|
HomeKeysScroll bool `hcl:"home_keys_scroll"`
|
||||||
|
Keybindings map[string]string `hcl:"keybindings"`
|
||||||
|
MaxStringSequence int `hcl:"max_string_sequence"`
|
||||||
|
MediaKeysAreFkeys bool `hcl:"media_keys_are_fkeys"`
|
||||||
|
MetaSendsEscape bool `hcl:"meta_sends_escape"`
|
||||||
|
MousePasteButton *int `hcl:"mouse_paste_button"`
|
||||||
|
PageKeysScroll bool `hcl:"page_keys_scroll"`
|
||||||
|
PassAltNumber *bool `hcl:"pass_alt_number"`
|
||||||
|
PassCtrlNumber *bool `hcl:"pass_ctrl_number"`
|
||||||
|
PassMetaNumber *bool `hcl:"pass_meta_number"`
|
||||||
|
PassMetaV bool `hcl:"pass_meta_v"`
|
||||||
|
ReceiveEncoding string `hcl:"receive_encoding"`
|
||||||
|
ScrollOnKeystroke bool `hcl:"scroll_on_keystroke"`
|
||||||
|
ScrollOnOutput bool `hcl:"scroll_on_output"`
|
||||||
|
ScrollbarVisible bool `hcl:"scrollbar_visible"`
|
||||||
|
ScrollWheelMoveMultiplier int `hcl:"scroll_wheel_move_multiplier"`
|
||||||
|
SendEncoding string `hcl:"send_encoding"`
|
||||||
|
ShiftInsertPaste bool `hcl:"shift_insert_paste"`
|
||||||
|
UserCss string `hcl:"user_css"`
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user