setup files for parser part

This commit is contained in:
Bilal Catic
2020-01-23 19:16:16 +01:00
parent 323e815d5f
commit cb93670a58
5 changed files with 38 additions and 7 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.idea
lexer.rb
lexer.rb
parser.rb

View File

@@ -1,15 +1,19 @@
# parser
###Prerequisites
### Prerequisites
* Rexical (rex)
* Racc
###Available commands
### Available commands
* `rake lexer` - generates `lexer.rb` file based on `specification.rex` file
* `rake parser` - generates `parser.rb` file based on `grammar.y` file
* `rake generate` - generates `lexer.rb` and `parser.rb` files
###Testing
### Testing
To run only `lexer` tests, execute : `rspec spec/query_lexer_spec.rb`
To run only `parser` tests, execute : `rspec spec/query_parser_spec.rb`
To run all tests, execute : `rake spec`

View File

@@ -2,11 +2,19 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new do |c|
options = ['--color']
options += ["--format", "documentation"]
options += %w[--format documentation]
c.rspec_opts = options
end
desc "Generate Lexer"
desc 'Generate Lexer'
task :lexer do
`rex specification.rex -o lexer.rb`
end
end
desc 'Generate Parser'
task :parser do
`racc grammar.y -o parser.rb`
end
desc 'Generate Lexer and Parser'
task generate: %i[lexer parser]

9
grammar.y Normal file
View File

@@ -0,0 +1,9 @@
class Query
rule
expression:
end
---- inner
def parse(input)
scan_str(input)
end

View File

@@ -0,0 +1,9 @@
require './parser'
class QueryParserTester
describe 'Testing the Parser' do
before do
@evaluator = Query.new
end
end
end