Allow configuring API prefix - close #9
This commit is contained in:
1 parent
7d7929a358
commit
5ce562cbc3
5 files changed
+136
-59
No files matched your search
@@ -12,6 +12,7 @@ class Propane
|
||||
attr_reader :tokens
|
||||
attr_reader :code_blocks
|
||||
attr_reader :ptypes
|
||||
attr_reader :prefix
|
||||
|
||||
def initialize(input)
|
||||
@patterns = []
|
||||
@@ -23,6 +24,7 @@ class Propane
|
||||
@mode = nil
|
||||
@input = input.gsub("\r\n", "\n")
|
||||
@ptypes = {"default" => "void *"}
|
||||
@prefix = "p_"
|
||||
parse_grammar!
|
||||
end
|
||||
|
||||
@@ -55,6 +57,7 @@ class Propane
|
||||
elsif parse_drop_statement!
|
||||
elsif parse_rule_statement!
|
||||
elsif parse_code_block_statement!
|
||||
elsif parse_prefix_statement!
|
||||
else
|
||||
if @input.size > 25
|
||||
@input = @input.slice(0..20) + "..."
|
||||
@@ -195,6 +198,13 @@ class Propane
|
||||
end
|
||||
end
|
||||
|
||||
def parse_prefix_statement!
|
||||
if md = consume!(/prefix\s+(#{IDENTIFIER_REGEX})\s*;/)
|
||||
@prefix = md[1]
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def parse_pattern!
|
||||
if md = consume!(%r{/})
|
||||
pattern = ""
|
||||
|
||||
Reference in new issue
Block a user