Commit Graph

8 Commits

Author SHA1 Message Date
Blue Swirl
33d05394a6 json-lexer: fix conflict with mingw32 ERROR definition
The name ERROR is too generic, it conflicts with mingw32 ERROR definition.

Replace ERROR with IN_ERROR.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-04-15 18:25:38 +00:00
Paolo Bonzini
28e91a681a remove unnecessary lookaheads
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-11 15:25:14 -03:00
Paolo Bonzini
f7c052747e implement optional lookahead in json lexer
Not requiring one extra character when lookahead is not necessary
ensures that clients behave properly even if they, for example,
send QMP requests without a trailing newline.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-11 15:25:14 -03:00
Luiz Capitulino
ecb50f5fef json-lexer: Drop 'buf'
QString supports adding a single char, 'buf' is unneeded.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-11 15:25:14 -03:00
Luiz Capitulino
1041ba7a14 json-lexer: Handle missing escapes
The JSON escape sequence "\/" and "\\" are valid and should be
handled.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-11 15:25:14 -03:00
Luiz Capitulino
03308f6c27 json-lexer: Initialize 'x' and 'y'
The 'lexer' variable is passed by the caller, it can contain anything
(eg. garbage).

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-11 15:25:14 -03:00
Roy Tam
2c0d4b36e7 json: fix PRId64 on Win32
OK we are fooled by the json lexer and parser. As we use %I64d to
print 'long long' variables in Win32, but lexer and parser only deal
with %lld but not %I64d, this patch add support for %I64d and solve
'info pci', 'powser_reset' and 'power_powerdown' assert failure in
Win32.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 12:47:58 -06:00
Anthony Liguori
5ab8558d9b Add a lexer for JSON
Our JSON parser is a three stage parser.  The first stage tokenizes the stream
into a set of lexical tokens.  Since the lexical grammar is regular, we can
use a finite state machine to model it.  The state machine will emit tokens
as they are identified.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-17 08:49:39 -06:00