src_lexer 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2I2ZmY3ZjlhNjU3MTBiYzE1ZmMzMTYwMjk0MzEwNTU3MmE3NWVlYw==
4
+ NmU4YzhmZmM1M2MwOWZhOTk1YTBlZmNlNWE4YTU0YTljMGUwNDNhMQ==
5
5
  data.tar.gz: !binary |-
6
- ZmQ2YjRkOTVkODhmODEyZDA4OWY2Y2JhN2M5Yzc3YjkxNzJjYmMzNQ==
6
+ Y2IyYmMxY2EyZDk3Y2ZlZWIwMDdhN2M3OGZlNmFkZjY1MGI3ZTY1ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTc4NmI5ZTM4MmZkNThlM2FiY2VkMDRiNTRjOWIzMzEzZjZlNzI2NGQ2NzU5
10
- MTM5ZGQ3MTY5NmY5MzFiYjQ3NzNkNzhiMDY3NmM0MmY4ZDVlNDlmM2RiZmQy
11
- NDdhYzk2YjI5MGU2MGQ3Yzc1YjQyYzVhYzE4MTJiMzAyYTI0Mzc=
9
+ ODAxYTBiYTk0MTg4ZjFhODcyZGNkMjZmODA3YjE1ODBlZTZkNTZmNjYyYWJi
10
+ ZjlmYmU3ODQ2MzVmMDI2NzFkYWMwMDBiZDE0NTJhZjUxZWU4MDNiZjcwMmQ2
11
+ NjFmYzlkMTM2ODM4ZmZmMDk1ODg4Mjc1NTczMTQ0MTE0NGY2M2M=
12
12
  data.tar.gz: !binary |-
13
- NTcyOWE4NjlmODE2ODMxMWEwMzlmZTJmNmZkNWVhYTcwNDEyODIzZjkwYTE2
14
- MDYyNjk5MzkxZGVkZTEzZDkzMmRhOTNlZjE2MjA3Y2UzNTkzNTc1N2JiZmRm
15
- NTgxNjQ1MGNmOWQxZmE4ODRkYjAxODVlNTk3ZTQ4ZjNjNTJjODg=
13
+ Zjc1MmVjZWMxZDUxYjcxODg1N2EwZTljMjU3NDBhYTY5YjQ5NTZkYzY3ZTkz
14
+ N2VkYWE3OWYzNWIzODBlM2ZhZGYwOWI5NmEzMmY4MDAzNGE3ODk1N2UxNDQy
15
+ MjdmNzkzMjk4YmUzYTM3YmQ4OTkxZDQ4NzFmMjg1M2M0YzhjM2I=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SrcLexer
2
2
 
3
- TODO: Write a gem description
3
+ SrcLexer is a simple source file lexer.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,62 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ lexer = SrcLexer::Lexer.new(
22
+ ['struct', 'enum', 'true', 'false'], # kyewords
23
+ ['{', '}', '(', ')', ',', '==', '=', ';'], # symbols
24
+ ['"', '"'], # string literal markers
25
+ '//', # line comment marker
26
+ ['/*', '*/'] # multi line comment markers
27
+ )
28
+
29
+ lexer.analyze(<<-'EOS')
30
+ // comment
31
+ enum ID {
32
+ First = 1,
33
+ Second = 1.5
34
+ }
35
+ /* comment
36
+ againe */
37
+ struct Data {
38
+ string name = "This is a name.";
39
+ ID id;
40
+ }
41
+ bool b = (true==false);
42
+ EOS
43
+
44
+ lexer.pop_token # => ['enum', SrcLexer::Token.new('enum', 2, 3)]
45
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('ID', 2, 8)]
46
+ lexer.pop_token # => ['{', SrcLexer::Token.new('{', 2, 11)]
47
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('First', 3, 5)]
48
+ lexer.pop_token # => ['=', SrcLexer::Token.new('=', 3, 11)]
49
+ lexer.pop_token # => [:NUMBER, SrcLexer::Token.new('1', 3, 13)]
50
+ lexer.pop_token # => [',', SrcLexer::Token.new(',', 3, 14)]
51
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('Second', 4, 5)]
52
+ lexer.pop_token # => ['=', SrcLexer::Token.new('=', 4, 12)]
53
+ lexer.pop_token # => [:NUMBER, SrcLexer::Token.new('1.5', 4, 14)]
54
+ lexer.pop_token # => ['}', SrcLexer::Token.new('}', 5, 3)]
55
+ lexer.pop_token # => ['struct', SrcLexer::Token.new('struct', 8, 3)]
56
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('Data', 8, 10)]
57
+ lexer.pop_token # => ['{', SrcLexer::Token.new('{', 8, 15)]
58
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('string', 9, 5)]
59
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('name', 9, 12)]
60
+ lexer.pop_token # => ['=', SrcLexer::Token.new('=', 9, 17)]
61
+ lexer.pop_token # => [:STRING, SrcLexer::Token.new('"This is a name."', 9, 19)]
62
+ lexer.pop_token # => [';', SrcLexer::Token.new(';', 9, 36)]
63
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('ID', 10, 5)]
64
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('id', 10, 8)]
65
+ lexer.pop_token # => [';', SrcLexer::Token.new(';', 10, 10)]
66
+ lexer.pop_token # => ['}', SrcLexer::Token.new('}', 11, 3)]
67
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('bool', 12, 3)]
68
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('b', 12, 8)]
69
+ lexer.pop_token # => [:IDENT, SrcLexer::Token.new('=', 12, 10)]
70
+ lexer.pop_token # => ['(', SrcLexer::Token.new('(', 12, 12)]
71
+ lexer.pop_token # => ['true', SrcLexer::Token.new('true', 12, 13)]
72
+ lexer.pop_token # => ['==', SrcLexer::Token.new('==', 12, 17)]
73
+ lexer.pop_token # => ['false', SrcLexer::Token.new('false', 12, 19)]
74
+ lexer.pop_token # => [')', SrcLexer::Token.new(')', 12, 24)]
75
+ lexer.pop_token # => [';', SrcLexer::Token.new(';', 12, 25)]
76
+ lexer.pop_token # => SrcLexer::Lexer::END_TOKEN
22
77
 
23
78
  ## Contributing
24
79
 
@@ -1,3 +1,3 @@
1
1
  module SrcLexer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["kkikzk@gmail.com"]
11
11
  spec.summary = %q{A simple source file lexer}
12
12
  spec.description = ""
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/kkikzk/src_lexer"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: src_lexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kkikzk
@@ -73,7 +73,7 @@ files:
73
73
  - spec/spec_helper.rb
74
74
  - spec/src_lexer_spec.rb
75
75
  - src_lexer.gemspec
76
- homepage: ''
76
+ homepage: https://github.com/kkikzk/src_lexer
77
77
  licenses:
78
78
  - MIT
79
79
  metadata: {}