source: trunk/src/gpu/lolfx-compiler.cpp @ 1930

Last change on this file since 1930 was 1930, checked in by sam, 7 years ago

lolfx: improve the LolFx compiler, including error reporting. We can now
successfully parse a few of our full GLSL/HLSL shaders.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <string>
16
17#include "core.h"
18#include "gpu/lolfx-compiler.h"
19
20namespace lol
21{
22
23LolFxCompiler::LolFxCompiler(LolFx &lolfx)
24    : m_lolfx(lolfx)
25{
26}
27
28bool LolFxCompiler::ParseString(char const *command)
29{
30    LolFxScanner scanner(command);
31    m_lexer = &scanner;
32    LolFxParser parser(*this);
33    if (parser.parse() != 0)
34        return false;
35    return true;
36}
37
38void LolFxCompiler::Error(const class location& l, const std::string& m)
39{
40    Log::Error("LolFx syntax error line %d column %d: %s\n",
41               l.begin.line, l.begin.column, m.c_str());
42}
43
44void LolFxCompiler::Error(const std::string& m)
45{
46    Log::Error("LolFx syntax error: %s\n", m.c_str());
47}
48
49} /* namespace lol */
50
Note: See TracBrowser for help on using the repository browser.